Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (197390 => 197391)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-01 08:11:20 UTC (rev 197391)
@@ -1,3 +1,46 @@
+2016-02-29 Saam barati <[email protected]>
+
+ [[PreventExtensions]] should be a virtual method in the method table.
+ https://bugs.webkit.org/show_bug.cgi?id=154800
+
+ Reviewed by Yusuke Suzuki.
+
+ This patch makes us more consistent with how the ES6 specification models the
+ [[PreventExtensions]] trap. Moving this method into ClassInfo::methodTable
+ is a prerequisite for implementing Proxy.[[PreventExtensions]].
+
+ * runtime/ClassInfo.h:
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::getGenericPropertyNames):
+ (JSC::JSCell::preventExtensions):
+ * runtime/JSCell.h:
+ * runtime/JSModuleNamespaceObject.cpp:
+ (JSC::JSModuleNamespaceObject::JSModuleNamespaceObject):
+ (JSC::JSModuleNamespaceObject::finishCreation):
+ (JSC::JSModuleNamespaceObject::destroy):
+ * runtime/JSModuleNamespaceObject.h:
+ (JSC::JSModuleNamespaceObject::create):
+ (JSC::JSModuleNamespaceObject::moduleRecord):
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::freeze):
+ (JSC::JSObject::preventExtensions):
+ (JSC::JSObject::reifyAllStaticProperties):
+ * runtime/JSObject.h:
+ (JSC::JSObject::isSealed):
+ (JSC::JSObject::isFrozen):
+ (JSC::JSObject::isExtensible):
+ * runtime/ObjectConstructor.cpp:
+ (JSC::objectConstructorSeal):
+ (JSC::objectConstructorFreeze):
+ (JSC::objectConstructorPreventExtensions):
+ (JSC::objectConstructorIsSealed):
+ * runtime/ReflectObject.cpp:
+ (JSC::reflectObjectPreventExtensions):
+ * runtime/Structure.cpp:
+ (JSC::Structure::Structure):
+ (JSC::Structure::preventExtensionsTransition):
+ * runtime/Structure.h:
+
2016-02-29 Yusuke Suzuki <[email protected]>
[JSC] Private symbols should not be trapped by proxy handler
Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/ClassInfo.h 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h 2016-03-01 08:11:20 UTC (rev 197391)
@@ -103,6 +103,9 @@
typedef PassRefPtr<ArrayBufferView> (*GetTypedArrayImpl)(JSArrayBufferView*);
GetTypedArrayImpl getTypedArrayImpl;
+ typedef bool (*PreventExtensionsFunctionPtr)(JSObject*, ExecState*);
+ PreventExtensionsFunctionPtr preventExtensions;
+
typedef void (*DumpToStreamFunctionPtr)(const JSCell*, PrintStream&);
DumpToStreamFunctionPtr dumpToStream;
@@ -154,6 +157,7 @@
&ClassName::defineOwnProperty, \
&ClassName::slowDownAndWasteMemory, \
&ClassName::getTypedArrayImpl, \
+ &ClassName::preventExtensions, \
&ClassName::dumpToStream, \
&ClassName::estimatedSize \
}, \
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -270,4 +270,9 @@
RELEASE_ASSERT_NOT_REACHED();
}
+bool JSCell::preventExtensions(JSObject*, ExecState*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2016-03-01 08:11:20 UTC (rev 197391)
@@ -206,6 +206,7 @@
static uint32_t getEnumerableLength(ExecState*, JSObject*);
static NO_RETURN_DUE_TO_CRASH void getStructurePropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static NO_RETURN_DUE_TO_CRASH void getGenericPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
+ static NO_RETURN_DUE_TO_CRASH bool preventExtensions(JSObject*, ExecState*);
static String className(const JSObject*);
JS_EXPORT_PRIVATE static bool customHasInstance(JSObject*, ExecState*, JSValue);
Modified: trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -49,8 +49,9 @@
{
}
-void JSModuleNamespaceObject::finishCreation(VM& vm, JSGlobalObject* globalObject, JSModuleRecord* moduleRecord, const IdentifierSet& exports)
+void JSModuleNamespaceObject::finishCreation(ExecState* exec, JSGlobalObject* globalObject, JSModuleRecord* moduleRecord, const IdentifierSet& exports)
{
+ VM& vm = exec->vm();
Base::finishCreation(vm);
ASSERT(inherits(info()));
@@ -78,7 +79,8 @@
// http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-setprototypeof-v
// http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-isextensible
// http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-preventextensions
- preventExtensions(vm);
+ methodTable(vm)->preventExtensions(this, exec);
+ ASSERT(!exec->hadException());
}
void JSModuleNamespaceObject::destroy(JSCell* cell)
Modified: trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h 2016-03-01 08:11:20 UTC (rev 197391)
@@ -41,7 +41,7 @@
static JSModuleNamespaceObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSModuleRecord* moduleRecord, const IdentifierSet& exports)
{
JSModuleNamespaceObject* object = new (NotNull, allocateCell<JSModuleNamespaceObject>(exec->vm().heap)) JSModuleNamespaceObject(exec->vm(), structure);
- object->finishCreation(exec->vm(), globalObject, moduleRecord, exports);
+ object->finishCreation(exec, globalObject, moduleRecord, exports);
return object;
}
@@ -62,7 +62,7 @@
JSModuleRecord* moduleRecord() { return m_moduleRecord.get(); }
protected:
- JS_EXPORT_PRIVATE void finishCreation(VM&, JSGlobalObject*, JSModuleRecord*, const IdentifierSet& exports);
+ JS_EXPORT_PRIVATE void finishCreation(ExecState*, JSGlobalObject*, JSModuleRecord*, const IdentifierSet& exports);
JS_EXPORT_PRIVATE JSModuleNamespaceObject(VM&, Structure*);
private:
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -1675,12 +1675,15 @@
setStructure(vm, Structure::freezeTransition(vm, structure(vm)));
}
-void JSObject::preventExtensions(VM& vm)
+bool JSObject::preventExtensions(JSObject* object, ExecState* exec)
{
- if (!isExtensible())
- return;
- enterDictionaryIndexingMode(vm);
- setStructure(vm, Structure::preventExtensionsTransition(vm, structure(vm)));
+ if (!object->isExtensible())
+ return true;
+
+ VM& vm = exec->vm();
+ object->enterDictionaryIndexingMode(vm);
+ object->setStructure(vm, Structure::preventExtensionsTransition(vm, object->structure(vm)));
+ return true;
}
void JSObject::reifyAllStaticProperties(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-01 08:11:20 UTC (rev 197391)
@@ -614,7 +614,7 @@
JS_EXPORT_PRIVATE void seal(VM&);
JS_EXPORT_PRIVATE void freeze(VM&);
- JS_EXPORT_PRIVATE void preventExtensions(VM&);
+ JS_EXPORT_PRIVATE static bool preventExtensions(JSObject*, ExecState*);
bool isSealed(VM& vm) { return structure(vm)->isSealed(vm); }
bool isFrozen(VM& vm) { return structure(vm)->isFrozen(vm); }
bool isExtensible() { return structure()->isExtensible(); }
Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -516,7 +516,9 @@
}
// 3. Set the [[Extensible]] internal property of O to false.
- object->preventExtensions(exec->vm());
+ object->methodTable(exec->vm())->preventExtensions(object, exec);
+ if (exec->hadException())
+ return JSValue::encode(JSValue());
// 4. Return O.
return JSValue::encode(obj);
@@ -554,7 +556,9 @@
}
// 3. Set the [[Extensible]] internal property of O to false.
- object->preventExtensions(exec->vm());
+ object->methodTable(exec->vm())->preventExtensions(object, exec);
+ if (exec->hadException())
+ return nullptr;
// 4. Return O.
return object;
@@ -566,16 +570,20 @@
JSValue obj = exec->argument(0);
if (!obj.isObject())
return JSValue::encode(obj);
- return JSValue::encode(objectConstructorFreeze(exec, asObject(obj)));
+ JSObject* result = objectConstructorFreeze(exec, asObject(obj));
+ if (exec->hadException())
+ return JSValue::encode(JSValue());
+ return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL objectConstructorPreventExtensions(ExecState* exec)
{
- JSValue obj = exec->argument(0);
- if (!obj.isObject())
- return JSValue::encode(obj);
- asObject(obj)->preventExtensions(exec->vm());
- return JSValue::encode(obj);
+ JSValue argument = exec->argument(0);
+ if (!argument.isObject())
+ return JSValue::encode(argument);
+ JSObject* object = asObject(argument);
+ object->methodTable(exec->vm())->preventExtensions(object, exec);
+ return JSValue::encode(object);
}
EncodedJSValue JSC_HOST_CALL objectConstructorIsSealed(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/ReflectObject.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/ReflectObject.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/ReflectObject.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -186,8 +186,11 @@
JSValue target = exec->argument(0);
if (!target.isObject())
return JSValue::encode(throwTypeError(exec, ASCIILiteral("Reflect.preventExtensions requires the first argument be an object")));
- asObject(target)->preventExtensions(exec->vm());
- return JSValue::encode(jsBoolean(true));
+ JSObject* object = asObject(target);
+ bool result = object->methodTable(exec->vm())->preventExtensions(object, exec);
+ if (exec->hadException())
+ return JSValue::encode(JSValue());
+ return JSValue::encode(jsBoolean(result));
}
// http://www.ecma-international.org/ecma-262/6.0/#sec-reflect.setprototypeof
Modified: trunk/Source/_javascript_Core/runtime/Structure.cpp (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/Structure.cpp 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/Structure.cpp 2016-03-01 08:11:20 UTC (rev 197391)
@@ -203,7 +203,7 @@
setHasReadOnlyOrGetterSetterPropertiesExcludingProto(classInfo->hasStaticSetterOrReadonlyProperties());
setHasNonEnumerableProperties(false);
setAttributesInPrevious(0);
- setPreventExtensions(false);
+ setDidPreventExtensions(false);
setDidTransition(false);
setStaticFunctionsReified(false);
setHasRareData(false);
@@ -235,7 +235,7 @@
setHasReadOnlyOrGetterSetterPropertiesExcludingProto(m_classInfo->hasStaticSetterOrReadonlyProperties());
setHasNonEnumerableProperties(false);
setAttributesInPrevious(0);
- setPreventExtensions(false);
+ setDidPreventExtensions(false);
setDidTransition(false);
setStaticFunctionsReified(false);
setHasRareData(false);
@@ -266,7 +266,7 @@
setHasReadOnlyOrGetterSetterPropertiesExcludingProto(previous->hasReadOnlyOrGetterSetterPropertiesExcludingProto());
setHasNonEnumerableProperties(previous->hasNonEnumerableProperties());
setAttributesInPrevious(0);
- setPreventExtensions(previous->preventExtensions());
+ setDidPreventExtensions(previous->didPreventExtensions());
setDidTransition(true);
setStaticFunctionsReified(previous->staticFunctionsReified());
setHasRareData(false);
@@ -625,7 +625,7 @@
structure->materializePropertyMapIfNecessary(vm, deferGC);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm));
transition->m_offset = structure->m_offset;
- transition->setPreventExtensions(true);
+ transition->setDidPreventExtensions(true);
transition->pin();
transition->checkOffsetConsistency();
Modified: trunk/Source/_javascript_Core/runtime/Structure.h (197390 => 197391)
--- trunk/Source/_javascript_Core/runtime/Structure.h 2016-03-01 07:39:23 UTC (rev 197390)
+++ trunk/Source/_javascript_Core/runtime/Structure.h 2016-03-01 08:11:20 UTC (rev 197391)
@@ -183,7 +183,7 @@
JS_EXPORT_PRIVATE bool isSealed(VM&);
JS_EXPORT_PRIVATE bool isFrozen(VM&);
- bool isExtensible() const { return !preventExtensions(); }
+ bool isExtensible() const { return !didPreventExtensions(); }
bool putWillGrowOutOfLineStorage();
size_t suggestedNewOutOfLineStorageCapacity();
@@ -579,7 +579,7 @@
DEFINE_BITFIELD(bool, hasReadOnlyOrGetterSetterPropertiesExcludingProto, HasReadOnlyOrGetterSetterPropertiesExcludingProto, 1, 4);
DEFINE_BITFIELD(bool, hasNonEnumerableProperties, HasNonEnumerableProperties, 1, 5);
DEFINE_BITFIELD(unsigned, attributesInPrevious, AttributesInPrevious, 14, 6);
- DEFINE_BITFIELD(bool, preventExtensions, PreventExtensions, 1, 20);
+ DEFINE_BITFIELD(bool, didPreventExtensions, DidPreventExtensions, 1, 20);
DEFINE_BITFIELD(bool, didTransition, DidTransition, 1, 21);
DEFINE_BITFIELD(bool, staticFunctionsReified, StaticFunctionsReified, 1, 22);
DEFINE_BITFIELD(bool, hasRareData, HasRareData, 1, 23);