diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 60a1c0cf4..2fe0c8916 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -278,7 +278,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { // Run verifier for bytecode methods if let Method::Bytecode(method) = method { - if method.verified_info.read().is_none() { + if method.verified_info.borrow().is_none() { BytecodeMethod::verify(method, &mut created_activation)?; } } @@ -449,11 +449,11 @@ impl<'a, 'gc> Activation<'a, 'gc> { self.max_scope_size = (body.max_scope_depth - body.init_scope_depth) as usize; // Everything is now setup for the verifier to run - if method.verified_info.read().is_none() { + if method.verified_info.borrow().is_none() { BytecodeMethod::verify(method, self)?; } - let verified_info = method.verified_info.read(); + let verified_info = method.verified_info.borrow(); let signature = &verified_info.as_ref().unwrap().param_config; if user_arguments.len() > signature.len() && !has_rest_or_args { @@ -753,7 +753,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { ) -> Result, Error<'gc>> { // The method must be verified at this point - let verified_info = method.verified_info.read(); + let verified_info = method.verified_info.borrow(); let verified_code = verified_info.as_ref().unwrap().parsed_code.as_slice(); self.ip = 0; @@ -784,7 +784,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { Error::RustError(_) => return Err(error), }; - let verified_info = method.verified_info.read(); + let verified_info = method.verified_info.borrow(); let exception_list = &verified_info.as_ref().unwrap().exceptions; // Use `coerce_to_object` so that we handle primitives correctly. @@ -1596,7 +1596,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { method: Gc<'gc, BytecodeMethod<'gc>>, index: Index, ) -> Result, Error<'gc>> { - let verified_info = method.verified_info.read(); + let verified_info = method.verified_info.borrow(); let exception_list = &verified_info.as_ref().unwrap().exceptions; let ex = &exception_list[index.0 as usize]; diff --git a/core/src/avm2/method.rs b/core/src/avm2/method.rs index 757df830d..b715a8728 100644 --- a/core/src/avm2/method.rs +++ b/core/src/avm2/method.rs @@ -11,7 +11,7 @@ use crate::avm2::Multiname; use crate::string::AvmString; use crate::tag_utils::SwfMovie; use gc_arena::barrier::unlock; -use gc_arena::lock::Lock; +use gc_arena::lock::{Lock, RefLock}; use gc_arena::{Collect, Gc, GcCell, Mutation}; use std::borrow::Cow; use std::fmt; @@ -135,7 +135,7 @@ pub struct BytecodeMethod<'gc> { /// The ABC method body this function uses. pub abc_method_body: Option, - pub verified_info: GcCell<'gc, Option>>, + pub verified_info: RefLock>>, /// The parameter signature of this method. pub signature: Vec>, @@ -162,8 +162,6 @@ impl<'gc> BytecodeMethod<'gc> { is_function: bool, activation: &mut Activation<'_, 'gc>, ) -> Result> { - let mc = activation.gc(); - let abc = txunit.abc(); let mut signature = Vec::new(); let mut return_type = activation.avm2().multinames.any; @@ -187,7 +185,7 @@ impl<'gc> BytecodeMethod<'gc> { abc: txunit.abc(), abc_method: abc_method.0, abc_method_body, - verified_info: GcCell::new(mc, None), + verified_info: RefLock::new(None), signature, return_type, is_function, @@ -233,8 +231,12 @@ impl<'gc> BytecodeMethod<'gc> { ) -> Result<(), Error<'gc>> { // TODO: avmplus seems to eaglerly verify some methods - *this.verified_info.write(activation.context.gc_context) = - Some(crate::avm2::verify::verify_method(activation, this)?); + *unlock!( + Gc::write(activation.context.gc_context, this), + BytecodeMethod, + verified_info + ) + .borrow_mut() = Some(crate::avm2::verify::verify_method(activation, this)?); Ok(()) } @@ -245,7 +247,7 @@ impl<'gc> BytecodeMethod<'gc> { } pub fn resolved_return_type(&self) -> Option> { - let verified_info = self.verified_info.read(); + let verified_info = self.verified_info.borrow(); verified_info.as_ref().unwrap().return_type }