-
-
Notifications
You must be signed in to change notification settings - Fork 776
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: Various Object / ClassObject cleanups #5325
Avm2: Various Object / ClassObject cleanups #5325
Conversation
c915b8f
to
8de7c55
Compare
I filed this PR adrian17#57 which should correctly make all classes instances of I won't be able to review the rest of this PR until later but what I saw of it looked good. Hopefully it doesn't conflict with #5317 too much. |
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.
Your PR looks good as is.
If you decide to merge in adrian17#57, I'll re-approve that immediately.
* avm2: Properly make all classes an instance of `Class`. Also, does this technically mean that `Class` is a metaclass? * avm2: Remove `Function::from_method_and_proto` as it will no longer be needed * avm2: Ensure builtin classes are also instances of `Class`. This requires tying a veritable gordian knot of classes; everything needs to be allocated up-front, linked together, and then properly initialized later on. This necessitated splitting the whole class construction process up into three steps: 1. Allocation via `from_class_partial`, which does everything that can be done without any other classes 2. Weaving via `link_prototype` and `link_type`, which links all of the allocated parts together correctly. This also includes initializing `SystemClasses` and `SystemPrototypes`. 3. Initialization via `into_finished_class`, which must be done *after* the weave has finished. Once complete you have core classes that are all instances of `Class`, along with prototypes that have their usual legacy quirks. Note that this does *not* make prototypes instances of their class. We do need to do that, but doing so breaks ES3 legacy support. This is because we currently only work with bound methods, but need to be able to call unbound methods in `callproperty`. * tests: Add a test for all core classes' instance-of relationships
e0198c3
to
797ec23
Compare
This changes aren't intended to have major observable impact, unless my fundamental assumptions or understanding of old implementation turn out to be completely wrong.
This is also a prelude to future PR, to make ScriptObject's instance traits not per-instance. Also prelude to the
SomeClass as Class
fix.In particular:
superclass_object
,instance_of
,SystemClasses
etc are always ClassObjects. I am willing to introduce this assumption in future PRs (unless someone proves me wrong), but not here.avm2: Replace all uses of as_class_object by instance_of
is a change in logic, in theoretical fringe cases where someone somehow passes a class object to specific instance initializer (but I don't even know if it's possible and it still shouldn't change observable behavior, I think). One place I am worried about isop_call_property/op_call_prop_void
, but for all I know this might actually be a change for the better.get_own_class_definition()
(oldas_class()
) in 99% of cases shouldn't be used; you either want an object as class (as_class_object()
) or an object's class (instance_of()
), not a mix of these.I'm delaying cleaning these up until future PR, as these changes will definitely increase strictness.nvm doing this now in the last commit; it'll probably require extra scrutiny.