-
Notifications
You must be signed in to change notification settings - Fork 857
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
Implement Symbol.prototype.description and refactor Symbol to use LambdaConstructor #1579
Implement Symbol.prototype.description and refactor Symbol to use LambdaConstructor #1579
Conversation
Are you aware of #1561? |
Yeah, I saw that PR tried the |
Thanks! Let's get the other two PRs worked out and we'll look at this one. I looked at doing this too, and I'm more happy to have you do it! There are other opportunities for improvement in this code since I had to work around all the limitations of our non-lambda world. For example:
|
Thanks for waiting a bit... @camnwalter added a new method to ScriptableObject and LambdaConstructor that will define the property the way that you want. I know that you did something similar in here. Now that that's merged in master, would you be willing to re-work this PR to use that? Then we're all set. Thanks! |
11836ea
to
d839483
Compare
Refactored `NativeSymbol` to use `LambdaConstructor` instead of `IdScriptableObject`.
d839483
to
6fee4ce
Compare
Rebased this on top of master. A couple of comments:
Yeah, it's horrible, but I'm not sure we can do better. The problem is in public static NativeSymbol construct(Context cx, Scriptable scope, Object[] args) {
cx.putThreadLocal(CONSTRUCTOR_SLOT, Boolean.TRUE);
try {
return (NativeSymbol) cx.newObject(scope, CLASS_NAME, args);
} finally {
cx.removeThreadLocal(CONSTRUCTOR_SLOT);
}
} We wanna use
I've attempted to implement that, but it seems to break the test262 case |
To my knowledge, the Symbol table isn't shared cross realm in Rhino currently, while according to the spec it should (see #1079) |
Well, this PR makes the test 26 case |
I thought you said you broke the test...🤔 |
No, implementing what Greg was suggesting in point 2) above would break the test (that is now passing, with this PR) |
Any chance to sort out this one? |
Looks like good progress and JavaScript has more weird angles than I expected. Are we waiting for another test to be fixed, or do we think that we're in a good place now? |
Does not pass because it uses
I don't have anything more planned for this PR. |
Maybe I'm not following the logic, but the the thread local is set before making calls to createStandardSymbol, which calls ctor.call, not ctor.construct. Unless I'm missing something, the theadlocal doesn't seem to do much |
Other than that: LGTM |
Will check after my vacation if my proxy impl solves this. |
I know that we keep changing the landscape but this work is exposing issues with the lambda stuff that we need to fix for everything. Can you take a look at this PR: It makes it possible to have different behaviors for a constructor when called via "new" and directly. However, you should not necessarily need this for this PR -- the existing LambdaConstructor already has "flags" and you should be able to use those to implement the functionality that you cannot create a Symbol using "new". |
I'm currently on vacation this week and the next, so I'll take a look at it, but not for a while. My 2 cents: if this PR looks good as it is, I would like to see it merged and do the removal of the thread-local in the (near) future, after #1622 has been merged. It's a small implementation detail anyway. |
Is there anything that stops us from merging this? Looks like another real step forward and like @andreabergia suggested we can access the thread-local thing later. At lease i like to have this merged.... |
Thank you for doing this! Things have changed so much and the LambdaConstructor class needed attention, so I decided to create a new PR that includes your commit with some tweaks on top as a way to keep this moving forward. Thank you for getting this going most of the way! I'm going to close this in favor of: |
In draft, because it's stacked on top of both #1577 and #1578 and will need to be rebases.
This PR changes
NativeSymbol
so that it does not extendIdScriptableObject
anymore, but rather uses theLambdaConstructor
APIs. This, combined with #1577, allows for easily adding theSymbol.prototype.descriptor
slot (which is a getter function).It makes all relevant test262 cases pass (and a few other unrelated ones). The one that does not pass,
prototype/description/this-val-non-symbol.js
, does not because it usesProxy
.