Skip to content

Commit e2dbf2c

Browse files
Lord-McSweeneyLord-McSweeney
Lord-McSweeney
authored and
Lord-McSweeney
committed
avm2: Use type information from return type of getters and methods in optimizer
1 parent 4bbed1a commit e2dbf2c

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

core/src/avm2/optimizer/optimize.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::avm2::optimizer::blocks::assemble_blocks;
66
use crate::avm2::optimizer::peephole;
77
use crate::avm2::property::Property;
88
use crate::avm2::verify::Exception;
9-
use crate::avm2::vtable::VTable;
9+
use crate::avm2::vtable::{ClassBoundMethod, VTable};
1010
use crate::avm2::{Activation, Class, Error};
1111

1212
use gc_arena::Gc;
@@ -1413,6 +1413,23 @@ fn abstract_interpret_ops<'gc>(
14131413
index: disp_id,
14141414
push_return_value: true,
14151415
});
1416+
1417+
stack_push_done = true;
1418+
1419+
let full_method = vtable
1420+
.get_full_method(disp_id)
1421+
.expect("Method should exist");
1422+
let ClassBoundMethod { method, .. } = full_method;
1423+
if !method.is_info_resolved() {
1424+
method.resolve_info(activation)?;
1425+
}
1426+
1427+
let return_type = method.resolved_return_type();
1428+
if let Some(return_type) = return_type {
1429+
stack.push_class(activation, return_type)?;
1430+
} else {
1431+
stack.push_any(activation)?;
1432+
}
14161433
}
14171434
_ => {}
14181435
}
@@ -1640,6 +1657,23 @@ fn abstract_interpret_ops<'gc>(
16401657
index: disp_id,
16411658
push_return_value: true,
16421659
});
1660+
1661+
stack_push_done = true;
1662+
1663+
let full_method = vtable
1664+
.get_full_method(disp_id)
1665+
.expect("Method should exist");
1666+
let ClassBoundMethod { method, .. } = full_method;
1667+
if !method.is_info_resolved() {
1668+
method.resolve_info(activation)?;
1669+
}
1670+
1671+
let return_type = method.resolved_return_type();
1672+
if let Some(return_type) = return_type {
1673+
stack.push_class(activation, return_type)?;
1674+
} else {
1675+
stack.push_any(activation)?;
1676+
}
16431677
}
16441678
Some(Property::Slot { slot_id })
16451679
| Some(Property::ConstSlot { slot_id }) => {

0 commit comments

Comments
 (0)