Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (198347 => 198348)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-17 20:13:18 UTC (rev 198348)
@@ -1,3 +1,38 @@
+2016-03-17 Michael Saboff <[email protected]>
+
+ [ES6] Getters and Setters should be prefixed appropriately
+ https://bugs.webkit.org/show_bug.cgi?id=155593
+
+ Reviewed by Mark Lam.
+
+ Changed the putDirectNativeIntrinsicGetter() to prepend "get " to the funtion name.
+
+ Updated places that had their own macro or hand constructed a getter function to use
+ the JSC_NATIVE_GETTER macro which will properly append "get ".
+
+ Prepended "get " and "set " to the __proto__ accessor created on the Object prototype.
+
+ When we create the Symbol.species getter, added an explicit function name of "get [Symbol.species]".
+
+ * inspector/JSInjectedScriptHostPrototype.cpp:
+ (Inspector::JSInjectedScriptHostPrototype::finishCreation):
+ (Inspector::jsInjectedScriptHostPrototypeAttributeEvaluate):
+ * inspector/JSJavaScriptCallFramePrototype.cpp:
+ (Inspector::JSJavaScriptCallFramePrototype::finishCreation):
+ (Inspector::jsJavaScriptCallFramePrototypeFunctionEvaluate):
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init):
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::putDirectNativeIntrinsicGetter):
+ * runtime/MapPrototype.cpp:
+ (JSC::MapPrototype::finishCreation):
+ (JSC::MapPrototype::getOwnPropertySlot):
+ * runtime/SetPrototype.cpp:
+ (JSC::SetPrototype::finishCreation):
+ (JSC::SetPrototype::getOwnPropertySlot):
+ * tests/stress/accessors-get-set-prefix.js: Added.
+ (tryGetOwnPropertyDescriptorGetName):
+
2016-03-16 Mark Lam <[email protected]>
Method names should not appear in the lexical scope of the method's body.
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -70,11 +70,7 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakSetEntries", jsInjectedScriptHostPrototypeFunctionWeakSetEntries, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("iteratorEntries", jsInjectedScriptHostPrototypeFunctionIteratorEntries, DontEnum, 1);
- Identifier evaluateIdentifier = Identifier::fromString(&vm, "evaluate");
- GetterSetter* accessor = GetterSetter::create(vm, globalObject);
- JSFunction* function = JSFunction::create(vm, globalObject, 0, evaluateIdentifier.string(), jsInjectedScriptHostPrototypeAttributeEvaluate);
- accessor->setGetter(vm, globalObject, function);
- putDirectNonIndexAccessor(vm, evaluateIdentifier, accessor, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("evaluate", jsInjectedScriptHostPrototypeAttributeEvaluate, DontEnum | Accessor);
}
EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState* exec)
Modified: trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFramePrototype.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFramePrototype.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFramePrototype.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -53,15 +53,6 @@
const ClassInfo JSJavaScriptCallFramePrototype::s_info = { "_javascript_CallFrame", &Base::s_info, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFramePrototype) };
-#define JSC_NATIVE_NON_INDEX_ACCESSOR(jsName, cppName, attributes) \
- { \
- Identifier identifier = Identifier::fromString(&vm, jsName); \
- GetterSetter* accessor = GetterSetter::create(vm, globalObject); \
- JSFunction* function = JSFunction::create(vm, globalObject, 0, identifier.string(), cppName); \
- accessor->setGetter(vm, globalObject, function); \
- putDirectNonIndexAccessor(vm, identifier, accessor, (attributes)); \
- }
-
void JSJavaScriptCallFramePrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
@@ -71,14 +62,14 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("evaluate", jsJavaScriptCallFramePrototypeFunctionEvaluate, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("scopeType", jsJavaScriptCallFramePrototypeFunctionScopeType, DontEnum, 1);
- JSC_NATIVE_NON_INDEX_ACCESSOR("caller", jsJavaScriptCallFrameAttributeCaller, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("sourceID", jsJavaScriptCallFrameAttributeSourceID, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("line", jsJavaScriptCallFrameAttributeLine, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("column", jsJavaScriptCallFrameAttributeColumn, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("functionName", jsJavaScriptCallFrameAttributeFunctionName, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("scopeChain", jsJavaScriptCallFrameAttributeScopeChain, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("thisObject", jsJavaScriptCallFrameAttributeThisObject, DontEnum | Accessor);
- JSC_NATIVE_NON_INDEX_ACCESSOR("type", jsJavaScriptCallFrameAttributeType, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("caller", jsJavaScriptCallFrameAttributeCaller, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("sourceID", jsJavaScriptCallFrameAttributeSourceID, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("line", jsJavaScriptCallFrameAttributeLine, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("column", jsJavaScriptCallFrameAttributeColumn, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("functionName", jsJavaScriptCallFrameAttributeFunctionName, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("scopeChain", jsJavaScriptCallFrameAttributeScopeChain, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("thisObject", jsJavaScriptCallFrameAttributeThisObject, DontEnum | Accessor);
+ JSC_NATIVE_GETTER("type", jsJavaScriptCallFrameAttributeType, DontEnum | Accessor);
}
EncodedJSValue JSC_HOST_CALL jsJavaScriptCallFramePrototypeFunctionEvaluate(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -301,8 +301,8 @@
m_nullSetterFunction.set(vm, this, NullSetterFunction::create(vm, NullSetterFunction::createStructure(vm, this, m_functionPrototype.get())));
m_objectPrototype.set(vm, this, ObjectPrototype::create(vm, this, ObjectPrototype::createStructure(vm, this, jsNull())));
GetterSetter* protoAccessor = GetterSetter::create(vm, this);
- protoAccessor->setGetter(vm, this, JSFunction::create(vm, this, 0, String(), globalFuncProtoGetter));
- protoAccessor->setSetter(vm, this, JSFunction::create(vm, this, 0, String(), globalFuncProtoSetter));
+ protoAccessor->setGetter(vm, this, JSFunction::create(vm, this, 0, makeString("get ", vm.propertyNames->underscoreProto.string()), globalFuncProtoGetter));
+ protoAccessor->setSetter(vm, this, JSFunction::create(vm, this, 0, makeString("set ", vm.propertyNames->underscoreProto.string()), globalFuncProtoSetter));
m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
@@ -408,7 +408,7 @@
// Constructors
GetterSetter* speciesGetterSetter = GetterSetter::create(vm, this);
- speciesGetterSetter->setGetter(vm, this, JSFunction::createBuiltinFunction(vm, globalObjectSpeciesGetterCodeGenerator(vm), this));
+ speciesGetterSetter->setGetter(vm, this, JSFunction::createBuiltinFunction(vm, globalObjectSpeciesGetterCodeGenerator(vm), this, "get [Symbol.species]"));
ObjectConstructor* objectConstructor = ObjectConstructor::create(vm, this, ObjectConstructor::createStructure(vm, this, m_functionPrototype.get()), m_objectPrototype.get());
m_objectConstructor.set(vm, this, objectConstructor);
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -2576,7 +2576,7 @@
bool JSObject::putDirectNativeIntrinsicGetter(VM& vm, JSGlobalObject* globalObject, Identifier name, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes)
{
GetterSetter* accessor = GetterSetter::create(vm, globalObject);
- JSFunction* function = JSFunction::create(vm, globalObject, 0, name.string(), nativeFunction, intrinsic);
+ JSFunction* function = JSFunction::create(vm, globalObject, 0, makeString("get ", name.string()), nativeFunction, intrinsic);
accessor->setGetter(vm, globalObject, function);
return putDirectNonIndexAccessor(vm, name, accessor, attributes);
}
Modified: trunk/Source/_javascript_Core/runtime/MapPrototype.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/runtime/MapPrototype.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/runtime/MapPrototype.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -85,10 +85,7 @@
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, entries, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map"), DontEnum | ReadOnly);
- GetterSetter* accessor = GetterSetter::create(vm, globalObject);
- JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), mapProtoFuncSize);
- accessor->setGetter(vm, globalObject, function);
- putDirectNonIndexAccessor(vm, vm.propertyNames->size, accessor, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->size, mapProtoFuncSize, DontEnum | Accessor);
}
bool MapPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
Modified: trunk/Source/_javascript_Core/runtime/SetPrototype.cpp (198347 => 198348)
--- trunk/Source/_javascript_Core/runtime/SetPrototype.cpp 2016-03-17 19:28:24 UTC (rev 198347)
+++ trunk/Source/_javascript_Core/runtime/SetPrototype.cpp 2016-03-17 20:13:18 UTC (rev 198348)
@@ -79,10 +79,7 @@
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, values, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Set"), DontEnum | ReadOnly);
- GetterSetter* accessor = GetterSetter::create(vm, globalObject);
- JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), setProtoFuncSize);
- accessor->setGetter(vm, globalObject, function);
- putDirectNonIndexAccessor(vm, vm.propertyNames->size, accessor, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->size, setProtoFuncSize, DontEnum | Accessor);
}
bool SetPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
Added: trunk/Source/_javascript_Core/tests/stress/accessors-get-set-prefix.js (0 => 198348)
--- trunk/Source/_javascript_Core/tests/stress/accessors-get-set-prefix.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/accessors-get-set-prefix.js 2016-03-17 20:13:18 UTC (rev 198348)
@@ -0,0 +1,27 @@
+function tryGetOwnPropertyDescriptorGetName(obj, property, expectedName)
+{
+ let descriptor = Object.getOwnPropertyDescriptor(obj, property);
+ if (!descriptor)
+ throw "Couldn't find property descriptor on object " + obj.toString() + " for property " + property.toString();
+
+ let getter = descriptor.get;
+ if (!getter)
+ throw "Property " + property.toString() + " on object " + obj.toString() + " is not a getter";
+
+ let getterName = getter.name;
+ if (getterName !== expectedName)
+ throw "Wrong getter name for property " + property.toString() + " on object " + obj.toString() + " expected " + expectedName + " got " + getterName;
+}
+
+tryGetOwnPropertyDescriptorGetName(Array, Symbol.species, "get [Symbol.species]");
+tryGetOwnPropertyDescriptorGetName(Map.prototype, "size", "get size");
+tryGetOwnPropertyDescriptorGetName(Set.prototype, "size", "get size");
+
+if (Object.__lookupGetter__("__proto__").name !== "get __proto__")
+ throw "Expected Object __proto__ getter to be named \"get __proto\"";
+
+if (Object.__lookupSetter__("__proto__").name !== "set __proto__")
+ throw "Expected Object __proto__ setter to be named \"set __proto\"";
+
+if (Int32Array.prototype.__lookupGetter__("byteOffset").name !== "get byteOffset")
+ throw "Expected TypedArray.prototype byteOffset getter to be named \"get byteOffset\"";