diff --git a/JSTests/ChakraCore.yaml b/JSTests/ChakraCore.yaml index 7cf8381e38f56..c0d37267a681c 100644 --- a/JSTests/ChakraCore.yaml +++ b/JSTests/ChakraCore.yaml @@ -303,7 +303,7 @@ - path: ChakraCore/test/Basics/scan.js cmd: runChakra :baseline, "NoException", "scan.baseline-jsc", [] - path: ChakraCore/test/Basics/enum.js - cmd: runChakra :baseline, "NoException", "enum.baseline-jsc", [] + cmd: runChakra :pass, "NoException", "", [] - path: ChakraCore/test/Basics/with3.js cmd: runChakra :baseline, "NoException", "with3.baseline-jsc", [] - path: ChakraCore/test/Basics/cross_site_accessor_main.js diff --git a/JSTests/ChakraCore/test/Basics/enum.baseline-jsc b/JSTests/ChakraCore/test/Basics/enum.baseline-jsc deleted file mode 100644 index 86911206a331c..0000000000000 --- a/JSTests/ChakraCore/test/Basics/enum.baseline-jsc +++ /dev/null @@ -1,117 +0,0 @@ -x:a.x -q:a.q -u:a.q -z:f.p.z -r:f.p.r -y:o.p.y -Object a -x -y -u -z -Math -u -x -y -z -Array -u -x -y -z -Array.prototype -u -x -y -z -Date -u -x -y -z -Number -u -x -y -z -String -u -x -y -z -Object.prototype -u -x -y -z -Object -u -x -y -z -Array.prototype.sort -u -x -y -z -function foo -u -x -y -z -x -u -y -z -me here -prototype chain -u -x -y -z -Literal String -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -zz -u -x -y -z -String Object -xx -yy -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -zz -u -x -y -z -5 -u -x -y -z -3 -u -x -y -z diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog index faef6ef6c0e7e..63ad61be70c0c 100644 --- a/JSTests/ChangeLog +++ b/JSTests/ChangeLog @@ -1,3 +1,21 @@ +2021-01-07 Alexey Shvayka + + [JSC] Simplify get*PropertyNames() methods and EnumerationMode + https://bugs.webkit.org/show_bug.cgi?id=212954 + + Reviewed by Yusuke Suzuki. + + * ChakraCore.yaml: + * ChakraCore/test/Basics/enum.baseline-jsc: Removed. + * microbenchmarks/for-in-on-object-with-lazily-materialized-properties.js: + Removed because ErrorInstance no longer materializes properties during for/in enumeration. + + * microbenchmarks/object-keys-cloned-arguments.js: Added. + * microbenchmarks/object-keys-error-object.js: Added. + * stress/arguments-properties-order.js: Added. + * stress/for-in-tests.js: + * stress/for-in-typed-array.js: + 2021-01-07 Yusuke Suzuki [JSC] New expression and value function call should reserve function register if arguments include assignments diff --git a/JSTests/microbenchmarks/for-in-on-object-with-lazily-materialized-properties.js b/JSTests/microbenchmarks/for-in-on-object-with-lazily-materialized-properties.js deleted file mode 100644 index e8c607684695c..0000000000000 --- a/JSTests/microbenchmarks/for-in-on-object-with-lazily-materialized-properties.js +++ /dev/null @@ -1,15 +0,0 @@ -//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py -function foo(o) { - var count = 0; - for (var p in o) { - if (o[p]) - count ++; - } - return count; -} -noInline(foo); - -var total = 0; -for (let j = 0; j < 100000; ++j) - total += foo(new Error); - diff --git a/JSTests/microbenchmarks/object-keys-cloned-arguments.js b/JSTests/microbenchmarks/object-keys-cloned-arguments.js new file mode 100644 index 0000000000000..f4b540e19ed08 --- /dev/null +++ b/JSTests/microbenchmarks/object-keys-cloned-arguments.js @@ -0,0 +1,9 @@ +noInline(Object.keys); + +function getArgs(a, b, c) { + "use strict"; + return arguments; +} + +for (var i = 0; i < 2e5; ++i) + Object.keys(getArgs(1, 2, 3)); diff --git a/JSTests/microbenchmarks/object-keys-error-object.js b/JSTests/microbenchmarks/object-keys-error-object.js new file mode 100644 index 0000000000000..7103313550e45 --- /dev/null +++ b/JSTests/microbenchmarks/object-keys-error-object.js @@ -0,0 +1,4 @@ +noInline(Object.keys); + +for (var i = 0; i < 2e5; ++i) + Object.keys(new Error()); diff --git a/JSTests/stress/arguments-properties-order.js b/JSTests/stress/arguments-properties-order.js new file mode 100644 index 0000000000000..7794711fb47be --- /dev/null +++ b/JSTests/stress/arguments-properties-order.js @@ -0,0 +1,79 @@ +function getMappedArguments(a, b) { return arguments; } +function getUnmappedArguments(a, b) { "use strict"; return arguments; } + +function shouldBeArray(actual, expected) { + var isEqual = + actual.length === expected.length && + actual.every((item, index) => item === expected[index]); + if (!isEqual) + throw new Error(`Expected [${actual.map(String)}] to equal [${expected.map(String)}]`); +} + +function forIn(object) { + var keys = []; + for (var key in object) + keys.push(key); + return keys; +} + +noInline(getMappedArguments); +noInline(getUnmappedArguments); +noInline(forIn); + +(function() { + for (var i = 0; i < 1e4; ++i) { + var mappedArguments = getMappedArguments(0, 1, 2); + shouldBeArray(forIn(mappedArguments), ["0", "1", "2"]); + shouldBeArray(Object.keys(mappedArguments), ["0", "1", "2"]); + shouldBeArray(Reflect.ownKeys(mappedArguments), ["0", "1", "2", "length", "callee", Symbol.iterator]); + + var unmappedArguments = getUnmappedArguments(0); + shouldBeArray(forIn(unmappedArguments), ["0"]); + shouldBeArray(Object.keys(unmappedArguments), ["0"]); + shouldBeArray(Reflect.ownKeys(unmappedArguments), ["0", "length", "callee", Symbol.iterator]); + } +})(); + +(function() { + for (var i = 0; i < 1e4; ++i) { + var mappedArguments = getMappedArguments(0, 1); + mappedArguments[8] = 8; + mappedArguments[2] = 2; + shouldBeArray(forIn(mappedArguments), ["0", "1", "2", "8"]); + shouldBeArray(Object.keys(mappedArguments), ["0", "1", "2", "8"]); + shouldBeArray(Reflect.ownKeys(mappedArguments), ["0", "1", "2", "8", "length", "callee", Symbol.iterator]); + + var unmappedArguments = getUnmappedArguments(); + unmappedArguments[12] = 12; + unmappedArguments[3] = 3; + shouldBeArray(forIn(unmappedArguments), ["3", "12"]); + shouldBeArray(Object.keys(unmappedArguments), ["3", "12"]); + shouldBeArray(Reflect.ownKeys(unmappedArguments), ["3", "12", "length", "callee", Symbol.iterator]); + } +})(); + +(function() { + for (var i = 0; i < 1e4; ++i) { + var mappedArguments = getMappedArguments(0); + mappedArguments.foo = 1; + mappedArguments.bar = 2; + shouldBeArray(forIn(mappedArguments), ["0", "foo", "bar"]); + shouldBeArray(Object.keys(mappedArguments), ["0", "foo", "bar"]); + // FIXME: Symbol.iterator should come after "foo" and "bar" + // shouldBeArray(Reflect.ownKeys(mappedArguments), ["0", "length", "callee", "foo", "bar", Symbol.iterator]); + + var unmappedArguments = getUnmappedArguments(0, 1, 2); + unmappedArguments.foo = 1; + unmappedArguments.bar = 2; + shouldBeArray(forIn(unmappedArguments), ["0", "1", "2", "foo", "bar"]); + shouldBeArray(Object.keys(unmappedArguments), ["0", "1", "2", "foo", "bar"]); + // FIXME: "callee" should come before "foo" and "bar" + // shouldBeArray(Reflect.ownKeys(unmappedArguments), ["0", "1", "2", "length", "callee", "foo", "bar", Symbol.iterator]); + } +})(); + +// FIXME: Add more tests, covering: +// * added symbol properties; +// * added together index, non-index, and symbol properties; +// * deleted, re-added, and redefined as DontEnum index properties, both within and beyond "length"; +// * deleted, re-added, and redefined as DontEnum "length", "callee", and Symbol.iterator properties. diff --git a/JSTests/stress/for-in-tests.js b/JSTests/stress/for-in-tests.js index 3282c5f1db439..2e4d6b842a242 100644 --- a/JSTests/stress/for-in-tests.js +++ b/JSTests/stress/for-in-tests.js @@ -87,6 +87,24 @@ function shouldThrowSyntaxError(script) { } foo(null); })(); +(function() { + // Iterate over an object with non-reified static property names & structure property + if (typeof WebAssembly === "undefined") + return; + + WebAssembly.foo = 1; + + function forIn() { + for (var key in WebAssembly) {} + return key; + } + noInline(forIn); + + for (var i = 0; i < 10000; ++i) { + if (forIn() !== "foo") + throw new Error("bad result"); + } +})(); (function() { var foo = function(a, b) { for (var p in b) { diff --git a/JSTests/stress/for-in-typed-array.js b/JSTests/stress/for-in-typed-array.js index 08f8828b961f4..02c9aca74fc69 100644 --- a/JSTests/stress/for-in-typed-array.js +++ b/JSTests/stress/for-in-typed-array.js @@ -16,3 +16,25 @@ } foo(null); })(); + +(function() { + function forIn() { + var a = new Int32Array(4); + a.foo = 1; + a.bar = 2; + for (var i = 0; i < a.length; ++i) + a[i] = i; + + var keys = []; + for (var k in a) + keys.push(k); + return keys.join("|"); + } + noInline(forIn); + + for (var i = 0; i < 1e4; ++i) { + var keys = forIn(); + if (keys !== "0|1|2|3|foo|bar") + throw new Error(`Bad result: ${keys}`); + } +})(); diff --git a/Source/JavaScriptCore/API/JSAPIValueWrapper.h b/Source/JavaScriptCore/API/JSAPIValueWrapper.h index 10a9397f5e03b..60f46ca75d196 100644 --- a/Source/JavaScriptCore/API/JSAPIValueWrapper.h +++ b/Source/JavaScriptCore/API/JSAPIValueWrapper.h @@ -33,13 +33,7 @@ class JSAPIValueWrapper final : public JSCell { friend JSValue jsAPIValueWrapper(JSGlobalObject*, JSValue); public: using Base = JSCell; - - // OverridesAnyFormOfGetPropertyNames (which used to be OverridesGetPropertyNames) was here - // since ancient times back when we pessimistically choose to apply this flag. I think we - // can remove it, but we should do more testing before we do so. - // Ref: http://trac.webkit.org/changeset/49694/webkit#file9 - // FIXME: https://bugs.webkit.org/show_bug.cgi?id=212954 - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesAnyFormOfGetPropertyNames | StructureIsImmortal; + static constexpr unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; template static IsoSubspace* subspaceFor(VM& vm) diff --git a/Source/JavaScriptCore/API/JSCallbackObject.h b/Source/JavaScriptCore/API/JSCallbackObject.h index 637e9ae96a486..5c5b71c013336 100644 --- a/Source/JavaScriptCore/API/JSCallbackObject.h +++ b/Source/JavaScriptCore/API/JSCallbackObject.h @@ -125,7 +125,7 @@ template class JSCallbackObject final : public Parent { public: using Base = Parent; - static constexpr unsigned StructureFlags = Base::StructureFlags | ProhibitsPropertyCaching | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | ImplementsHasInstance | OverridesAnyFormOfGetPropertyNames | OverridesGetCallData; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames | OverridesGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | ImplementsHasInstance | ProhibitsPropertyCaching; static_assert(!(StructureFlags & ImplementsDefaultHasInstance), "using customHasInstance"); ~JSCallbackObject(); @@ -211,7 +211,7 @@ class JSCallbackObject final : public Parent { static bool customHasInstance(JSObject*, JSGlobalObject*, JSValue); - static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static CallData getConstructData(JSCell*); static CallData getCallData(JSCell*); diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h index 3cbe76eca8c03..886885790516a 100644 --- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -569,7 +569,7 @@ EncodedJSValue JSCallbackObject::callImpl(JSGlobalObject* globalObject, } template -void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSCallbackObject::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = getVM(globalObject); JSCallbackObject* thisObject = jsCast(object); @@ -588,7 +588,7 @@ void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, JSG for (iterator it = staticValues->begin(); it != end; ++it) { StringImpl* name = it->key.get(); StaticValueEntry* entry = it->value.get(); - if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties())) { + if (entry->getProperty && (mode == DontEnumPropertiesMode::Include || !(entry->attributes & kJSPropertyAttributeDontEnum))) { ASSERT(!name->isSymbol()); propertyNames.add(Identifier::fromString(vm, String(name))); } @@ -601,15 +601,13 @@ void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, JSG for (iterator it = staticFunctions->begin(); it != end; ++it) { StringImpl* name = it->key.get(); StaticFunctionEntry* entry = it->value.get(); - if (!(entry->attributes & kJSPropertyAttributeDontEnum) || mode.includeDontEnumProperties()) { + if (mode == DontEnumPropertiesMode::Include || !(entry->attributes & kJSPropertyAttributeDontEnum)) { ASSERT(!name->isSymbol()); propertyNames.add(Identifier::fromString(vm, String(name))); } } } } - - Parent::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode); } template diff --git a/Source/JavaScriptCore/API/JSObjectRef.cpp b/Source/JavaScriptCore/API/JSObjectRef.cpp index 363b8af4b48bb..9584f76e5cfef 100644 --- a/Source/JavaScriptCore/API/JSObjectRef.cpp +++ b/Source/JavaScriptCore/API/JSObjectRef.cpp @@ -808,7 +808,7 @@ JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef o JSObject* jsObject = toJS(object); JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(&vm); PropertyNameArray array(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - jsObject->methodTable(vm)->getPropertyNames(jsObject, globalObject, array, EnumerationMode()); + jsObject->getPropertyNames(globalObject, array, DontEnumPropertiesMode::Exclude); size_t size = array.size(); propertyNames->array.reserveInitialCapacity(size); diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index ecc6b8d10e21a..5b563ccadeb8d 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,219 @@ +2021-01-07 Alexey Shvayka + + [JSC] Simplify get*PropertyNames() methods and EnumerationMode + https://bugs.webkit.org/show_bug.cgi?id=212954 + + Reviewed by Yusuke Suzuki. + + Before this change, [[OwnPropertyKeys]] overrides were sometimes implemented + inconsistently, via different get*PropertyNames() methods that duplicated logic + (e.g. ErrorInstance, RegExpObject, and StringObject). + + This patch: + + 1. Introduces a clear convention to implement [[OwnPropertyKeys]] overrides: + if it's defined by the spec, getOwnPropertyNames() method is used; otherwise, + non-materialized properties are enumerated / reified in getOwnSpecialPropertyNames(). + While no class should define both methods, we don't assert this to support inheritance. + + Removes getOwnNonIndexPropertyNames() from the method table and converts it to instance + method; its overrides were renamed to getOwnSpecialPropertyNames() and exempted from + calling the no-op base method. + + This approach was chosen, instead of getOwnNonIndexPropertyNames() override, because + for/in enumeration must be sure there are no enumerable properties between + getEnumerableLength() and the first structure property. + + Also, removes getStructurePropertyNames() from the method table as it's unreasonable + to override it. + + 2. Extracts JSObject::getOwnIndexPropertyNames() instance method to enforce + correct enumeration order in getOwnPropertyNames() overrides: special indices => + butterfly storage => special properties => non-reified static => structure properties. + + Loose mode `arguments` were fixed to enumerate indices from butterfly storage before + special properties [1], aligning JSC with V8 and SpiderMonkey. + + 3. Reworks for/in enumeration so the special properties always come before structure ones, + aligning enumeration order of String objects [2] and typed arrays [3] that have expando + properties with the spec, V8, and SpiderMonkey. + + Removes getPropertyNames() and getGenericPropertyNames() from the method table, along + with their overrides, because ES7 disabled customization of for/in enumeration [4]. + Instead, JSObject::getPropertyNames() instance method and getEnumerablePropertyNames() + are introduced, featuring a loop instead of recursion. + + Also, this enabled dropping hard-to-follow JSObjectPropertiesMode bit and simplifying + EnumerationMode to an enum. + + for/in and Object.keys microbenchmarks are neutral. This change does not affect + JSPropertyNameEnumerator caching, nor fast paths of its bytecodes. + + [1]: https://tc39.es/ecma262/#sec-createmappedargumentsobject (steps 15-16 and 20-21) + [2]: https://tc39.es/ecma262/#sec-string-exotic-objects-ownpropertykeys + [3]: https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-ownpropertykeys + [4]: https://github.com/tc39/ecma262/pull/367 + + * API/JSAPIValueWrapper.h: + Remove OverridesAnyFormOfGetPropertyNames structure flag as it should never be queried + from JSCell instances. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (JSC::JSCallbackObject::getOwnSpecialPropertyNames): + (JSC::JSCallbackObject::getOwnNonIndexPropertyNames): Deleted. + * API/JSObjectRef.cpp: + (JSObjectCopyPropertyNames): + * bindings/ScriptValue.cpp: + (Inspector::jsToInspectorValue): + * bytecode/ObjectAllocationProfileInlines.h: + (JSC::ObjectAllocationProfileBase::possibleDefaultPropertyCount): + Use DontEnumPropertyMode::Include as the intent is to count all properties, even + private symbols. EnumerationMode() defaults did exclude non-enumerable properties. + + * debugger/DebuggerScope.cpp: + (JSC::DebuggerScope::getOwnPropertyNames): + * debugger/DebuggerScope.h: + * runtime/ClassInfo.h: + * runtime/ClonedArguments.cpp: + (JSC::ClonedArguments::getOwnSpecialPropertyNames): + Don't materialize DontEnum properties unless it's DontEnumPropertiesMode::Include, + advancing provided microbenchmark by ~23%. + + (JSC::ClonedArguments::getOwnPropertyNames): Deleted. + * runtime/ClonedArguments.h: + * runtime/EnumerationMode.h: + Explicitly specify enum type to reduce its size. + + (JSC::EnumerationMode::EnumerationMode): Deleted. + (JSC::EnumerationMode::includeDontEnumProperties): Deleted. + (JSC::EnumerationMode::includeJSObjectProperties): Deleted. + * runtime/ErrorInstance.cpp: + (JSC::ErrorInstance::getOwnSpecialPropertyNames): + Don't materialize DontEnum properties unless it's DontEnumPropertiesMode::Include, + advancing provided microbenchmark by a factor of 5. + + (JSC::ErrorInstance::getOwnNonIndexPropertyNames): Deleted. + (JSC::ErrorInstance::getStructurePropertyNames): Deleted. + * runtime/ErrorInstance.h: + * runtime/GenericArguments.h: + * runtime/GenericArgumentsInlines.h: + (JSC::GenericArguments::getOwnPropertyNames): + * runtime/JSArray.cpp: + (JSC::JSArray::getOwnSpecialPropertyNames): + (JSC::JSArray::getOwnNonIndexPropertyNames): Deleted. + * runtime/JSArray.h: + * runtime/JSCell.cpp: + (JSC::JSCell::getOwnPropertyNames): + (JSC::JSCell::getOwnSpecialPropertyNames): + (JSC::JSCell::getOwnNonIndexPropertyNames): Deleted. + (JSC::JSCell::getPropertyNames): Deleted. + (JSC::JSCell::getStructurePropertyNames): Deleted. + (JSC::JSCell::getGenericPropertyNames): Deleted. + * runtime/JSCell.h: + * runtime/JSFunction.cpp: + (JSC::JSFunction::getOwnSpecialPropertyNames): + (JSC::JSFunction::getOwnNonIndexPropertyNames): Deleted. + * runtime/JSFunction.h: + * runtime/JSGenericTypedArrayView.h: + * runtime/JSGenericTypedArrayViewInlines.h: + (JSC::JSGenericTypedArrayView::getOwnPropertyNames): + * runtime/JSGlobalObject.h: + Remove OverridesAnyFormOfGetPropertyNames structure flag as it's inherited from + JSSymbolTableObject, and JSGlobalObject itself doesn't override getOwn*PropertyNames(). + + * runtime/JSLexicalEnvironment.cpp: + (JSC::JSLexicalEnvironment::getOwnSpecialPropertyNames): + (JSC::JSLexicalEnvironment::getOwnNonIndexPropertyNames): Deleted. + * runtime/JSLexicalEnvironment.h: + * runtime/JSModuleEnvironment.cpp: + (JSC::JSModuleEnvironment::getOwnSpecialPropertyNames): + (JSC::JSModuleEnvironment::getOwnNonIndexPropertyNames): Deleted. + * runtime/JSModuleEnvironment.h: + * runtime/JSModuleNamespaceObject.cpp: + (JSC::JSModuleNamespaceObject::getOwnPropertyNames): + Call getOwnNonIndexPropertyNames() directly, guarded by includeSymbolProperties() check, + since module namespace objects can't have string properties besides m_names. + (See https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-defineownproperty-p-desc) + + * runtime/JSModuleNamespaceObject.h: + * runtime/JSONObject.cpp: + (JSC::Stringifier::Holder::appendNextProperty): + (JSC::Walker::walk): + * runtime/JSObject.cpp: + (JSC::JSObject::getNonReifiedStaticPropertyNames): + (JSC::JSObject::getPropertyNames): + (JSC::JSObject::getOwnPropertyNames): + (JSC::JSObject::getOwnSpecialPropertyNames): + (JSC::JSObject::getOwnIndexedPropertyNames): + (JSC::JSObject::getOwnNonIndexPropertyNames): + (JSC::getClassPropertyNames): Deleted. + (JSC::JSObject::getStructurePropertyNames): Deleted. + (JSC::JSObject::getGenericPropertyNames): Deleted. + * runtime/JSObject.h: + (JSC::JSObject::getOwnSpecialPropertyNames): + * runtime/JSPropertyNameEnumerator.cpp: + (JSC::getEnumerablePropertyNames): + * runtime/JSPropertyNameEnumerator.h: + (JSC::propertyNameEnumerator): + * runtime/JSProxy.cpp: + (JSC::JSProxy::getOwnPropertyNames): + (JSC::JSProxy::getPropertyNames): Deleted. + (JSC::JSProxy::getStructurePropertyNames): Deleted. + (JSC::JSProxy::getGenericPropertyNames): Deleted. + * runtime/JSProxy.h: + * runtime/JSSymbolTableObject.cpp: + (JSC::JSSymbolTableObject::getOwnSpecialPropertyNames): + (JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames): Deleted. + * runtime/JSSymbolTableObject.h: + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesGetOwnPropertyNames const): + (JSC::TypeInfo::overridesGetOwnSpecialPropertyNames const): + (JSC::TypeInfo::overridesAnyFormOfGetOwnPropertyNames const): + (JSC::TypeInfo::overridesGetPropertyNames const): Deleted. + (JSC::TypeInfo::overridesAnyFormOfGetPropertyNames const): Deleted. + * runtime/ObjectConstructor.cpp: + (JSC::objectConstructorGetOwnPropertyDescriptors): + (JSC::JSC_DEFINE_HOST_FUNCTION): + (JSC::defineProperties): + (JSC::setIntegrityLevel): + (JSC::testIntegrityLevel): + (JSC::ownPropertyKeys): + * runtime/ProxyObject.cpp: + (JSC::ProxyObject::performGetOwnPropertyNames): + (JSC::ProxyObject::getOwnPropertyNames): + (JSC::ProxyObject::getPropertyNames): Deleted. + (JSC::ProxyObject::getOwnNonIndexPropertyNames): Deleted. + (JSC::ProxyObject::getStructurePropertyNames): Deleted. + (JSC::ProxyObject::getGenericPropertyNames): Deleted. + * runtime/ProxyObject.h: + Remove IsQuickPropertyAccessAllowedForEnumeration flag from ProxyObject's structure + since canAccessPropertiesQuicklyForEnumeration() now checks for method overrides. + + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::getOwnSpecialPropertyNames): + (JSC::RegExpObject::getOwnNonIndexPropertyNames): Deleted. + (JSC::RegExpObject::getPropertyNames): Deleted. + (JSC::RegExpObject::getGenericPropertyNames): Deleted. + * runtime/RegExpObject.h: + * runtime/StringObject.cpp: + (JSC::StringObject::getOwnPropertyNames): + (JSC::StringObject::getOwnNonIndexPropertyNames): Deleted. + * runtime/StringObject.h: + * runtime/Structure.cpp: + (JSC::Structure::validateFlags): + Strengthen overridesGetOwn*PropertyNames and overridesGetPrototype asserts into + equivalence tests. + + (JSC::Structure::getPropertyNamesFromStructure): + (JSC::Structure::canAccessPropertiesQuicklyForEnumeration const): + * runtime/Structure.h: + * runtime/StructureInlines.h: + (JSC::Structure::canCacheOwnPropertyNames const): + * tools/JSDollarVM.cpp: + Remove OverridesAnyFormOfGetPropertyNames structure flag as it's inherited from + JSArray, and RuntimeArray itself doesn't override getOwn*PropertyNames(). + 2021-01-07 Yusuke Suzuki [JSC] New expression and value function call should reserve function register if arguments include assignments diff --git a/Source/JavaScriptCore/bindings/ScriptValue.cpp b/Source/JavaScriptCore/bindings/ScriptValue.cpp index 7968b90a73b28..52d955b1e4929 100644 --- a/Source/JavaScriptCore/bindings/ScriptValue.cpp +++ b/Source/JavaScriptCore/bindings/ScriptValue.cpp @@ -77,7 +77,7 @@ static RefPtr jsToInspectorValue(JSGlobalObject* globalObject, JSVa auto inspectorObject = JSON::Object::create(); auto& object = *value.getObject(); PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - object.methodTable(vm)->getOwnPropertyNames(&object, globalObject, propertyNames, EnumerationMode()); + object.methodTable(vm)->getOwnPropertyNames(&object, globalObject, propertyNames, DontEnumPropertiesMode::Exclude); for (auto& name : propertyNames) { auto inspectorValue = jsToInspectorValue(globalObject, object.get(globalObject, name), maxDepth); if (!inspectorValue) diff --git a/Source/JavaScriptCore/bytecode/ObjectAllocationProfileInlines.h b/Source/JavaScriptCore/bytecode/ObjectAllocationProfileInlines.h index 182f624b3cb1c..928c39eb14358 100644 --- a/Source/JavaScriptCore/bytecode/ObjectAllocationProfileInlines.h +++ b/Source/JavaScriptCore/bytecode/ObjectAllocationProfileInlines.h @@ -147,7 +147,7 @@ ALWAYS_INLINE unsigned ObjectAllocationProfileBase::possibleDefaultProp size_t count = 0; PropertyNameArray propertyNameArray(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Include); - prototype->structure(vm)->getPropertyNamesFromStructure(vm, propertyNameArray, EnumerationMode()); + prototype->structure(vm)->getPropertyNamesFromStructure(vm, propertyNameArray, DontEnumPropertiesMode::Include); PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArray.data()->propertyNameVector(); for (size_t i = 0; i < propertyNameVector.size(); ++i) { JSValue value = prototype->getDirect(vm, propertyNameVector[i]); diff --git a/Source/JavaScriptCore/debugger/DebuggerScope.cpp b/Source/JavaScriptCore/debugger/DebuggerScope.cpp index d92b58f5ba986..10b70df656ec8 100644 --- a/Source/JavaScriptCore/debugger/DebuggerScope.cpp +++ b/Source/JavaScriptCore/debugger/DebuggerScope.cpp @@ -138,14 +138,14 @@ bool DebuggerScope::deleteProperty(JSCell* cell, JSGlobalObject* globalObject, P return thisObject->methodTable(globalObject->vm())->deleteProperty(thisObject, globalObject, propertyName, slot); } -void DebuggerScope::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void DebuggerScope::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { DebuggerScope* scope = jsCast(object); ASSERT(scope->isValid()); if (!scope->isValid()) return; JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); - thisObject->methodTable(globalObject->vm())->getPropertyNames(thisObject, globalObject, propertyNames, mode); + thisObject->getPropertyNames(globalObject, propertyNames, mode); } bool DebuggerScope::defineOwnProperty(JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) diff --git a/Source/JavaScriptCore/debugger/DebuggerScope.h b/Source/JavaScriptCore/debugger/DebuggerScope.h index 6f46e34310511..0e006c3223044 100644 --- a/Source/JavaScriptCore/debugger/DebuggerScope.h +++ b/Source/JavaScriptCore/debugger/DebuggerScope.h @@ -36,7 +36,7 @@ class JSScope; class DebuggerScope final : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames; template static IsoSubspace* subspaceFor(VM& vm) @@ -52,7 +52,7 @@ class DebuggerScope final : public JSNonFinalObject { static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); DECLARE_EXPORT_INFO; diff --git a/Source/JavaScriptCore/runtime/ClassInfo.h b/Source/JavaScriptCore/runtime/ClassInfo.h index 12368120d47bb..6c8807c9d08f1 100644 --- a/Source/JavaScriptCore/runtime/ClassInfo.h +++ b/Source/JavaScriptCore/runtime/ClassInfo.h @@ -80,21 +80,13 @@ struct MethodTable { using DefaultValueFunctionPtr = JSValue (*)(const JSObject*, JSGlobalObject*, PreferredPrimitiveType); DefaultValueFunctionPtr METHOD_TABLE_ENTRY(defaultValue); - using GetOwnPropertyNamesFunctionPtr = void (*)(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + using GetOwnPropertyNamesFunctionPtr = void (*)(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); GetOwnPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getOwnPropertyNames); - - using GetOwnNonIndexPropertyNamesFunctionPtr = void (*)(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - GetOwnNonIndexPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getOwnNonIndexPropertyNames); - - using GetPropertyNamesFunctionPtr = void (*)(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - GetPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getPropertyNames); + GetOwnPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getOwnSpecialPropertyNames); using GetEnumerableLengthFunctionPtr = uint32_t (*)(JSGlobalObject*, JSObject*); GetEnumerableLengthFunctionPtr METHOD_TABLE_ENTRY(getEnumerableLength); - GetPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getStructurePropertyNames); - GetPropertyNamesFunctionPtr METHOD_TABLE_ENTRY(getGenericPropertyNames); - using ClassNameFunctionPtr = String (*)(const JSObject*, VM&); ClassNameFunctionPtr METHOD_TABLE_ENTRY(className); @@ -168,11 +160,8 @@ struct MethodTable { &ClassName::toThis, \ &ClassName::defaultValue, \ &ClassName::getOwnPropertyNames, \ - &ClassName::getOwnNonIndexPropertyNames, \ - &ClassName::getPropertyNames, \ + &ClassName::getOwnSpecialPropertyNames, \ &ClassName::getEnumerableLength, \ - &ClassName::getStructurePropertyNames, \ - &ClassName::getGenericPropertyNames, \ &ClassName::className, \ &ClassName::toStringName, \ &ClassName::customHasInstance, \ diff --git a/Source/JavaScriptCore/runtime/ClonedArguments.cpp b/Source/JavaScriptCore/runtime/ClonedArguments.cpp index cf814e75cf387..a02d658915dc3 100644 --- a/Source/JavaScriptCore/runtime/ClonedArguments.cpp +++ b/Source/JavaScriptCore/runtime/ClonedArguments.cpp @@ -197,11 +197,11 @@ bool ClonedArguments::getOwnPropertySlot(JSObject* object, JSGlobalObject* globa return Base::getOwnPropertySlot(thisObject, globalObject, ident, slot); } -void ClonedArguments::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& array, EnumerationMode mode) +void ClonedArguments::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray&, DontEnumPropertiesMode mode) { ClonedArguments* thisObject = jsCast(object); - thisObject->materializeSpecialsIfNecessary(globalObject); - Base::getOwnPropertyNames(thisObject, globalObject, array, mode); + if (mode == DontEnumPropertiesMode::Include) + thisObject->materializeSpecialsIfNecessary(globalObject); } bool ClonedArguments::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName ident, JSValue value, PutPropertySlot& slot) diff --git a/Source/JavaScriptCore/runtime/ClonedArguments.h b/Source/JavaScriptCore/runtime/ClonedArguments.h index 5ea1ea745c464..06b791d458350 100644 --- a/Source/JavaScriptCore/runtime/ClonedArguments.h +++ b/Source/JavaScriptCore/runtime/ClonedArguments.h @@ -40,7 +40,7 @@ namespace JSC { class ClonedArguments final : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; template static IsoSubspace* subspaceFor(VM& vm) @@ -70,7 +70,7 @@ class ClonedArguments final : public JSNonFinalObject { static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype, IndexingType); static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); diff --git a/Source/JavaScriptCore/runtime/EnumerationMode.h b/Source/JavaScriptCore/runtime/EnumerationMode.h index 31798f946fb34..7afb0b6bdbc71 100644 --- a/Source/JavaScriptCore/runtime/EnumerationMode.h +++ b/Source/JavaScriptCore/runtime/EnumerationMode.h @@ -27,56 +27,20 @@ namespace JSC { -enum class PropertyNameMode { +enum class PropertyNameMode : uint8_t { Symbols = 1 << 0, Strings = 1 << 1, StringsAndSymbols = Symbols | Strings, }; -enum class PrivateSymbolMode { +enum class PrivateSymbolMode : uint8_t { Include, Exclude }; -enum class DontEnumPropertiesMode { +enum class DontEnumPropertiesMode : uint8_t { Include, Exclude }; -enum class JSObjectPropertiesMode { - Include, - Exclude -}; - -class EnumerationMode { -public: - EnumerationMode(DontEnumPropertiesMode dontEnumPropertiesMode = DontEnumPropertiesMode::Exclude, JSObjectPropertiesMode jsObjectPropertiesMode = JSObjectPropertiesMode::Include) - : m_dontEnumPropertiesMode(dontEnumPropertiesMode) - , m_jsObjectPropertiesMode(jsObjectPropertiesMode) - { - } - - EnumerationMode(const EnumerationMode& mode, JSObjectPropertiesMode jsObjectPropertiesMode) - : m_dontEnumPropertiesMode(mode.m_dontEnumPropertiesMode) - , m_jsObjectPropertiesMode(jsObjectPropertiesMode) - { - } - - // Add other constructors as needed for convenience - - bool includeDontEnumProperties() - { - return m_dontEnumPropertiesMode == DontEnumPropertiesMode::Include; - } - - bool includeJSObjectProperties() - { - return m_jsObjectPropertiesMode == JSObjectPropertiesMode::Include; - } - -private: - DontEnumPropertiesMode m_dontEnumPropertiesMode; - JSObjectPropertiesMode m_jsObjectPropertiesMode; -}; - } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.cpp b/Source/JavaScriptCore/runtime/ErrorInstance.cpp index cf54c417275f0..2e4ec39f12058 100644 --- a/Source/JavaScriptCore/runtime/ErrorInstance.cpp +++ b/Source/JavaScriptCore/runtime/ErrorInstance.cpp @@ -260,20 +260,12 @@ bool ErrorInstance::getOwnPropertySlot(JSObject* object, JSGlobalObject* globalO return Base::getOwnPropertySlot(thisObject, globalObject, propertyName, slot); } -void ErrorInstance::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNameArray, EnumerationMode enumerationMode) +void ErrorInstance::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray&, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); ErrorInstance* thisObject = jsCast(object); - thisObject->materializeErrorInfoIfNeeded(vm); - Base::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNameArray, enumerationMode); -} - -void ErrorInstance::getStructurePropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNameArray, EnumerationMode enumerationMode) -{ - VM& vm = globalObject->vm(); - ErrorInstance* thisObject = jsCast(object); - thisObject->materializeErrorInfoIfNeeded(vm); - Base::getStructurePropertyNames(thisObject, globalObject, propertyNameArray, enumerationMode); + if (mode == DontEnumPropertiesMode::Include) + thisObject->materializeErrorInfoIfNeeded(vm); } bool ErrorInstance::defineOwnProperty(JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.h b/Source/JavaScriptCore/runtime/ErrorInstance.h index 03f2cdb7a5915..da66eb76e7ade 100644 --- a/Source/JavaScriptCore/runtime/ErrorInstance.h +++ b/Source/JavaScriptCore/runtime/ErrorInstance.h @@ -29,7 +29,7 @@ namespace JSC { class ErrorInstance : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; static constexpr bool needsDestruction = true; static void destroy(JSCell* cell) @@ -93,8 +93,7 @@ class ErrorInstance : public JSNonFinalObject { void finishCreation(VM&, JSGlobalObject*, const String&, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true); static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); - static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static void getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); diff --git a/Source/JavaScriptCore/runtime/GenericArguments.h b/Source/JavaScriptCore/runtime/GenericArguments.h index 60382ed302779..0c29e9ca0dbf3 100644 --- a/Source/JavaScriptCore/runtime/GenericArguments.h +++ b/Source/JavaScriptCore/runtime/GenericArguments.h @@ -36,7 +36,7 @@ template class GenericArguments : public JSNonFinalObject { public: typedef JSNonFinalObject Base; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; protected: GenericArguments(VM& vm, Structure* structure) @@ -47,7 +47,7 @@ class GenericArguments : public JSNonFinalObject { static void visitChildren(JSCell*, SlotVisitor&); static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); static bool getOwnPropertySlotByIndex(JSObject*, JSGlobalObject*, unsigned propertyName, PropertySlot&); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool putByIndex(JSCell*, JSGlobalObject*, unsigned propertyName, JSValue, bool shouldThrow); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); diff --git a/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h b/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h index 54ed77ba58663..46ed43358f0b4 100644 --- a/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h +++ b/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h @@ -90,7 +90,7 @@ bool GenericArguments::getOwnPropertySlotByIndex(JSObject* object, JSGloba } template -void GenericArguments::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& array, EnumerationMode mode) +void GenericArguments::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& array, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); Type* thisObject = jsCast(object); @@ -101,15 +101,15 @@ void GenericArguments::getOwnPropertyNames(JSObject* object, JSGlobalObjec continue; array.add(Identifier::from(vm, i)); } + thisObject->getOwnIndexedPropertyNames(globalObject, array, mode); } - if (mode.includeDontEnumProperties() && !thisObject->overrodeThings()) { + if (mode == DontEnumPropertiesMode::Include && !thisObject->overrodeThings()) { array.add(vm.propertyNames->length); array.add(vm.propertyNames->callee); - if (array.includeSymbolProperties()) - array.add(vm.propertyNames->iteratorSymbol); + array.add(vm.propertyNames->iteratorSymbol); } - Base::getOwnPropertyNames(thisObject, globalObject, array, mode); + thisObject->getOwnNonIndexPropertyNames(globalObject, array, mode); } template diff --git a/Source/JavaScriptCore/runtime/JSArray.cpp b/Source/JavaScriptCore/runtime/JSArray.cpp index 471a9776103ae..e42f39c9f8a21 100644 --- a/Source/JavaScriptCore/runtime/JSArray.cpp +++ b/Source/JavaScriptCore/runtime/JSArray.cpp @@ -283,15 +283,11 @@ static int compareKeysForQSort(const void* a, const void* b) return (da > db) - (da < db); } -void JSArray::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSArray::getOwnSpecialPropertyNames(JSObject*, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); - JSArray* thisObject = jsCast(object); - - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) propertyNames.add(vm.propertyNames->length); - - JSObject::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode); } // This method makes room in the vector, but leaves the new space for count slots uncleared. diff --git a/Source/JavaScriptCore/runtime/JSArray.h b/Source/JavaScriptCore/runtime/JSArray.h index 2ba73172b8aac..8b741d3198619 100644 --- a/Source/JavaScriptCore/runtime/JSArray.h +++ b/Source/JavaScriptCore/runtime/JSArray.h @@ -40,7 +40,7 @@ class JSArray : public JSNonFinalObject { public: typedef JSNonFinalObject Base; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; static size_t allocationSize(Checked inlineCapacity) { @@ -189,7 +189,7 @@ class JSArray : public JSNonFinalObject { static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); - JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); private: bool isLengthWritable() diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp index 2a1fee543819a..c47fec060d929 100644 --- a/Source/JavaScriptCore/runtime/JSCell.cpp +++ b/Source/JavaScriptCore/runtime/JSCell.cpp @@ -206,12 +206,12 @@ void JSCell::doPutPropertySecurityCheck(JSObject*, JSGlobalObject*, PropertyName RELEASE_ASSERT_NOT_REACHED(); } -void JSCell::getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) +void JSCell::getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode) { RELEASE_ASSERT_NOT_REACHED(); } -void JSCell::getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) +void JSCell::getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode) { RELEASE_ASSERT_NOT_REACHED(); } @@ -233,11 +233,6 @@ const char* JSCell::className(VM& vm) const return classInfo(vm)->className; } -void JSCell::getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - RELEASE_ASSERT_NOT_REACHED(); -} - bool JSCell::customHasInstance(JSObject*, JSGlobalObject*, JSValue) { RELEASE_ASSERT_NOT_REACHED(); @@ -256,16 +251,6 @@ uint32_t JSCell::getEnumerableLength(JSGlobalObject*, JSObject*) return 0; } -void JSCell::getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - RELEASE_ASSERT_NOT_REACHED(); -} - -void JSCell::getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - RELEASE_ASSERT_NOT_REACHED(); -} - bool JSCell::preventExtensions(JSObject*, JSGlobalObject*) { RELEASE_ASSERT_NOT_REACHED(); diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h index f2ef6b56d52cf..a60bc036f2823 100644 --- a/Source/JavaScriptCore/runtime/JSCell.h +++ b/Source/JavaScriptCore/runtime/JSCell.h @@ -244,13 +244,10 @@ class JSCell : public HeapCell { // Dummy implementations of override-able static functions for classes to put in their MethodTable static JSValue defaultValue(const JSObject*, JSGlobalObject*, PreferredPrimitiveType); - static NO_RETURN_DUE_TO_CRASH void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static NO_RETURN_DUE_TO_CRASH void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + static NO_RETURN_DUE_TO_CRASH void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static uint32_t getEnumerableLength(JSGlobalObject*, JSObject*); - static NO_RETURN_DUE_TO_CRASH void getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); static NO_RETURN_DUE_TO_CRASH bool preventExtensions(JSObject*, JSGlobalObject*); static NO_RETURN_DUE_TO_CRASH bool isExtensible(JSObject*, JSGlobalObject*); static NO_RETURN_DUE_TO_CRASH bool setPrototype(JSObject*, JSGlobalObject*, JSValue, bool); diff --git a/Source/JavaScriptCore/runtime/JSFunction.cpp b/Source/JavaScriptCore/runtime/JSFunction.cpp index 39dfa32c50acb..8a8a458f22fea 100644 --- a/Source/JavaScriptCore/runtime/JSFunction.cpp +++ b/Source/JavaScriptCore/runtime/JSFunction.cpp @@ -469,13 +469,13 @@ bool JSFunction::getOwnPropertySlot(JSObject* object, JSGlobalObject* globalObje RELEASE_AND_RETURN(scope, Base::getOwnPropertySlot(thisObject, globalObject, propertyName, slot)); } -void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSFunction::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { JSFunction* thisObject = jsCast(object); VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - if (mode.includeDontEnumProperties()) { + if (mode == DontEnumPropertiesMode::Include) { if (!thisObject->isHostOrBuiltinFunction()) { // Make sure prototype has been reified. PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry, &vm); @@ -499,7 +499,6 @@ void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* g } } } - RELEASE_AND_RETURN(scope, Base::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode)); } bool JSFunction::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot) diff --git a/Source/JavaScriptCore/runtime/JSFunction.h b/Source/JavaScriptCore/runtime/JSFunction.h index 258955f0e3b2b..0e5dd8438bf02 100644 --- a/Source/JavaScriptCore/runtime/JSFunction.h +++ b/Source/JavaScriptCore/runtime/JSFunction.h @@ -70,7 +70,7 @@ class JSFunction : public JSCallee { } typedef JSCallee Base; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames | OverridesGetCallData; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames | OverridesGetCallData; static size_t allocationSize(Checked inlineCapacity) { @@ -173,7 +173,7 @@ class JSFunction : public JSCallee { void finishCreation(VM&); static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); - static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode = EnumerationMode()); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); diff --git a/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h b/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h index ceb4851aca2c7..74f89aa8a4dc9 100644 --- a/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h +++ b/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h @@ -96,7 +96,7 @@ class JSGenericTypedArrayView final : public JSArrayBufferView { using Base = JSArrayBufferView; typedef typename Adaptor::Type ElementType; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesAnyFormOfGetPropertyNames | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; static constexpr unsigned elementSize = sizeof(typename Adaptor::Type); @@ -304,7 +304,7 @@ class JSGenericTypedArrayView final : public JSArrayBufferView { static bool putByIndex(JSCell*, JSGlobalObject*, unsigned propertyName, JSValue, bool shouldThrow); static bool deletePropertyByIndex(JSCell*, JSGlobalObject*, unsigned propertyName); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static size_t estimatedSize(JSCell*, VM&); static void visitChildren(JSCell*, SlotVisitor&); diff --git a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h index 85540892e9089..3cda637eef77e 100644 --- a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h +++ b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h @@ -464,7 +464,7 @@ bool JSGenericTypedArrayView::deletePropertyByIndex( template void JSGenericTypedArrayView::getOwnPropertyNames( - JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& array, EnumerationMode mode) + JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& array, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); JSGenericTypedArrayView* thisObject = jsCast(object); @@ -474,7 +474,7 @@ void JSGenericTypedArrayView::getOwnPropertyNames( array.add(Identifier::from(vm, i)); } - return Base::getOwnPropertyNames(object, globalObject, array, mode); + thisObject->getOwnNonIndexPropertyNames(globalObject, array, mode); } template diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h index 4cb05325aad6b..5903783312691 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.h +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h @@ -571,9 +571,7 @@ class JSGlobalObject : public JSSegmentedVariableObject { public: using Base = JSSegmentedVariableObject; - // Do we realy need OverridesAnyFormOfGetPropertyNames here? - // FIXME: https://bugs.webkit.org/show_bug.cgi?id=212954 - static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames | IsImmutablePrototypeExoticObject; + static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable | OverridesGetOwnPropertySlot | IsImmutablePrototypeExoticObject; static constexpr bool needsDestruction = true; template diff --git a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp index d43815db0bac2..5d6c0f4f6cf95 100644 --- a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp +++ b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp @@ -64,7 +64,7 @@ void JSLexicalEnvironment::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) } } -void JSLexicalEnvironment::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSLexicalEnvironment::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { JSLexicalEnvironment* thisObject = jsCast(object); @@ -73,7 +73,7 @@ void JSLexicalEnvironment::getOwnNonIndexPropertyNames(JSObject* object, JSGloba SymbolTable::Map::iterator end = thisObject->symbolTable()->end(locker); VM& vm = globalObject->vm(); for (SymbolTable::Map::iterator it = thisObject->symbolTable()->begin(locker); it != end; ++it) { - if (it->value.getAttributes() & PropertyAttribute::DontEnum && !mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Exclude && it->value.isDontEnum()) continue; if (!thisObject->isValidScopeOffset(it->value.scopeOffset())) continue; @@ -82,8 +82,6 @@ void JSLexicalEnvironment::getOwnNonIndexPropertyNames(JSObject* object, JSGloba propertyNames.add(Identifier::fromUid(vm, it->key.get())); } } - // Skip the JSSymbolTableObject's implementation of getOwnNonIndexPropertyNames - JSObject::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode); } bool JSLexicalEnvironment::getOwnPropertySlot(JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, PropertySlot& slot) diff --git a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h index b4e953a3c55bc..5a611da85b962 100644 --- a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h +++ b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h @@ -48,7 +48,7 @@ class JSLexicalEnvironment : public JSSymbolTableObject { } using Base = JSSymbolTableObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; WriteBarrierBase* variables() { @@ -106,7 +106,7 @@ class JSLexicalEnvironment : public JSSymbolTableObject { } static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); - static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); diff --git a/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp b/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp index b88f1dd674143..87c556f1a5b29 100644 --- a/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp +++ b/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp @@ -96,7 +96,7 @@ bool JSModuleEnvironment::getOwnPropertySlot(JSObject* cell, JSGlobalObject* glo return Base::getOwnPropertySlot(thisObject, globalObject, propertyName, slot); } -void JSModuleEnvironment::getOwnNonIndexPropertyNames(JSObject* cell, JSGlobalObject* globalObject, PropertyNameArray& propertyNamesArray, EnumerationMode mode) +void JSModuleEnvironment::getOwnSpecialPropertyNames(JSObject* cell, JSGlobalObject*, PropertyNameArray& propertyNamesArray, DontEnumPropertiesMode) { JSModuleEnvironment* thisObject = jsCast(cell); if (propertyNamesArray.includeStringProperties()) { @@ -106,7 +106,6 @@ void JSModuleEnvironment::getOwnNonIndexPropertyNames(JSObject* cell, JSGlobalOb propertyNamesArray.add(importEntry.localName); } } - return Base::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNamesArray, mode); } bool JSModuleEnvironment::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot) diff --git a/Source/JavaScriptCore/runtime/JSModuleEnvironment.h b/Source/JavaScriptCore/runtime/JSModuleEnvironment.h index bf0708a3355f7..88c1c109a349b 100644 --- a/Source/JavaScriptCore/runtime/JSModuleEnvironment.h +++ b/Source/JavaScriptCore/runtime/JSModuleEnvironment.h @@ -40,7 +40,7 @@ class JSModuleEnvironment final : public JSLexicalEnvironment { friend class LLIntOffsetsExtractor; public: using Base = JSLexicalEnvironment; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; static JSModuleEnvironment* create(VM& vm, JSGlobalObject* globalObject, JSScope* currentScope, SymbolTable* symbolTable, JSValue initialValue, AbstractModuleRecord* moduleRecord) { @@ -73,7 +73,7 @@ class JSModuleEnvironment final : public JSLexicalEnvironment { } static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); - static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); diff --git a/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp b/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp index 2371265a54311..a420101a90b38 100644 --- a/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp +++ b/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp @@ -217,7 +217,7 @@ bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, JSGlobalObject* globa return !thisObject->m_exports.contains(propertyName.uid()); } -void JSModuleNamespaceObject::getOwnPropertyNames(JSObject* cell, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSModuleNamespaceObject::getOwnPropertyNames(JSObject* cell, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -225,7 +225,7 @@ void JSModuleNamespaceObject::getOwnPropertyNames(JSObject* cell, JSGlobalObject // https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-ownpropertykeys JSModuleNamespaceObject* thisObject = jsCast(cell); for (const auto& name : thisObject->m_names) { - if (!mode.includeDontEnumProperties()) { + if (mode == DontEnumPropertiesMode::Exclude) { // Perform [[GetOwnProperty]] to throw ReferenceError if binding is uninitialized. PropertySlot slot(cell, PropertySlot::InternalMethodType::GetOwnProperty); thisObject->getOwnPropertySlotCommon(globalObject, name.impl(), slot); @@ -233,7 +233,8 @@ void JSModuleNamespaceObject::getOwnPropertyNames(JSObject* cell, JSGlobalObject } propertyNames.add(name.impl()); } - Base::getOwnPropertyNames(thisObject, globalObject, propertyNames, mode); + if (propertyNames.includeSymbolProperties()) + thisObject->getOwnNonIndexPropertyNames(globalObject, propertyNames, mode); } bool JSModuleNamespaceObject::defineOwnProperty(JSObject* cell, JSGlobalObject* globalObject, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) diff --git a/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h b/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h index 16e70b7bd8d74..41e6c36307fbf 100644 --- a/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h +++ b/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h @@ -33,7 +33,7 @@ namespace JSC { class JSModuleNamespaceObject final : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames | GetOwnPropertySlotIsImpureForPropertyAbsence | IsImmutablePrototypeExoticObject; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | GetOwnPropertySlotIsImpureForPropertyAbsence | IsImmutablePrototypeExoticObject; static constexpr bool needsDestruction = true; static void destroy(JSCell*); @@ -57,7 +57,7 @@ class JSModuleNamespaceObject final : public JSNonFinalObject { JS_EXPORT_PRIVATE static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); JS_EXPORT_PRIVATE static bool putByIndex(JSCell*, JSGlobalObject*, unsigned propertyName, JSValue, bool shouldThrow); JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); - JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); DECLARE_EXPORT_INFO; diff --git a/Source/JavaScriptCore/runtime/JSONObject.cpp b/Source/JavaScriptCore/runtime/JSONObject.cpp index 5794257683d3a..4edb78d912c90 100644 --- a/Source/JavaScriptCore/runtime/JSONObject.cpp +++ b/Source/JavaScriptCore/runtime/JSONObject.cpp @@ -500,7 +500,7 @@ bool Stringifier::Holder::appendNextProperty(Stringifier& stringifier, StringBui m_propertyNames = stringifier.m_arrayReplacerPropertyNames.data(); else { PropertyNameArray objectPropertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - m_object->methodTable(vm)->getOwnPropertyNames(m_object, globalObject, objectPropertyNames, EnumerationMode()); + m_object->methodTable(vm)->getOwnPropertyNames(m_object, globalObject, objectPropertyNames, DontEnumPropertiesMode::Exclude); RETURN_IF_EXCEPTION(scope, false); m_propertyNames = objectPropertyNames.releaseData(); } @@ -719,7 +719,7 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) markedStack.appendWithCrashOnOverflow(object); indexStack.append(0); propertyStack.append(PropertyNameArray(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude)); - object->methodTable(vm)->getOwnPropertyNames(object, m_globalObject, propertyStack.last(), EnumerationMode()); + object->methodTable(vm)->getOwnPropertyNames(object, m_globalObject, propertyStack.last(), DontEnumPropertiesMode::Exclude); RETURN_IF_EXCEPTION(scope, { }); } objectStartVisitMember: diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp index 88084df77a5bb..33300d2264a6d 100644 --- a/Source/JavaScriptCore/runtime/JSObject.cpp +++ b/Source/JavaScriptCore/runtime/JSObject.cpp @@ -72,18 +72,19 @@ const ClassInfo JSObject::s_info = { "Object", nullptr, nullptr, nullptr, CREATE const ClassInfo JSFinalObject::s_info = { "Object", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFinalObject) }; -static inline void getClassPropertyNames(JSGlobalObject* globalObject, const ClassInfo* classInfo, PropertyNameArray& propertyNames, EnumerationMode mode) +ALWAYS_INLINE void JSObject::getNonReifiedStaticPropertyNames(VM& vm, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { - VM& vm = globalObject->vm(); + if (staticPropertiesReified(vm)) + return; // Add properties from the static hashtables of properties - for (; classInfo; classInfo = classInfo->parentClass) { - const HashTable* table = classInfo->staticPropHashTable; + for (const ClassInfo* info = classInfo(vm); info; info = info->parentClass) { + const HashTable* table = info->staticPropHashTable; if (!table) continue; for (auto iter = table->begin(); iter != table->end(); ++iter) { - if (!(iter->attributes() & PropertyAttribute::DontEnum) || mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include || !(iter->attributes() & PropertyAttribute::DontEnum)) propertyNames.add(Identifier::fromString(vm, iter.key())); } } @@ -2380,54 +2381,49 @@ JSC_DEFINE_HOST_FUNCTION(objectPrivateFuncInstanceOf, (JSGlobalObject* globalObj return JSValue::encode(jsBoolean(JSObject::defaultHasInstance(globalObject, value, proto))); } -// FIXME: Assert that properties returned by getOwnPropertyNames() are reported enumerable by getOwnPropertySlot(). -// https://bugs.webkit.org/show_bug.cgi?id=219926 -void JSObject::getPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSObject::getPropertyNames(JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - if (UNLIKELY(!vm.isSafeToRecurseSoft())) { - throwStackOverflowError(globalObject, scope); - return; - } + JSObject* object = this; + unsigned prototypeCount = 0; - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, propertyNames, mode); - RETURN_IF_EXCEPTION(scope, void()); + while (true) { + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, propertyNames, mode); + RETURN_IF_EXCEPTION(scope, void()); - JSValue nextProto = object->getPrototype(vm, globalObject); - RETURN_IF_EXCEPTION(scope, void()); - if (nextProto.isNull()) - return; + JSValue prototype = object->getPrototype(vm, globalObject); + RETURN_IF_EXCEPTION(scope, void()); + if (prototype.isNull()) + break; - JSObject* prototype = asObject(nextProto); - while(1) { - if (prototype->structure(vm)->typeInfo().overridesGetPropertyNames()) { - scope.release(); - prototype->methodTable(vm)->getPropertyNames(prototype, globalObject, propertyNames, mode); + if (UNLIKELY(++prototypeCount > maximumPrototypeChainDepth)) { + throwStackOverflowError(globalObject, scope); return; } - prototype->methodTable(vm)->getOwnPropertyNames(prototype, globalObject, propertyNames, mode); - RETURN_IF_EXCEPTION(scope, void()); - nextProto = prototype->getPrototype(vm, globalObject); - RETURN_IF_EXCEPTION(scope, void()); - if (nextProto.isNull()) - break; - prototype = asObject(nextProto); + + object = asObject(prototype); } } -void JSObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { - VM& vm = globalObject->vm(); - if (!mode.includeJSObjectProperties()) { - // We still have to get non-indexed properties from any subclasses of JSObject that have them. - object->methodTable(vm)->getOwnNonIndexPropertyNames(object, globalObject, propertyNames, mode); - return; - } + object->getOwnIndexedPropertyNames(globalObject, propertyNames, mode); + object->getOwnNonIndexPropertyNames(globalObject, propertyNames, mode); +} + +void JSObject::getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode) +{ + // Structure::validateFlags() breaks if this method isn't exported, which is impossible if it's inlined. +} + +void JSObject::getOwnIndexedPropertyNames(JSGlobalObject*, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) +{ + JSObject* object = this; if (propertyNames.includeStringProperties()) { - // Add numeric properties first. That appears to be the accepted convention. + // Add numeric properties first per step 2 of https://tc39.es/ecma262/#sec-ordinaryownpropertykeys // FIXME: Filling PropertyNameArray with an identifier for every integer // is incredibly inefficient for large arrays. We need a different approach, // which almost certainly means a different structure for PropertyNameArray. @@ -2475,7 +2471,7 @@ void JSObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObjec SparseArrayValueMap::const_iterator end = map->end(); for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) { - if (mode.includeDontEnumProperties() || !(it->value.attributes() & PropertyAttribute::DontEnum)) + if (mode == DontEnumPropertiesMode::Include || !(it->value.attributes() & PropertyAttribute::DontEnum)) keys.uncheckedAppend(static_cast(it->key)); } @@ -2490,20 +2486,19 @@ void JSObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObjec RELEASE_ASSERT_NOT_REACHED(); } } - - object->methodTable(vm)->getOwnNonIndexPropertyNames(object, globalObject, propertyNames, mode); } -void JSObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSObject::getOwnNonIndexPropertyNames(JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); - if (!object->staticPropertiesReified(vm)) - getClassPropertyNames(globalObject, object->classInfo(vm), propertyNames, mode); + auto scope = DECLARE_THROW_SCOPE(vm); - if (!mode.includeJSObjectProperties()) - return; - - object->structure(vm)->getPropertyNamesFromStructure(vm, propertyNames, mode); + methodTable(vm)->getOwnSpecialPropertyNames(this, globalObject, propertyNames, mode); + RETURN_IF_EXCEPTION(scope, void()); + + getNonReifiedStaticPropertyNames(vm, propertyNames, mode); + structure(vm)->getPropertyNamesFromStructure(vm, propertyNames, mode); + scope.assertNoException(); } double JSObject::toNumber(JSGlobalObject* globalObject) const @@ -3837,41 +3832,6 @@ uint32_t JSObject::getEnumerableLength(JSGlobalObject* globalObject, JSObject* o } } -void JSObject::getStructurePropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - VM& vm = globalObject->vm(); - object->structure(vm)->getPropertyNamesFromStructure(vm, propertyNames, mode); -} - -void JSObject::getGenericPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - VM& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, propertyNames, EnumerationMode(mode, JSObjectPropertiesMode::Exclude)); - RETURN_IF_EXCEPTION(scope, void()); - - JSValue nextProto = object->getPrototype(vm, globalObject); - RETURN_IF_EXCEPTION(scope, void()); - if (nextProto.isNull()) - return; - - JSObject* prototype = asObject(nextProto); - while (true) { - if (prototype->structure(vm)->typeInfo().overridesGetPropertyNames()) { - scope.release(); - prototype->methodTable(vm)->getPropertyNames(prototype, globalObject, propertyNames, mode); - return; - } - prototype->methodTable(vm)->getOwnPropertyNames(prototype, globalObject, propertyNames, mode); - RETURN_IF_EXCEPTION(scope, void()); - nextProto = prototype->getPrototype(vm, globalObject); - RETURN_IF_EXCEPTION(scope, void()); - if (nextProto.isNull()) - break; - prototype = asObject(nextProto); - } -} - // Implements GetMethod(O, P) in section 7.3.9 of the spec. // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-getmethod JSValue JSObject::getMethod(JSGlobalObject* globalObject, CallData& callData, const Identifier& ident, const String& errorMessage) diff --git a/Source/JavaScriptCore/runtime/JSObject.h b/Source/JavaScriptCore/runtime/JSObject.h index 50ff5953101a2..9b938b3e5e7a0 100644 --- a/Source/JavaScriptCore/runtime/JSObject.h +++ b/Source/JavaScriptCore/runtime/JSObject.h @@ -674,13 +674,15 @@ class JSObject : public JSCell { JS_EXPORT_PRIVATE bool hasInstance(JSGlobalObject*, JSValue); static bool defaultHasInstance(JSGlobalObject*, JSValue, JSValue prototypeProperty); - JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static constexpr unsigned maximumPrototypeChainDepth = 40000; + JS_EXPORT_PRIVATE void getPropertyNames(JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + JS_EXPORT_PRIVATE static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + JS_EXPORT_PRIVATE void getOwnIndexedPropertyNames(JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + JS_EXPORT_PRIVATE void getOwnNonIndexPropertyNames(JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); + void getNonReifiedStaticPropertyNames(VM&, PropertyNameArray&, DontEnumPropertiesMode); JS_EXPORT_PRIVATE static uint32_t getEnumerableLength(JSGlobalObject*, JSObject*); - JS_EXPORT_PRIVATE static void getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); JS_EXPORT_PRIVATE JSValue toPrimitive(JSGlobalObject*, PreferredPrimitiveType = NoPreference) const; JS_EXPORT_PRIVATE double toNumber(JSGlobalObject*) const; diff --git a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp index 9e00647bbfbb6..bf307967e3add 100644 --- a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp +++ b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp @@ -87,4 +87,52 @@ void JSPropertyNameEnumerator::visitChildren(JSCell* cell, SlotVisitor& visitor) } } +// FIXME: Assert that properties returned by getOwnPropertyNames() are reported enumerable by getOwnPropertySlot(). +// https://bugs.webkit.org/show_bug.cgi?id=219926 +void getEnumerablePropertyNames(JSGlobalObject* globalObject, JSObject* base, PropertyNameArray& propertyNames, uint32_t& indexedLength, uint32_t& structurePropertyCount) +{ + VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + Structure* structure = base->structure(vm); + if (structure->canAccessPropertiesQuicklyForEnumeration() && indexedLength == base->getArrayLength()) { + // Inlined JSObject::getOwnNonIndexPropertyNames() + base->methodTable(vm)->getOwnSpecialPropertyNames(base, globalObject, propertyNames, DontEnumPropertiesMode::Exclude); + RETURN_IF_EXCEPTION(scope, void()); + + base->getNonReifiedStaticPropertyNames(vm, propertyNames, DontEnumPropertiesMode::Exclude); + unsigned nonStructurePropertyCount = propertyNames.size(); + structure->getPropertyNamesFromStructure(vm, propertyNames, DontEnumPropertiesMode::Exclude); + scope.assertNoException(); + + // |propertyNames| contains properties exclusively from the structure. + if (!nonStructurePropertyCount) + structurePropertyCount = propertyNames.size(); + } else { + base->methodTable(vm)->getOwnPropertyNames(base, globalObject, propertyNames, DontEnumPropertiesMode::Exclude); + RETURN_IF_EXCEPTION(scope, void()); + // |propertyNames| contains all indexed properties, so disable enumeration based on getEnumerableLength(). + indexedLength = 0; + } + + JSObject* object = base; + unsigned prototypeCount = 0; + + while (true) { + JSValue prototype = object->getPrototype(vm, globalObject); + RETURN_IF_EXCEPTION(scope, void()); + if (prototype.isNull()) + break; + + if (UNLIKELY(++prototypeCount > JSObject::maximumPrototypeChainDepth)) { + throwStackOverflowError(globalObject, scope); + return; + } + + object = asObject(prototype); + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, propertyNames, DontEnumPropertiesMode::Exclude); + RETURN_IF_EXCEPTION(scope, void()); + } +} + } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h index 0f67f216e64d7..8ed27348c8ef1 100644 --- a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h +++ b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h @@ -101,6 +101,8 @@ class JSPropertyNameEnumerator final : public JSCell { uint32_t m_cachedInlineCapacity; }; +void getEnumerablePropertyNames(JSGlobalObject*, JSObject*, PropertyNameArray&, uint32_t& indexedLength, uint32_t& structurePropertyCount); + inline JSPropertyNameEnumerator* propertyNameEnumerator(JSGlobalObject* globalObject, JSObject* base) { VM& vm = getVM(globalObject); @@ -117,22 +119,8 @@ inline JSPropertyNameEnumerator* propertyNameEnumerator(JSGlobalObject* globalOb return enumerator; uint32_t numberStructureProperties = 0; - PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - - if (structure->canAccessPropertiesQuicklyForEnumeration() && indexedLength == base->getArrayLength()) { - base->methodTable(vm)->getStructurePropertyNames(base, globalObject, propertyNames, EnumerationMode()); - scope.assertNoException(); - - numberStructureProperties = propertyNames.size(); - - base->methodTable(vm)->getGenericPropertyNames(base, globalObject, propertyNames, EnumerationMode()); - } else { - // Generic property names vector contains all indexed property names. - // So disable indexed property enumeration phase by setting |indexedLength| to 0. - indexedLength = 0; - base->methodTable(vm)->getPropertyNames(base, globalObject, propertyNames, EnumerationMode()); - } + getEnumerablePropertyNames(globalObject, base, propertyNames, indexedLength, numberStructureProperties); RETURN_IF_EXCEPTION(scope, nullptr); ASSERT(propertyNames.size() < UINT32_MAX); diff --git a/Source/JavaScriptCore/runtime/JSProxy.cpp b/Source/JavaScriptCore/runtime/JSProxy.cpp index 4ad46ef88c606..2857b4ab76cf5 100644 --- a/Source/JavaScriptCore/runtime/JSProxy.cpp +++ b/Source/JavaScriptCore/runtime/JSProxy.cpp @@ -115,32 +115,13 @@ bool JSProxy::deletePropertyByIndex(JSCell* cell, JSGlobalObject* globalObject, return thisObject->target()->methodTable(globalObject->vm())->deletePropertyByIndex(thisObject->target(), globalObject, propertyName); } -void JSProxy::getPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - JSProxy* thisObject = jsCast(object); - thisObject->target()->methodTable(globalObject->vm())->getPropertyNames(thisObject->target(), globalObject, propertyNames, mode); -} - uint32_t JSProxy::getEnumerableLength(JSGlobalObject* globalObject, JSObject* object) { JSProxy* thisObject = jsCast(object); return thisObject->target()->methodTable(globalObject->vm())->getEnumerableLength(globalObject, thisObject->target()); } -void JSProxy::getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - // Skip the structure loop, since it is invalid for proxies. -} - -void JSProxy::getGenericPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - JSProxy* thisObject = jsCast(object); - // Get *all* of the property names, not just the generic ones, since we skipped the structure - // ones above. - thisObject->target()->methodTable(globalObject->vm())->getPropertyNames(thisObject->target(), globalObject, propertyNames, mode); -} - -void JSProxy::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSProxy::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { JSProxy* thisObject = jsCast(object); thisObject->target()->methodTable(globalObject->vm())->getOwnPropertyNames(thisObject->target(), globalObject, propertyNames, mode); diff --git a/Source/JavaScriptCore/runtime/JSProxy.h b/Source/JavaScriptCore/runtime/JSProxy.h index 75fdc57bbaa11..c9e4ac10dbf70 100644 --- a/Source/JavaScriptCore/runtime/JSProxy.h +++ b/Source/JavaScriptCore/runtime/JSProxy.h @@ -32,7 +32,7 @@ namespace JSC { class JSProxy : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesAnyFormOfGetPropertyNames | OverridesGetPrototype | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | OverridesGetPrototype | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; template static IsoSubspace* subspaceFor(VM& vm) @@ -95,11 +95,8 @@ class JSProxy : public JSNonFinalObject { JS_EXPORT_PRIVATE static bool putByIndex(JSCell*, JSGlobalObject*, unsigned, JSValue, bool shouldThrow); JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); JS_EXPORT_PRIVATE static bool deletePropertyByIndex(JSCell*, JSGlobalObject*, unsigned); - JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); JS_EXPORT_PRIVATE static uint32_t getEnumerableLength(JSGlobalObject*, JSObject*); - JS_EXPORT_PRIVATE static void getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); JS_EXPORT_PRIVATE static bool setPrototype(JSObject*, JSGlobalObject*, JSValue, bool shouldThrowIfCantSet); JS_EXPORT_PRIVATE static JSValue getPrototype(JSObject*, JSGlobalObject*); diff --git a/Source/JavaScriptCore/runtime/JSSymbolTableObject.cpp b/Source/JavaScriptCore/runtime/JSSymbolTableObject.cpp index 125f6c3150e96..0b153fd17921b 100644 --- a/Source/JavaScriptCore/runtime/JSSymbolTableObject.cpp +++ b/Source/JavaScriptCore/runtime/JSSymbolTableObject.cpp @@ -53,7 +53,7 @@ bool JSSymbolTableObject::deleteProperty(JSCell* cell, JSGlobalObject* globalObj return Base::deleteProperty(thisObject, globalObject, propertyName, slot); } -void JSSymbolTableObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSSymbolTableObject::getOwnSpecialPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); JSSymbolTableObject* thisObject = jsCast(object); @@ -61,15 +61,13 @@ void JSSymbolTableObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobal ConcurrentJSLocker locker(thisObject->symbolTable()->m_lock); SymbolTable::Map::iterator end = thisObject->symbolTable()->end(locker); for (SymbolTable::Map::iterator it = thisObject->symbolTable()->begin(locker); it != end; ++it) { - if (!(it->value.getAttributes() & PropertyAttribute::DontEnum) || mode.includeDontEnumProperties()) { + if (mode == DontEnumPropertiesMode::Include || !it->value.isDontEnum()) { if (it->key->isSymbol() && !propertyNames.includeSymbolProperties()) continue; propertyNames.add(Identifier::fromUid(vm, it->key.get())); } } } - - Base::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode); } } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/JSSymbolTableObject.h b/Source/JavaScriptCore/runtime/JSSymbolTableObject.h index d398589f57f26..427fe4631e263 100644 --- a/Source/JavaScriptCore/runtime/JSSymbolTableObject.h +++ b/Source/JavaScriptCore/runtime/JSSymbolTableObject.h @@ -39,12 +39,12 @@ namespace JSC { class JSSymbolTableObject : public JSScope { public: using Base = JSScope; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnSpecialPropertyNames; SymbolTable* symbolTable() const { return m_symbolTable.get(); } JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); - JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static ptrdiff_t offsetOfSymbolTable() { return OBJECT_OFFSETOF(JSSymbolTableObject, m_symbolTable); } diff --git a/Source/JavaScriptCore/runtime/JSTypeInfo.h b/Source/JavaScriptCore/runtime/JSTypeInfo.h index 0e367b00848db..27c0b75214e4e 100644 --- a/Source/JavaScriptCore/runtime/JSTypeInfo.h +++ b/Source/JavaScriptCore/runtime/JSTypeInfo.h @@ -48,13 +48,8 @@ static constexpr unsigned TypeInfoPerCellBit = 1 << 7; // Unlike other inline fl // Out of line flags. static constexpr unsigned ImplementsHasInstance = 1 << 8; -static constexpr unsigned OverridesGetPropertyNames = 1 << 9; -// OverridesAnyFormOfGetPropertyNames means that we cannot make assumptions about -// the cacheability or enumerability of property names, and therefore, we'll need -// to disable certain optimizations. This flag should be set if one or more of the -// following Object methods are overridden: -// getOwnPropertyNames, getOwnNonIndexPropertyNames, getPropertyNames -static constexpr unsigned OverridesAnyFormOfGetPropertyNames = 1 << 10; +static constexpr unsigned OverridesGetOwnPropertyNames = 1 << 9; +static constexpr unsigned OverridesGetOwnSpecialPropertyNames = 1 << 10; static constexpr unsigned ProhibitsPropertyCaching = 1 << 11; static constexpr unsigned GetOwnPropertySlotIsImpure = 1 << 12; static constexpr unsigned NewImpurePropertyFiresWatchpoints = 1 << 13; @@ -103,8 +98,9 @@ class TypeInfo { static bool perCellBit(InlineTypeFlags flags) { return flags & TypeInfoPerCellBit; } bool overridesToThis() const { return isSetOnFlags1(); } bool structureIsImmortal() const { return isSetOnFlags2(); } - bool overridesGetPropertyNames() const { return isSetOnFlags2(); } - bool overridesAnyFormOfGetPropertyNames() const { return isSetOnFlags2(); } + bool overridesGetOwnPropertyNames() const { return isSetOnFlags2(); } + bool overridesGetOwnSpecialPropertyNames() const { return isSetOnFlags2(); } + bool overridesAnyFormOfGetOwnPropertyNames() const { return overridesGetOwnPropertyNames() || overridesGetOwnSpecialPropertyNames(); } bool overridesGetPrototype() const { return isSetOnFlags2(); } bool prohibitsPropertyCaching() const { return isSetOnFlags2(); } bool getOwnPropertySlotIsImpure() const { return isSetOnFlags2(); } diff --git a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp index 5805bffc2c850..bfae53e0317e2 100644 --- a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp +++ b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp @@ -186,7 +186,7 @@ JSValue objectConstructorGetOwnPropertyDescriptors(JSGlobalObject* globalObject, VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); PropertyNameArray properties(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, EnumerationMode(DontEnumPropertiesMode::Include)); + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, { }); JSObject* descriptors = constructEmptyObject(globalObject); @@ -294,7 +294,7 @@ JSC_DEFINE_HOST_FUNCTION(objectConstructorAssign, (JSGlobalObject* globalObject, auto canPerformFastPropertyEnumerationForObjectAssign = [] (Structure* structure) { if (structure->typeInfo().overridesGetOwnPropertySlot()) return false; - if (structure->typeInfo().overridesAnyFormOfGetPropertyNames()) + if (structure->typeInfo().overridesAnyFormOfGetOwnPropertyNames()) return false; // FIXME: Indexed properties can be handled. // https://bugs.webkit.org/show_bug.cgi?id=185358 @@ -357,7 +357,7 @@ JSC_DEFINE_HOST_FUNCTION(objectConstructorAssign, (JSGlobalObject* globalObject, targetCanPerformFastPut = false; PropertyNameArray properties(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - source->methodTable(vm)->getOwnPropertyNames(source, globalObject, properties, EnumerationMode(DontEnumPropertiesMode::Include)); + source->methodTable(vm)->getOwnPropertyNames(source, globalObject, properties, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, { }); unsigned numProperties = properties.size(); @@ -403,7 +403,7 @@ JSC_DEFINE_HOST_FUNCTION(objectConstructorValues, (JSGlobalObject* globalObject, RETURN_IF_EXCEPTION(scope, { }); PropertyNameArray properties(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - target->methodTable(vm)->getOwnPropertyNames(target, globalObject, properties, EnumerationMode(DontEnumPropertiesMode::Include)); + target->methodTable(vm)->getOwnPropertyNames(target, globalObject, properties, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, { }); unsigned index = 0; @@ -557,7 +557,7 @@ static JSValue defineProperties(JSGlobalObject* globalObject, JSObject* object, auto scope = DECLARE_THROW_SCOPE(vm); PropertyNameArray propertyNames(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), globalObject, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude)); + asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), globalObject, propertyNames, DontEnumPropertiesMode::Exclude); RETURN_IF_EXCEPTION(scope, { }); size_t numProperties = propertyNames.size(); Vector descriptors; @@ -648,7 +648,7 @@ bool setIntegrityLevel(JSGlobalObject* globalObject, VM& vm, JSObject* object) return false; PropertyNameArray properties(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, EnumerationMode(DontEnumPropertiesMode::Include)); + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, false); PropertyNameArray::const_iterator end = properties.end(); @@ -695,7 +695,7 @@ bool testIntegrityLevel(JSGlobalObject* globalObject, VM& vm, JSObject* object) // 6. Let keys be ? O.[[OwnPropertyKeys]](). PropertyNameArray keys(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, keys, EnumerationMode(DontEnumPropertiesMode::Include)); + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, keys, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, { }); // 7. For each element k of keys, do @@ -877,7 +877,7 @@ JSArray* ownPropertyKeys(JSGlobalObject* globalObject, JSObject* object, Propert } PropertyNameArray properties(vm, propertyNameMode, PrivateSymbolMode::Exclude); - object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, EnumerationMode(dontEnumPropertiesMode)); + object->methodTable(vm)->getOwnPropertyNames(object, globalObject, properties, dontEnumPropertiesMode); RETURN_IF_EXCEPTION(scope, nullptr); if (propertyNameMode != PropertyNameMode::StringsAndSymbols) { diff --git a/Source/JavaScriptCore/runtime/ProxyObject.cpp b/Source/JavaScriptCore/runtime/ProxyObject.cpp index 51962af80d9a9..10c91a9cf1cd1 100644 --- a/Source/JavaScriptCore/runtime/ProxyObject.cpp +++ b/Source/JavaScriptCore/runtime/ProxyObject.cpp @@ -890,10 +890,9 @@ void ProxyObject::performGetOwnPropertyNames(JSGlobalObject* globalObject, Prope JSValue ownKeysMethod = handler->getMethod(globalObject, callData, makeIdentifier(vm, "ownKeys"), "'ownKeys' property of a Proxy's handler should be callable"_s); RETURN_IF_EXCEPTION(scope, void()); JSObject* target = this->target(); - EnumerationMode enumerationMode(DontEnumPropertiesMode::Include); if (ownKeysMethod.isUndefined()) { scope.release(); - target->methodTable(vm)->getOwnPropertyNames(target, globalObject, propertyNames, enumerationMode); + target->methodTable(vm)->getOwnPropertyNames(target, globalObject, propertyNames, DontEnumPropertiesMode::Include); return; } @@ -946,7 +945,7 @@ void ProxyObject::performGetOwnPropertyNames(JSGlobalObject* globalObject, Prope RETURN_IF_EXCEPTION(scope, void()); PropertyNameArray targetKeys(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); - target->methodTable(vm)->getOwnPropertyNames(target, globalObject, targetKeys, enumerationMode); + target->methodTable(vm)->getOwnPropertyNames(target, globalObject, targetKeys, DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, void()); Vector targetConfigurableKeys; Vector targetNonConfigurableKeys; @@ -1013,37 +1012,15 @@ void ProxyObject::performGetOwnEnumerablePropertyNames(JSGlobalObject* globalObj } } -void ProxyObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNameArray, EnumerationMode enumerationMode) +void ProxyObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNameArray, DontEnumPropertiesMode mode) { ProxyObject* thisObject = jsCast(object); - if (enumerationMode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) thisObject->performGetOwnPropertyNames(globalObject, propertyNameArray); else thisObject->performGetOwnEnumerablePropertyNames(globalObject, propertyNameArray); } -void ProxyObject::getPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNameArray, EnumerationMode enumerationMode) -{ - NO_TAIL_CALLS(); - JSObject::getPropertyNames(object, globalObject, propertyNameArray, enumerationMode); -} - -void ProxyObject::getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - RELEASE_ASSERT_NOT_REACHED(); -} - -void ProxyObject::getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - // We should always go down the getOwnPropertyNames path. - RELEASE_ASSERT_NOT_REACHED(); -} - -void ProxyObject::getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode) -{ - RELEASE_ASSERT_NOT_REACHED(); -} - bool ProxyObject::performSetPrototype(JSGlobalObject* globalObject, JSValue prototype, bool shouldThrowIfCantSet) { NO_TAIL_CALLS(); diff --git a/Source/JavaScriptCore/runtime/ProxyObject.h b/Source/JavaScriptCore/runtime/ProxyObject.h index e0861e6642775..289b237364450 100644 --- a/Source/JavaScriptCore/runtime/ProxyObject.h +++ b/Source/JavaScriptCore/runtime/ProxyObject.h @@ -34,7 +34,7 @@ class ProxyObject final : public JSNonFinalObject { public: typedef JSNonFinalObject Base; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | OverridesAnyFormOfGetPropertyNames | OverridesGetPrototype | ProhibitsPropertyCaching; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | OverridesGetPrototype | OverridesGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | ProhibitsPropertyCaching; template static IsoSubspace* subspaceFor(VM& vm) @@ -57,7 +57,6 @@ class ProxyObject final : public JSNonFinalObject { if (isCallable) flags |= (ImplementsHasInstance | ImplementsDefaultHasInstance); Structure* result = Structure::create(vm, globalObject, prototype, TypeInfo(ProxyObjectType, flags), info(), NonArray | MayHaveIndexedAccessors); - result->setIsQuickPropertyAccessAllowedForEnumeration(false); RELEASE_ASSERT(!result->canAccessPropertiesQuicklyForEnumeration()); RELEASE_ASSERT(!result->canCachePropertyNameEnumerator(vm)); return result; @@ -89,11 +88,7 @@ class ProxyObject final : public JSNonFinalObject { static bool preventExtensions(JSObject*, JSGlobalObject*); static bool isExtensible(JSObject*, JSGlobalObject*); static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static void getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getStructurePropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - static NO_RETURN_DUE_TO_CRASH void getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool setPrototype(JSObject*, JSGlobalObject*, JSValue prototype, bool shouldThrowIfCantSet); static JSValue getPrototype(JSObject*, JSGlobalObject*); static void visitChildren(JSCell*, SlotVisitor&); diff --git a/Source/JavaScriptCore/runtime/RegExpObject.cpp b/Source/JavaScriptCore/runtime/RegExpObject.cpp index 1f0927e43593f..dc53f9b89853b 100644 --- a/Source/JavaScriptCore/runtime/RegExpObject.cpp +++ b/Source/JavaScriptCore/runtime/RegExpObject.cpp @@ -75,28 +75,11 @@ bool RegExpObject::deleteProperty(JSCell* cell, JSGlobalObject* globalObject, Pr return Base::deleteProperty(cell, globalObject, propertyName, slot); } -void RegExpObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void RegExpObject::getOwnSpecialPropertyNames(JSObject*, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) propertyNames.add(vm.propertyNames->lastIndex); - Base::getOwnNonIndexPropertyNames(object, globalObject, propertyNames, mode); -} - -void RegExpObject::getPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - VM& vm = globalObject->vm(); - if (mode.includeDontEnumProperties()) - propertyNames.add(vm.propertyNames->lastIndex); - Base::getPropertyNames(object, globalObject, propertyNames, mode); -} - -void RegExpObject::getGenericPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - VM& vm = globalObject->vm(); - if (mode.includeDontEnumProperties()) - propertyNames.add(vm.propertyNames->lastIndex); - Base::getGenericPropertyNames(object, globalObject, propertyNames, mode); } bool RegExpObject::defineOwnProperty(JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) diff --git a/Source/JavaScriptCore/runtime/RegExpObject.h b/Source/JavaScriptCore/runtime/RegExpObject.h index 5b28bdef4258b..0f70738d91409 100644 --- a/Source/JavaScriptCore/runtime/RegExpObject.h +++ b/Source/JavaScriptCore/runtime/RegExpObject.h @@ -30,7 +30,7 @@ namespace JSC { class RegExpObject final : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnSpecialPropertyNames; template static IsoSubspace* subspaceFor(VM& vm) @@ -146,9 +146,7 @@ class RegExpObject final : public JSNonFinalObject { } JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); - JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getGenericPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnSpecialPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); MatchResult matchInline(JSGlobalObject*, JSString*); diff --git a/Source/JavaScriptCore/runtime/StringObject.cpp b/Source/JavaScriptCore/runtime/StringObject.cpp index e6d64177dd354..505c18cdb8885 100644 --- a/Source/JavaScriptCore/runtime/StringObject.cpp +++ b/Source/JavaScriptCore/runtime/StringObject.cpp @@ -145,7 +145,7 @@ bool StringObject::deletePropertyByIndex(JSCell* cell, JSGlobalObject* globalObj return JSObject::deletePropertyByIndex(thisObject, globalObject, i); } -void StringObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void StringObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = globalObject->vm(); StringObject* thisObject = jsCast(object); @@ -153,17 +153,11 @@ void StringObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* globalO int size = thisObject->internalValue()->length(); for (int i = 0; i < size; ++i) propertyNames.add(Identifier::from(vm, i)); + thisObject->getOwnIndexedPropertyNames(globalObject, propertyNames, mode); } - return JSObject::getOwnPropertyNames(thisObject, globalObject, propertyNames, mode); -} - -void StringObject::getOwnNonIndexPropertyNames(JSObject* object, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode) -{ - VM& vm = globalObject->vm(); - StringObject* thisObject = jsCast(object); - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) propertyNames.add(vm.propertyNames->length); - return JSObject::getOwnNonIndexPropertyNames(thisObject, globalObject, propertyNames, mode); + thisObject->getOwnNonIndexPropertyNames(globalObject, propertyNames, mode); } String StringObject::toStringName(const JSObject*, JSGlobalObject*) diff --git a/Source/JavaScriptCore/runtime/StringObject.h b/Source/JavaScriptCore/runtime/StringObject.h index f0eb12a855fa8..109a9050eea8c 100644 --- a/Source/JavaScriptCore/runtime/StringObject.h +++ b/Source/JavaScriptCore/runtime/StringObject.h @@ -28,7 +28,7 @@ namespace JSC { class StringObject : public JSWrapperObject { public: using Base = JSWrapperObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; template static IsoSubspace* subspaceFor(VM& vm) @@ -59,8 +59,7 @@ class StringObject : public JSWrapperObject { JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&); JS_EXPORT_PRIVATE static bool deletePropertyByIndex(JSCell*, JSGlobalObject*, unsigned propertyName); - JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); - JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); static String toStringName(const JSObject*, JSGlobalObject*); diff --git a/Source/JavaScriptCore/runtime/Structure.cpp b/Source/JavaScriptCore/runtime/Structure.cpp index f53e2d32546ea..d38c39e447d63 100644 --- a/Source/JavaScriptCore/runtime/Structure.cpp +++ b/Source/JavaScriptCore/runtime/Structure.cpp @@ -194,32 +194,20 @@ void Structure::validateFlags() && methodTable.doPutPropertySecurityCheck != JSCell::doPutPropertySecurityCheck; RELEASE_ASSERT(overridesPutPropertySecurityCheck == typeInfo().hasPutPropertySecurityCheck()); - bool overridesGetPropertyNames = - methodTable.getPropertyNames != JSObject::getPropertyNames - && methodTable.getPropertyNames != JSCell::getPropertyNames; bool overridesGetOwnPropertyNames = methodTable.getOwnPropertyNames != JSObject::getOwnPropertyNames && methodTable.getOwnPropertyNames != JSCell::getOwnPropertyNames; - bool overridesGetOwnNonIndexPropertyNames = - methodTable.getOwnNonIndexPropertyNames != JSObject::getOwnNonIndexPropertyNames - && methodTable.getOwnNonIndexPropertyNames != JSCell::getOwnNonIndexPropertyNames; + RELEASE_ASSERT(overridesGetOwnPropertyNames == typeInfo().overridesGetOwnPropertyNames()); - RELEASE_ASSERT(overridesGetPropertyNames == typeInfo().overridesGetPropertyNames()); - - // We can strengthen this into an equivalence test if there are no classes - // that specifies this flag without overriding any of the forms of getPropertyNames. - // FIXME: https://bugs.webkit.org/show_bug.cgi?id=212954 - if (overridesGetPropertyNames - || overridesGetOwnPropertyNames - || overridesGetOwnNonIndexPropertyNames) - RELEASE_ASSERT(typeInfo().overridesAnyFormOfGetPropertyNames()); + bool overridesGetOwnSpecialPropertyNames = + methodTable.getOwnSpecialPropertyNames != JSObject::getOwnSpecialPropertyNames + && methodTable.getOwnSpecialPropertyNames != JSCell::getOwnSpecialPropertyNames; + RELEASE_ASSERT(overridesGetOwnSpecialPropertyNames == typeInfo().overridesGetOwnSpecialPropertyNames()); bool overridesGetPrototype = methodTable.getPrototype != static_cast(JSObject::getPrototype) && methodTable.getPrototype != JSCell::getPrototype; - - if (overridesGetPrototype) - RELEASE_ASSERT(typeInfo().overridesGetPrototype()); + RELEASE_ASSERT(overridesGetPrototype == typeInfo().overridesGetPrototype()); } #else inline void Structure::validateFlags() { } @@ -1203,7 +1191,7 @@ PropertyOffset Structure::attributeChange(VM& vm, PropertyName propertyName, uns }); } -void Structure::getPropertyNamesFromStructure(VM& vm, PropertyNameArray& propertyNames, EnumerationMode mode) +void Structure::getPropertyNamesFromStructure(VM& vm, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { PropertyTable* table = ensurePropertyTableIfNotEmpty(vm); if (!table) @@ -1213,7 +1201,7 @@ void Structure::getPropertyNamesFromStructure(VM& vm, PropertyNameArray& propert bool foundSymbol = false; auto checkDontEnumAndAdd = [&](PropertyTable::iterator iter) { - if (!(iter->attributes & PropertyAttribute::DontEnum) || mode.includeDontEnumProperties()) { + if (mode == DontEnumPropertiesMode::Include || !(iter->attributes & PropertyAttribute::DontEnum)) { if (knownUnique) propertyNames.addUnchecked(iter->key); else @@ -1492,6 +1480,8 @@ bool Structure::canAccessPropertiesQuicklyForEnumeration() const return false; if (isUncacheableDictionary()) return false; + if (typeInfo().overridesGetOwnPropertyNames()) + return false; return true; } diff --git a/Source/JavaScriptCore/runtime/Structure.h b/Source/JavaScriptCore/runtime/Structure.h index 000bb980d7ca6..3e47514c9cd61 100644 --- a/Source/JavaScriptCore/runtime/Structure.h +++ b/Source/JavaScriptCore/runtime/Structure.h @@ -530,7 +530,7 @@ class Structure final : public JSCell { void setCachedPropertyNames(VM&, CachedPropertyNamesKind, JSImmutableButterfly*); bool canCacheOwnPropertyNames() const; - void getPropertyNamesFromStructure(VM&, PropertyNameArray&, EnumerationMode); + void getPropertyNamesFromStructure(VM&, PropertyNameArray&, DontEnumPropertiesMode); JSValue cachedSpecialProperty(CachedSpecialPropertyKey key) { diff --git a/Source/JavaScriptCore/runtime/StructureInlines.h b/Source/JavaScriptCore/runtime/StructureInlines.h index 730735f996dd2..739e1ef3b9c7c 100644 --- a/Source/JavaScriptCore/runtime/StructureInlines.h +++ b/Source/JavaScriptCore/runtime/StructureInlines.h @@ -275,7 +275,7 @@ inline bool Structure::canCacheOwnPropertyNames() const return false; if (hasIndexedProperties(indexingType())) return false; - if (typeInfo().overridesAnyFormOfGetPropertyNames()) + if (typeInfo().overridesAnyFormOfGetOwnPropertyNames()) return false; return true; } diff --git a/Source/JavaScriptCore/tools/JSDollarVM.cpp b/Source/JavaScriptCore/tools/JSDollarVM.cpp index cdd38bff7026d..48d9ca5d5ef7c 100644 --- a/Source/JavaScriptCore/tools/JSDollarVM.cpp +++ b/Source/JavaScriptCore/tools/JSDollarVM.cpp @@ -543,7 +543,7 @@ static JSC_DECLARE_CUSTOM_GETTER(runtimeArrayLengthGetter); class RuntimeArray : public JSArray { public: typedef JSArray Base; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; IGNORE_WARNINGS_BEGIN("unused-const-variable") static constexpr bool needsDestruction = false; diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 28e135ab9e9b3..9a8c48d79e109 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,37 @@ +2021-01-07 Alexey Shvayka + + [JSC] Simplify get*PropertyNames() methods and EnumerationMode + https://bugs.webkit.org/show_bug.cgi?id=212954 + + Reviewed by Yusuke Suzuki. + + Adjust for changes in JSC's MethodTable, TypeInfo, and EnumerationMode. + + No new tests, no behavior change. + + * animation/KeyframeEffect.cpp: + (WebCore::processKeyframeLikeObject): + * bindings/js/JSDOMConvertRecord.h: + * bindings/js/JSDOMWindowCustom.cpp: + (WebCore::JSDOMWindow::getOwnPropertyNames): + * bindings/js/JSLocationCustom.cpp: + (WebCore::JSLocation::getOwnPropertyNames): + * bindings/js/JSRemoteDOMWindowCustom.cpp: + (WebCore::JSRemoteDOMWindow::getOwnPropertyNames): + * bindings/js/SerializedScriptValue.cpp: + (WebCore::CloneSerializer::serialize): + * bindings/scripts/CodeGeneratorJS.pm: + (GenerateGetOwnPropertyNames): + (GenerateHeader): + * bindings/scripts/test/JS/*: Updated. + * bridge/NP_jsobject.cpp: + * bridge/runtime_array.cpp: + (JSC::RuntimeArray::getOwnPropertyNames): + * bridge/runtime_array.h: + * bridge/runtime_object.cpp: + (JSC::Bindings::RuntimeObject::getOwnPropertyNames): + * bridge/runtime_object.h: + 2021-01-07 Wenson Hsieh Text fields should not be translated while typing diff --git a/Source/WebCore/animation/KeyframeEffect.cpp b/Source/WebCore/animation/KeyframeEffect.cpp index 626d9dd410884..d122288b1c6ca 100644 --- a/Source/WebCore/animation/KeyframeEffect.cpp +++ b/Source/WebCore/animation/KeyframeEffect.cpp @@ -238,7 +238,7 @@ static inline ExceptionOr processKeyframeLik // 3. Let input properties be the result of calling the EnumerableOwnNames operation with keyframe input as the object. PropertyNameArray inputProperties(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - JSObject::getOwnPropertyNames(keyframesInput.get(), &lexicalGlobalObject, inputProperties, EnumerationMode()); + JSObject::getOwnPropertyNames(keyframesInput.get(), &lexicalGlobalObject, inputProperties, DontEnumPropertiesMode::Exclude); // 4. Make up a new list animation properties that consists of all of the properties that are in both input properties and animatable // properties, or which are in input properties and conform to the production. diff --git a/Source/WebCore/bindings/js/JSDOMConvertRecord.h b/Source/WebCore/bindings/js/JSDOMConvertRecord.h index 4f6536d5c7492..20bc3397a43e7 100644 --- a/Source/WebCore/bindings/js/JSDOMConvertRecord.h +++ b/Source/WebCore/bindings/js/JSDOMConvertRecord.h @@ -100,7 +100,7 @@ template struct Converter> : DefaultConv // 4. Let keys be ? O.[[OwnPropertyKeys]](). JSC::PropertyNameArray keys(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); - object->methodTable(vm)->getOwnPropertyNames(object, &lexicalGlobalObject, keys, JSC::EnumerationMode(JSC::DontEnumPropertiesMode::Include)); + object->methodTable(vm)->getOwnPropertyNames(object, &lexicalGlobalObject, keys, JSC::DontEnumPropertiesMode::Include); RETURN_IF_EXCEPTION(scope, { }); @@ -113,7 +113,7 @@ template struct Converter> : DefaultConv // 2. If desc is not undefined and desc.[[Enumerable]] is true: - // It's necessary to filter enumerable here rather than using the default EnumerationMode, + // It's necessary to filter enumerable here rather than using DontEnumPropertiesMode::Exclude, // to prevent an observable extra [[GetOwnProperty]] operation in the case of ProxyObject records. if (didGetDescriptor && descriptor.enumerable()) { // 1. Let typedKey be key converted to an IDL value of type K. diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp index 6c28b0ca39d28..e89a677c82e4e 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -454,14 +454,14 @@ static void addScopedChildrenIndexes(JSGlobalObject& lexicalGlobalObject, DOMWin } // https://html.spec.whatwg.org/#windowproxy-ownpropertykeys -void JSDOMWindow::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSDOMWindow::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { JSDOMWindow* thisObject = jsCast(object); addScopedChildrenIndexes(*lexicalGlobalObject, thisObject->wrapped(), propertyNames); if (!BindingSecurity::shouldAllowAccessToDOMWindow(lexicalGlobalObject, thisObject->wrapped(), DoNotReportSecurityError)) { - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) addCrossOriginOwnPropertyNames(*lexicalGlobalObject, propertyNames); return; } diff --git a/Source/WebCore/bindings/js/JSLocationCustom.cpp b/Source/WebCore/bindings/js/JSLocationCustom.cpp index 9f06237e9b54b..1f35202fc52a5 100644 --- a/Source/WebCore/bindings/js/JSLocationCustom.cpp +++ b/Source/WebCore/bindings/js/JSLocationCustom.cpp @@ -176,11 +176,11 @@ bool JSLocation::deletePropertyByIndex(JSCell* cell, JSGlobalObject* lexicalGlob return Base::deletePropertyByIndex(thisObject, lexicalGlobalObject, propertyName); } -void JSLocation::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSLocation::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { JSLocation* thisObject = jsCast(object); if (!BindingSecurity::shouldAllowAccessToDOMWindow(lexicalGlobalObject, thisObject->wrapped().window(), DoNotReportSecurityError)) { - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) addCrossOriginOwnPropertyNames(*lexicalGlobalObject, propertyNames); return; } diff --git a/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp index 55805f1c3f872..192105c319f5b 100644 --- a/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp +++ b/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp @@ -100,11 +100,11 @@ bool JSRemoteDOMWindow::deletePropertyByIndex(JSCell*, JSGlobalObject* lexicalGl return false; } -void JSRemoteDOMWindow::getOwnPropertyNames(JSObject*, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSRemoteDOMWindow::getOwnPropertyNames(JSObject*, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { // FIXME: Add scoped children indexes. - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) addCrossOriginOwnPropertyNames(*lexicalGlobalObject, propertyNames); } diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.cpp b/Source/WebCore/bindings/js/SerializedScriptValue.cpp index 7bb8a6d9d32cf..9dc925f43c7f9 100644 --- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/js/SerializedScriptValue.cpp @@ -1728,7 +1728,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) lengthStack.removeLast(); propertyStack.append(PropertyNameArray(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude)); - array->methodTable(vm)->getOwnNonIndexPropertyNames(array, m_lexicalGlobalObject, propertyStack.last(), EnumerationMode()); + array->getOwnNonIndexPropertyNames(m_lexicalGlobalObject, propertyStack.last(), DontEnumPropertiesMode::Exclude); if (propertyStack.last().size()) { write(NonIndexPropertiesTag); indexStack.append(0); @@ -1778,7 +1778,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) inputObjectStack.append(inObject); indexStack.append(0); propertyStack.append(PropertyNameArray(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude)); - inObject->methodTable(vm)->getOwnPropertyNames(inObject, m_lexicalGlobalObject, propertyStack.last(), EnumerationMode()); + inObject->methodTable(vm)->getOwnPropertyNames(inObject, m_lexicalGlobalObject, propertyStack.last(), DontEnumPropertiesMode::Exclude); } objectStartVisitMember: FALLTHROUGH; @@ -1846,7 +1846,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) JSObject* object = inputObjectStack.last(); ASSERT(jsDynamicCast(vm, object)); propertyStack.append(PropertyNameArray(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude)); - object->methodTable(vm)->getOwnPropertyNames(object, m_lexicalGlobalObject, propertyStack.last(), EnumerationMode()); + object->methodTable(vm)->getOwnPropertyNames(object, m_lexicalGlobalObject, propertyStack.last(), DontEnumPropertiesMode::Exclude); write(NonMapPropertiesTag); indexStack.append(0); goto objectStartVisitMember; @@ -1890,7 +1890,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) JSObject* object = inputObjectStack.last(); ASSERT(jsDynamicCast(vm, object)); propertyStack.append(PropertyNameArray(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude)); - object->methodTable(vm)->getOwnPropertyNames(object, m_lexicalGlobalObject, propertyStack.last(), EnumerationMode()); + object->methodTable(vm)->getOwnPropertyNames(object, m_lexicalGlobalObject, propertyStack.last(), DontEnumPropertiesMode::Exclude); write(NonSetPropertiesTag); indexStack.append(0); goto objectStartVisitMember; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index 394ab0177397b..fb0d4671385ee 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1104,7 +1104,7 @@ sub GenerateGetOwnPropertyNames my $namedGetterOperation = GetNamedGetterOperation($interface); my $indexedGetterOperation = GetIndexedGetterOperation($interface); - push(@$outputArray, "void ${className}::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode)\n"); + push(@$outputArray, "void ${className}::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode)\n"); push(@$outputArray, "{\n"); if ($indexedGetterOperation || $namedGetterOperation) { push(@$outputArray, " VM& vm = JSC::getVM(lexicalGlobalObject);\n"); @@ -1130,7 +1130,7 @@ sub GenerateGetOwnPropertyNames push(@$outputArray, " for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())\n"); push(@$outputArray, " propertyNames.add(Identifier::fromString(vm, propertyName));\n"); } else { - push(@$outputArray, " if (mode.includeDontEnumProperties()) {\n"); + push(@$outputArray, " if (mode == DontEnumPropertiesMode::Include) {\n"); push(@$outputArray, " for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())\n"); push(@$outputArray, " propertyNames.add(Identifier::fromString(vm, propertyName));\n"); push(@$outputArray, " }\n"); @@ -2962,8 +2962,8 @@ sub GenerateHeader } if (InstanceOverridesGetOwnPropertyNames($interface)) { - push(@headerContent, " static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode = JSC::EnumerationMode());\n"); - $structureFlags{"JSC::OverridesAnyFormOfGetPropertyNames"} = 1; + push(@headerContent, " static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode);\n"); + $structureFlags{"JSC::OverridesGetOwnPropertyNames"} = 1; } if (InstanceOverridesPut($interface)) { diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp index be1b339d68b99..4c50302559ad5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp @@ -208,7 +208,7 @@ bool JSTestEventTarget::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObje return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestEventTarget::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestEventTarget::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h index 88d226b104421..4765f5de522b3 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h @@ -43,7 +43,7 @@ class JSTestEventTarget : public JSEventTarget { static TestEventTarget* toWrapped(JSC::VM&, JSC::JSValue); static bool getOwnPropertySlot(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&); static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::JSGlobalObject*, unsigned propertyName, JSC::PropertySlot&); - static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode = JSC::EnumerationMode()); + static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode); DECLARE_INFO; @@ -66,7 +66,7 @@ class JSTestEventTarget : public JSEventTarget { return static_cast(Base::wrapped()); } public: - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpureForPropertyAbsence | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::MasqueradesAsUndefined | JSC::OverridesAnyFormOfGetPropertyNames | JSC::OverridesGetOwnPropertySlot; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpureForPropertyAbsence | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::MasqueradesAsUndefined | JSC::OverridesGetOwnPropertyNames | JSC::OverridesGetOwnPropertySlot; protected: JSTestEventTarget(JSC::Structure*, JSDOMGlobalObject&, Ref&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp index 70efcf91ac705..a2ce93c721b87 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.cpp @@ -178,7 +178,7 @@ bool JSTestIndexedSetterNoIdentifier::getOwnPropertySlotByIndex(JSObject* object return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestIndexedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestIndexedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h index e41646e1ae94c..8d75acff765cc 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h @@ -41,7 +41,7 @@ class JSTestIndexedSetterNoIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp index 7c3272ef19e45..bc2d1c7e9aa6c 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.cpp @@ -178,7 +178,7 @@ bool JSTestIndexedSetterThrowingException::getOwnPropertySlotByIndex(JSObject* o return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestIndexedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestIndexedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h index d220bc432728b..06e5b866003f5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h @@ -41,7 +41,7 @@ class JSTestIndexedSetterThrowingException : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp index b8e6ac837b8c3..b103926025bf4 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.cpp @@ -185,7 +185,7 @@ bool JSTestIndexedSetterWithIdentifier::getOwnPropertySlotByIndex(JSObject* obje return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestIndexedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestIndexedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h index fe417e502fa84..283464c779be2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h @@ -41,7 +41,7 @@ class JSTestIndexedSetterWithIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.cpp index 50f1b24230083..a82c60961d39c 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.cpp @@ -199,7 +199,7 @@ bool JSTestLegacyOverrideBuiltIns::getOwnPropertySlotByIndex(JSObject* object, J return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.h b/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.h index 67191b47b182a..901c404185d7a 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestLegacyOverrideBuiltIns.h @@ -41,7 +41,7 @@ class JSTestLegacyOverrideBuiltIns : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp index ca0d5ca050dda..d7ad74c4eba6f 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.cpp @@ -207,7 +207,7 @@ bool JSTestNamedAndIndexedSetterNoIdentifier::getOwnPropertySlotByIndex(JSObject return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedAndIndexedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedAndIndexedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h index 949640769c1b1..7068fec576d75 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedAndIndexedSetterNoIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp index 35ab17bdd919a..c494b144eb2fe 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.cpp @@ -207,7 +207,7 @@ bool JSTestNamedAndIndexedSetterThrowingException::getOwnPropertySlotByIndex(JSO return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedAndIndexedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedAndIndexedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h index ee19306d25086..1d49e26071e82 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h @@ -41,7 +41,7 @@ class JSTestNamedAndIndexedSetterThrowingException : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp index 429d339bbe84e..9706d666f91cd 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.cpp @@ -216,7 +216,7 @@ bool JSTestNamedAndIndexedSetterWithIdentifier::getOwnPropertySlotByIndex(JSObje return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedAndIndexedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedAndIndexedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h index 2233329e40c58..4ca986aa1b929 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedAndIndexedSetterWithIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.cpp index 93b9b602568a8..de5f045464cee 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.cpp @@ -190,7 +190,7 @@ bool JSTestNamedDeleterNoIdentifier::getOwnPropertySlotByIndex(JSObject* object, return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedDeleterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedDeleterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h index 23712208c210b..702345cf8a4d2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedDeleterNoIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.cpp index da460efb050f9..22dc0f9c4b0c4 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.cpp @@ -190,7 +190,7 @@ bool JSTestNamedDeleterThrowingException::getOwnPropertySlotByIndex(JSObject* ob return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedDeleterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedDeleterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h index e835009541582..d760ec63bd6fb 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h @@ -41,7 +41,7 @@ class JSTestNamedDeleterThrowingException : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.cpp index 53979b24853c1..c1e72beac27c5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.cpp @@ -196,7 +196,7 @@ bool JSTestNamedDeleterWithIdentifier::getOwnPropertySlotByIndex(JSObject* objec return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedDeleterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedDeleterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h index 7477947742f48..cc713a74383a2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedDeleterWithIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp index a88b67df782ac..b33413d1911b0 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.cpp @@ -207,7 +207,7 @@ bool JSTestNamedDeleterWithIndexedGetter::getOwnPropertySlotByIndex(JSObject* ob return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedDeleterWithIndexedGetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedDeleterWithIndexedGetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h index b45318be1c66a..b947c8d8f28d8 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h @@ -41,7 +41,7 @@ class JSTestNamedDeleterWithIndexedGetter : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.cpp index a376f4b96827f..2c2ce686baa80 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.cpp @@ -190,7 +190,7 @@ bool JSTestNamedGetterCallWith::getOwnPropertySlotByIndex(JSObject* object, JSGl return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedGetterCallWith::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedGetterCallWith::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.h index 44919ff194bb1..5e6390bc71d73 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterCallWith.h @@ -41,7 +41,7 @@ class JSTestNamedGetterCallWith : public JSDOMWrapper { static TestNamedGetterCallWith* toWrapped(JSC::VM&, JSC::JSValue); static bool getOwnPropertySlot(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&); static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::JSGlobalObject*, unsigned propertyName, JSC::PropertySlot&); - static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode = JSC::EnumerationMode()); + static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode); static void destroy(JSC::JSCell*); DECLARE_INFO; @@ -61,7 +61,7 @@ class JSTestNamedGetterCallWith : public JSDOMWrapper { static JSC::IsoSubspace* subspaceForImpl(JSC::VM& vm); static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); public: - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpureForPropertyAbsence | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesAnyFormOfGetPropertyNames | JSC::OverridesGetOwnPropertySlot; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpureForPropertyAbsence | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertyNames | JSC::OverridesGetOwnPropertySlot; protected: JSTestNamedGetterCallWith(JSC::Structure*, JSDOMGlobalObject&, Ref&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.cpp index 600ef364f9c23..0616c2de299a9 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.cpp @@ -190,7 +190,7 @@ bool JSTestNamedGetterNoIdentifier::getOwnPropertySlotByIndex(JSObject* object, return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedGetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedGetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h index 13d882994dd92..4cdde5ee55ec5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedGetterNoIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.cpp index cc6f6a60bf53a..81b330ad3ea36 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.cpp @@ -196,7 +196,7 @@ bool JSTestNamedGetterWithIdentifier::getOwnPropertySlotByIndex(JSObject* object return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedGetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedGetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h index 148dd666c2e83..9ec20fef070d4 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedGetterWithIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.cpp index 0a21a6251b9f0..07c5f625c499c 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.cpp @@ -190,7 +190,7 @@ bool JSTestNamedSetterNoIdentifier::getOwnPropertySlotByIndex(JSObject* object, return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterNoIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h index 3b4eef53363d8..55461ddfaa21a 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedSetterNoIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.cpp index b27b5d87654fd..59906fcb38ae7 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.cpp @@ -190,7 +190,7 @@ bool JSTestNamedSetterThrowingException::getOwnPropertySlotByIndex(JSObject* obj return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterThrowingException::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h index 615e9b7198a32..cd37584e87345 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h @@ -41,7 +41,7 @@ class JSTestNamedSetterThrowingException : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.cpp index baea855ef6fa7..f9bc69a729593 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.cpp @@ -196,7 +196,7 @@ bool JSTestNamedSetterWithIdentifier::getOwnPropertySlotByIndex(JSObject* object return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithIdentifier::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h index 5e2567a0cd05f..4807e3d9cbef7 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithIdentifier : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp index 3b1332a81fdea..b87f69acd5cfc 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.cpp @@ -216,7 +216,7 @@ bool JSTestNamedSetterWithIndexedGetter::getOwnPropertySlotByIndex(JSObject* obj return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithIndexedGetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithIndexedGetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h index a2f36255691ec..cc21e90ed71bf 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithIndexedGetter : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp index f5221eb349622..16d09f44a5cc6 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.cpp @@ -216,7 +216,7 @@ bool JSTestNamedSetterWithIndexedGetterAndSetter::getOwnPropertySlotByIndex(JSOb return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithIndexedGetterAndSetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithIndexedGetterAndSetter::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h index 0dbddd0a9f891..2f25681e554ab 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithIndexedGetterAndSetter : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.cpp index bb3103bbe9dac..1190b648a495d 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.cpp @@ -190,7 +190,7 @@ bool JSTestNamedSetterWithLegacyOverrideBuiltIns::getOwnPropertySlotByIndex(JSOb return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.h index 52f42fc7f812b..c85b4ad0595b0 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyOverrideBuiltIns.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithLegacyOverrideBuiltIns : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.cpp index 8bfb70703a515..c62c2ca3e9752 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.cpp @@ -214,7 +214,7 @@ bool JSTestNamedSetterWithLegacyUnforgeableProperties::getOwnPropertySlotByIndex return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithLegacyUnforgeableProperties::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithLegacyUnforgeableProperties::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.h index 43ed6acfbcbd6..330f10554c4f5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeableProperties.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithLegacyUnforgeableProperties : public JSDOMWrapper&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.cpp index 52e90b3f0e899..20b03b6ca9a32 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.cpp @@ -214,7 +214,7 @@ bool JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns:: return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.h index 937caac750a41..3f5cbd7f5e3a0 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.h @@ -41,7 +41,7 @@ class JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns static TestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns* toWrapped(JSC::VM&, JSC::JSValue); static bool getOwnPropertySlot(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&); static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::JSGlobalObject*, unsigned propertyName, JSC::PropertySlot&); - static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode = JSC::EnumerationMode()); + static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode); static bool put(JSC::JSCell*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&); static bool putByIndex(JSC::JSCell*, JSC::JSGlobalObject*, unsigned propertyName, JSC::JSValue, bool shouldThrow); static bool defineOwnProperty(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, const JSC::PropertyDescriptor&, bool shouldThrow); @@ -64,7 +64,7 @@ class JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns static JSC::IsoSubspace* subspaceForImpl(JSC::VM& vm); static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); public: - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpure | JSC::HasStaticPropertyTable | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesAnyFormOfGetPropertyNames | JSC::OverridesGetOwnPropertySlot | JSC::ProhibitsPropertyCaching; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::GetOwnPropertySlotIsImpure | JSC::HasStaticPropertyTable | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertyNames | JSC::OverridesGetOwnPropertySlot | JSC::ProhibitsPropertyCaching; protected: JSTestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns(JSC::Structure*, JSDOMGlobalObject&, Ref&&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 3b58846983079..75eb43bf21148 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -2528,7 +2528,7 @@ bool JSTestObj::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObject* lexi return JSObject::getOwnPropertySlotByIndex(object, lexicalGlobalObject, index, slot); } -void JSTestObj::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSTestObj::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = JSC::getVM(lexicalGlobalObject); auto* thisObject = jsCast(object); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h index 00ef073e46389..d02fe1fd8dece 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -43,7 +43,7 @@ class JSTestObj : public JSDOMWrapper { static TestObj* toWrapped(JSC::VM&, JSC::JSValue); static bool getOwnPropertySlot(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&); static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::JSGlobalObject*, unsigned propertyName, JSC::PropertySlot&); - static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode = JSC::EnumerationMode()); + static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode); static void destroy(JSC::JSCell*); DECLARE_INFO; @@ -82,7 +82,7 @@ class JSTestObj : public JSDOMWrapper { static JSC::JSValue testStaticCustomPromiseFunction(JSC::JSGlobalObject&, JSC::CallFrame&, Ref&&); JSC::JSValue testCustomReturnsOwnPromiseFunction(JSC::JSGlobalObject&, JSC::CallFrame&); public: - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::HasStaticPropertyTable | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesAnyFormOfGetPropertyNames | JSC::OverridesGetOwnPropertySlot; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::HasStaticPropertyTable | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertyNames | JSC::OverridesGetOwnPropertySlot; protected: JSTestObj(JSC::Structure*, JSDOMGlobalObject&, Ref&&); diff --git a/Source/WebCore/bridge/NP_jsobject.cpp b/Source/WebCore/bridge/NP_jsobject.cpp index 940de45e9b04a..cdc6d6b9c257f 100644 --- a/Source/WebCore/bridge/NP_jsobject.cpp +++ b/Source/WebCore/bridge/NP_jsobject.cpp @@ -487,7 +487,7 @@ bool _NPN_Enumerate(NPP, NPObject* o, NPIdentifier** identifier, uint32_t* count JSGlobalObject* lexicalGlobalObject = globalObject; PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - obj->imp->methodTable(vm)->getPropertyNames(obj->imp, lexicalGlobalObject, propertyNames, EnumerationMode()); + obj->imp->getPropertyNames(lexicalGlobalObject, propertyNames, DontEnumPropertiesMode::Exclude); unsigned size = static_cast(propertyNames.size()); // FIXME: This should really call NPN_MemAlloc but that's in WebKit NPIdentifier* identifiers = static_cast(malloc(sizeof(NPIdentifier) * size)); diff --git a/Source/WebCore/bridge/runtime_array.cpp b/Source/WebCore/bridge/runtime_array.cpp index f565370313900..00e6265c8a432 100644 --- a/Source/WebCore/bridge/runtime_array.cpp +++ b/Source/WebCore/bridge/runtime_array.cpp @@ -75,7 +75,7 @@ JSC_DEFINE_CUSTOM_GETTER(arrayLengthGetter, (JSGlobalObject* lexicalGlobalObject return JSValue::encode(jsNumber(thisObject->getLength())); } -void RuntimeArray::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode) +void RuntimeArray::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode mode) { VM& vm = lexicalGlobalObject->vm(); RuntimeArray* thisObject = jsCast(object); @@ -83,10 +83,10 @@ void RuntimeArray::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexical for (unsigned i = 0; i < length; ++i) propertyNames.add(Identifier::from(vm, i)); - if (mode.includeDontEnumProperties()) + if (mode == DontEnumPropertiesMode::Include) propertyNames.add(vm.propertyNames->length); - JSObject::getOwnPropertyNames(thisObject, lexicalGlobalObject, propertyNames, mode); + thisObject->getOwnNonIndexPropertyNames(lexicalGlobalObject, propertyNames, mode); } bool RuntimeArray::getOwnPropertySlot(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyName propertyName, PropertySlot& slot) diff --git a/Source/WebCore/bridge/runtime_array.h b/Source/WebCore/bridge/runtime_array.h index 3c4c7e8610481..054114147f8eb 100644 --- a/Source/WebCore/bridge/runtime_array.h +++ b/Source/WebCore/bridge/runtime_array.h @@ -35,7 +35,7 @@ namespace JSC { class RuntimeArray final : public JSArray { public: using Base = JSArray; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesAnyFormOfGetPropertyNames; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero; static constexpr bool needsDestruction = true; template @@ -59,7 +59,7 @@ class RuntimeArray final : public JSArray { ~RuntimeArray(); static void destroy(JSCell*); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); static bool getOwnPropertySlotByIndex(JSObject*, JSGlobalObject*, unsigned, PropertySlot&); static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); diff --git a/Source/WebCore/bridge/runtime_object.cpp b/Source/WebCore/bridge/runtime_object.cpp index e759e4d0c7e79..5b20a17b3db2b 100644 --- a/Source/WebCore/bridge/runtime_object.cpp +++ b/Source/WebCore/bridge/runtime_object.cpp @@ -280,7 +280,7 @@ CallData RuntimeObject::getConstructData(JSCell* cell) return constructData; } -void RuntimeObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode) +void RuntimeObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, DontEnumPropertiesMode) { VM& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/Source/WebCore/bridge/runtime_object.h b/Source/WebCore/bridge/runtime_object.h index 65991c51593ad..1bc4570a92d9c 100644 --- a/Source/WebCore/bridge/runtime_object.h +++ b/Source/WebCore/bridge/runtime_object.h @@ -37,7 +37,7 @@ Exception* throwRuntimeObjectInvalidAccessError(JSGlobalObject*, ThrowScope&); class WEBCORE_EXPORT RuntimeObject : public JSNonFinalObject { public: using Base = JSNonFinalObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesAnyFormOfGetPropertyNames | OverridesGetCallData; + static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | OverridesGetCallData; static constexpr bool needsDestruction = true; template @@ -64,7 +64,7 @@ class WEBCORE_EXPORT RuntimeObject : public JSNonFinalObject { static CallData getCallData(JSCell*); static CallData getConstructData(JSCell*); - static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, EnumerationMode); + static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode); void invalidate(); diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index 011f35c4a98b0..64945bba9d5bd 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,20 @@ +2021-01-07 Alexey Shvayka + + [JSC] Simplify get*PropertyNames() methods and EnumerationMode + https://bugs.webkit.org/show_bug.cgi?id=212954 + + Reviewed by Yusuke Suzuki. + + Adjust for changes in JSC's MethodTable, TypeInfo, and EnumerationMode. + + No new tests, no behavior change. + + * WebProcess/Plugins/Netscape/JSNPObject.cpp: + (WebKit::JSNPObject::getOwnPropertyNames): + * WebProcess/Plugins/Netscape/JSNPObject.h: + * WebProcess/Plugins/Netscape/NPJSObject.cpp: + (WebKit::NPJSObject::enumerate): + 2021-01-07 Commit Queue Unreviewed, reverting r271192. diff --git a/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.cpp b/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.cpp index 6146b8198fdf5..9df470056b0dc 100644 --- a/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.cpp +++ b/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.cpp @@ -425,7 +425,7 @@ bool JSNPObject::deleteProperty(JSGlobalObject* lexicalGlobalObject, NPIdentifie return true; } -void JSNPObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNameArray, EnumerationMode) +void JSNPObject::getOwnPropertyNames(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNameArray, DontEnumPropertiesMode) { VM& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); diff --git a/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h b/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h index 2ad2769dc3587..b894e0aa30419 100644 --- a/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h +++ b/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h @@ -44,7 +44,7 @@ class NPRuntimeObjectMap; class JSNPObject final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; - static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot | JSC::OverridesAnyFormOfGetPropertyNames | JSC::OverridesGetCallData; + static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetOwnPropertyNames | JSC::OverridesGetCallData; template static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) @@ -99,7 +99,7 @@ class JSNPObject final : public JSC::JSDestructibleObject { bool deleteProperty(JSC::JSGlobalObject*, NPIdentifier propertyName); - static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::EnumerationMode); + static void getOwnPropertyNames(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyNameArray&, JSC::DontEnumPropertiesMode); NPRuntimeObjectMap* m_objectMap; NPObject* m_npObject; diff --git a/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp b/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp index 8712c18123d31..129b75518bbd1 100644 --- a/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp +++ b/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp @@ -253,7 +253,7 @@ bool NPJSObject::enumerate(NPIdentifier** identifiers, uint32_t* identifierCount JSLockHolder lock(vm); PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - m_jsObject->methodTable(vm)->getPropertyNames(m_jsObject.get(), lexicalGlobalObject, propertyNames, EnumerationMode()); + m_jsObject->getPropertyNames(lexicalGlobalObject, propertyNames, DontEnumPropertiesMode::Exclude); NPIdentifier* nameIdentifiers = npnMemNewArray(propertyNames.size()); diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index 519d8a07b87a2..52e573ce31b57 100644 --- a/Source/WebKitLegacy/mac/ChangeLog +++ b/Source/WebKitLegacy/mac/ChangeLog @@ -1,3 +1,13 @@ +2021-01-07 Alexey Shvayka + + [JSC] Simplify get*PropertyNames() methods and EnumerationMode + https://bugs.webkit.org/show_bug.cgi?id=212954 + + Reviewed by Yusuke Suzuki. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::enumerate): + 2021-01-06 Jer Noble [Cocoa] Revert audioTimePitchAlgorithm to "TimeDomain" from "Spectral" diff --git a/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm index d3bd1ec2ebb0d..b70e75e3eecdd 100644 --- a/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm +++ b/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm @@ -1273,7 +1273,7 @@ JSGlobalObject* lexicalGlobalObject = frame->script().globalObject(pluginWorld()); PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - object->methodTable(vm)->getPropertyNames(object, lexicalGlobalObject, propertyNames, EnumerationMode()); + object->getPropertyNames(lexicalGlobalObject, propertyNames, DontEnumPropertiesMode::Exclude); RetainPtr array = adoptNS([[NSMutableArray alloc] init]); for (unsigned i = 0; i < propertyNames.size(); i++) {