Changeset 154253 in webkit


Ignore:
Timestamp:
Aug 18, 2013, 12:29:15 PM (12 years ago)
Author:
barraclough@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=119972
Add attributes field to PropertySlot

Reviewed by Geoff Garen.

For all JSC types, this makes getOwnPropertyDescriptor redundant.
There will be a bit more hacking required in WebCore to remove GOPD whilst maintaining current behaviour.
(Current behaviour is in many ways broken, particularly in that GOPD & GOPS are inconsistent, but we should fix incrementally).

Source/JavaScriptCore:

No performance impact.

  • runtime/PropertySlot.h:

(JSC::PropertySlot::setValue):
(JSC::PropertySlot::setCustom):
(JSC::PropertySlot::setCacheableCustom):
(JSC::PropertySlot::setCustomIndex):
(JSC::PropertySlot::setGetterSlot):
(JSC::PropertySlot::setCacheableGetterSlot):

  • These mathods now all require 'attributes'.
  • runtime/JSObject.h:

(JSC::JSObject::getDirect):
(JSC::JSObject::getDirectOffset):
(JSC::JSObject::inlineGetOwnPropertySlot):

  • Added variants of getDirect, getDirectOffset that return the attributes.
  • API/JSCallbackObjectFunctions.h:

(JSC::::getOwnPropertySlot):

  • runtime/Arguments.cpp:

(JSC::Arguments::getOwnPropertySlotByIndex):
(JSC::Arguments::getOwnPropertySlot):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::symbolTableGet):
(JSC::JSActivation::getOwnPropertySlot):

  • runtime/JSArray.cpp:

(JSC::JSArray::getOwnPropertySlot):

  • runtime/JSArrayBuffer.cpp:

(JSC::JSArrayBuffer::getOwnPropertySlot):

  • runtime/JSArrayBufferView.cpp:

(JSC::JSArrayBufferView::getOwnPropertySlot):

  • runtime/JSDataView.cpp:

(JSC::JSDataView::getOwnPropertySlot):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnPropertySlot):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::::getOwnPropertySlot):
(JSC::::getOwnPropertySlotByIndex):

  • runtime/JSObject.cpp:

(JSC::JSObject::getOwnPropertySlotByIndex):
(JSC::JSObject::fillGetterPropertySlot):

  • runtime/JSString.h:

(JSC::JSString::getStringPropertySlot):

  • runtime/JSSymbolTableObject.h:

(JSC::symbolTableGet):

  • runtime/Lookup.cpp:

(JSC::setUpStaticFunctionSlot):

  • runtime/Lookup.h:

(JSC::getStaticPropertySlot):
(JSC::getStaticPropertyDescriptor):
(JSC::getStaticValueSlot):
(JSC::getStaticValueDescriptor):

  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::getOwnPropertySlot):

  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayEntry::get):

  • Pass attributes to PropertySlot::set* methods.

Source/WebCore:

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::JSCSSStyleDeclaration::getOwnPropertySlotDelegate):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
(WebCore::JSDOMWindow::getOwnPropertyDescriptor):

  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::getOwnPropertySlotDelegate):
(WebCore::JSHistory::getOwnPropertyDescriptorDelegate):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::getOwnPropertySlotDelegate):
(WebCore::JSLocation::getOwnPropertyDescriptorDelegate):

  • bindings/js/JSPluginElementFunctions.cpp:

(WebCore::runtimeObjectCustomGetOwnPropertySlot):
(WebCore::runtimeObjectCustomGetOwnPropertyDescriptor):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateGetOwnPropertySlotBody):
(GenerateGetOwnPropertyDescriptorBody):
(GenerateImplementation):

  • bridge/runtime_array.cpp:

(JSC::RuntimeArray::getOwnPropertySlot):
(JSC::RuntimeArray::getOwnPropertyDescriptor):
(JSC::RuntimeArray::getOwnPropertySlotByIndex):

  • bridge/runtime_method.cpp:

(JSC::RuntimeMethod::getOwnPropertySlot):
(JSC::RuntimeMethod::getOwnPropertyDescriptor):

  • bridge/runtime_object.cpp:

(JSC::Bindings::RuntimeObject::getOwnPropertySlot):
(JSC::Bindings::RuntimeObject::getOwnPropertyDescriptor):

  • Pass attributes to PropertySlot::set* methods.

Source/WebKit2:

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::JSNPObject::getOwnPropertySlot):
(WebKit::JSNPObject::getOwnPropertyDescriptor):

  • Pass attributes to PropertySlot::set* methods.
