Ignore:
Timestamp:
Mar 1, 2016, 1:45:16 PM (9 years ago)
Author:
[email protected]
Message:

IsExtensible should be a virtual method in the method table
https://bugs.webkit.org/show_bug.cgi?id=154799

Reviewed by Mark Lam.

This patch makes us more consistent with how the ES6 specification models the
IsExtensible trap. Moving this method into ClassInfo::methodTable
is a prerequisite for implementing Proxy.IsExtensible.

  • runtime/ClassInfo.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::preventExtensions):
(JSC::JSCell::isExtensible):

  • runtime/JSCell.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoSetter):

  • runtime/JSObject.cpp:

(JSC::JSObject::preventExtensions):
(JSC::JSObject::isExtensible):
(JSC::JSObject::reifyAllStaticProperties):
(JSC::JSObject::defineOwnIndexedProperty):
(JSC::JSObject::putByIndexBeyondVectorLengthWithArrayStorage):
(JSC::JSObject::putDirectIndexBeyondVectorLengthWithArrayStorage):
(JSC::JSObject::defineOwnNonIndexProperty):
(JSC::JSObject::defineOwnProperty):

  • runtime/JSObject.h:

(JSC::JSObject::isSealed):
(JSC::JSObject::isFrozen):
(JSC::JSObject::isExtensibleImpl):
(JSC::JSObject::isStructureExtensible):
(JSC::JSObject::isExtensibleInline):
(JSC::JSObject::indexingShouldBeSparse):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::isExtensible): Deleted.

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorSetPrototypeOf):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::objectConstructorIsExtensible):
(JSC::objectConstructorIs):

  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::performInternalMethodGetOwnProperty):
(JSC::ProxyObject::performHasProperty):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectIsExtensible):
(JSC::reflectObjectSetPrototypeOf):

  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayValueMap::putEntry):
(JSC::SparseArrayValueMap::putDirect):

  • runtime/StringObject.cpp:

(JSC::StringObject::defineOwnProperty):

  • runtime/Structure.cpp:

(JSC::Structure::isSealed):
(JSC::Structure::isFrozen):

  • runtime/Structure.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r197391 r197412  
    16781678bool JSObject::preventExtensions(JSObject* object, ExecState* exec)
    16791679{
    1680     if (!object->isExtensible())
     1680    if (!object->isStructureExtensible()) {
     1681        // We've already set the internal [[PreventExtensions]] field to false.
     1682        // We don't call the methodTable isExtensible here because it's not defined
     1683        // that way in the specification. We are just doing an optimization here.
    16811684        return true;
     1685    }
    16821686
    16831687    VM& vm = exec->vm();
     
    16851689    object->setStructure(vm, Structure::preventExtensionsTransition(vm, object->structure(vm)));
    16861690    return true;
     1691}
     1692
     1693bool JSObject::isExtensible(JSObject* obj, ExecState*)
     1694{
     1695    return obj->isExtensibleImpl();
    16871696}
    16881697
     
    18221831    // 4. If current is undefined and extensible is true, then
    18231832    if (result.isNewEntry) {
    1824         if (!isExtensible()) {
     1833        if (!isStructureExtensible()) {
    18251834            map->remove(result.iterator);
    18261835            return reject(exec, throwException, "Attempting to define property on object that is not extensible.");
     
    20382047    if (LIKELY(!map)) {
    20392048        // If the array is not extensible, we should have entered dictionary mode, and created the sparse map.
    2040         ASSERT(isExtensible());
     2049        ASSERT(isStructureExtensible());
    20412050   
    20422051        // Update m_length if necessary.
     
    20642073    if (i >= length) {
    20652074        // Prohibit growing the array if length is not writable.
    2066         if (map->lengthIsReadOnly() || !isExtensible()) {
     2075        if (map->lengthIsReadOnly() || !isStructureExtensible()) {
    20672076            if (shouldThrow)
    20682077                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     
    21842193    if (LIKELY(!map)) {
    21852194        // If the array is not extensible, we should have entered dictionary mode, and created the spare map.
    2186         ASSERT(isExtensible());
     2195        ASSERT(isStructureExtensible());
    21872196   
    21882197        // Update m_length if necessary.
     
    22142223            if (map->lengthIsReadOnly())
    22152224                return reject(exec, mode == PutDirectIndexShouldThrow, StrictModeReadonlyPropertyWriteError);
    2216             if (!isExtensible())
     2225            if (!isStructureExtensible())
    22172226                return reject(exec, mode == PutDirectIndexShouldThrow, "Attempting to define property on object that is not extensible.");
    22182227        }
     
    28492858    PropertyDescriptor current;
    28502859    bool isCurrentDefined = getOwnPropertyDescriptor(exec, propertyName, current);
    2851     return validateAndApplyPropertyDescriptor(exec, this, propertyName, isExtensible(), descriptor, isCurrentDefined, current, throwException);
     2860    bool isExtensible = isExtensibleInline(exec);
     2861    if (UNLIKELY(exec->hadException()))
     2862        return false;
     2863    return validateAndApplyPropertyDescriptor(exec, this, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
    28522864}
    28532865
Note: See TracChangeset for help on using the changeset viewer.