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

Support ES2015 Proxies & Reflect API #268

Open
p-bakker opened this issue Feb 9, 2016 · 12 comments · May be fixed by #1431
Open

Support ES2015 Proxies & Reflect API #268

p-bakker opened this issue Feb 9, 2016 · 12 comments · May be fixed by #1431
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec feature Issues considered a new feature
Milestone

Comments

@p-bakker
Copy link
Collaborator

p-bakker commented Feb 9, 2016

As the title says.

I've done work implementing Proxy as a ScriptableObject which basically delegates all calls to methods of the Scriptable interface to the provided Handler object or else to the ScriptableObject that was passed into the Proxy constructor.

This work was done against an older version of Rhino. With that version, I ran into two issues described here: https://groups.google.com/d/msg/mozilla-rhino/FII66nW7KMI/uBh8WBmdBgAJ

I can provide my Proxy code or could see if I can take it to the next level, but I'd need some pointers on the issues mentioned in the Google Groups discussion above

@gbrail
Copy link
Collaborator

gbrail commented Feb 12, 2016

I don't have my head around how Proxies are supposed to work yet but it sounds like a tough one.

Right now all I can suggest is that it's time to look at the whole Object.getIds[] mechanism anyway. For instance, in cases when we're actually doing some sort of big loop, making a copy of the array is not great. Furthermore, lots of subclasses of ScriptableObject override this, and they end up generating arrays that need to be copied, and reallocated, and so on and so forth.

Plus, there is code scattered all over Rhino that tries to optimize the case of generating these arrays.

So I am thinking that for various reasons we need some different mechanism to get the ids from an object -- one that is based on more like an Iterator interface. We need to maintain support for the existing Scriptable interface so that existing code doesn't break, but we could add an "IterableScriptable" or something and have the runtime look for that.

I know that this is fairly high-level but could you imagine some sort of set of changes to the way iteration works that would make your problem easier?

@maok
Copy link

maok commented Apr 22, 2017

Can you share your code?

@p-bakker
Copy link
Collaborator Author

I can, but it'll be a few weeks before I get to it, due to other priorities

@maok
Copy link

maok commented May 10, 2017

That would be great.
I need it with the android asdl using javascript, like the local code to access other processes

@p-bakker p-bakker changed the title Support ES6 Proxies & Reflect API Support ES2015 Proxies & Reflect API Jun 23, 2021
@p-bakker p-bakker added this to the ES2015 milestone Jun 29, 2021
@p-bakker p-bakker added the feature Issues considered a new feature label Oct 14, 2021
@p-bakker p-bakker added the test262 harness Issues related to failing test262 tests, due to Rhino not yet support certain JS features label Oct 24, 2021
@p-bakker
Copy link
Collaborator Author

p-bakker commented Oct 24, 2021

At least the Reflect API is being used by tests in the Test262 suite (that aren't about Reflect)

Need to see if Reflect can be done independantly of Proxies and whether either can be implemented before #940 is resolved

@rbri
Copy link
Collaborator

rbri commented Dec 23, 2021

https://stackoverflow.com/questions/70448591/access-fritzbox-via-htmlunit/70465092#70465092

@p-bakker please share your code - i like to get the proxy stuff working

@p-bakker
Copy link
Collaborator Author

p-bakker commented Dec 23, 2021

I'll try to find some time to share my WIP, but if I recall correctly, one of the main reasons I didn't finish was because Rhino doesn't properly implement strict mode and fixing that requires at least one major breaking change, namely of the Callable interface: the parameter for the 'this' value is currently defined as Scriptable, but it should allow anything.

As proxy/reflect deals with the 'this' value a lot (thus also a lot of the tests in test262), I parked my efforts and first focused on getting to a point where we can make this breaking change.

That point being: implement all features so we can run against the latest version of the test262 suite AND get everything ready for a Rhino 2.0.0 release

@rbri
Copy link
Collaborator

rbri commented May 27, 2023

FYI: i have done a complete impl of Reflect during the last days. Currently i have to fix some issues but it looks good so far - mot of the test262 tests passing.
Have to fix something for the PropertyDesciptor and then i can do the PR.

@rbri
Copy link
Collaborator

rbri commented Aug 8, 2023

@p-bakker any chance to get my hands your proxy code; i really do not like to start from scratch and i need it for HtmlUnit.

@p-bakker
Copy link
Collaborator Author

p-bakker commented Aug 8, 2023

I'll try to share, but most likely won't get to it before somewhere next week

While chatting: any update on #1183?

@p-bakker
Copy link
Collaborator Author

p-bakker commented Aug 9, 2023

@rbri See https://github.com/p-bakker/rhino/tree/WIP_NativeProxy/Reflect_attempt

It's really an attempt at a prototype, more than anything else

@rbri
Copy link
Collaborator

rbri commented Aug 9, 2023

@p-bakker thanks will have a look....

@p-bakker p-bakker linked a pull request Apr 9, 2024 that will close this issue
@p-bakker p-bakker added Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec and removed test262 harness Issues related to failing test262 tests, due to Rhino not yet support certain JS features labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec feature Issues considered a new feature
Projects
None yet
4 participants