avm1: We don't need to lock StackFrames anymore, the borrow checker will steer us right

This commit is contained in:
Nathan Adams 2020-06-30 21:26:57 +02:00
parent 2288919663
commit a989aa235a
1 changed files with 2 additions and 26 deletions

View File

@ -303,21 +303,16 @@ impl<'a, 'gc: 'a> StackFrame<'a, 'gc> {
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
code: SwfSlice, code: SwfSlice,
) -> Result<ReturnType<'gc>, Error<'gc>> { ) -> Result<ReturnType<'gc>, Error<'gc>> {
self.lock()?;
let mut read = Reader::new(code.as_ref(), self.swf_version()); let mut read = Reader::new(code.as_ref(), self.swf_version());
let result = loop { loop {
let result = self.do_action(&code, context, &mut read); let result = self.do_action(&code, context, &mut read);
match result { match result {
Ok(FrameControl::Return(return_type)) => break Ok(return_type), Ok(FrameControl::Return(return_type)) => break Ok(return_type),
Ok(FrameControl::Continue) => {} Ok(FrameControl::Continue) => {}
Err(e) => break Err(e), Err(e) => break Err(e),
} }
}; }
self.unlock_execution();
result
} }
/// Run a single action from a given action reader. /// Run a single action from a given action reader.
@ -2906,23 +2901,4 @@ impl<'a, 'gc: 'a> StackFrame<'a, 'gc> {
pub fn set_constant_pool(&mut self, constant_pool: GcCell<'gc, Vec<String>>) { pub fn set_constant_pool(&mut self, constant_pool: GcCell<'gc, Vec<String>>) {
self.constant_pool = constant_pool; self.constant_pool = constant_pool;
} }
/// Attempts to lock the activation frame for execution.
///
/// If this frame is already executing, that is an error condition.
pub fn lock(&mut self) -> Result<(), Error<'gc>> {
if self.is_executing {
return Err(Error::AlreadyExecutingFrame);
}
self.is_executing = true;
Ok(())
}
/// Unlock the activation object. This allows future execution to run on it
/// again.
pub fn unlock_execution(&mut self) {
self.is_executing = false;
}
} }