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

Handle super.__proto__, which has a special implementation #1737

Closed
wants to merge 2 commits into from

Conversation

andreabergia
Copy link
Contributor

@andreabergia andreabergia commented Nov 27, 2024

This PR, co-authored with @0xe, adds support for the crazy super.__proto__. It is stacked on top of #1735.

In Rhino there is a special implementation that uses Ref and GET_REF (and similar) for things like a.__proto__, a.__parent__ and xml access. We have extended this to super.

A really surprising thing that we discovered looking at other engines is that the semantics of super.__proto__ is a bit confusing - it ends up being this.__proto__ basically, because __proto__ is resolved on super but then accessed on this. So, the implementation uses a horrible hack: it replaces super.__proto__ with this.__proto__ in the IR. This seems to work, according to the tests that we have added, and while a bit dirty, it seems fine to us for such a strange edge case.

andreabergia and others added 2 commits December 2, 2024 08:29
Copy link
Collaborator

@gbrail gbrail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK (but it's a weird language feature). Thanks!

@andreabergia
Copy link
Contributor Author

Merged this onto #1735

@andreabergia andreabergia deleted the super-ref branch December 4, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants