Changeset 281799 in webkit
- Timestamp:
- Aug 31, 2021 5:48:14 AM (11 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
JSTests/test262/config.yaml (modified) (2 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CommonIdentifiers.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ObjectConstructor.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ObjectPrototype.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/ObjectPrototype.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/OptionsList.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/test262/config.yaml
r281429 r281799 8 8 String.prototype.at: useAtMethod 9 9 array-find-from-last: useArrayFindLastMethod 10 Object.hasOwn: useHasOwn 10 11 skip: 11 12 features: … … 15 16 - cleanupSome 16 17 - resizable-arraybuffer 17 - Object.hasOwn18 18 - Temporal 19 19 - import-assertions -
trunk/Source/JavaScriptCore/ChangeLog
r281791 r281799 1 2021-08-31 Aditi Singh <asingh@igalia.com> 2 3 Implement Object.hasOwn() 4 https://bugs.webkit.org/show_bug.cgi?id=226291 5 6 Reviewed by Alexey Shvayka. 7 8 This patch implements Object.hasOwn() method which is a stage 3 proposal. The method is disabled by default and can be enabled using the feature flag. 9 The proposal details can be found here: https://github.com/tc39/proposal-accessible-object-hasownproperty. 10 The patch also refines objectPrototypeHasOwnProperty() to accept JSObject* base rather than JSValue. 11 12 * dfg/DFGOperations.cpp: 13 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 14 * runtime/CommonIdentifiers.h: 15 * runtime/CommonSlowPaths.cpp: 16 (JSC::JSC_DEFINE_COMMON_SLOW_PATH): 17 * runtime/ObjectConstructor.cpp: 18 (JSC::ObjectConstructor::finishCreation): 19 (JSC::JSC_DEFINE_HOST_FUNCTION): 20 * runtime/ObjectPrototype.cpp: 21 (JSC::objectPrototypeHasOwnProperty): 22 (JSC::JSC_DEFINE_HOST_FUNCTION): 23 * runtime/ObjectPrototype.h: 24 * runtime/OptionsList.h: 25 1 26 2021-08-26 Darin Adler <darin@apple.com> 2 27 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r281500 r281799 2554 2554 auto identifier = propertyName->toIdentifier(globalObject); 2555 2555 RETURN_IF_EXCEPTION(scope, { }); 2556 RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(objectPrototypeHasOwnProperty(globalObject, base, identifier)))); 2556 JSObject* baseObject = base.toObject(globalObject); 2557 RETURN_IF_EXCEPTION(scope, { }); 2558 RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(objectPrototypeHasOwnProperty(globalObject, baseObject, identifier)))); 2557 2559 } 2558 2560 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r281788 r281799 134 134 macro(has) \ 135 135 macro(hasIndices) \ 136 macro(hasOwn) \ 136 137 macro(hasOwnProperty) \ 137 138 macro(hash) \ -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r280760 r281799 1093 1093 auto propertyName = string->toIdentifier(globalObject); 1094 1094 CHECK_EXCEPTION(); 1095 RETURN(jsBoolean(objectPrototypeHasOwnProperty(globalObject, baseValue, propertyName))); 1095 JSObject* baseObject = baseValue.toObject(globalObject); 1096 CHECK_EXCEPTION(); 1097 RETURN(jsBoolean(objectPrototypeHasOwnProperty(globalObject, baseObject, propertyName))); 1096 1098 } 1097 1099 -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r279690 r281799 47 47 static JSC_DECLARE_HOST_FUNCTION(objectConstructorIsFrozen); 48 48 static JSC_DECLARE_HOST_FUNCTION(objectConstructorIsExtensible); 49 static JSC_DECLARE_HOST_FUNCTION(objectConstructorHasOwn); 49 50 50 51 } … … 101 102 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().createPrivateName(), objectConstructorCreate, static_cast<unsigned>(PropertyAttribute::DontEnum), 2); 102 103 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().definePropertyPrivateName(), objectConstructorDefineProperty, static_cast<unsigned>(PropertyAttribute::DontEnum), 3); 104 if (Options::useHasOwn()) 105 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->hasOwn, objectConstructorHasOwn, static_cast<unsigned>(PropertyAttribute::DontEnum), 2); 103 106 } 104 107 … … 1012 1015 } 1013 1016 1017 JSC_DEFINE_HOST_FUNCTION(objectConstructorHasOwn, (JSGlobalObject* globalObject, CallFrame* callFrame)) 1018 { 1019 VM& vm = globalObject->vm(); 1020 auto scope = DECLARE_THROW_SCOPE(vm); 1021 JSObject* base = callFrame->argument(0).toObject(globalObject); 1022 RETURN_IF_EXCEPTION(scope, { }); 1023 auto propertyName = callFrame->argument(1).toPropertyKey(globalObject); 1024 RETURN_IF_EXCEPTION(scope, { }); 1025 RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(objectPrototypeHasOwnProperty(globalObject, base, propertyName)))); 1026 } 1027 1014 1028 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r278888 r281799 90 90 } 91 91 92 bool objectPrototypeHasOwnProperty(JSGlobalObject* globalObject, JSValue base, const Identifier& propertyName) 93 { 94 VM& vm = globalObject->vm(); 95 auto scope = DECLARE_THROW_SCOPE(vm); 96 JSValue thisValue = base.toThis(globalObject, ECMAMode::strict()); 97 JSObject* thisObject = thisValue.toObject(globalObject); 98 EXCEPTION_ASSERT(!!scope.exception() == !thisObject); 99 if (UNLIKELY(!thisObject)) 100 return false; 101 92 bool objectPrototypeHasOwnProperty(JSGlobalObject* globalObject, JSObject* thisObject, const Identifier& propertyName) 93 { 94 VM& vm = globalObject->vm(); 95 auto scope = DECLARE_THROW_SCOPE(vm); 102 96 Structure* structure = thisObject->structure(vm); 103 97 HasOwnPropertyCache* hasOwnPropertyCache = vm.ensureHasOwnPropertyCache(); … … 124 118 auto propertyName = callFrame->argument(0).toPropertyKey(globalObject); 125 119 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 126 scope.release(); 127 return JSValue::encode(jsBoolean(objectPrototypeHasOwnProperty(globalObject, base, propertyName))); 120 JSObject* thisObject = base.toThis(globalObject, ECMAMode::strict()).toObject(globalObject); 121 RETURN_IF_EXCEPTION(scope, { }); 122 RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(objectPrototypeHasOwnProperty(globalObject, thisObject, propertyName)))); 128 123 } 129 124 -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.h
r275544 r281799 53 53 JS_EXPORT_PRIVATE JSC_DECLARE_HOST_FUNCTION(objectProtoFuncToString); 54 54 JSString* objectPrototypeToString(JSGlobalObject*, JSValue thisValue); 55 bool objectPrototypeHasOwnProperty(JSGlobalObject*, JS Valuebase, const Identifier& property);55 bool objectPrototypeHasOwnProperty(JSGlobalObject*, JSObject* base, const Identifier& property); 56 56 57 57 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r281693 r281799 543 543 v(Bool, useArrayFindLastMethod, true, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \ 544 544 v(Bool, useIntlEnumeration, true, Normal, "Expose the Intl enumeration APIs.") \ 545 v(Bool, useHasOwn, false, Normal, "Expose the Object.hasOwn method") \ 545 546 546 547
Note: See TracChangeset
for help on using the changeset viewer.