-
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] Different @@species getter for each constructor
https://bugs.webkit.org/show_bug.cgi?id=267039 Reviewed by Keith Miller. In JavaScriptCore, `Object.getOwnPropertyDescriptor(Array, Symbol.species).get === Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get` evaluates to true. This patch changes the @@species getters of each constructor to be different objects, so that the result of this expression becomes false. Remove the global `m_speciesGetterSetter` and create `m_arraySpeciesGetterSetter` and `m_regExpSpeciesGetterSetter` and ... for each constructor. Instead of passing the `GetterSetter*` type values as arguments to the create function of each constructor, refer to them from the `globalObject`. https://tc39.es/ecma262/#sec-get-regexp-@@species https://tc39.es/ecma262/#sec-get-array-@@species https://tc39.es/ecma262/#sec-get-%typedarray%-@@species https://tc39.es/ecma262/#sec-get-map-@@species https://tc39.es/ecma262/#sec-get-set-@@species https://tc39.es/ecma262/#sec-get-arraybuffer-@@species https://tc39.es/ecma262/#sec-sharedarraybuffer-@@species https://tc39.es/ecma262/#sec-get-promise-@@species * JSTests/stress/species-equivalence-typedarray.js: Added. (shouldBe): (readTypedArraySymbolSpeciesGetter): (runTest): * JSTests/stress/species-equivalence.js: Added. (shouldNotBe): (readSymbolSpeciesGetter): (runTest): * Source/JavaScriptCore/runtime/ArrayConstructor.cpp: (JSC::ArrayConstructor::finishCreation): * Source/JavaScriptCore/runtime/ArrayConstructor.h: * Source/JavaScriptCore/runtime/BigIntConstructor.h: * Source/JavaScriptCore/runtime/BooleanConstructor.cpp: (JSC::BooleanConstructor::create): * Source/JavaScriptCore/runtime/BooleanConstructor.h: * Source/JavaScriptCore/runtime/DateConstructor.h: * Source/JavaScriptCore/runtime/ErrorConstructor.h: * Source/JavaScriptCore/runtime/FinalizationRegistryConstructor.h: * Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp: (JSC::JSGenericArrayBufferConstructor<sharingMode>::finishCreation): * Source/JavaScriptCore/runtime/JSArrayBufferConstructor.h: * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildrenImpl): (JSC::JSGlobalObject::tryInstallSpeciesWatchpoint): (JSC::JSGlobalObject::installArraySpeciesWatchpoint): (JSC::JSGlobalObject::tryInstallArrayBufferSpeciesWatchpoint): (JSC::JSGlobalObject::tryInstallTypedArraySpeciesWatchpoint): (JSC::JSGlobalObject::installTypedArrayConstructorSpeciesWatchpoint): * Source/JavaScriptCore/runtime/JSGlobalObject.h: (JSC::JSGlobalObject::arraySpeciesGetterSetter const): (JSC::JSGlobalObject::typedArraySpeciesGetterSetter const): (JSC::JSGlobalObject::speciesGetterSetter const): Deleted. * Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h: (JSC::JSGlobalObject::arrayBufferSpeciesGetterSetter const): * Source/JavaScriptCore/runtime/JSInternalPromiseConstructor.cpp: (JSC::JSInternalPromiseConstructor::create): * Source/JavaScriptCore/runtime/JSInternalPromiseConstructor.h: * Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp: (JSC::JSPromiseConstructor::create): (JSC::JSPromiseConstructor::finishCreation): * Source/JavaScriptCore/runtime/JSPromiseConstructor.h: * Source/JavaScriptCore/runtime/JSTypedArrayViewConstructor.cpp: (JSC::JSTypedArrayViewConstructor::finishCreation): * Source/JavaScriptCore/runtime/JSTypedArrayViewConstructor.h: * Source/JavaScriptCore/runtime/MapConstructor.cpp: (JSC::MapConstructor::finishCreation): * Source/JavaScriptCore/runtime/MapConstructor.h: * Source/JavaScriptCore/runtime/NumberConstructor.cpp: (JSC::NumberConstructor::create): * Source/JavaScriptCore/runtime/NumberConstructor.h: * Source/JavaScriptCore/runtime/RegExpConstructor.cpp: (JSC::RegExpConstructor::finishCreation): * Source/JavaScriptCore/runtime/RegExpConstructor.h: * Source/JavaScriptCore/runtime/SetConstructor.cpp: (JSC::SetConstructor::finishCreation): * Source/JavaScriptCore/runtime/SetConstructor.h: * Source/JavaScriptCore/runtime/ShadowRealmConstructor.h: * Source/JavaScriptCore/runtime/StringConstructor.cpp: (JSC::StringConstructor::create): * Source/JavaScriptCore/runtime/StringConstructor.h: * Source/JavaScriptCore/runtime/SymbolConstructor.h: * Source/JavaScriptCore/runtime/WeakMapConstructor.h: * Source/JavaScriptCore/runtime/WeakObjectRefConstructor.h: * Source/JavaScriptCore/runtime/WeakSetConstructor.h: Canonical link: https://commits.webkit.org/275064@main
- Loading branch information
1 parent
29ee719
commit d91d519
Showing
36 changed files
with
175 additions
and
75 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,32 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error("Failed assertion: actual " + actual + " should be " + expected); | ||
} | ||
|
||
function readTypedArraySymbolSpeciesGetter(constructor) { | ||
return Object.getOwnPropertyDescriptor(Object.getPrototypeOf(constructor), Symbol.species).get; | ||
} | ||
|
||
function runTest(constructors) { | ||
for (let i = 0; i < constructors.length; i++) { | ||
for (let j = 0; j < constructors.length; j++) { | ||
if (i !== j) { | ||
shouldBe(readTypedArraySymbolSpeciesGetter(constructors[i]), readTypedArraySymbolSpeciesGetter(constructors[j])); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const constructors = [ | ||
Int8Array, | ||
Uint8Array, | ||
Uint8ClampedArray, | ||
Int16Array, | ||
Uint16Array, | ||
Int32Array, | ||
Uint32Array, | ||
Float32Array, | ||
Float64Array | ||
]; | ||
|
||
runTest(constructors); |
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,31 @@ | ||
function shouldNotBe(actual, expected) { | ||
if (actual === expected) | ||
throw new Error("Failed assertion: actual " + actual + " should not be " + expected); | ||
} | ||
|
||
function readSymbolSpeciesGetter(constructor) { | ||
return Object.getOwnPropertyDescriptor(constructor, Symbol.species).get; | ||
} | ||
|
||
function runTest(constructors) { | ||
for (let i = 0; i < constructors.length; i++) { | ||
for (let j = 0; j < constructors.length; j++) { | ||
if (i !== j) { | ||
shouldNotBe(readSymbolSpeciesGetter(constructors[i]), readSymbolSpeciesGetter(constructors[j])); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const constructors = [ | ||
Array, | ||
RegExp, | ||
Set, | ||
Map, | ||
Promise, | ||
ArrayBuffer, | ||
SharedArrayBuffer, | ||
Object.getPrototypeOf(Uint16Array) | ||
]; | ||
|
||
runTest(constructors); |
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
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
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
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
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
Oops, something went wrong.