-
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.
Reflect.construct can churn cached internalFunctionAllocationStructure
https://bugs.webkit.org/show_bug.cgi?id=263945 rdar://117556294 Reviewed by Keith Miller. Reviewed by Mark Lam. Reflect.construct can churn the cached internalFunctionAllocationStructure when calling the target's prototype getter, causing us to fail a debug assert. This isn't really a problem though, since accidentally making a second structure shouldn't break anything (like our watchpoints or structure transition logic). We just add an extra check to silence the debug assert and be slightly more optimal. * JSTests/stress/reflect-construct-reenter-prototype-get-different-global.js: Added. (newTarget): (get let): * JSTests/stress/reflect-construct-reenter-prototype-get.js: Added. (newTarget): (get let): * Source/JavaScriptCore/runtime/InternalFunction.cpp: (JSC::InternalFunction::createSubclassStructure): Canonical link: https://commits.webkit.org/270084@main
- Loading branch information
Justin Michaud
committed
Nov 1, 2023
1 parent
50b8e0f
commit ae0b70e
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
JSTests/stress/reflect-construct-reenter-prototype-get-different-global.js
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,25 @@ | ||
var buffer = new ArrayBuffer(3); | ||
|
||
var newTarget = function () { | ||
}.bind(null) | ||
|
||
let i = 0 | ||
|
||
let newGlobal = $vm.createGlobalObject() | ||
|
||
Object.defineProperty(newTarget, 'prototype', { | ||
get: function () { | ||
let iter = i | ||
++i; | ||
// print(iter) | ||
if (iter >= 1) | ||
return { } | ||
// print("Construct B", iter) | ||
Reflect.construct(newGlobal.Object, [], newTarget); | ||
// print("Construct B Done: ", iter) | ||
return { }; | ||
} | ||
}); | ||
|
||
// print("Construct A") | ||
var result = Reflect.construct(Object, [], newTarget); |
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,23 @@ | ||
var buffer = new ArrayBuffer(3); | ||
|
||
var newTarget = function () { | ||
}.bind(null) | ||
|
||
let i = 0 | ||
|
||
Object.defineProperty(newTarget, 'prototype', { | ||
get: function () { | ||
let iter = i | ||
++i; | ||
// print(iter) | ||
if (iter >= 1) | ||
return { } | ||
// print("Construct B", iter) | ||
Reflect.construct(Object, [], newTarget); | ||
// print("Construct B Done: ", iter) | ||
return { }; | ||
} | ||
}); | ||
|
||
// print("Construct A") | ||
var result = Reflect.construct(Object, [], newTarget); |
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