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.h

    r197391 r197412  
    616616    JS_EXPORT_PRIVATE void freeze(VM&);
    617617    JS_EXPORT_PRIVATE static bool preventExtensions(JSObject*, ExecState*);
     618    JS_EXPORT_PRIVATE static bool isExtensible(JSObject*, ExecState*);
    618619    bool isSealed(VM& vm) { return structure(vm)->isSealed(vm); }
    619620    bool isFrozen(VM& vm) { return structure(vm)->isFrozen(vm); }
    620     bool isExtensible() { return structure()->isExtensible(); }
     621private:
     622    ALWAYS_INLINE bool isExtensibleImpl() { return isStructureExtensible(); }
     623public:
     624    // You should only call isStructureExtensible() when:
     625    // - Performing this check in a way that isn't described in the specification
     626    //   as calling the virtual [[IsExtensible]] trap.
     627    // - When you're guaranteed that object->methodTable()->isExtensible isn't
     628    //   overridden.
     629    ALWAYS_INLINE bool isStructureExtensible() { return structure()->isStructureExtensible(); }
     630    // You should call this when performing [[IsExtensible]] trap in a place
     631    // that is described in the specification. This performs the fully virtual
     632    // [[IsExtensible]] trap.
     633    ALWAYS_INLINE bool isExtensibleInline(ExecState* exec)
     634    {
     635        VM& vm = exec->vm();
     636        auto isExtensibleMethod = methodTable(vm)->isExtensible;
     637        if (LIKELY(isExtensibleMethod == JSObject::isExtensible))
     638            return isExtensibleImpl();
     639
     640        return isExtensibleMethod(this, exec);
     641    }
    621642    bool indexingShouldBeSparse()
    622643    {
    623         return !isExtensible()
     644        return !isStructureExtensible()
    624645            || structure()->typeInfo().interceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero();
    625646    }
     
    12731294        }
    12741295
    1275         if ((mode == PutModePut) && !isExtensible())
     1296        if ((mode == PutModePut) && !isStructureExtensible())
    12761297            return false;
    12771298
     
    13381359    }
    13391360
    1340     if ((mode == PutModePut) && !isExtensible())
     1361    if ((mode == PutModePut) && !isStructureExtensible())
    13411362        return false;
    13421363
Note: See TracChangeset for help on using the changeset viewer.