Location:
trunk/Source
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r154113 r154253  
    138138                APICallbackShim callbackShim(exec);
    139139                if (hasProperty(ctx, thisRef, propertyNameRef.get())) {
    140                     slot.setCustom(thisObject, callbackGetter);
     140                    slot.setCustom(thisObject, ReadOnly | DontEnum, callbackGetter);
    141141                    return true;
    142142                }
     
    152152                if (exception) {
    153153                    throwError(exec, toJS(exec, exception));
    154                     slot.setValue(thisObject, jsUndefined());
     154                    slot.setValue(thisObject, ReadOnly | DontEnum, jsUndefined());
    155155                    return true;
    156156                }
    157157                if (value) {
    158                     slot.setValue(thisObject, toJS(exec, value));
     158                    slot.setValue(thisObject, ReadOnly | DontEnum, toJS(exec, value));
    159159                    return true;
    160160                }
     
    165165                    JSValue value = thisObject->getStaticValue(exec, propertyName);
    166166                    if (value) {
    167                         slot.setValue(thisObject, value);
     167                        slot.setValue(thisObject, ReadOnly | DontEnum, value);
    168168                        return true;
    169169                    }
     
    173173            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    174174                if (staticFunctions->contains(name)) {
    175                     slot.setCustom(thisObject, staticFunctionGetter);
     175                    slot.setCustom(thisObject, ReadOnly | DontEnum, staticFunctionGetter);
    176176                    return true;
    177177                }
  • trunk/Source/JavaScriptCore/ChangeLog

    r154245 r154253  
     12013-08-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=119972
     4        Add attributes field to PropertySlot
     5
     6        Reviewed by Geoff Garen.
     7
     8        For all JSC types, this makes getOwnPropertyDescriptor redundant.
     9        There will be a bit more hacking required in WebCore to remove GOPD whilst maintaining current behaviour.
     10        (Current behaviour is in many ways broken, particularly in that GOPD & GOPS are inconsistent, but we should fix incrementally).
     11
     12        No performance impact.
     13
     14        * runtime/PropertySlot.h:
     15        (JSC::PropertySlot::setValue):
     16        (JSC::PropertySlot::setCustom):
     17        (JSC::PropertySlot::setCacheableCustom):
     18        (JSC::PropertySlot::setCustomIndex):
     19        (JSC::PropertySlot::setGetterSlot):
     20        (JSC::PropertySlot::setCacheableGetterSlot):
     21            - These mathods now all require 'attributes'.
     22        * runtime/JSObject.h:
     23        (JSC::JSObject::getDirect):
     24        (JSC::JSObject::getDirectOffset):
     25        (JSC::JSObject::inlineGetOwnPropertySlot):
     26            - Added variants of getDirect, getDirectOffset that return the attributes.
     27        * API/JSCallbackObjectFunctions.h:
     28        (JSC::::getOwnPropertySlot):
     29        * runtime/Arguments.cpp:
     30        (JSC::Arguments::getOwnPropertySlotByIndex):
     31        (JSC::Arguments::getOwnPropertySlot):
     32        * runtime/JSActivation.cpp:
     33        (JSC::JSActivation::symbolTableGet):
     34        (JSC::JSActivation::getOwnPropertySlot):
     35        * runtime/JSArray.cpp:
     36        (JSC::JSArray::getOwnPropertySlot):
     37        * runtime/JSArrayBuffer.cpp:
     38        (JSC::JSArrayBuffer::getOwnPropertySlot):
     39        * runtime/JSArrayBufferView.cpp:
     40        (JSC::JSArrayBufferView::getOwnPropertySlot):
     41        * runtime/JSDataView.cpp:
     42        (JSC::JSDataView::getOwnPropertySlot):
     43        * runtime/JSFunction.cpp:
     44        (JSC::JSFunction::getOwnPropertySlot):
     45        * runtime/JSGenericTypedArrayViewInlines.h:
     46        (JSC::::getOwnPropertySlot):
     47        (JSC::::getOwnPropertySlotByIndex):
     48        * runtime/JSObject.cpp:
     49        (JSC::JSObject::getOwnPropertySlotByIndex):
     50        (JSC::JSObject::fillGetterPropertySlot):
     51        * runtime/JSString.h:
     52        (JSC::JSString::getStringPropertySlot):
     53        * runtime/JSSymbolTableObject.h:
     54        (JSC::symbolTableGet):
     55        * runtime/Lookup.cpp:
     56        (JSC::setUpStaticFunctionSlot):
     57        * runtime/Lookup.h:
     58        (JSC::getStaticPropertySlot):
     59        (JSC::getStaticPropertyDescriptor):
     60        (JSC::getStaticValueSlot):
     61        (JSC::getStaticValueDescriptor):
     62        * runtime/RegExpObject.cpp:
     63        (JSC::RegExpObject::getOwnPropertySlot):
     64        * runtime/SparseArrayValueMap.cpp:
     65        (JSC::SparseArrayEntry::get):
     66            - Pass attributes to PropertySlot::set* methods.
     67
    1682013-08-17  Mark Hahnenberg  <mhahnenberg@apple.com>
    269
  • trunk/Source/JavaScriptCore/runtime/Arguments.cpp

    r154113 r154253  
    9595    Arguments* thisObject = jsCast<Arguments*>(object);
    9696    if (JSValue value = thisObject->tryGetArgument(i)) {
    97         slot.setValue(thisObject, value);
     97        slot.setValue(thisObject, None, value);
    9898        return true;
    9999    }
     
    130130    if (JSValue value = thisObject->tryGetArgument(i)) {
    131131        RELEASE_ASSERT(i < PropertyName::NotAnIndex);
    132         slot.setValue(thisObject, value);
     132        slot.setValue(thisObject, None, value);
    133133        return true;
    134134    }
    135135
    136136    if (propertyName == exec->propertyNames().length && LIKELY(!thisObject->m_overrodeLength)) {
    137         slot.setValue(thisObject, jsNumber(thisObject->m_numArguments));
     137        slot.setValue(thisObject, DontEnum, jsNumber(thisObject->m_numArguments));
    138138        return true;
    139139    }
     
    141141    if (propertyName == exec->propertyNames().callee && LIKELY(!thisObject->m_overrodeCallee)) {
    142142        if (!thisObject->m_isStrictMode) {
    143             slot.setValue(thisObject, thisObject->m_callee.get());
     143            slot.setValue(thisObject, DontEnum, thisObject->m_callee.get());
    144144            return true;
    145145        }
  • trunk/Source/JavaScriptCore/runtime/JSActivation.cpp

    r154113 r154253  
    6767        return false;
    6868
    69     slot.setValue(this, registerAt(entry.getIndex()).get());
     69    slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get());
    7070    return true;
    7171}
     
    158158        // Defend against the inspector asking for the arguments object after it has been optimized out.
    159159        if (!thisObject->isTornOff()) {
    160             slot.setCustom(thisObject, thisObject->getArgumentsGetter());
     160            slot.setCustom(thisObject, DontEnum, thisObject->getArgumentsGetter());
    161161            return true;
    162162        }
     
    166166        return true;
    167167
    168     if (JSValue value = thisObject->getDirect(exec->vm(), propertyName)) {
    169         slot.setValue(thisObject, value);
     168    unsigned attributes;
     169    if (JSValue value = thisObject->getDirect(exec->vm(), propertyName, attributes)) {
     170        slot.setValue(thisObject, attributes, value);
    170171        return true;
    171172    }
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r154113 r154253  
    182182    JSArray* thisObject = jsCast<JSArray*>(object);
    183183    if (propertyName == exec->propertyNames().length) {
    184         slot.setValue(thisObject, jsNumber(thisObject->length()));
     184        unsigned attributes = thisObject->isLengthWritable() ? DontDelete | DontEnum : DontDelete | DontEnum | ReadOnly;
     185        slot.setValue(thisObject, attributes, jsNumber(thisObject->length()));
    185186        return true;
    186187    }
  • trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp

    r154127 r154253  
    7272   
    7373    if (propertyName == exec->propertyNames().byteLength) {
    74         slot.setValue(thisObject, jsNumber(thisObject->impl()->byteLength()));
     74        slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->impl()->byteLength()));
    7575        return true;
    7676    }
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp

    r154127 r154253  
    126126    JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(object);
    127127    if (propertyName == exec->propertyNames().byteOffset) {
    128         slot.setValue(thisObject, jsNumber(thisObject->byteOffset()));
     128        slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->byteOffset()));
    129129        return true;
    130130    }
     
    132132    if (propertyName == exec->propertyNames().buffer) {
    133133        slot.setValue(
    134             thisObject, exec->vm().m_typedArrayController->toJS(
     134            thisObject, DontDelete | ReadOnly, exec->vm().m_typedArrayController->toJS(
    135135                exec, thisObject->globalObject(), thisObject->buffer()));
    136136        return true;
  • trunk/Source/JavaScriptCore/runtime/JSDataView.cpp

    r154127 r154253  
    8989    JSDataView* thisObject = jsCast<JSDataView*>(object);
    9090    if (propertyName == exec->propertyNames().byteLength) {
    91         slot.setValue(thisObject, jsNumber(thisObject->m_length));
     91        slot.setValue(thisObject, DontEnum | ReadOnly, jsNumber(thisObject->m_length));
    9292        return true;
    9393    }
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r154038 r154253  
    249249    if (propertyName == exec->propertyNames().prototype) {
    250250        VM& vm = exec->vm();
    251         PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName);
     251        unsigned attributes;
     252        PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName, attributes);
    252253        if (!isValidOffset(offset)) {
    253254            JSObject* prototype = constructEmptyObject(exec);
    254255            prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum);
    255256            thisObject->putDirect(vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);
    256             offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype);
     257            offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes);
    257258            ASSERT(isValidOffset(offset));
    258259        }
    259260
    260         slot.setValue(thisObject, thisObject->getDirect(offset), offset);
     261        slot.setValue(thisObject, attributes, thisObject->getDirect(offset), offset);
    261262    }
    262263
     
    271272            return result;
    272273        }
    273         slot.setCacheableCustom(thisObject, argumentsGetter);
     274        slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, argumentsGetter);
    274275        return true;
    275276    }
    276277
    277278    if (propertyName == exec->propertyNames().length) {
    278         slot.setCacheableCustom(thisObject, lengthGetter);
     279        slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, lengthGetter);
    279280        return true;
    280281    }
    281282
    282283    if (propertyName == exec->propertyNames().name) {
    283         slot.setCacheableCustom(thisObject, nameGetter);
     284        slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, nameGetter);
    284285        return true;
    285286    }
     
    295296            return result;
    296297        }
    297         slot.setCacheableCustom(thisObject, callerGetter);
     298        slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter);
    298299        return true;
    299300    }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r154127 r154253  
    216216    JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object);
    217217    if (propertyName == exec->propertyNames().length) {
    218         slot.setValue(thisObject, jsNumber(thisObject->length()));
     218        slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->length()));
    219219        return true;
    220220    }
    221221   
    222222    if (propertyName == exec->propertyNames().byteLength) {
    223         slot.setValue(thisObject, jsNumber(thisObject->byteLength()));
     223        slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->byteLength()));
    224224        return true;
    225225    }
     
    227227    unsigned index = propertyName.asIndex();
    228228    if (index != PropertyName::NotAnIndex && thisObject->canGetIndexQuickly(index)) {
    229         slot.setValue(thisObject, thisObject->getIndexQuickly(index));
     229        slot.setValue(thisObject, DontDelete | ReadOnly, thisObject->getIndexQuickly(index));
    230230        return true;
    231231    }
     
    325325        return false;
    326326   
    327     slot.setValue(thisObject, thisObject->getIndexQuickly(propertyName));
     327    slot.setValue(thisObject, None, thisObject->getIndexQuickly(propertyName));
    328328    return true;
    329329}
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r154113 r154253  
    290290        JSValue value = butterfly->contiguous()[i].get();
    291291        if (value) {
    292             slot.setValue(thisObject, value);
     292            slot.setValue(thisObject, None, value);
    293293            return true;
    294294        }
     
    304304        double value = butterfly->contiguousDouble()[i];
    305305        if (value == value) {
    306             slot.setValue(thisObject, JSValue(JSValue::EncodeAsDouble, value));
     306            slot.setValue(thisObject, None, JSValue(JSValue::EncodeAsDouble, value));
    307307            return true;
    308308        }
     
    319319            JSValue value = storage->m_vector[i].get();
    320320            if (value) {
    321                 slot.setValue(thisObject, value);
     321                slot.setValue(thisObject, None, value);
    322322                return true;
    323323            }
     
    16261626}
    16271627
    1628 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, PropertyOffset offset)
     1628NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, unsigned attributes, PropertyOffset offset)
    16291629{
    16301630    if (structure()->isDictionary()) {
    1631         slot.setGetterSlot(this, jsCast<GetterSetter*>(getterSetter));
    1632         return;
    1633     }
    1634 
    1635     slot.setCacheableGetterSlot(this, jsCast<GetterSetter*>(getterSetter), offset);
     1631        slot.setGetterSlot(this, attributes, jsCast<GetterSetter*>(getterSetter));
     1632        return;
     1633    }
     1634
     1635    slot.setCacheableGetterSlot(this, attributes, jsCast<GetterSetter*>(getterSetter), offset);
    16361636}
    16371637
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r154199 r154253  
    7373JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, const String&);
    7474extern JS_EXPORTDATA const char* StrictModeReadonlyPropertyWriteError;
    75 
    76 // ECMA 262-3 8.6.1
    77 // Property attributes
    78 enum Attribute {
    79     None         = 0,
    80     ReadOnly     = 1 << 1,  // property can be only read, not written
    81     DontEnum     = 1 << 2,  // property doesn't appear in (for .. in ..)
    82     DontDelete   = 1 << 3,  // property can't be deleted
    83     Function     = 1 << 4,  // property is a function - only used by static hashtables
    84     Accessor     = 1 << 5,  // property is a getter/setter
    85 };
    8675
    8776COMPILE_ASSERT(None < FirstInternalAttribute, None_is_below_FirstInternalAttribute);
     
    511500    }
    512501
     502    JSValue getDirect(VM& vm, PropertyName propertyName, unsigned& attributes) const
     503    {
     504        JSCell* specific;
     505        PropertyOffset offset = structure()->get(vm, propertyName, attributes, specific);
     506        checkOffset(offset, structure()->inlineCapacity());
     507        return offset != invalidOffset ? getDirect(offset) : JSValue();
     508    }
     509
    513510    PropertyOffset getDirectOffset(VM& vm, PropertyName propertyName)
    514511    {
    515512        PropertyOffset offset = structure()->get(vm, propertyName);
     513        checkOffset(offset, structure()->inlineCapacity());
     514        return offset;
     515    }
     516
     517    PropertyOffset getDirectOffset(VM& vm, PropertyName propertyName, unsigned& attributes)
     518    {
     519        JSCell* specific;
     520        PropertyOffset offset = structure()->get(vm, propertyName, attributes, specific);
    516521        checkOffset(offset, structure()->inlineCapacity());
    517522        return offset;
     
    937942
    938943    bool inlineGetOwnPropertySlot(ExecState*, PropertyName, PropertySlot&);
    939     JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, JSValue, PropertyOffset);
     944    JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, JSValue, unsigned, PropertyOffset);
    940945
    941946    const HashEntry* findPropertyHashEntry(ExecState*, PropertyName) const;
     
    11691174ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    11701175{
    1171     PropertyOffset offset = structure()->get(exec->vm(), propertyName);
     1176    unsigned attributes;
     1177    JSCell* specific;
     1178    PropertyOffset offset = structure()->get(exec->vm(), propertyName, attributes, specific);
    11721179    if (LIKELY(isValidOffset(offset))) {
    11731180        JSValue value = getDirect(offset);
    11741181        if (structure()->hasGetterSetterProperties() && value.isGetterSetter())
    1175             fillGetterPropertySlot(slot, value, offset);
     1182            fillGetterPropertySlot(slot, value, attributes, offset);
    11761183        else
    1177             slot.setValue(this, value, offset);
     1184            slot.setValue(this, attributes, value, offset);
    11781185        return true;
    11791186    }
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r154113 r154253  
    474474    {
    475475        if (propertyName == exec->propertyNames().length) {
    476             slot.setValue(this, jsNumber(m_length));
     476            slot.setValue(this, DontEnum | DontDelete | ReadOnly, jsNumber(m_length));
    477477            return true;
    478478        }
     
    481481        if (i < m_length) {
    482482            ASSERT(i != PropertyName::NotAnIndex); // No need for an explicit check, the above test would always fail!
    483             slot.setValue(this, getIndex(exec, i));
     483            slot.setValue(this, DontDelete | ReadOnly, getIndex(exec, i));
    484484            return true;
    485485        }
     
    491491    {
    492492        if (propertyName < m_length) {
    493             slot.setValue(this, getIndex(exec, propertyName));
     493            slot.setValue(this, DontDelete | ReadOnly, getIndex(exec, propertyName));
    494494            return true;
    495495        }
  • trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.h

    r154113 r154253  
    8080    SymbolTableEntry::Fast entry = iter->value;
    8181    ASSERT(!entry.isNull());
    82     slot.setValue(object, object->registerAt(entry.getIndex()).get());
     82    slot.setValue(object, entry.getAttributes(), object->registerAt(entry.getIndex()).get());
    8383    return true;
    8484}
     
    112112    SymbolTableEntry::Fast entry = iter->value;
    113113    ASSERT(!entry.isNull());
    114     slot.setValue(object, object->registerAt(entry.getIndex()).get());
     114    slot.setValue(object, entry.getAttributes(), object->registerAt(entry.getIndex()).get());
    115115    slotIsWriteable = !entry.isReadOnly();
    116116    return true;
  • trunk/Source/JavaScriptCore/runtime/Lookup.cpp

    r148696 r154253  
    7070    ASSERT(thisObj->globalObject());
    7171    ASSERT(entry->attributes() & Function);
    72     PropertyOffset offset = thisObj->getDirectOffset(exec->vm(), propertyName);
     72    unsigned attributes;
     73    PropertyOffset offset = thisObj->getDirectOffset(exec->vm(), propertyName, attributes);
    7374
    7475    if (!isValidOffset(offset)) {
     
    8182            exec, thisObj->globalObject(), propertyName, entry->functionLength(),
    8283            entry->function(), entry->intrinsic(), entry->attributes());
    83         offset = thisObj->getDirectOffset(exec->vm(), propertyName);
     84        offset = thisObj->getDirectOffset(exec->vm(), propertyName, attributes);
    8485        ASSERT(isValidOffset(offset));
    8586    }
    8687
    87     slot.setValue(thisObj, thisObj->getDirect(offset), offset);
     88    slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset);
    8889    return true;
    8990}
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r153673 r154253  
    252252            return setUpStaticFunctionSlot(exec, entry, thisObj, propertyName, slot);
    253253
    254         slot.setCacheableCustom(thisObj, entry->propertyGetter());
     254        slot.setCacheableCustom(thisObj, entry->attributes(), entry->propertyGetter());
    255255        return true;
    256256    }
     
    272272        }
    273273
    274         slot.setCustom(thisObj, entry->propertyGetter());
     274        slot.setCustom(thisObj, entry->attributes(), entry->propertyGetter());
    275275        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    276276        return true;
     
    331331        ASSERT(!(entry->attributes() & Function));
    332332
    333         slot.setCacheableCustom(thisObj, entry->propertyGetter());
     333        slot.setCacheableCustom(thisObj, entry->attributes(), entry->propertyGetter());
    334334        return true;
    335335    }
     
    349349        ASSERT(!(entry->attributes() & Function));
    350350        PropertySlot slot(thisObj);
    351         slot.setCustom(thisObj, entry->propertyGetter());
     351        slot.setCustom(thisObj, entry->attributes(), entry->propertyGetter());
    352352        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    353353        return true;
  • trunk/Source/JavaScriptCore/runtime/PropertySlot.h

    r154113 r154253  
    3333class ExecState;
    3434class GetterSetter;
     35
     36// ECMA 262-3 8.6.1
     37// Property attributes
     38enum Attribute {
     39    None         = 0,
     40    ReadOnly     = 1 << 1,  // property can be only read, not written
     41    DontEnum     = 1 << 2,  // property doesn't appear in (for .. in ..)
     42    DontDelete   = 1 << 3,  // property can't be deleted
     43    Function     = 1 << 4,  // property is a function - only used by static hashtables
     44    Accessor     = 1 << 5,  // property is a getter/setter
     45};
    3546
    3647class PropertySlot {
     
    8091    }
    8192
    82     void setValue(JSObject* slotBase, JSValue value)
     93    void setValue(JSObject* slotBase, unsigned attributes, JSValue value)
    8394    {
    8495        ASSERT(value);
    8596        m_data.value = JSValue::encode(value);
     97        m_attributes = attributes;
    8698
    8799        ASSERT(slotBase);
     
    91103    }
    92104   
    93     void setValue(JSObject* slotBase, JSValue value, PropertyOffset offset)
     105    void setValue(JSObject* slotBase, unsigned attributes, JSValue value, PropertyOffset offset)
    94106    {
    95107        ASSERT(value);
    96108        m_data.value = JSValue::encode(value);
     109        m_attributes = attributes;
    97110
    98111        ASSERT(slotBase);
     
    102115    }
    103116
    104     void setValue(JSString*, JSValue value)
     117    void setValue(JSString*, unsigned attributes, JSValue value)
    105118    {
    106119        ASSERT(value);
    107120        m_data.value = JSValue::encode(value);
     121        m_attributes = attributes;
    108122
    109123        m_slotBase = 0;
     
    112126    }
    113127
    114     void setCustom(JSObject* slotBase, GetValueFunc getValue)
     128    void setCustom(JSObject* slotBase, unsigned attributes, GetValueFunc getValue)
    115129    {
    116130        ASSERT(getValue);
    117131        m_data.custom.getValue = getValue;
     132        m_attributes = attributes;
    118133
    119134        ASSERT(slotBase);
     
    123138    }
    124139   
    125     void setCacheableCustom(JSObject* slotBase, GetValueFunc getValue)
     140    void setCacheableCustom(JSObject* slotBase, unsigned attributes, GetValueFunc getValue)
    126141    {
    127142        ASSERT(getValue);
    128143        m_data.custom.getValue = getValue;
     144        m_attributes = attributes;
    129145
    130146        ASSERT(slotBase);
     
    134150    }
    135151
    136     void setCustomIndex(JSObject* slotBase, unsigned index, GetIndexValueFunc getIndexValue)
     152    void setCustomIndex(JSObject* slotBase, unsigned attributes, unsigned index, GetIndexValueFunc getIndexValue)
    137153    {
    138154        ASSERT(getIndexValue);
    139155        m_data.customIndex.getIndexValue = getIndexValue;
    140156        m_data.customIndex.index = index;
     157        m_attributes = attributes;
    141158
    142159        ASSERT(slotBase);
     
    146163    }
    147164
    148     void setGetterSlot(JSObject* slotBase, GetterSetter* getterSetter)
     165    void setGetterSlot(JSObject* slotBase, unsigned attributes, GetterSetter* getterSetter)
    149166    {
    150167        ASSERT(getterSetter);
    151168        m_data.getter.getterSetter = getterSetter;
     169        m_attributes = attributes;
    152170
    153171        ASSERT(slotBase);
     
    157175    }
    158176
    159     void setCacheableGetterSlot(JSObject* slotBase, GetterSetter* getterSetter, PropertyOffset offset)
     177    void setCacheableGetterSlot(JSObject* slotBase, unsigned attributes, GetterSetter* getterSetter, PropertyOffset offset)
    160178    {
    161179        ASSERT(getterSetter);
    162180        m_data.getter.getterSetter = getterSetter;
     181        m_attributes = attributes;
    163182
    164183        ASSERT(slotBase);
     
    180199    JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const;
    181200
     201    unsigned m_attributes;
    182202    union {
    183203        EncodedJSValue value;
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r154038 r154253  
    9494    if (propertyName == exec->propertyNames().lastIndex) {
    9595        RegExpObject* regExp = asRegExpObject(object);
    96         slot.setValue(regExp, regExp->getLastIndex());
     96        unsigned attributes = regExp->m_lastIndexIsWritable ? DontDelete | DontEnum : DontDelete | DontEnum | ReadOnly;
     97        slot.setValue(regExp, attributes, regExp->getLastIndex());
    9798        return true;
    9899    }
  • trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp

    r154113 r154253  
    129129
    130130    if (LIKELY(!value.isGetterSetter())) {
    131         slot.setValue(thisObject, value);
     131        slot.setValue(thisObject, attributes, value);
    132132        return;
    133133    }
    134134
    135     slot.setGetterSlot(thisObject, jsCast<GetterSetter*>(value));
     135    slot.setGetterSlot(thisObject, attributes, jsCast<GetterSetter*>(value));
    136136}
    137137
  • trunk/Source/WebCore/ChangeLog

    r154252 r154253  
     12013-08-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=119972
     4        Add attributes field to PropertySlot
     5
     6        Reviewed by Geoff Garen.
     7
     8        For all JSC types, this makes getOwnPropertyDescriptor redundant.
     9        There will be a bit more hacking required in WebCore to remove GOPD whilst maintaining current behaviour.
     10        (Current behaviour is in many ways broken, particularly in that GOPD & GOPS are inconsistent, but we should fix incrementally).
     11
     12        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     13        (WebCore::JSCSSStyleDeclaration::getOwnPropertySlotDelegate):
     14        * bindings/js/JSDOMWindowCustom.cpp:
     15        (WebCore::JSDOMWindow::getOwnPropertySlot):
     16        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
     17        (WebCore::JSDOMWindow::getOwnPropertyDescriptor):
     18        * bindings/js/JSHistoryCustom.cpp:
     19        (WebCore::JSHistory::getOwnPropertySlotDelegate):
     20        (WebCore::JSHistory::getOwnPropertyDescriptorDelegate):
     21        * bindings/js/JSLocationCustom.cpp:
     22        (WebCore::JSLocation::getOwnPropertySlotDelegate):
     23        (WebCore::JSLocation::getOwnPropertyDescriptorDelegate):
     24        * bindings/js/JSPluginElementFunctions.cpp:
     25        (WebCore::runtimeObjectCustomGetOwnPropertySlot):
     26        (WebCore::runtimeObjectCustomGetOwnPropertyDescriptor):
     27        * bindings/scripts/CodeGeneratorJS.pm:
     28        (GenerateGetOwnPropertySlotBody):
     29        (GenerateGetOwnPropertyDescriptorBody):
     30        (GenerateImplementation):
     31        * bridge/runtime_array.cpp:
     32        (JSC::RuntimeArray::getOwnPropertySlot):
     33        (JSC::RuntimeArray::getOwnPropertyDescriptor):
     34        (JSC::RuntimeArray::getOwnPropertySlotByIndex):
     35        * bridge/runtime_method.cpp:
     36        (JSC::RuntimeMethod::getOwnPropertySlot):
     37        (JSC::RuntimeMethod::getOwnPropertyDescriptor):
     38        * bridge/runtime_object.cpp:
     39        (JSC::Bindings::RuntimeObject::getOwnPropertySlot):
     40        (JSC::Bindings::RuntimeObject::getOwnPropertyDescriptor):
     41            - Pass attributes to PropertySlot::set* methods.
     42
    1432013-08-18  Ryosuke Niwa  <rniwa@webkit.org>
    244
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r154038 r154253  
    331331
    332332    if (propertyInfo.hadPixelOrPosPrefix)
    333         slot.setCustomIndex(this, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterPixelOrPosPrefixCallback);
     333        slot.setCustomIndex(this, ReadOnly | DontDelete | DontEnum, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterPixelOrPosPrefixCallback);
    334334    else
    335         slot.setCustomIndex(this, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterCallback);
     335        slot.setCustomIndex(this, ReadOnly | DontDelete | DontEnum, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterCallback);
    336336    return true;
    337337}
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r154219 r154253  
    127127        entry = s_info.propHashTable(exec)->entry(exec, propertyName);
    128128        if (entry && !(entry->attributes() & JSC::Function) && entry->propertyGetter() == jsDOMWindowClosed) {
    129             slot.setCustom(thisObject, entry->propertyGetter());
     129            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, entry->propertyGetter());
    130130            return true;
    131131        }
    132132        entry = JSDOMWindowPrototype::info()->propHashTable(exec)->entry(exec, propertyName);
    133133        if (entry && (entry->attributes() & JSC::Function) && entry->function() == jsDOMWindowPrototypeFunctionClose) {
    134             slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
     134            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
    135135            return true;
    136136        }
     
    162162            if (entry->function() == jsDOMWindowPrototypeFunctionBlur) {
    163163                if (!allowsAccess) {
    164                     slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionBlur, 0>);
     164                    slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionBlur, 0>);
    165165                    return true;
    166166                }
    167167            } else if (entry->function() == jsDOMWindowPrototypeFunctionClose) {
    168168                if (!allowsAccess) {
    169                     slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
     169                    slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
    170170                    return true;
    171171                }
    172172            } else if (entry->function() == jsDOMWindowPrototypeFunctionFocus) {
    173173                if (!allowsAccess) {
    174                     slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionFocus, 0>);
     174                    slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionFocus, 0>);
    175175                    return true;
    176176                }
    177177            } else if (entry->function() == jsDOMWindowPrototypeFunctionPostMessage) {
    178178                if (!allowsAccess) {
    179                     slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionPostMessage, 2>);
     179                    slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionPostMessage, 2>);
    180180                    return true;
    181181                }
     
    191191        if (propertyName == exec->propertyNames().toString) {
    192192            if (!allowsAccess) {
    193                 slot.setCustom(thisObject, objectToStringFunctionGetter);
     193                slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter);
    194194                return true;
    195195            }
     
    199199    entry = JSDOMWindow::info()->propHashTable(exec)->entry(exec, propertyName);
    200200    if (entry) {
    201         slot.setCustom(thisObject, entry->propertyGetter());
     201        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());
    202202        return true;
    203203    }
     
    209209    // it the Moz way.
    210210    if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) {
    211         slot.setCustom(thisObject, childFrameGetter);
     211        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter);
    212212        return true;
    213213    }
     
    233233    if (i < thisObject->impl()->frame()->tree()->scopedChildCount()) {
    234234        ASSERT(i != PropertyName::NotAnIndex);
    235         slot.setCustomIndex(thisObject, i, indexGetter);
     235        slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, i, indexGetter);
    236236        return true;
    237237    }
     
    248248        AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
    249249        if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) {
    250             slot.setCustom(thisObject, namedItemGetter);
     250            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
    251251            return true;
    252252        }
     
    286286    // it the Moz way.
    287287    if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) {
    288         slot.setCustom(thisObject, childFrameGetter);
     288        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter);
    289289        return true;
    290290    }
     
    309309    if (index < thisObject->impl()->frame()->tree()->scopedChildCount()) {
    310310        ASSERT(index != PropertyName::NotAnIndex);
    311         slot.setCustomIndex(thisObject, index, indexGetter);
     311        slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, index, indexGetter);
    312312        return true;
    313313    }
     
    324324        AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
    325325        if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) {
    326             slot.setCustom(thisObject, namedItemGetter);
     326            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
    327327            return true;
    328328        }
     
    353353        if (entry && (entry->attributes() & JSC::Function) && entry->function() == jsDOMWindowPrototypeFunctionClose) {
    354354            PropertySlot slot(thisObject);
    355             slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
     355            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);
    356356            descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    357357            return true;
     
    364364    if (entry) {
    365365        PropertySlot slot(thisObject);
    366         slot.setCustom(thisObject, entry->propertyGetter());
     366        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());
    367367        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    368368        return true;
     
    376376    if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) {
    377377        PropertySlot slot(thisObject);
    378         slot.setCustom(thisObject, childFrameGetter);
     378        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter);
    379379        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    380380        return true;
     
    385385        ASSERT(i != PropertyName::NotAnIndex);
    386386        PropertySlot slot(thisObject);
    387         slot.setCustomIndex(thisObject, i, indexGetter);
     387        slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, i, indexGetter);
    388388        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    389389        return true;
     
    396396        if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) {
    397397            PropertySlot slot(thisObject);
    398             slot.setCustom(thisObject, namedItemGetter);
     398            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
    399399            descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    400400            return true;
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r154038 r154253  
    7171        if (entry->attributes() & JSC::Function) {
    7272            if (entry->function() == jsHistoryPrototypeFunctionBack) {
    73                 slot.setCustom(this, nonCachingStaticBackFunctionGetter);
     73                slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter);
    7474                return true;
    7575            } else if (entry->function() == jsHistoryPrototypeFunctionForward) {
    76                 slot.setCustom(this, nonCachingStaticForwardFunctionGetter);
     76                slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter);
    7777                return true;
    7878            } else if (entry->function() == jsHistoryPrototypeFunctionGo) {
    79                 slot.setCustom(this, nonCachingStaticGoFunctionGetter);
     79                slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter);
    8080                return true;
    8181            }
     
    8484        // Allow access to toString() cross-domain, but always Object.toString.
    8585        if (propertyName == exec->propertyNames().toString) {
    86             slot.setCustom(this, objectToStringFunctionGetter);
     86            slot.setCustom(this, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter);
    8787            return true;
    8888        }
     
    112112        if (entry->attributes() & JSC::Function) {
    113113            if (entry->function() == jsHistoryPrototypeFunctionBack) {
    114                 slot.setCustom(this, nonCachingStaticBackFunctionGetter);
     114                slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter);
    115115                descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    116116                return true;
    117117            } else if (entry->function() == jsHistoryPrototypeFunctionForward) {
    118                 slot.setCustom(this, nonCachingStaticForwardFunctionGetter);
     118                slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter);
    119119                descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    120120                return true;
    121121            } else if (entry->function() == jsHistoryPrototypeFunctionGo) {
    122                 slot.setCustom(this, nonCachingStaticGoFunctionGetter);
     122                slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter);
    123123                descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    124124                return true;
     
    129129        if (propertyName == exec->propertyNames().toString) {
    130130            PropertySlot slot(this);
    131             slot.setCustom(this, objectToStringFunctionGetter);
     131            slot.setCustom(this, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter);
    132132            descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    133133            return true;
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r154038 r154253  
    6767    if (entry && (entry->attributes() & JSC::Function)) {
    6868        if (entry->function() == jsLocationPrototypeFunctionReplace) {
    69             slot.setCustom(this, nonCachingStaticReplaceFunctionGetter);
     69            slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter);
    7070            return true;
    7171        } else if (entry->function() == jsLocationPrototypeFunctionReload) {
    72             slot.setCustom(this, nonCachingStaticReloadFunctionGetter);
     72            slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter);
    7373            return true;
    7474        } else if (entry->function() == jsLocationPrototypeFunctionAssign) {
    75             slot.setCustom(this, nonCachingStaticAssignFunctionGetter);
     75            slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter);
    7676            return true;
    7777        }
     
    104104    if (entry && (entry->attributes() & JSC::Function)) {
    105105        if (entry->function() == jsLocationPrototypeFunctionReplace) {
    106             slot.setCustom(this, nonCachingStaticReplaceFunctionGetter);
     106            slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter);
    107107            descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    108108            return true;
    109109        } else if (entry->function() == jsLocationPrototypeFunctionReload) {
    110             slot.setCustom(this, nonCachingStaticReloadFunctionGetter);
     110            slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter);
    111111            descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    112112            return true;
    113113        } else if (entry->function() == jsLocationPrototypeFunctionAssign) {
    114             slot.setCustom(this, nonCachingStaticAssignFunctionGetter);
     114            slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter);
    115115            descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    116116            return true;
  • trunk/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp

    r153677 r154253  
    119119    if (!scriptObject->hasProperty(exec, propertyName))
    120120        return false;
    121     slot.setCustom(element, runtimeObjectPropertyGetter);
     121    slot.setCustom(element, DontDelete | DontEnum, runtimeObjectPropertyGetter);
    122122    return true;
    123123}
     
    131131        return false;
    132132    PropertySlot slot(element);
    133     slot.setCustom(element, runtimeObjectPropertyGetter);
     133    slot.setCustom(element, DontDelete | DontEnum, runtimeObjectPropertyGetter);
    134134    // While we don't know what the plugin allows, we do know that we prevent
    135135    // enumeration or deletion of properties, so we mark plugin properties
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r154219 r154253  
    362362            push(@getOwnPropertySlotImpl, "    const ${namespaceMaybe}HashEntry* entry = getStaticValueSlotEntryWithoutCaching<$className>(exec, propertyName);\n");
    363363            push(@getOwnPropertySlotImpl, "    if (entry) {\n");
    364             push(@getOwnPropertySlotImpl, "        slot.setCustom(thisObject, entry->propertyGetter());\n");
     364            push(@getOwnPropertySlotImpl, "        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());\n");
    365365            push(@getOwnPropertySlotImpl, "        return true;\n");
    366366            push(@getOwnPropertySlotImpl, "    }\n");
     
    382382            push(@getOwnPropertySlotImpl, "    if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n");
    383383        }
     384        # Assume that if there's a setter, the index will be writable
     385        if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
     386            push(@getOwnPropertySlotImpl, "        unsigned attributes = ${namespaceMaybe}DontDelete;\n");
     387        } else {
     388            push(@getOwnPropertySlotImpl, "        unsigned attributes = ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly;\n");
     389        }
    384390        if ($hasNumericIndexedGetter) {
    385             push(@getOwnPropertySlotImpl, "        slot.setValue(thisObject, thisObject->getByIndex(exec, index));\n");
     391            push(@getOwnPropertySlotImpl, "        slot.setValue(thisObject, attributes, thisObject->getByIndex(exec, index));\n");
    386392        } else {
    387             push(@getOwnPropertySlotImpl, "        slot.setCustomIndex(thisObject, index, indexGetter);\n");
     393            push(@getOwnPropertySlotImpl, "        slot.setCustomIndex(thisObject, attributes, index, indexGetter);\n");
    388394        }
    389395        push(@getOwnPropertySlotImpl, "        return true;\n");
     
    393399    if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) {
    394400        push(@getOwnPropertySlotImpl, "    if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n");
    395         push(@getOwnPropertySlotImpl, "        slot.setCustom(thisObject, thisObject->nameGetter);\n");
     401        push(@getOwnPropertySlotImpl, "        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);\n");
    396402        push(@getOwnPropertySlotImpl, "        return true;\n");
    397403        push(@getOwnPropertySlotImpl, "    }\n");
     
    459465            push(@getOwnPropertyDescriptorImpl, "    if (entry) {\n");
    460466            push(@getOwnPropertyDescriptorImpl, "        PropertySlot slot(thisObject);\n");
    461             push(@getOwnPropertyDescriptorImpl, "        slot.setCustom(thisObject, entry->propertyGetter());\n");
     467            push(@getOwnPropertyDescriptorImpl, "        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());\n");
    462468            push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());\n");
    463469            push(@getOwnPropertyDescriptorImpl, "        return true;\n");
     
    473479        push(@getOwnPropertyDescriptorImpl, "    unsigned index = propertyName.asIndex();\n");
    474480        push(@getOwnPropertyDescriptorImpl, "    if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n");
     481        # Assume that if there's a setter, the index will be writable
     482        if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
     483            push(@getOwnPropertyDescriptorImpl, "        unsigned attributes = ${namespaceMaybe}DontDelete;\n");
     484        } else {
     485            push(@getOwnPropertyDescriptorImpl, "        unsigned attributes = ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly;\n");
     486        }
    475487        if ($hasNumericIndexedGetter) {
    476             # Assume that if there's a setter, the index will be writable
    477             if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
    478                 push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(thisObject->getByIndex(exec, index), ${namespaceMaybe}DontDelete);\n");
    479             } else {
    480                 push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(thisObject->getByIndex(exec, index), ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly);\n");
    481             }
     488            push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(thisObject->getByIndex(exec, index), attributes);\n");
    482489        } else {
    483490            push(@getOwnPropertyDescriptorImpl, "        ${namespaceMaybe}PropertySlot slot(thisObject);\n");
    484             push(@getOwnPropertyDescriptorImpl, "        slot.setCustomIndex(thisObject, index, indexGetter);\n");
    485             # Assume that if there's a setter, the index will be writable
    486             if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
    487                 push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(slot.getValue(exec, propertyName), ${namespaceMaybe}DontDelete);\n");
    488             } else {
    489                 push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(slot.getValue(exec, propertyName), ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly);\n");
    490             }
     491            push(@getOwnPropertyDescriptorImpl, "        slot.setCustomIndex(thisObject, attributes, index, indexGetter);\n");
     492            push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(slot.getValue(exec, propertyName), attributes);\n");
    491493        }
    492494        push(@getOwnPropertyDescriptorImpl, "        return true;\n");
     
    497499        push(@getOwnPropertyDescriptorImpl, "    if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n");
    498500        push(@getOwnPropertyDescriptorImpl, "        ${namespaceMaybe}PropertySlot slot(thisObject);\n");
    499         push(@getOwnPropertyDescriptorImpl, "        slot.setCustom(thisObject, nameGetter);\n");
     501        push(@getOwnPropertyDescriptorImpl, "        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter);\n");
    500502        push(@getOwnPropertyDescriptorImpl, "        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);\n");
    501503        push(@getOwnPropertyDescriptorImpl, "        return true;\n");
     
    19351937                    push(@implContent, "    if (index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n");
    19361938                }
     1939                # Assume that if there's a setter, the index will be writable
     1940                if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
     1941                    push(@implContent, "        unsigned attributes = DontDelete;\n");
     1942                } else {
     1943                    push(@implContent, "        unsigned attributes = DontDelete | ReadOnly;\n");
     1944                }
    19371945                if ($hasNumericIndexedGetter) {
    1938                     push(@implContent, "        slot.setValue(thisObject, thisObject->getByIndex(exec, index));\n");
     1946                    push(@implContent, "        slot.setValue(thisObject, attributes, thisObject->getByIndex(exec, index));\n");
    19391947                } else {
    1940                     push(@implContent, "        slot.setCustomIndex(thisObject, index, thisObject->indexGetter);\n");
     1948                    push(@implContent, "        slot.setCustomIndex(thisObject, attributes, index, thisObject->indexGetter);\n");
    19411949                }
    19421950                push(@implContent, "        return true;\n");
     
    19471955                &$propertyNameGeneration();
    19481956                push(@implContent, "    if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n");
    1949                 push(@implContent, "        slot.setCustom(thisObject, thisObject->nameGetter);\n");
     1957                push(@implContent, "        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);\n");
    19501958                push(@implContent, "        return true;\n");
    19511959                push(@implContent, "    }\n");
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp

    r154038 r154253  
    138138    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    139139    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
    140         slot.setCustom(thisObject, thisObject->nameGetter);
     140        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
    141141        return true;
    142142    }
     
    150150    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
    151151        PropertySlot slot(thisObject);
    152         slot.setCustom(thisObject, nameGetter);
     152        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter);
    153153        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    154154        return true;
     
    163163    PropertyName propertyName = Identifier::from(exec, index);
    164164    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
    165         slot.setCustom(thisObject, thisObject->nameGetter);
     165        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
    166166        return true;
    167167    }
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp

    r154038 r154253  
    148148    const HashEntry* entry = getStaticValueSlotEntryWithoutCaching<JSTestEventTarget>(exec, propertyName);
    149149    if (entry) {
    150         slot.setCustom(thisObject, entry->propertyGetter());
     150        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());
    151151        return true;
    152152    }
    153153    unsigned index = propertyName.asIndex();
    154154    if (index != PropertyName::NotAnIndex && index < static_cast<TestEventTarget*>(thisObject->impl())->length()) {
    155         slot.setCustomIndex(thisObject, index, indexGetter);
     155        unsigned attributes = DontDelete | ReadOnly;
     156        slot.setCustomIndex(thisObject, attributes, index, indexGetter);
    156157        return true;
    157158    }
    158159    if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) {
    159         slot.setCustom(thisObject, thisObject->nameGetter);
     160        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
    160161        return true;
    161162    }
     
    170171    if (entry) {
    171172        PropertySlot slot(thisObject);
    172         slot.setCustom(thisObject, entry->propertyGetter());
     173        slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());
    173174        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
    174175        return true;
     
    176177    unsigned index = propertyName.asIndex();
    177178    if (index != PropertyName::NotAnIndex && index < static_cast<TestEventTarget*>(thisObject->impl())->length()) {
     179        unsigned attributes = DontDelete | ReadOnly;
    178180        PropertySlot slot(thisObject);
    179         slot.setCustomIndex(thisObject, index, indexGetter);
    180         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
     181        slot.setCustomIndex(thisObject, attributes, index, indexGetter);
     182        descriptor.setDescriptor(slot.getValue(exec, propertyName), attributes);
    181183        return true;
    182184    }
    183185    if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) {
    184186        PropertySlot slot(thisObject);
    185         slot.setCustom(thisObject, nameGetter);
     187        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter);
    186188        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    187189        return true;
     
    195197    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    196198    if (index < static_cast<TestEventTarget*>(thisObject->impl())->length()) {
    197         slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
     199        unsigned attributes = DontDelete | ReadOnly;
     200        slot.setCustomIndex(thisObject, attributes, index, thisObject->indexGetter);
    198201        return true;
    199202    }
    200203    PropertyName propertyName = Identifier::from(exec, index);
    201204    if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) {
    202         slot.setCustom(thisObject, thisObject->nameGetter);
     205        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
    203206        return true;
    204207    }
  • trunk/Source/WebCore/bridge/runtime_array.cpp

    r154038 r154253  
    9090    RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
    9191    if (propertyName == exec->propertyNames().length) {
    92         slot.setCacheableCustom(thisObject, thisObject->lengthGetter);
     92        slot.setCacheableCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->lengthGetter);
    9393        return true;
    9494    }
     
    9797    if (index < thisObject->getLength()) {
    9898        ASSERT(index != PropertyName::NotAnIndex);
    99         slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
     99        slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, thisObject->indexGetter);
    100100        return true;
    101101    }
     
    109109    if (propertyName == exec->propertyNames().length) {
    110110        PropertySlot slot(thisObject);
    111         slot.setCustom(thisObject, lengthGetter);
     111        slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter);
    112112        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    113113        return true;
     
    118118        ASSERT(index != PropertyName::NotAnIndex);
    119119        PropertySlot slot(thisObject);
    120         slot.setCustomIndex(thisObject, index, indexGetter);
     120        slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, indexGetter);
    121121        descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum);
    122122        return true;
     
    130130    RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
    131131    if (index < thisObject->getLength()) {
    132         slot.setCustomIndex(thisObject, index, thisObject->indexGetter);
     132        slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, thisObject->indexGetter);
    133133        return true;
    134134    }
  • trunk/Source/WebCore/bridge/runtime_method.cpp

    r154038 r154253  
    6666    RuntimeMethod* thisObject = jsCast<RuntimeMethod*>(object);
    6767    if (propertyName == exec->propertyNames().length) {
    68         slot.setCacheableCustom(thisObject, thisObject->lengthGetter);
     68        slot.setCacheableCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->lengthGetter);
    6969        return true;
    7070    }
     
    7878    if (propertyName == exec->propertyNames().length) {
    7979        PropertySlot slot(thisObject);
    80         slot.setCustom(thisObject, lengthGetter);
     80        slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter);
    8181        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
    8282        return true;
  • trunk/Source/WebCore/bridge/runtime_object.cpp

    r154038 r154253  
    135135        Field *aField = aClass->fieldNamed(propertyName, instance.get());
    136136        if (aField) {
    137             slot.setCustom(thisObject, thisObject->fieldGetter);
     137            slot.setCustom(thisObject, DontDelete, thisObject->fieldGetter);
    138138            instance->end();
    139139            return true;
     
    142142            // that method.
    143143            if (aClass->methodNamed(propertyName, instance.get())) {
    144                 slot.setCustom(thisObject, thisObject->methodGetter);
     144                slot.setCustom(thisObject, DontDelete | ReadOnly, thisObject->methodGetter);
    145145               
    146146                instance->end();
     
    151151        // Try a fallback object.
    152152        if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) {
    153             slot.setCustom(thisObject, thisObject->fallbackObjectGetter);
     153            slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->fallbackObjectGetter);
    154154            instance->end();
    155155            return true;
     
    180180        if (aField) {
    181181            PropertySlot slot(thisObject);
    182             slot.setCustom(thisObject, fieldGetter);
     182            slot.setCustom(thisObject, DontDelete, fieldGetter);
    183183            instance->end();
    184184            descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete);
     
    189189            if (aClass->methodNamed(propertyName, instance.get())) {
    190190                PropertySlot slot(thisObject);
    191                 slot.setCustom(thisObject, methodGetter);
     191                slot.setCustom(thisObject, DontDelete | ReadOnly, methodGetter);
    192192                instance->end();
    193193                descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
     
    199199        if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) {
    200200            PropertySlot slot(thisObject);
    201             slot.setCustom(thisObject, fallbackObjectGetter);
     201            slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, fallbackObjectGetter);
    202202            instance->end();
    203203            descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum);
  • trunk/Source/WebKit2/ChangeLog

    r154251 r154253  
     12013-08-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=119972
     4        Add attributes field to PropertySlot
     5
     6        Reviewed by Geoff Garen.
     7
     8        For all JSC types, this makes getOwnPropertyDescriptor redundant.
     9        There will be a bit more hacking required in WebCore to remove GOPD whilst maintaining current behaviour.
     10        (Current behaviour is in many ways broken, particularly in that GOPD & GOPS are inconsistent, but we should fix incrementally).
     11
     12        * WebProcess/Plugins/Netscape/JSNPObject.cpp:
     13        (WebKit::JSNPObject::getOwnPropertySlot):
     14        (WebKit::JSNPObject::getOwnPropertyDescriptor):
     15            - Pass attributes to PropertySlot::set* methods.
     16
    1172013-08-16  Sam Weinig  <sam@webkit.org>
    218
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp

    r154038 r154253  
    277277    // First, check if the NPObject has a property with this name.
    278278    if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) {
    279         slot.setCustom(thisObject, thisObject->propertyGetter);
     279        slot.setCustom(thisObject, DontDelete, thisObject->propertyGetter);
    280280        return true;
    281281    }
     
    283283    // Second, check if the NPObject has a method with this name.
    284284    if (thisObject->m_npObject->_class->hasMethod && thisObject->m_npObject->_class->hasMethod(thisObject->m_npObject, npIdentifier)) {
    285         slot.setCustom(thisObject, thisObject->methodGetter);
     285        slot.setCustom(thisObject, DontDelete | ReadOnly, thisObject->methodGetter);
    286286        return true;
    287287    }
     
    309309    if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) {
    310310        PropertySlot slot(thisObject);
    311         slot.setCustom(thisObject, propertyGetter);
     311        slot.setCustom(thisObject, DontDelete, propertyGetter);
    312312        descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete);
    313313        return true;
     
    317317    if (thisObject->m_npObject->_class->hasMethod && thisObject->m_npObject->_class->hasMethod(thisObject->m_npObject, npIdentifier)) {
    318318        PropertySlot slot(thisObject);
    319         slot.setCustom(thisObject, methodGetter);
     319        slot.setCustom(thisObject, DontDelete | ReadOnly, methodGetter);
    320320        descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
    321321        return true;
Note: See TracChangeset for help on using the changeset viewer.