Ignore:
Timestamp:
Feb 25, 2016, 2:58:23 PM (9 years ago)
Author:
[email protected]
Message:

[ES6] Implement Proxy.Set
https://bugs.webkit.org/show_bug.cgi?id=154511

Reviewed by Filip Pizlo.

This patch is mostly an implementation of
Proxy.Set with respect to section 9.5.9
of the ECMAScript spec.
https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver

This patch also changes JSObject::putInline and JSObject::putByIndex
to be aware that a Proxy in the prototype chain will intercept
property accesses.

  • runtime/JSObject.cpp:

(JSC::JSObject::putInlineSlow):
(JSC::JSObject::attemptToInterceptPutByIndexOnHoleForPrototype):

  • runtime/JSObject.h:
  • runtime/JSObjectInlines.h:

(JSC::JSObject::canPerformFastPutInline):
(JSC::JSObject::putInline):

  • runtime/JSType.h:
  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::getOwnPropertySlotByIndex):
(JSC::ProxyObject::performPut):
(JSC::ProxyObject::put):
(JSC::ProxyObject::putByIndexCommon):
(JSC::ProxyObject::putByIndex):
(JSC::performProxyCall):
(JSC::ProxyObject::getCallData):
(JSC::performProxyConstruct):
(JSC::ProxyObject::deletePropertyByIndex):
(JSC::ProxyObject::visitChildren):

  • runtime/ProxyObject.h:

(JSC::ProxyObject::create):
(JSC::ProxyObject::createStructure):
(JSC::ProxyObject::target):
(JSC::ProxyObject::handler):

  • tests/es6.yaml:
  • tests/stress/proxy-set.js: Added.

(assert):
(throw.new.Error.let.handler.set 45):
(throw.new.Error):
(let.target.set x):
(let.target.get x):
(set let):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.h

    r197042 r197136  
    3636    typedef JSNonFinalObject Base;
    3737
    38     const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | TypeOfShouldCallGetCallData;
     38    const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | TypeOfShouldCallGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero;
    3939
    4040    static ProxyObject* create(ExecState* exec, Structure* structure, JSValue target, JSValue handler)
     
    4848    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    4949    {
    50         return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
     50        return Structure::create(vm, globalObject, prototype, TypeInfo(ProxyObjectType, StructureFlags), info(), NonArray | MayHaveIndexedAccessors);
    5151    }
    5252
     
    5555    JSObject* target() { return m_target.get(); }
    5656    JSValue handler() { return m_handler.get(); }
     57
     58    static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
     59    static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
     60    void putByIndexCommon(ExecState*, JSValue thisValue, unsigned propertyName, JSValue putValue, bool shouldThrow);
    5761
    5862private:
     
    7377    template <typename DefaultDeleteFunction>
    7478    bool performDelete(ExecState*, PropertyName, DefaultDeleteFunction);
     79    template <typename PerformDefaultPutFunction>
     80    void performPut(ExecState*, JSValue putValue, JSValue thisValue, PropertyName, PerformDefaultPutFunction);
    7581
    7682    WriteBarrier<JSObject> m_target;
Note: See TracChangeset for help on using the changeset viewer.