-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSC] Create (async) generator object after performing FunctionDeclar…
…ationInstantiation https://bugs.webkit.org/show_bug.cgi?id=263617 <rdar://problem/117439419> Reviewed by Justin Michaud. initializeDefaultParameterValuesAndSetupFunctionScopeStack(), which implements steps 25-26 of FunctionDeclarationInstantiation [1], may call into arbitrary userland code when evaluating default parameters, affecting the [[Prototype]] of created & returned (async) generator object. With this change, (async) generator object creation happens after parameter initialization, aligning JSC with the spec [1][2] and SpiderMonkey. [1]: https://tc39.es/ecma262/#sec-functiondeclarationinstantiation [2]: https://tc39.es/ecma262/#sec-runtime-semantics-evaluategeneratorbody (step 2) [3]: https://tc39.es/ecma262/#sec-runtime-semantics-evaluateasyncgeneratorbody (step 2) * JSTests/stress/regress-263617.js: Added. * JSTests/test262/expectations.yaml: Mark 8 tests as passing. * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): Canonical link: https://commits.webkit.org/269823@main
- Loading branch information
Alexey Shvayka
committed
Oct 26, 2023
1 parent
8ba72bd
commit d9e5846
Showing
3 changed files
with
21 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function assert(x) { | ||
if (!x) | ||
throw new Error("Bad assertion!"); | ||
} | ||
|
||
class Foo { | ||
static * staticGen(arg = (Foo.staticGen.prototype = 1)) {} | ||
async * asyncGen(arg = (Foo.prototype.asyncGen.prototype = true)) {} | ||
} | ||
|
||
const staticGenOriginalPrototype = Foo.staticGen.prototype; | ||
const asyncGenOriginalPrototype = Foo.prototype.asyncGen.prototype; | ||
|
||
assert(Foo.staticGen().__proto__ !== staticGenOriginalPrototype); | ||
assert(Foo.prototype.asyncGen().__proto__ !== asyncGenOriginalPrototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters