Skip to content
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: Class refactor #16783

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Lord-McSweeney
Copy link
Collaborator

@Lord-McSweeney Lord-McSweeney commented Jun 19, 2024

This refactors classes to match avmplus, which simplifies a lot of Class-related stuff and improves the optimizer.

Notable changes:

  • There are now two Classes for every class. One holds the instance info, while the other holds the class info. Each of them holds a link to the other.
  • The core class weave is simplified
    • init_instance_vtable is now called from within ClassObject::from_class_partial
    • The global global class is no longer special
  • ClassObject now delegates to Class for the instance allocator
  • ClassObject no longer stores its class vtable on itself
  • TraitKind::Class slots on vtables are now properly typed (this should help some optimizations)
  • The ClassObject -> symbol registry is now a Class -> symbol registry; hopefully this can't break anything
  • ScriptObjectData now stores a Class instead of a ClassObject to represent its constructor
  • describeType is simplified
  • Classless objects no longer exist; instance_class isn't Optional anymore
  • void no longer has a ClassObject

Box2d optimization stats:

FindPropStrict -> GetScriptGlobals : 62.18%
FindPropStrict -> GetOuterScope : 7.76%
FindPropStrict -> GetScopeObject : 8.24%

FindProperty -> GetOuterScope : 2.83%
FindProperty -> GetScopeObject : 94.34%

InitProperty -> SetSlot : 38.74% (-2.19%)
InitProperty -> SetSlotNoCoerce : 46.7% (+2.19%)

SetProperty -> SetSlot : 23.95% (-1.57%)
SetProperty -> SetSlotNoCoerce : 44.76% (+2.10%)
SetProperty -> CallMethod : 1.57%

GetProperty -> GetSlot : 73.69% (+6.38%)
GetProperty -> CallMethod : 0.34%

CallProperty -> CallMethod : 70.97% (+29.84%)
CallPropVoid -> CallMethod : 75.38% (+1.14%)

Coerce -> Nop : 51.71% (+1.93%)

CoerceD -> Nop : 81.34%

CoerceB -> Nop : 10.81% (+2.70%)

CoerceU -> Nop : 50%

CoerceI -> Nop : 33%

ReturnValue -> ReturnValueNoCoerce : 71.56% 

@danielhjacobs danielhjacobs added the avm2 AVM2 (ActionScript 3.0) issues label Jun 20, 2024
@Lord-McSweeney Lord-McSweeney force-pushed the avm2-class-refactor-1 branch 2 times, most recently from 7570dc7 to 4bfbff5 Compare June 20, 2024 19:28
@Lord-McSweeney Lord-McSweeney marked this pull request as ready for review June 20, 2024 19:34
@Lord-McSweeney Lord-McSweeney added waiting-on-review Waiting on review from a Ruffle team member labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avm2 AVM2 (ActionScript 3.0) issues waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants