Fix some issues in the ShadowRealm implementation
Categories
(Core :: JavaScript: Standard Library, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox108 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(11 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Assignee | ||
Comment 1•2 years ago
|
||
Clang-format writes each entry on a separate line when a trailing comma is
present. This produces nicer output in some cases.
Assignee | ||
Comment 2•2 years ago
|
||
CallArgs::operator[]
returns a rooted value, so it's not necessary to
re-root it.- It's not necessary to root a value when it's stored in
CallArgs::rval()
.
Depends on D160504
Assignee | ||
Comment 3•2 years ago
|
||
Prefer the internal API for consistency with the rest of SpiderMonkey. This
also avoids some extra overhead, for example we don't have to store the call
arguments first in RootedVector<Valu>
and then copy them into InvokeArgs
.
Directly using InvokeArgs
also fixes some cross-compartment assertions in the
current code, because it skips the compartment checks from JS::Call
when it
directly calls js::Call
. Part 10 will fix this code to use the correct
compartment for all values.
Depends on D160505
Assignee | ||
Comment 4•2 years ago
|
||
Avoid to call the resolve hook for the "name" property and avoid unnecessary
atomisation of the "name" string: IdToFunctionName
returns its input when
no function prefix is passed and the input is a JSAtom. And JS_StringToId
only
atomises the input string. Both operations are unnecessary here.
Also avoid single letter, upper case variable names for consistency with the
rest of the SpiderMonkey code base.
Depends on D160506
Assignee | ||
Comment 5•2 years ago
|
||
Depends on D160507
Assignee | ||
Comment 6•2 years ago
|
||
This matches how we handle this case for Promise handlers and it's much
faster.
Depends on D160508
Assignee | ||
Comment 7•2 years ago
|
||
NewBuiltinClassInstance
automatically selects the correct prototype.
Depends on D160509
Assignee | ||
Comment 8•2 years ago
|
||
The previous code assumed that the "name" property is always a string, but
user-code can redefine it to any value, which could easily lead to an exploit.
Furthermore the spec requires that the computed string matches the NativeFunction
production, so even if we only append the "name" when it's a string value, we'd
first have to parse the string as an identifier to determine if the string has to
be escaped or not. This is non-trivial, so instead follow the toString
output
of bound functions and return an unnamed function source code string.
Depends on D160510
Assignee | ||
Comment 9•2 years ago
|
||
This implements the changes from https://github.com/tc39/proposal-shadowrealm/pull/356.
Depends on D160511
Assignee | ||
Comment 10•2 years ago
|
||
Move the AutoRealm
in WrappedFunctionCreate
into a separate block to ensure
we're back in the original realm when we call CopyNameAndLength
. Without this
change an error thrown CopyNameAndLength
can escape the wrong realm to resp.
from the ShadowRealm.
Also add some cx->check()
calls to ensure arguments are in the correct compartment
in GetWrappedValue
and WrappedFunctionCreate
. And add cx->compartment()->wrap()
in some places which we're using the wrong compartment.
Depends on D160512
Assignee | ||
Comment 11•2 years ago
|
||
ValidateShadowRealmObject
didn't correctly handle non-CCW wrappers and was
missing error reporting when CheckedUnwrapDynamic()
returned nullptr
. Switch
to UnwrapAndTypeCheckValue
to fix both issues.
Depends on D160513
Comment 12•2 years ago
|
||
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
Backed out for causing spidermonkey failures on WrappedFunctionObject.cpp.
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/checkouts/gecko/js/src/builtin/WrappedFunctionObject.cpp:122:12: error: no member named 'Call' in namespace 'js'
Assignee | ||
Updated•2 years ago
|
Comment 15•2 years ago
|
||
Comment 16•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/81e98a6cf3cd
https://hg.mozilla.org/mozilla-central/rev/b396bff2aad9
https://hg.mozilla.org/mozilla-central/rev/356aa1ad2aa7
https://hg.mozilla.org/mozilla-central/rev/f448d1f36f8c
https://hg.mozilla.org/mozilla-central/rev/de23ee558eac
https://hg.mozilla.org/mozilla-central/rev/b4a1d3a92cd2
https://hg.mozilla.org/mozilla-central/rev/e375bc432e37
https://hg.mozilla.org/mozilla-central/rev/a900fb44f606
https://hg.mozilla.org/mozilla-central/rev/8083ae8e8e43
https://hg.mozilla.org/mozilla-central/rev/a581812a6162
https://hg.mozilla.org/mozilla-central/rev/9fc0e520ba91
Description
•