Changeset 161033 in webkit


Ignore:
Timestamp:
Dec 23, 2013, 4:11:25 PM (12 years ago)
Author:
[email protected]
Message:

Refactor PutPropertySlot to be aware of custom properties
https://bugs.webkit.org/show_bug.cgi?id=126187

Reviewed by msaboff.

Source/JavaScriptCore:

Refactor PutPropertySlot, making the constructor take the thisValue
used as a target. This results in a wide range of boilerplate changes
to pass the new parameter.

  • API/JSObjectRef.cpp:

(JSObjectSetProperty):

  • dfg/DFGOperations.cpp:

(JSC::DFG::operationPutByValInternal):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • jit/JITOperations.cpp:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/Arguments.cpp:

(JSC::Arguments::putByIndex):

  • runtime/ArrayPrototype.cpp:

(JSC::putProperty):
(JSC::arrayProtoFuncPush):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::putToPrimitiveByIndex):

  • runtime/JSCell.cpp:

(JSC::JSCell::putByIndex):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::put):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::putByIndex):

  • runtime/JSONObject.cpp:

(JSC::Walker::walk):

  • runtime/JSObject.cpp:

(JSC::JSObject::putByIndex):
(JSC::JSObject::putDirectNonIndexAccessor):
(JSC::JSObject::deleteProperty):

  • runtime/JSObject.h:

(JSC::JSObject::putDirect):

  • runtime/Lookup.h:

(JSC::putEntry):
(JSC::lookupPut):

  • runtime/PutPropertySlot.h:

(JSC::PutPropertySlot::PutPropertySlot):
(JSC::PutPropertySlot::setCustomProperty):
(JSC::PutPropertySlot::thisValue):
(JSC::PutPropertySlot::isCacheable):

Source/WebCore:

Update the bindings code generation and custom objects
to the new function signatures

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::put):

  • bindings/objc/WebScriptObject.mm:

(-[WebScriptObject setValue:forKey:]):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):

  • bindings/scripts/test/JS/JSTestInterface.cpp:

(WebCore::JSTestInterface::putByIndex):

  • bridge/NP_jsobject.cpp:

(_NPN_SetProperty):

Source/WebKit/mac:

Update for new method signatures.

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::setProperty):

Source/WebKit2:

Update for new method signatures.

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::setProperty):

