Closed
Bug 1471924
Opened 8 years ago
Closed 8 years ago
Implement realm switching for Class call/construct hooks
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla63
| Tracking | Status | |
|---|---|---|
| firefox63 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
Details
Attachments
(3 files, 1 obsolete file)
|
10.18 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
5.74 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
843 bytes,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
These hooks are just JSNatives and it's nice to have the invariant that all JSNatives are called with cx->realm == the callee's realm.
Now, we don't want to switch realms for proxies (bug 1297179) and proxies are currently special-cased in JSObject::{callHook,constructHook}. We can do some nice refactoring though to pull the proxy code out of callHook/constructHook and just have InternalCallOrConstruct call Proxy::{call,construct} directly if we have a proxy. After that we can always enter the callee's realm in CallJSNative.
| Assignee | ||
Comment 1•8 years ago
|
||
Attachment #8988517 -
Flags: review?(luke)
| Assignee | ||
Comment 2•8 years ago
|
||
Now CallJSNative is never called for proxy callees so we can simply enter the callee's realm there.
Attachment #8988518 -
Flags: review?(luke)
Comment 3•8 years ago
|
||
Comment on attachment 8988517 [details] [diff] [review]
Part 1 - Stop pretending proxies have a JSNative call/construct hook
Review of attachment 8988517 [details] [diff] [review]:
-----------------------------------------------------------------
Wow, nice.
Attachment #8988517 -
Flags: review?(luke) → review+
Updated•8 years ago
|
Attachment #8988518 -
Flags: review?(luke) → review+
Comment 5•8 years ago
|
||
Thanks for fixing bug 1331410, too. :-D
| Assignee | ||
Comment 6•8 years ago
|
||
(In reply to André Bargull [:anba] from comment #5)
> Thanks for fixing bug 1331410, too. :-D
\o/
| Assignee | ||
Comment 7•8 years ago
|
||
It just occurred to me we can actually add a proxy test too. Bug 1297179 should be partially fixed with same-compartment realms (the proxy part, not the bound function part) so I had to see if that test passes now and it does :)
Attachment #8988601 -
Flags: review?(andrebargull)
| Assignee | ||
Comment 8•8 years ago
|
||
Attachment #8988601 -
Attachment is obsolete: true
Attachment #8988601 -
Flags: review?(andrebargull)
Attachment #8988604 -
Flags: review?(andrebargull)
Comment 9•8 years ago
|
||
Comment on attachment 8988604 [details] [diff] [review]
Part 3 - Add a proxy testcase
Review of attachment 8988604 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jit-test/tests/realms/proxy-realm.js
@@ +2,5 @@
> +
> +load(libdir + "asserts.js");
> +
> +var g = newGlobal({sameCompartmentAs: this});
> +var {proxy, revoke} = g.eval(`Proxy.revocable(() => {}, {})`);
The |new proxy()| case was actually already passing when using an arrow function as the underlying proxy target. Only when the proxy target is actually a constructor, which then makes the proxy a constructor, too, |new proxy()| doesn't throw a TypeError from the correct realm.
Attachment #8988604 -
Flags: review?(andrebargull) → review+
| Assignee | ||
Comment 10•8 years ago
|
||
(In reply to André Bargull [:anba] from comment #9)
> The |new proxy()| case was actually already passing when using an arrow
> function as the underlying proxy target.
D'oh, good catch. I'll change it to a non-arrow function and verify adding an AutoRealm before the Proxy::construct call breaks the test (I checked this for Proxy::call but not Proxy::construct..).
Comment 11•8 years ago
|
||
Pushed by jandemooij@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/da138f7c70ef
part 1 - Stop pretending proxies have a JSNative call/construct hook. r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/0807cc4090d9
part 2 - Enter callee's realm when calling Class call/construct hooks. r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/a7a4c5bb5efb
part 3 - Add a proxy testcase. r=anba
Comment 12•8 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/da138f7c70ef
https://hg.mozilla.org/mozilla-central/rev/0807cc4090d9
https://hg.mozilla.org/mozilla-central/rev/a7a4c5bb5efb
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•