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`)
This commit is contained in:
Aaron Hill 2024-08-12 20:07:13 -04:00
parent 953c6732cc
commit 1b700c8a06
4 changed files with 10 additions and 7 deletions

View File

@ -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();

View File

@ -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(())
}

View File

@ -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<Op<'gc>>,
resolved_parameters: &[ResolvedParamConfig<'gc>],
return_type: Option<Class<'gc>>,

View File

@ -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<VerifiedMethodInfo<'gc>, Error<'gc>> {
let body = method
.body()