Location:
trunk/Source
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r159531 r161033  
    332332        jsObject->methodTable()->defineOwnProperty(jsObject, exec, name, desc, false);
    333333    } else {
    334         PutPropertySlot slot;
     334        PutPropertySlot slot(jsObject);
    335335        jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
    336336    }
  • trunk/Source/JavaScriptCore/ChangeLog

    r161031 r161033  
     12013-12-23  Oliver Hunt  <[email protected]>
     2
     3        Refactor PutPropertySlot to be aware of custom properties
     4        https://bugs.webkit.org/show_bug.cgi?id=126187
     5
     6        Reviewed by msaboff.
     7
     8        Refactor PutPropertySlot, making the constructor take the thisValue
     9        used as a target.  This results in a wide range of boilerplate changes
     10        to pass the new parameter.
     11
     12        * API/JSObjectRef.cpp:
     13        (JSObjectSetProperty):
     14        * dfg/DFGOperations.cpp:
     15        (JSC::DFG::operationPutByValInternal):
     16        * interpreter/Interpreter.cpp:
     17        (JSC::Interpreter::execute):
     18        * jit/JITOperations.cpp:
     19        * llint/LLIntSlowPaths.cpp:
     20        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     21        * runtime/Arguments.cpp:
     22        (JSC::Arguments::putByIndex):
     23        * runtime/ArrayPrototype.cpp:
     24        (JSC::putProperty):
     25        (JSC::arrayProtoFuncPush):
     26        * runtime/JSCJSValue.cpp:
     27        (JSC::JSValue::putToPrimitiveByIndex):
     28        * runtime/JSCell.cpp:
     29        (JSC::JSCell::putByIndex):
     30        * runtime/JSFunction.cpp:
     31        (JSC::JSFunction::put):
     32        * runtime/JSGenericTypedArrayViewInlines.h:
     33        (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex):
     34        * runtime/JSONObject.cpp:
     35        (JSC::Walker::walk):
     36        * runtime/JSObject.cpp:
     37        (JSC::JSObject::putByIndex):
     38        (JSC::JSObject::putDirectNonIndexAccessor):
     39        (JSC::JSObject::deleteProperty):
     40        * runtime/JSObject.h:
     41        (JSC::JSObject::putDirect):
     42        * runtime/Lookup.h:
     43        (JSC::putEntry):
     44        (JSC::lookupPut):
     45        * runtime/PutPropertySlot.h:
     46        (JSC::PutPropertySlot::PutPropertySlot):
     47        (JSC::PutPropertySlot::setCustomProperty):
     48        (JSC::PutPropertySlot::thisValue):
     49        (JSC::PutPropertySlot::isCacheable):
     50
    1512013-12-23  Benjamin Poulain  <[email protected]>
    252
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r159798 r161033  
    111111
    112112    if (isName(property)) {
    113         PutPropertySlot slot(strict);
     113        PutPropertySlot slot(baseValue, strict);
    114114        if (direct) {
    115115            RELEASE_ASSERT(baseValue.isObject());
     
    123123    Identifier ident(exec, property.toString(exec)->value(exec));
    124124    if (!vm->exception()) {
    125         PutPropertySlot slot(strict);
     125        PutPropertySlot slot(baseValue, strict);
    126126        if (direct) {
    127127            RELEASE_ASSERT(baseValue.isObject());
     
    400400    }
    401401   
    402     PutPropertySlot slot(true);
     402    PutPropertySlot slot(array, true);
    403403    array->methodTable()->put(
    404404        array, exec, Identifier::from(exec, index), JSValue::decode(encodedValue), slot);
     
    415415    }
    416416   
    417     PutPropertySlot slot(false);
     417    PutPropertySlot slot(array, false);
    418418    array->methodTable()->put(
    419419        array, exec, Identifier::from(exec, index), JSValue::decode(encodedValue), slot);
     
    432432    }
    433433   
    434     PutPropertySlot slot(true);
     434    PutPropertySlot slot(array, true);
    435435    array->methodTable()->put(
    436436        array, exec, Identifier::from(exec, index), jsValue, slot);
     
    449449    }
    450450   
    451     PutPropertySlot slot(false);
     451    PutPropertySlot slot(array, false);
    452452    array->methodTable()->put(
    453453        array, exec, Identifier::from(exec, index), jsValue, slot);
     
    495495    }
    496496   
    497     PutPropertySlot slot(true);
     497    PutPropertySlot slot(array, true);
    498498    array->putDirect(exec->vm(), Identifier::from(exec, index), JSValue::decode(encodedValue), slot);
    499499}
     
    509509    }
    510510   
    511     PutPropertySlot slot(false);
     511    PutPropertySlot slot(array, false);
    512512    array->putDirect(exec->vm(), Identifier::from(exec, index), JSValue::decode(encodedValue), slot);
    513513}
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r160244 r161033  
    799799            if (JSONPPath.size() == 1 && JSONPPath[0].m_type == JSONPPathEntryTypeDeclare) {
    800800                globalObject->addVar(callFrame, JSONPPath[0].m_pathEntryName);
    801                 PutPropertySlot slot;
     801                PutPropertySlot slot(globalObject);
    802802                globalObject->methodTable()->put(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
    803803                result = jsUndefined();
     
    834834                }
    835835            }
    836             PutPropertySlot slot;
     836            PutPropertySlot slot(baseObject);
    837837            switch (JSONPPath.last().m_type) {
    838838            case JSONPPathEntryTypeCall: {
     
    11631163            const Identifier& ident = codeBlock->variable(i);
    11641164            if (!variableObject->hasProperty(callFrame, ident)) {
    1165                 PutPropertySlot slot;
     1165                PutPropertySlot slot(variableObject);
    11661166                variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot);
    11671167            }
     
    11701170        for (int i = 0; i < numFunctions; ++i) {
    11711171            FunctionExecutable* function = codeBlock->functionDecl(i);
    1172             PutPropertySlot slot;
     1172            PutPropertySlot slot(variableObject);
    11731173            variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
    11741174        }
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r160796 r161033  
    240240   
    241241    Identifier ident(vm, uid);
    242     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     242    PutPropertySlot slot(JSValue::decode(encodedBase), true, exec->codeBlock()->putByIdContext());
    243243    JSValue::decode(encodedBase).put(exec, ident, JSValue::decode(encodedValue), slot);
    244244}
     
    250250   
    251251    Identifier ident(vm, uid);
    252     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     252    PutPropertySlot slot(JSValue::decode(encodedBase), false, exec->codeBlock()->putByIdContext());
    253253    JSValue::decode(encodedBase).put(exec, ident, JSValue::decode(encodedValue), slot);
    254254}
     
    260260   
    261261    Identifier ident(vm, uid);
    262     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     262    PutPropertySlot slot(JSValue::decode(encodedBase), true, exec->codeBlock()->putByIdContext());
    263263    asObject(JSValue::decode(encodedBase))->putDirect(exec->vm(), ident, JSValue::decode(encodedValue), slot);
    264264}
     
    270270   
    271271    Identifier ident(vm, uid);
    272     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     272    PutPropertySlot slot(JSValue::decode(encodedBase), false, exec->codeBlock()->putByIdContext());
    273273    asObject(JSValue::decode(encodedBase))->putDirect(exec->vm(), ident, JSValue::decode(encodedValue), slot);
    274274}
     
    284284    JSValue value = JSValue::decode(encodedValue);
    285285    JSValue baseValue = JSValue::decode(encodedBase);
    286     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     286    PutPropertySlot slot(baseValue, true, exec->codeBlock()->putByIdContext());
    287287   
    288288    baseValue.put(exec, ident, value, slot);
     
    307307    JSValue value = JSValue::decode(encodedValue);
    308308    JSValue baseValue = JSValue::decode(encodedBase);
    309     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     309    PutPropertySlot slot(baseValue, false, exec->codeBlock()->putByIdContext());
    310310   
    311311    baseValue.put(exec, ident, value, slot);
     
    330330    JSValue value = JSValue::decode(encodedValue);
    331331    JSObject* baseObject = asObject(JSValue::decode(encodedBase));
    332     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     332    PutPropertySlot slot(baseObject, true, exec->codeBlock()->putByIdContext());
    333333   
    334334    baseObject->putDirect(exec->vm(), ident, value, slot);
     
    353353    JSValue value = JSValue::decode(encodedValue);
    354354    JSObject* baseObject = asObject(JSValue::decode(encodedBase));
    355     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     355    PutPropertySlot slot(baseObject, false, exec->codeBlock()->putByIdContext());
    356356   
    357357    baseObject->putDirect(exec->vm(), ident, value, slot);
     
    376376    JSValue value = JSValue::decode(encodedValue);
    377377    JSValue baseValue = JSValue::decode(encodedBase);
    378     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     378    PutPropertySlot slot(baseValue, true, exec->codeBlock()->putByIdContext());
    379379   
    380380    baseValue.put(exec, ident, value, slot);
     
    396396    JSValue value = JSValue::decode(encodedValue);
    397397    JSValue baseValue = JSValue::decode(encodedBase);
    398     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     398    PutPropertySlot slot(baseValue, false, exec->codeBlock()->putByIdContext());
    399399   
    400400    baseValue.put(exec, ident, value, slot);
     
    416416    JSValue value = JSValue::decode(encodedValue);
    417417    JSObject* baseObject = asObject(JSValue::decode(encodedBase));
    418     PutPropertySlot slot(true, exec->codeBlock()->putByIdContext());
     418    PutPropertySlot slot(baseObject, true, exec->codeBlock()->putByIdContext());
    419419   
    420420    baseObject->putDirect(exec->vm(), ident, value, slot);
     
    436436    JSValue value = JSValue::decode(encodedValue);
    437437    JSObject* baseObject = asObject(JSValue::decode(encodedBase));
    438     PutPropertySlot slot(false, exec->codeBlock()->putByIdContext());
     438    PutPropertySlot slot(baseObject, false, exec->codeBlock()->putByIdContext());
    439439   
    440440    baseObject ->putDirect(exec->vm(), ident, value, slot);
     
    470470            baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
    471471    } else if (isName(subscript)) {
    472         PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
     472        PutPropertySlot slot(baseValue, callFrame->codeBlock()->isStrictMode());
    473473        baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    474474    } else {
    475475        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
    476476        if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception.
    477             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
     477            PutPropertySlot slot(baseValue, callFrame->codeBlock()->isStrictMode());
    478478            baseValue.put(callFrame, property, value, slot);
    479479        }
     
    487487        baseObject->putDirectIndex(callFrame, i, value);
    488488    } else if (isName(subscript)) {
    489         PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
     489        PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode());
    490490        baseObject->putDirect(callFrame->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    491491    } else {
    492492        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
    493493        if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception.
    494             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
     494            PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode());
    495495            baseObject->putDirect(callFrame->vm(), property, value, slot);
    496496        }
     
    16691669    }
    16701670
    1671     PutPropertySlot slot(codeBlock->isStrictMode());
     1671    PutPropertySlot slot(scope, codeBlock->isStrictMode());
    16721672    scope->methodTable()->put(scope, exec, ident, value, slot);
    16731673   
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r160244 r161033  
    579579   
    580580    JSValue baseValue = LLINT_OP_C(1).jsValue();
    581     PutPropertySlot slot(codeBlock->isStrictMode(), codeBlock->putByIdContext());
     581    PutPropertySlot slot(baseValue, codeBlock->isStrictMode(), codeBlock->putByIdContext());
    582582    if (pc[8].u.operand)
    583583        asObject(baseValue)->putDirect(vm, ident, LLINT_OP_C(3).jsValue(), slot);
     
    735735
    736736    if (isName(subscript)) {
    737         PutPropertySlot slot(exec->codeBlock()->isStrictMode());
     737        PutPropertySlot slot(baseValue, exec->codeBlock()->isStrictMode());
    738738        baseValue.put(exec, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    739739        LLINT_END();
     
    742742    Identifier property(exec, subscript.toString(exec)->value(exec));
    743743    LLINT_CHECK_EXCEPTION();
    744     PutPropertySlot slot(exec->codeBlock()->isStrictMode());
     744    PutPropertySlot slot(baseValue, exec->codeBlock()->isStrictMode());
    745745    baseValue.put(exec, property, value, slot);
    746746    LLINT_END();
     
    760760        baseObject->putDirectIndex(exec, i, value);
    761761    } else if (isName(subscript)) {
    762         PutPropertySlot slot(exec->codeBlock()->isStrictMode());
     762        PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode());
    763763        baseObject->putDirect(exec->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    764764    } else {
    765765        Identifier property(exec, subscript.toString(exec)->value(exec));
    766766        if (!exec->vm().exception()) { // Don't put to an object if toString threw an exception.
    767             PutPropertySlot slot(exec->codeBlock()->isStrictMode());
     767            PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode());
    768768            baseObject->putDirect(exec->vm(), property, value, slot);
    769769        }
     
    13691369        LLINT_THROW(createUndefinedVariableError(exec, ident));
    13701370
    1371     PutPropertySlot slot(codeBlock->isStrictMode());
     1371    PutPropertySlot slot(scope, codeBlock->isStrictMode());
    13721372    scope->methodTable()->put(scope, exec, ident, value, slot);
    13731373
  • trunk/Source/JavaScriptCore/runtime/Arguments.cpp

    r158793 r161033  
    188188        return;
    189189
    190     PutPropertySlot slot(shouldThrow);
     190    PutPropertySlot slot(thisObject, shouldThrow);
    191191    JSObject::put(thisObject, exec, Identifier::from(exec, i), value, slot);
    192192}
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r159063 r161033  
    161161static void putProperty(ExecState* exec, JSObject* obj, PropertyName propertyName, JSValue value)
    162162{
    163     PutPropertySlot slot;
     163    PutPropertySlot slot(obj);
    164164    obj->methodTable()->put(obj, exec, propertyName, value, slot);
    165165}
     
    502502            thisObj->methodTable()->putByIndex(thisObj, exec, length + n, exec->uncheckedArgument(n), true);
    503503        else {
    504             PutPropertySlot slot;
     504            PutPropertySlot slot(thisObj);
    505505            Identifier propertyName(exec, JSValue(static_cast<int64_t>(length) + static_cast<int64_t>(n)).toWTFString(exec));
    506506            thisObj->methodTable()->put(thisObj, exec, propertyName, exec->uncheckedArgument(n), slot);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r157082 r161033  
    173173{
    174174    if (propertyName > MAX_ARRAY_INDEX) {
    175         PutPropertySlot slot(shouldThrow);
     175        PutPropertySlot slot(*this, shouldThrow);
    176176        putToPrimitive(exec, Identifier::from(exec, propertyName), value, slot);
    177177        return;
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r155143 r161033  
    9797{
    9898    if (cell->isString()) {
    99         PutPropertySlot slot(shouldThrow);
     99        PutPropertySlot slot(cell, shouldThrow);
    100100        JSValue(cell).putToPrimitive(exec, Identifier::from(exec, identifier), value, slot);
    101101        return;
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r160208 r161033  
    390390        thisObject->m_allocationProfileWatchpoint.fireAll();
    391391        // Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile.
    392         PutPropertySlot dontCache;
     392        PutPropertySlot dontCache(thisObject);
    393393        Base::put(thisObject, exec, propertyName, value, dontCache);
    394394        return;
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r158583 r161033  
    384384   
    385385    if (propertyName > MAX_ARRAY_INDEX) {
    386         PutPropertySlot slot(shouldThrow);
     386        PutPropertySlot slot(JSValue(thisObject), shouldThrow);
    387387        thisObject->methodTable()->put(
    388388            thisObject, exec, Identifier::from(exec, propertyName), value, slot);
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r157614 r161033  
    747747                JSObject* object = objectStack.peek();
    748748                Identifier prop = propertyStack.last()[indexStack.last()];
    749                 PutPropertySlot slot;
     749                PutPropertySlot slot(object);
    750750                JSValue filteredValue = callReviver(object, jsString(m_exec, prop.string()), outValue);
    751751                if (filteredValue.isUndefined())
     
    776776    }
    777777    JSObject* finalHolder = constructEmptyObject(m_exec);
    778     PutPropertySlot slot;
     778    PutPropertySlot slot(finalHolder);
    779779    finalHolder->methodTable()->put(finalHolder, m_exec, m_exec->vm().propertyNames->emptyIdentifier, outValue, slot);
    780780    return callReviver(finalHolder, jsEmptyString(m_exec), outValue);
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r160347 r161033  
    412412   
    413413    if (propertyName > MAX_ARRAY_INDEX) {
    414         PutPropertySlot slot(shouldThrow);
     414        PutPropertySlot slot(cell, shouldThrow);
    415415        thisObject->methodTable()->put(thisObject, exec, Identifier::from(exec, propertyName), value, slot);
    416416        return;
     
    12161216void JSObject::putDirectNonIndexAccessor(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes)
    12171217{
    1218     PutPropertySlot slot;
     1218    PutPropertySlot slot(this);
    12191219    putDirectInternal<PutModeDefineOwnProperty>(vm, propertyName, value, attributes, slot, getCallableObject(value));
    12201220
     
    12701270            return false; // this builtin property can't be deleted
    12711271
    1272         putEntry(exec, entry, propertyName, jsUndefined(), thisObject);
     1272        PutPropertySlot slot(thisObject);
     1273        putEntry(exec, entry, propertyName, jsUndefined(), slot);
    12731274    }
    12741275
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r160347 r161033  
    14231423{
    14241424    ASSERT(!value.isGetterSetter() && !(attributes & Accessor));
    1425     PutPropertySlot slot;
     1425    PutPropertySlot slot(this);
    14261426    putDirectInternal<PutModeDefineOwnProperty>(vm, propertyName, value, attributes, slot, getCallableObject(value));
    14271427}
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r161009 r161033  
    2727#include "JSGlobalObject.h"
    2828#include "PropertySlot.h"
     29#include "PutPropertySlot.h"
    2930#include <wtf/Assertions.h>
    3031
     
    4243    // ie. typedef JSValue (*GetFunction)(ExecState*, JSObject* baseObject)
    4344    typedef PropertySlot::GetValueFunc GetFunction;
    44     typedef void (*PutFunction)(ExecState*, EncodedJSValue base, EncodedJSValue value);
     45    typedef PutPropertySlot::PutValueFunc PutFunction;
    4546
    4647    class HashEntry {
     
    291292    }
    292293
    293     template <class ThisImp>
    294     inline void putEntry(ExecState* exec, const HashEntry* entry, PropertyName propertyName, JSValue value, ThisImp* thisObj, bool shouldThrow = false)
     294    inline void putEntry(ExecState* exec, const HashEntry* entry, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
    295295    {
    296296        // If this is a function put it as an override property.
    297297        if (entry->attributes() & Function)
    298             thisObj->putDirect(exec->vm(), propertyName, value);
    299         else if (!(entry->attributes() & ReadOnly))
    300             entry->propertyPutter()(exec, JSValue::encode(thisObj), JSValue::encode(value));
    301         else if (shouldThrow)
     298            slot.base()->putDirect(exec->vm(), propertyName, value);
     299        else if (!(entry->attributes() & ReadOnly)) {
     300            entry->propertyPutter()(exec, JSValue::encode(slot.thisValue()), JSValue::encode(value));
     301            slot.setCustomProperty(slot.base(), entry->propertyPutter());
     302        } else if (slot.isStrictMode())
    302303            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
    303304    }
     
    308309     * is found it sets the value and returns true, else it returns false.
    309310     */
    310     template <class ThisImp>
    311     inline bool lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable& table, ThisImp* thisObj, bool shouldThrow = false)
     311    inline bool lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable& table, PutPropertySlot& slot)
    312312    {
    313313        const HashEntry* entry = table.entry(exec, propertyName);
     
    316316            return false;
    317317
    318         putEntry<ThisImp>(exec, entry, propertyName, value, thisObj, shouldThrow);
     318        putEntry(exec, entry, propertyName, value, slot);
    319319        return true;
    320320    }
     
    329329    inline void lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable& table, ThisImp* thisObj, PutPropertySlot& slot)
    330330    {
    331         if (!lookupPut<ThisImp>(exec, propertyName, value, table, thisObj, slot.isStrictMode()))
     331        if (!lookupPut(exec, propertyName, value, table, slot))
    332332            ParentImp::put(thisObj, exec, propertyName, value, slot); // not found: forward to parent
    333333    }
  • trunk/Source/JavaScriptCore/runtime/PutPropertySlot.h

    r154199 r161033  
    2828#define PutPropertySlot_h
    2929
     30#include "JSCJSValue.h"
     31
    3032#include <wtf/Assertions.h>
    3133
     
    3739    class PutPropertySlot {
    3840    public:
    39         enum Type { Uncachable, ExistingProperty, NewProperty };
     41        enum Type { Uncachable, ExistingProperty, NewProperty, CustomProperty };
    4042        enum Context { UnknownContext, PutById, PutByIdEval };
     43        typedef void (*PutValueFunc)(ExecState*, EncodedJSValue base, EncodedJSValue value);
    4144
    42         PutPropertySlot(bool isStrictMode = false, Context context = UnknownContext)
     45        PutPropertySlot(JSValue thisValue, bool isStrictMode = false, Context context = UnknownContext)
    4346            : m_type(Uncachable)
    4447            , m_base(0)
     48            , m_thisValue(thisValue)
    4549            , m_isStrictMode(isStrictMode)
    4650            , m_context(context)
     51            , m_putFunction(nullptr)
    4752        {
    4853        }
     
    6166            m_offset = offset;
    6267        }
     68
     69        void setCustomProperty(JSObject* base, PutValueFunc function)
     70        {
     71            m_type = CustomProperty;
     72            m_base = base;
     73            m_putFunction = function;
     74        }
    6375       
    6476        Context context() const { return static_cast<Context>(m_context); }
     
    6678        Type type() const { return m_type; }
    6779        JSObject* base() const { return m_base; }
     80        JSValue thisValue() const { return m_thisValue; }
    6881
    6982        bool isStrictMode() const { return m_isStrictMode; }
    70         bool isCacheable() const { return m_type != Uncachable; }
     83        bool isCacheable() const { return m_type != Uncachable && m_type != CustomProperty; }
    7184        PropertyOffset cachedOffset() const
    7285        {
     
    7891        Type m_type;
    7992        JSObject* m_base;
     93        JSValue m_thisValue;
    8094        PropertyOffset m_offset;
    8195        bool m_isStrictMode;
    8296        uint8_t m_context;
     97        PutValueFunc m_putFunction;
     98
    8399    };
    84100
  • trunk/Source/WebCore/ChangeLog

    r161031 r161033  
     12013-12-23  Oliver Hunt  <[email protected]>
     2
     3        Refactor PutPropertySlot to be aware of custom properties
     4        https://bugs.webkit.org/show_bug.cgi?id=126187
     5
     6        Reviewed by msaboff.
     7
     8        Update the bindings code generation and custom objects
     9        to the new function signatures
     10
     11        * bindings/js/JSDOMWindowCustom.cpp:
     12        (WebCore::JSDOMWindow::put):
     13        * bindings/objc/WebScriptObject.mm:
     14        (-[WebScriptObject setValue:forKey:]):
     15        * bindings/scripts/CodeGeneratorJS.pm:
     16        (GenerateImplementation):
     17        * bindings/scripts/test/JS/JSTestInterface.cpp:
     18        (WebCore::JSTestInterface::putByIndex):
     19        * bridge/NP_jsobject.cpp:
     20        (_NPN_SetProperty):
     21
    1222013-12-23  Benjamin Poulain  <[email protected]>
    223
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r160208 r161033  
    340340    }
    341341
    342     if (lookupPut<JSDOMWindow>(exec, propertyName, value, *s_info.propHashTable(exec), thisObject))
     342    if (lookupPut(exec, propertyName, value, *s_info.propHashTable(exec), slot))
    343343        return;
    344344
  • trunk/Source/WebCore/bindings/objc/WebScriptObject.mm

    r159605 r161033  
    377377
    378378    JSLockHolder lock(exec);
    379 
    380     PutPropertySlot slot;
    381     [self _imp]->methodTable()->put([self _imp], exec, Identifier(exec, String(key)), convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject]), slot);
     379    JSObject* object = JSC::jsDynamicCast<JSObject*>([self _imp]);
     380    PutPropertySlot slot(object);
     381    object->methodTable()->put(object, exec, Identifier(exec, String(key)), convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject]), slot);
    382382
    383383    if (exec->hadException()) {
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r161009 r161033  
    21312131                    if ($interface->extendedAttributes->{"CustomNamedSetter"}) {
    21322132                        push(@implContent, "    PropertyName propertyName = Identifier::from(exec, index);\n");
    2133                         push(@implContent, "    PutPropertySlot slot(shouldThrow);\n");
     2133                        push(@implContent, "    PutPropertySlot slot(thisObject, shouldThrow);\n");
    21342134                        push(@implContent, "    if (thisObject->putDelegate(exec, propertyName, value, slot))\n");
    21352135                        push(@implContent, "        return;\n");
     
    21612161                        if (!$attribute->isStatic) {
    21622162                            push(@implContent, "    ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");
     2163                            if ($interfaceName eq "DOMWindow") {
     2164                                push(@implContent, "    if (!castedThis) {\n");
     2165                                push(@implContent, "        if (JSDOMWindowShell* shell = jsDynamicCast<JSDOMWindowShell*>(JSValue::decode(thisValue)))\n");
     2166                                push(@implContent, "            castedThis = shell->window();\n");
     2167                                push(@implContent, "    }\n");
     2168                            }
    21632169                            push(@implContent, "    if (!castedThis) {\n");
    21642170                            push(@implContent, "        throwVMTypeError(exec);\n");
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r161009 r161033  
    456456    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    457457    PropertyName propertyName = Identifier::from(exec, index);
    458     PutPropertySlot slot(shouldThrow);
     458    PutPropertySlot slot(thisObject, shouldThrow);
    459459    if (thisObject->putDelegate(exec, propertyName, value, slot))
    460460        return;
  • trunk/Source/WebCore/bridge/NP_jsobject.cpp

    r154967 r161033  
    325325
    326326        if (i->isString()) {
    327             PutPropertySlot slot;
     327            PutPropertySlot slot(obj->imp);
    328328            obj->imp->methodTable()->put(obj->imp, exec, identifierFromNPIdentifier(exec, i->string()), convertNPVariantToValue(exec, variant, rootObject), slot);
    329329        } else
  • trunk/Source/WebKit/mac/ChangeLog

    r161003 r161033  
     12013-12-23  Oliver Hunt  <[email protected]>
     2
     3        Refactor PutPropertySlot to be aware of custom properties
     4        https://bugs.webkit.org/show_bug.cgi?id=126187
     5
     6        Reviewed by msaboff.
     7
     8        Update for new method signatures.
     9
     10        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     11        (WebKit::NetscapePluginInstanceProxy::setProperty):
     12
    1132013-12-23  Lucas Forschler  <[email protected]>
    214
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r160457 r161033  
    10611061
    10621062    JSValue value = demarshalValue(exec, valueData, valueLength);
    1063     PutPropertySlot slot;
     1063    PutPropertySlot slot(object);
    10641064    object->methodTable()->put(object, exec, propertyName, value, slot);
    10651065   
  • trunk/Source/WebKit2/ChangeLog

    r161020 r161033  
     12013-12-23  Oliver Hunt  <[email protected]>
     2
     3        Refactor PutPropertySlot to be aware of custom properties
     4        https://bugs.webkit.org/show_bug.cgi?id=126187
     5
     6        Reviewed by msaboff.
     7
     8        Update for new method signatures.
     9
     10        * WebProcess/Plugins/Netscape/NPJSObject.cpp:
     11        (WebKit::NPJSObject::setProperty):
     12
    1132013-12-23  Zan Dobersek  <[email protected]>
    214
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp

    r154038 r161033  
    193193    JSValue jsValue = m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), *value);
    194194    if (identifierRep->isString()) {
    195         PutPropertySlot slot;
     195        PutPropertySlot slot(m_jsObject.get());
    196196        m_jsObject->methodTable()->put(m_jsObject.get(), exec, identifierFromIdentifierRep(exec, identifierRep), jsValue, slot);
    197197    } else
Note: See TracChangeset for help on using the changeset viewer.