From 3b9d9cf230177532fb809caeef7cfb7911d7921f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 12 Aug 2024 20:07:13 -0400 Subject: [PATCH] avm2: Pass in `Gc<'gc, BytecodeMethod<'gc>>` to `optimize` This allows us to pretty-print a method name from within `optimize` using `display_function` (which needs to do `Gc::ptr_eq`) --- core/src/avm2/activation.rs | 4 ++-- core/src/avm2/method.rs | 9 ++++++--- core/src/avm2/optimize.rs | 2 +- core/src/avm2/verify.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 2fe6b6c2c..ceb52070a 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -274,7 +274,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() { - method.verify(&mut created_activation)?; + BytecodeMethod::verify(method, &mut created_activation)?; } } @@ -442,7 +442,7 @@ impl<'a, 'gc> Activation<'a, 'gc> { // Everything is now setup for the verifier to run if method.verified_info.read().is_none() { - method.verify(self)?; + BytecodeMethod::verify(method, self)?; } let verified_info = method.verified_info.read(); diff --git a/core/src/avm2/method.rs b/core/src/avm2/method.rs index 698412896..94d534ebd 100644 --- a/core/src/avm2/method.rs +++ b/core/src/avm2/method.rs @@ -240,11 +240,14 @@ impl<'gc> BytecodeMethod<'gc> { } #[inline(never)] - pub fn verify(&self, activation: &mut Activation<'_, 'gc>) -> Result<(), Error<'gc>> { + pub fn verify( + this: Gc<'gc, BytecodeMethod<'gc>>, + activation: &mut Activation<'_, 'gc>, + ) -> Result<(), Error<'gc>> { // TODO: avmplus seems to eaglerly verify some methods - *self.verified_info.write(activation.context.gc_context) = - Some(crate::avm2::verify::verify_method(activation, self)?); + *this.verified_info.write(activation.context.gc_context) = + Some(crate::avm2::verify::verify_method(activation, this)?); Ok(()) } diff --git a/core/src/avm2/optimize.rs b/core/src/avm2/optimize.rs index 27bfbb3c4..09c40646a 100644 --- a/core/src/avm2/optimize.rs +++ b/core/src/avm2/optimize.rs @@ -307,7 +307,7 @@ fn has_simple_scope_structure( pub fn optimize<'gc>( activation: &mut Activation<'_, 'gc>, - method: &BytecodeMethod<'gc>, + method: Gc<'gc, BytecodeMethod<'gc>>, code: &mut Vec>, resolved_parameters: &[ResolvedParamConfig<'gc>], return_type: Option>, diff --git a/core/src/avm2/verify.rs b/core/src/avm2/verify.rs index f5990ef53..ee3bc60bf 100644 --- a/core/src/avm2/verify.rs +++ b/core/src/avm2/verify.rs @@ -66,7 +66,7 @@ pub enum JumpSource { pub fn verify_method<'gc>( activation: &mut Activation<'_, 'gc>, - method: &BytecodeMethod<'gc>, + method: Gc<'gc, BytecodeMethod<'gc>>, ) -> Result, Error<'gc>> { let body = method .body()