-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avm2: Optimizer improvements #15105
avm2: Optimizer improvements #15105
Conversation
a74dcc4
to
ef23851
Compare
core/src/avm2/verify.rs
Outdated
stack.pop(); | ||
stack.push_int(); | ||
} | ||
_ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned on discord, I think we should just have all of these checked in one go - otherwise this can't be used for verification, and can randomly inhibit optimizations.
bbcc1f4
to
464274a
Compare
@@ -2243,23 +2249,23 @@ impl<'a, 'gc> Activation<'a, 'gc> { | |||
let value2 = self.pop_stack().coerce_to_i32(self)?; | |||
let value1 = self.pop_stack().coerce_to_i32(self)?; | |||
|
|||
self.push_stack(value1.wrapping_mul(value2)); | |||
self.push_raw(value1.wrapping_mul(value2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could also be applied to some more ops: add
, subtract
, swap
, astype
, astypelate
? For the last three, since other ops guarantee that stack never has PrimitiveObject, then they can also never encounter a PrimitiveObject.
deaf921
to
06cbbe4
Compare
7787587
to
5af94c9
Compare
5af94c9
to
6bdca88
Compare
…e than one `ClassObject` had been constructed for the class
6bdca88
to
d2971e8
Compare
} | ||
|
||
fn popn(&mut self, count: u32) { | ||
for _ in 0..count { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if something like self.0.truncate(self.0.len() - count)
would be more efficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to be too worried about performance here
890c690
to
dce4238
Compare
Based off @adrian17's
abstract-optimizer
branch.Testing on the Box2D demo SWF shows that:
55% of
GetProperty
calls are converted toGetSlot
orCallMethod
calls36% of
SetProperty
calls are converted toSetSlot
calls74% of
InitProperty
calls are converted toSetSlot
calls25% of
CallProperty
calls are converted toCallMethod
callsTesting on Sniper Team shows that
PropertyMap::get_for_multiname
is pushed down significantly. HoweverActivation::run_actions
is still too high for it to make a noticeable difference.Fixes #15227
Fixes #15273
Fixes #15309
TODO:
Constant pooling fixesFor laterCallProperty
toCallMethod
Also support setters forFor laterSetProperty
andInitProperty
RemoveFor laterNop
s (requires recalculating branch and jump targets)Use it for determining type returned byFor laterfindproperty
/findpropstrict
Implement more opsFor later