Closed
Bug 1395360
Opened 7 years ago
Closed 7 years ago
Make easier for JSAPI to execute in NonSyntacticVariablesObject environments
Categories
(Core :: JavaScript Engine, defect, P1)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla57
Tracking | Status | |
---|---|---|
firefox57 | --- | fixed |
People
(Reporter: tcampbell, Assigned: tcampbell)
References
Details
Attachments
(2 files)
The JSM loader use-case pre-populates an NSVO with properties such as __URI__. This patch adds a new jsfriendapi ExecuteInNonSyntacticGlobal that allows environment to be in-outs.
This allows allocating the environment before execution and setting properties. The environment is also returned out to allow executing other scripts in same context or looking at bindings.
NOTE: The |this| binding is still the global and not the NSVO. I'm working on follow-up patches to untangle that.
Comment hidden (mozreview-request) |
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → tcampbell
Assignee | ||
Comment 2•7 years ago
|
||
Depends on Bug 1394490 to be able to set |this| to NSVO.
Depends on: 1394490
Updated•7 years ago
|
Status: NEW → ASSIGNED
Updated•7 years ago
|
Priority: -- → P1
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 9•7 years ago
|
||
mozreview-review |
Comment on attachment 8902927 [details]
Bug 1395360 - Factor out ExecuteInNonSyntacticGlobalInternal
https://reviewboard.mozilla.org/r/174658/#review180680
::: js/src/builtin/Eval.cpp:457
(Diff revision 4)
> +{
> + RootedObject varEnv(cx, NonSyntacticVariablesObject::create(cx));
> + if (!varEnv)
> + return false;
> +
> + RootedObject lexEnv(cx, LexicalEnvironmentObject::createNonSyntactic(cx, varEnv, varEnv));
We need to add this to the non-syntactic lexical environments map for the compartment, like we do when calling ExecuteScript with an env chain, or the component loader won't be able to resolve exported lexical symbols when loading modules:
http://searchfox.org/mozilla-central/rev/51b3d67a5ec1758bd2fe7d7b6e75ad6b6b5da223/js/src/jsapi.cpp#3569
http://searchfox.org/mozilla-central/rev/51b3d67a5ec1758bd2fe7d7b6e75ad6b6b5da223/js/src/jscompartment.cpp#588
http://searchfox.org/mozilla-central/rev/51b3d67a5ec1758bd2fe7d7b6e75ad6b6b5da223/js/xpconnect/loader/mozJSComponentLoader.cpp#315-332
Assignee | ||
Updated•7 years ago
|
Attachment #8902927 -
Flags: review?(jorendorff)
Attachment #8903758 -
Flags: review?(jorendorff)
Assignee | ||
Comment 10•7 years ago
|
||
Pulling review request. It was premature before we have the JSM bug working since it is the only consumer of this API change. Sorry :(
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•7 years ago
|
Attachment #8902927 -
Flags: review?(jorendorff)
Attachment #8903758 -
Flags: review?(jorendorff)
Assignee | ||
Comment 15•7 years ago
|
||
Putting new attempt up for review now. This works with the JSM shared global patch and that build has been stable for my daily browser for a couple days.
Comment 16•7 years ago
|
||
mozreview-review |
Comment on attachment 8902927 [details]
Bug 1395360 - Factor out ExecuteInNonSyntacticGlobalInternal
https://reviewboard.mozilla.org/r/174658/#review182588
::: js/src/builtin/Eval.cpp:454
(Diff revision 5)
> - MutableHandleObject envArg)
> + HandleObject varEnv, HandleObject lexEnv)
> {
> CHECK_REQUEST(cx);
> assertSameCompartment(cx, global);
> + assertSameCompartment(cx, varEnv);
> + assertSameCompartment(cx, lexEnv);
There are overrides so that you can say:
assertSameCompartment(cx, global, varEnv, lexEnv);
Attachment #8902927 -
Flags: review?(jorendorff) → review+
Comment 17•7 years ago
|
||
mozreview-review |
Comment on attachment 8903758 [details]
Bug 1395360 - Add ExecuteInNonSyntacticGlobal to jsfriendapi
https://reviewboard.mozilla.org/r/175506/#review182592
::: js/src/builtin/Eval.cpp:498
(Diff revision 6)
> envArg.set(lexEnv);
> return true;
> }
> +
> +JS_FRIEND_API(JSObject*)
> +js::CreateNonSyntacticGlobal(JSContext* cx)
I don't think it's a good idea to call this a "NonSyntacticGlobal". It really isn't a global; at best it's an object that acts kind of like a global. And "non-syntactic" as a qualifier won't help anyone figure out the distinction...
I'd be happier with `js::NewJSMEnvironment(cx)`. Any name better than that is just gravy.
Attachment #8903758 -
Flags: review?(jorendorff) → review+
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 20•7 years ago
|
||
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d89ac77cac51
Factor out ExecuteInNonSyntacticGlobalInternal r=jorendorff
https://hg.mozilla.org/integration/autoland/rev/d731723c09f7
Add ExecuteInNonSyntacticGlobal to jsfriendapi r=jorendorff
Comment 21•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d89ac77cac51
https://hg.mozilla.org/mozilla-central/rev/d731723c09f7
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in
before you can comment on or make changes to this bug.
Description
•