-
Notifications
You must be signed in to change notification settings - Fork 903
Destructuring fixes #2145
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
base: master
Are you sure you want to change the base?
Destructuring fixes #2145
Conversation
|
@0xe wow, this looks really promising - > 300 more passing tests |
fae67c7 to
88a0b70
Compare
|
That is awesome @0xe, thanks! |
gbrail
left a comment
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.
This is very good feedback -- thanks!
Is there a way that DestructuringIterator can be a ScriptableObject (using lambdas if necessary) instead of an IdScriptableObject? We're trying to phase that thing out.
Sure. AFK for a week or so, will take a look once I get back. |
|
@0xe have done a first smoke test by merging this into core-js and run the whole HtmlUnit test suit. Nothing broken - looks really good! |
88a0b70 to
67d1f75
Compare
Thanks, I've made it just a ScriptableObject. |
aardvark179
left a comment
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.
Okay, I like the overall effect of this PR, but I'm not sure we should be introducing a new byte code just for this.
Let me try and unwind this from the implementation side:
- In the interpreter we want to:
- Get the iterator for the array
- Get the
nextmethod from that - Iterate using the iterator the required number of times to get values, assigning if needed..
DestructuringIteratorseems to be a special implementation of an Iterator Record, which would likely be a useful thing to have for implementing all the iterator prototype methods, but I'm not sure is needed here because in the interpreter we can simply hold the method and the iterator object on the stack or in variables.
I was going to say that it looks like we're diving to implementation details too early by doing that in the parser… but tracing through things I see that's all called from the IR factory, and just lives in the parser to confuse simple bears like me. 😀
I’m working on addressing @aardvark179’s suggestions. |
- Implement support for reading from [Symbol.iterator] - Implement support for nested destructuring
And iterator wrapper which is not needed.
ed5388e to
3c523f1
Compare
I've addressed your suggestions by removing the new bytecodes by doing the transformations in the IR. You were right, we didn't really need the new bytecodes or the new wrapper class. The changes which are really only in Here's how the transforms look: function f([a, b]) {
return a + b;
} |
|
Looking at why java 21 multi-threaded test is failing in CI. It runs successfully for me locally with |
|
This task has failed in the multithreaded test: I think this is unrelated. |
Restart the test solves the problem.... :-D |
|
Smoke test done again with the latest sources - still no smoke! |
|
I’ve seen the decycle problem locally at least once. I haven’t debugged it properly to know if it’s a simple race between a few parts of the build or something else. |
To me, this looks very complex frankly. A call to a function in Me and @0xe noticed that V8 has a generic "invokeruntime" opcode; I think that could be an idea to investigate, if we want to keep the number of opcodes in check. |
|
So I think there are a few different things to consider here:
So introducing byte codes for array destructuring seems like a bad move because it is a little user feature and it makes better optimisation harder. A more general runtime call byte code could carry its weight. As it could be reused elsewhere. Thinking about all the other iterator methods in the spec might also help in designing this. Standard array iterators are likely a special case because they very fixed behaviour and the close operation can be trivial. oh, and the parse tree should express the concept of destructuring assignment, and whatever our implementation details are should only be introduce either in the IR factory or by the compilers’ transform routines. |
The parse tree itself is reasonably clean. The implementation logic gets added only during IR transforms. For the example above, this is the AST:
Looking at the Interpreter among the instructions that call into ScriptRuntime about 5 are just direct calls which can benefit from something like V8's CallRuntime bytecode. A few more manipulate the stack before/after calling but I think they can still be refactored into using such a bytecode. For example, these are only direct calls to ScriptRuntime: DoLeaveWith - ScriptRuntime.leaveWith(scope) A few more are single calls but after a However, I think that's starting to sound like a separate PR. :) |
Fixes for #1641