Skip to content

Commit 0314d49

Browse files
committed
remove dead code
Signed-off-by: Jorge Prendes <[email protected]>
1 parent 6f066b5 commit 0314d49

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

src/hyperlight_host/src/func/call_ctx.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ impl MultiUseGuestCallContext {
4747
pub fn start(sbox: MultiUseSandbox) -> Self {
4848
Self { sbox }
4949
}
50-
51-
/// Close out the context and get back the internally-stored
52-
/// `MultiUseSandbox`. Future contexts opened by the returned sandbox
53-
/// will have guest state restored.
54-
#[instrument(err(Debug), skip(self), parent = Span::current())]
55-
pub fn finish(mut self) -> Result<MultiUseSandbox> {
56-
self.sbox.restore_state()?;
57-
Ok(self.sbox)
58-
}
5950
}
6051

6152
impl Callable for MultiUseGuestCallContext {
@@ -96,8 +87,6 @@ mod tests {
9687

9788
use hyperlight_testing::simple_guest_as_string;
9889

99-
use super::MultiUseGuestCallContext;
100-
use crate::sandbox::Callable;
10190
use crate::sandbox_state::sandbox::EvolvableSandbox;
10291
use crate::sandbox_state::transition::Noop;
10392
use crate::{GuestBinary, HyperlightError, MultiUseSandbox, Result, UninitializedSandbox};
@@ -134,12 +123,12 @@ mod tests {
134123
// requests to execute batches of calls
135124
let recv_hdl = thread::spawn(move || {
136125
let mut sbox: MultiUseSandbox = new_uninit().unwrap().evolve(Noop::default()).unwrap();
126+
let snapshot = sbox.snapshot().unwrap();
137127
while let Ok(calls) = recv.recv() {
138-
let mut ctx = sbox.new_call_context();
139128
for call in calls {
140-
call.call(&mut ctx);
129+
call.call(&mut sbox);
141130
}
142-
sbox = ctx.finish().unwrap();
131+
sbox.restore(&snapshot).unwrap();
143132
}
144133
});
145134

@@ -151,11 +140,15 @@ mod tests {
151140
let calls = vec![
152141
TestFuncCall::new(move |ctx| {
153142
let msg = format!("Hello {}", i);
154-
let ret: String = ctx.call("Echo", msg.clone()).unwrap();
143+
let ret: String = ctx
144+
.call_guest_function_by_name("Echo", msg.clone())
145+
.unwrap();
155146
assert_eq!(ret, msg)
156147
}),
157148
TestFuncCall::new(move |ctx| {
158-
let ret: i32 = ctx.call("CallMalloc", i + 2).unwrap();
149+
let ret: i32 = ctx
150+
.call_guest_function_by_name("CallMalloc", i + 2)
151+
.unwrap();
159152
assert_eq!(ret, i + 2)
160153
}),
161154
];
@@ -187,7 +180,9 @@ mod tests {
187180
let snapshot = self.sandbox.snapshot()?;
188181
let mut sum: i32 = 0;
189182
for n in 0..i {
190-
let result = self.sandbox.call_guest_function_by_name::<i32>("AddToStatic", n);
183+
let result = self
184+
.sandbox
185+
.call_guest_function_by_name::<i32>("AddToStatic", n);
191186
sum += n;
192187
println!("{:?}", result);
193188
let result = result.unwrap();
@@ -226,14 +221,14 @@ mod tests {
226221
assert!(result.is_ok());
227222
}
228223

229-
struct TestFuncCall(Box<dyn FnOnce(&mut MultiUseGuestCallContext) + Send>);
224+
struct TestFuncCall(Box<dyn FnOnce(&mut MultiUseSandbox) + Send>);
230225

231226
impl TestFuncCall {
232-
fn new(f: impl FnOnce(&mut MultiUseGuestCallContext) + Send + 'static) -> Self {
227+
fn new(f: impl FnOnce(&mut MultiUseSandbox) + Send + 'static) -> Self {
233228
TestFuncCall(Box::new(f))
234229
}
235230

236-
fn call(self, ctx: &mut MultiUseGuestCallContext) {
231+
fn call(self, ctx: &mut MultiUseSandbox) {
237232
(self.0)(ctx);
238233
}
239234
}

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ impl MultiUseSandbox {
206206
})
207207
}
208208

209-
/// Restore the Sandbox's state
210-
#[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")]
211-
pub(crate) fn restore_state(&mut self) -> Result<()> {
212-
let mem_mgr = self.mem_mgr.unwrap_mgr_mut();
213-
mem_mgr.restore_state_from_last_snapshot()
214-
}
215-
216209
pub(crate) fn call_guest_function_by_name_no_reset(
217210
&mut self,
218211
function_name: &str,
@@ -246,8 +239,7 @@ impl MultiUseSandbox {
246239
self.check_stack_guard()?;
247240
check_for_guest_error(self.get_mgr_wrapper_mut())?;
248241

249-
self
250-
.get_mgr_wrapper_mut()
242+
self.get_mgr_wrapper_mut()
251243
.as_mut()
252244
.get_guest_function_call_result()
253245
})();

0 commit comments

Comments
 (0)