Bug 221093 - Support Ergonomic Brand Checks proposal (`#x in obj`)
Summary: Support Ergonomic Brand Checks proposal (`#x in obj`)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ross Kirsling
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-28 10:27 PST by Jordan Harband
Modified: 2021-05-22 20:50 PDT (History)
12 users (show)

See Also:


Attachments
Patch (44.98 KB, patch)
2021-05-06 16:53 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (45.07 KB, patch)
2021-05-17 12:45 PDT, Ross Kirsling
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (45.08 KB, patch)
2021-05-17 13:16 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (47.49 KB, patch)
2021-05-22 16:23 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch for landing (47.53 KB, patch)
2021-05-22 20:03 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jordan Harband 2021-01-28 10:27:55 PST
See https://github.com/tc39/proposal-private-fields-in-in - as of yesterday, it is now stage 3. It'd be great to see Webkit ship this feature ASAP!
Comment 1 Radar WebKit Bug Importer 2021-02-04 10:28:12 PST
<rdar://problem/73987372>
Comment 2 Jordan Harband 2021-04-19 07:53:26 PDT
test262 tests have landed: https://github.com/tc39/test262/pull/2963

it'd be great to see this implemented :-D
Comment 3 Ross Kirsling 2021-05-06 16:53:42 PDT
Created attachment 427961 [details]
Patch
Comment 4 Ross Kirsling 2021-05-10 13:50:56 PDT
Comment on attachment 427961 [details]
Patch

(Marking r? since this is a fully-working patch, but I've asked for backend guidance on Slack.)
Comment 5 Caio Lima 2021-05-11 12:13:59 PDT
Comment on attachment 427961 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=427961&action=review

Patch LGTM. I left couple of suggestions.

> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2823
> +        emitThrowTypeError("Cannot access static private method or accessor");

Thank you for fixing this.

> Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:2111
> +            fixEdge<CellUse>(node->child1());

Since we throw on anything but Object, I think it would be fine use `ObjectUse` here. However, this choice will cause OSR whenever `base` (i.e child1) is not an object. It is also true for non-cell types for the code as it is.

> Source/JavaScriptCore/jit/JITOperations.cpp:484
> +        return JSValue::encode(jsBoolean(false));

I’d prefer return here `JSValue()`

> Source/JavaScriptCore/jit/JITOperations.cpp:506
> +        return JSValue::encode(jsBoolean(false));

ditto
Comment 6 Ross Kirsling 2021-05-11 14:34:50 PDT
(In reply to Caio Lima from comment #5)
> > Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:2111
> > +            fixEdge<CellUse>(node->child1());
> 
> Since we throw on anything but Object, I think it would be fine use
> `ObjectUse` here. However, this choice will cause OSR whenever `base` (i.e
> child1) is not an object. It is also true for non-cell types for the code as
> it is.

Hmm, one way or another, I think I'd like to keep this part consistent with InByVal/InById, since this operand behaves identically.
Comment 7 Ross Kirsling 2021-05-17 12:45:44 PDT
Created attachment 428855 [details]
Patch

Addressed comments and made the feature off-by-default per our meeting. Will aim to optimize InByVal itself next and then mimic that functionality for this feature.
Comment 8 Ross Kirsling 2021-05-17 13:16:07 PDT
Created attachment 428857 [details]
Patch
Comment 9 Caio Lima 2021-05-21 09:51:17 PDT
Comment on attachment 428857 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=428857&action=review

r=me with comments

> Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:3220
> +        }

I’d assert here if it’s a private method or accessor

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:8279
> +            auto bytecode = currentInstruction->as<OpHasPrivateName>();

Could you add a FIXME to point to a bug where we could inline this operation?

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:8285
> +            auto bytecode = currentInstruction->as<OpHasPrivateBrand>();

Ditto

> Source/JavaScriptCore/runtime/JSObjectInlines.h:702
> +    ASSERT(brand.isSymbol());

Could we assert here that it’s also a PrivateSymbol?

> JSTests/stress/private-in.js:58
> +  shouldThrowTypeError(() => SS.isSS(3));

It would be nice test cases where we evaluate a class more than once.
Comment 10 Ross Kirsling 2021-05-22 16:23:00 PDT
Created attachment 429435 [details]
Patch
Comment 11 EWS 2021-05-22 19:45:40 PDT
Caio Lima found in /Volumes/Data/worker/Commit-Queue/build/JSTests/ChangeLog does not appear to be a valid reviewer according to contributors.json.
/Volumes/Data/worker/Commit-Queue/build/JSTests/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).
Comment 12 Ross Kirsling 2021-05-22 20:03:05 PDT
Created attachment 429451 [details]
Patch for landing
Comment 13 EWS 2021-05-22 20:50:14 PDT
Committed r277926 (238057@main): <https://commits.webkit.org/238057@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429451 [details].