Changeset 154253 in webkit
- Timestamp:
- Aug 18, 2013, 12:29:15 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r154113 r154253 138 138 APICallbackShim callbackShim(exec); 139 139 if (hasProperty(ctx, thisRef, propertyNameRef.get())) { 140 slot.setCustom(thisObject, callbackGetter);140 slot.setCustom(thisObject, ReadOnly | DontEnum, callbackGetter); 141 141 return true; 142 142 } … … 152 152 if (exception) { 153 153 throwError(exec, toJS(exec, exception)); 154 slot.setValue(thisObject, jsUndefined());154 slot.setValue(thisObject, ReadOnly | DontEnum, jsUndefined()); 155 155 return true; 156 156 } 157 157 if (value) { 158 slot.setValue(thisObject, toJS(exec, value));158 slot.setValue(thisObject, ReadOnly | DontEnum, toJS(exec, value)); 159 159 return true; 160 160 } … … 165 165 JSValue value = thisObject->getStaticValue(exec, propertyName); 166 166 if (value) { 167 slot.setValue(thisObject, value);167 slot.setValue(thisObject, ReadOnly | DontEnum, value); 168 168 return true; 169 169 } … … 173 173 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { 174 174 if (staticFunctions->contains(name)) { 175 slot.setCustom(thisObject, staticFunctionGetter);175 slot.setCustom(thisObject, ReadOnly | DontEnum, staticFunctionGetter); 176 176 return true; 177 177 } -
trunk/Source/JavaScriptCore/ChangeLog
r154245 r154253 1 2013-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 1 68 2013-08-17 Mark Hahnenberg <mhahnenberg@apple.com> 2 69 -
trunk/Source/JavaScriptCore/runtime/Arguments.cpp
r154113 r154253 95 95 Arguments* thisObject = jsCast<Arguments*>(object); 96 96 if (JSValue value = thisObject->tryGetArgument(i)) { 97 slot.setValue(thisObject, value);97 slot.setValue(thisObject, None, value); 98 98 return true; 99 99 } … … 130 130 if (JSValue value = thisObject->tryGetArgument(i)) { 131 131 RELEASE_ASSERT(i < PropertyName::NotAnIndex); 132 slot.setValue(thisObject, value);132 slot.setValue(thisObject, None, value); 133 133 return true; 134 134 } 135 135 136 136 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)); 138 138 return true; 139 139 } … … 141 141 if (propertyName == exec->propertyNames().callee && LIKELY(!thisObject->m_overrodeCallee)) { 142 142 if (!thisObject->m_isStrictMode) { 143 slot.setValue(thisObject, thisObject->m_callee.get());143 slot.setValue(thisObject, DontEnum, thisObject->m_callee.get()); 144 144 return true; 145 145 } -
trunk/Source/JavaScriptCore/runtime/JSActivation.cpp
r154113 r154253 67 67 return false; 68 68 69 slot.setValue(this, registerAt(entry.getIndex()).get());69 slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get()); 70 70 return true; 71 71 } … … 158 158 // Defend against the inspector asking for the arguments object after it has been optimized out. 159 159 if (!thisObject->isTornOff()) { 160 slot.setCustom(thisObject, thisObject->getArgumentsGetter());160 slot.setCustom(thisObject, DontEnum, thisObject->getArgumentsGetter()); 161 161 return true; 162 162 } … … 166 166 return true; 167 167 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); 170 171 return true; 171 172 } -
trunk/Source/JavaScriptCore/runtime/JSArray.cpp
r154113 r154253 182 182 JSArray* thisObject = jsCast<JSArray*>(object); 183 183 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())); 185 186 return true; 186 187 } -
trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp
r154127 r154253 72 72 73 73 if (propertyName == exec->propertyNames().byteLength) { 74 slot.setValue(thisObject, jsNumber(thisObject->impl()->byteLength()));74 slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->impl()->byteLength())); 75 75 return true; 76 76 } -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp
r154127 r154253 126 126 JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(object); 127 127 if (propertyName == exec->propertyNames().byteOffset) { 128 slot.setValue(thisObject, jsNumber(thisObject->byteOffset()));128 slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->byteOffset())); 129 129 return true; 130 130 } … … 132 132 if (propertyName == exec->propertyNames().buffer) { 133 133 slot.setValue( 134 thisObject, exec->vm().m_typedArrayController->toJS(134 thisObject, DontDelete | ReadOnly, exec->vm().m_typedArrayController->toJS( 135 135 exec, thisObject->globalObject(), thisObject->buffer())); 136 136 return true; -
trunk/Source/JavaScriptCore/runtime/JSDataView.cpp
r154127 r154253 89 89 JSDataView* thisObject = jsCast<JSDataView*>(object); 90 90 if (propertyName == exec->propertyNames().byteLength) { 91 slot.setValue(thisObject, jsNumber(thisObject->m_length));91 slot.setValue(thisObject, DontEnum | ReadOnly, jsNumber(thisObject->m_length)); 92 92 return true; 93 93 } -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r154038 r154253 249 249 if (propertyName == exec->propertyNames().prototype) { 250 250 VM& vm = exec->vm(); 251 PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName); 251 unsigned attributes; 252 PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName, attributes); 252 253 if (!isValidOffset(offset)) { 253 254 JSObject* prototype = constructEmptyObject(exec); 254 255 prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum); 255 256 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); 257 258 ASSERT(isValidOffset(offset)); 258 259 } 259 260 260 slot.setValue(thisObject, thisObject->getDirect(offset), offset);261 slot.setValue(thisObject, attributes, thisObject->getDirect(offset), offset); 261 262 } 262 263 … … 271 272 return result; 272 273 } 273 slot.setCacheableCustom(thisObject, argumentsGetter);274 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, argumentsGetter); 274 275 return true; 275 276 } 276 277 277 278 if (propertyName == exec->propertyNames().length) { 278 slot.setCacheableCustom(thisObject, lengthGetter);279 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, lengthGetter); 279 280 return true; 280 281 } 281 282 282 283 if (propertyName == exec->propertyNames().name) { 283 slot.setCacheableCustom(thisObject, nameGetter);284 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, nameGetter); 284 285 return true; 285 286 } … … 295 296 return result; 296 297 } 297 slot.setCacheableCustom(thisObject, callerGetter);298 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter); 298 299 return true; 299 300 } -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r154127 r154253 216 216 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object); 217 217 if (propertyName == exec->propertyNames().length) { 218 slot.setValue(thisObject, jsNumber(thisObject->length()));218 slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->length())); 219 219 return true; 220 220 } 221 221 222 222 if (propertyName == exec->propertyNames().byteLength) { 223 slot.setValue(thisObject, jsNumber(thisObject->byteLength()));223 slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject->byteLength())); 224 224 return true; 225 225 } … … 227 227 unsigned index = propertyName.asIndex(); 228 228 if (index != PropertyName::NotAnIndex && thisObject->canGetIndexQuickly(index)) { 229 slot.setValue(thisObject, thisObject->getIndexQuickly(index));229 slot.setValue(thisObject, DontDelete | ReadOnly, thisObject->getIndexQuickly(index)); 230 230 return true; 231 231 } … … 325 325 return false; 326 326 327 slot.setValue(thisObject, thisObject->getIndexQuickly(propertyName));327 slot.setValue(thisObject, None, thisObject->getIndexQuickly(propertyName)); 328 328 return true; 329 329 } -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r154113 r154253 290 290 JSValue value = butterfly->contiguous()[i].get(); 291 291 if (value) { 292 slot.setValue(thisObject, value);292 slot.setValue(thisObject, None, value); 293 293 return true; 294 294 } … … 304 304 double value = butterfly->contiguousDouble()[i]; 305 305 if (value == value) { 306 slot.setValue(thisObject, JSValue(JSValue::EncodeAsDouble, value));306 slot.setValue(thisObject, None, JSValue(JSValue::EncodeAsDouble, value)); 307 307 return true; 308 308 } … … 319 319 JSValue value = storage->m_vector[i].get(); 320 320 if (value) { 321 slot.setValue(thisObject, value);321 slot.setValue(thisObject, None, value); 322 322 return true; 323 323 } … … 1626 1626 } 1627 1627 1628 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, PropertyOffset offset)1628 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, unsigned attributes, PropertyOffset offset) 1629 1629 { 1630 1630 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); 1636 1636 } 1637 1637 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r154199 r154253 73 73 JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, const String&); 74 74 extern JS_EXPORTDATA const char* StrictModeReadonlyPropertyWriteError; 75 76 // ECMA 262-3 8.6.177 // Property attributes78 enum Attribute {79 None = 0,80 ReadOnly = 1 << 1, // property can be only read, not written81 DontEnum = 1 << 2, // property doesn't appear in (for .. in ..)82 DontDelete = 1 << 3, // property can't be deleted83 Function = 1 << 4, // property is a function - only used by static hashtables84 Accessor = 1 << 5, // property is a getter/setter85 };86 75 87 76 COMPILE_ASSERT(None < FirstInternalAttribute, None_is_below_FirstInternalAttribute); … … 511 500 } 512 501 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 513 510 PropertyOffset getDirectOffset(VM& vm, PropertyName propertyName) 514 511 { 515 512 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); 516 521 checkOffset(offset, structure()->inlineCapacity()); 517 522 return offset; … … 937 942 938 943 bool inlineGetOwnPropertySlot(ExecState*, PropertyName, PropertySlot&); 939 JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, JSValue, PropertyOffset);944 JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, JSValue, unsigned, PropertyOffset); 940 945 941 946 const HashEntry* findPropertyHashEntry(ExecState*, PropertyName) const; … … 1169 1174 ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot) 1170 1175 { 1171 PropertyOffset offset = structure()->get(exec->vm(), propertyName); 1176 unsigned attributes; 1177 JSCell* specific; 1178 PropertyOffset offset = structure()->get(exec->vm(), propertyName, attributes, specific); 1172 1179 if (LIKELY(isValidOffset(offset))) { 1173 1180 JSValue value = getDirect(offset); 1174 1181 if (structure()->hasGetterSetterProperties() && value.isGetterSetter()) 1175 fillGetterPropertySlot(slot, value, offset);1182 fillGetterPropertySlot(slot, value, attributes, offset); 1176 1183 else 1177 slot.setValue(this, value, offset);1184 slot.setValue(this, attributes, value, offset); 1178 1185 return true; 1179 1186 } -
trunk/Source/JavaScriptCore/runtime/JSString.h
r154113 r154253 474 474 { 475 475 if (propertyName == exec->propertyNames().length) { 476 slot.setValue(this, jsNumber(m_length));476 slot.setValue(this, DontEnum | DontDelete | ReadOnly, jsNumber(m_length)); 477 477 return true; 478 478 } … … 481 481 if (i < m_length) { 482 482 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)); 484 484 return true; 485 485 } … … 491 491 { 492 492 if (propertyName < m_length) { 493 slot.setValue(this, getIndex(exec, propertyName));493 slot.setValue(this, DontDelete | ReadOnly, getIndex(exec, propertyName)); 494 494 return true; 495 495 } -
trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.h
r154113 r154253 80 80 SymbolTableEntry::Fast entry = iter->value; 81 81 ASSERT(!entry.isNull()); 82 slot.setValue(object, object->registerAt(entry.getIndex()).get());82 slot.setValue(object, entry.getAttributes(), object->registerAt(entry.getIndex()).get()); 83 83 return true; 84 84 } … … 112 112 SymbolTableEntry::Fast entry = iter->value; 113 113 ASSERT(!entry.isNull()); 114 slot.setValue(object, object->registerAt(entry.getIndex()).get());114 slot.setValue(object, entry.getAttributes(), object->registerAt(entry.getIndex()).get()); 115 115 slotIsWriteable = !entry.isReadOnly(); 116 116 return true; -
trunk/Source/JavaScriptCore/runtime/Lookup.cpp
r148696 r154253 70 70 ASSERT(thisObj->globalObject()); 71 71 ASSERT(entry->attributes() & Function); 72 PropertyOffset offset = thisObj->getDirectOffset(exec->vm(), propertyName); 72 unsigned attributes; 73 PropertyOffset offset = thisObj->getDirectOffset(exec->vm(), propertyName, attributes); 73 74 74 75 if (!isValidOffset(offset)) { … … 81 82 exec, thisObj->globalObject(), propertyName, entry->functionLength(), 82 83 entry->function(), entry->intrinsic(), entry->attributes()); 83 offset = thisObj->getDirectOffset(exec->vm(), propertyName );84 offset = thisObj->getDirectOffset(exec->vm(), propertyName, attributes); 84 85 ASSERT(isValidOffset(offset)); 85 86 } 86 87 87 slot.setValue(thisObj, thisObj->getDirect(offset), offset);88 slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset); 88 89 return true; 89 90 } -
trunk/Source/JavaScriptCore/runtime/Lookup.h
r153673 r154253 252 252 return setUpStaticFunctionSlot(exec, entry, thisObj, propertyName, slot); 253 253 254 slot.setCacheableCustom(thisObj, entry-> propertyGetter());254 slot.setCacheableCustom(thisObj, entry->attributes(), entry->propertyGetter()); 255 255 return true; 256 256 } … … 272 272 } 273 273 274 slot.setCustom(thisObj, entry-> propertyGetter());274 slot.setCustom(thisObj, entry->attributes(), entry->propertyGetter()); 275 275 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 276 276 return true; … … 331 331 ASSERT(!(entry->attributes() & Function)); 332 332 333 slot.setCacheableCustom(thisObj, entry-> propertyGetter());333 slot.setCacheableCustom(thisObj, entry->attributes(), entry->propertyGetter()); 334 334 return true; 335 335 } … … 349 349 ASSERT(!(entry->attributes() & Function)); 350 350 PropertySlot slot(thisObj); 351 slot.setCustom(thisObj, entry-> propertyGetter());351 slot.setCustom(thisObj, entry->attributes(), entry->propertyGetter()); 352 352 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 353 353 return true; -
trunk/Source/JavaScriptCore/runtime/PropertySlot.h
r154113 r154253 33 33 class ExecState; 34 34 class GetterSetter; 35 36 // ECMA 262-3 8.6.1 37 // Property attributes 38 enum 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 }; 35 46 36 47 class PropertySlot { … … 80 91 } 81 92 82 void setValue(JSObject* slotBase, JSValue value)93 void setValue(JSObject* slotBase, unsigned attributes, JSValue value) 83 94 { 84 95 ASSERT(value); 85 96 m_data.value = JSValue::encode(value); 97 m_attributes = attributes; 86 98 87 99 ASSERT(slotBase); … … 91 103 } 92 104 93 void setValue(JSObject* slotBase, JSValue value, PropertyOffset offset)105 void setValue(JSObject* slotBase, unsigned attributes, JSValue value, PropertyOffset offset) 94 106 { 95 107 ASSERT(value); 96 108 m_data.value = JSValue::encode(value); 109 m_attributes = attributes; 97 110 98 111 ASSERT(slotBase); … … 102 115 } 103 116 104 void setValue(JSString*, JSValue value)117 void setValue(JSString*, unsigned attributes, JSValue value) 105 118 { 106 119 ASSERT(value); 107 120 m_data.value = JSValue::encode(value); 121 m_attributes = attributes; 108 122 109 123 m_slotBase = 0; … … 112 126 } 113 127 114 void setCustom(JSObject* slotBase, GetValueFunc getValue)128 void setCustom(JSObject* slotBase, unsigned attributes, GetValueFunc getValue) 115 129 { 116 130 ASSERT(getValue); 117 131 m_data.custom.getValue = getValue; 132 m_attributes = attributes; 118 133 119 134 ASSERT(slotBase); … … 123 138 } 124 139 125 void setCacheableCustom(JSObject* slotBase, GetValueFunc getValue)140 void setCacheableCustom(JSObject* slotBase, unsigned attributes, GetValueFunc getValue) 126 141 { 127 142 ASSERT(getValue); 128 143 m_data.custom.getValue = getValue; 144 m_attributes = attributes; 129 145 130 146 ASSERT(slotBase); … … 134 150 } 135 151 136 void setCustomIndex(JSObject* slotBase, unsigned index, GetIndexValueFunc getIndexValue)152 void setCustomIndex(JSObject* slotBase, unsigned attributes, unsigned index, GetIndexValueFunc getIndexValue) 137 153 { 138 154 ASSERT(getIndexValue); 139 155 m_data.customIndex.getIndexValue = getIndexValue; 140 156 m_data.customIndex.index = index; 157 m_attributes = attributes; 141 158 142 159 ASSERT(slotBase); … … 146 163 } 147 164 148 void setGetterSlot(JSObject* slotBase, GetterSetter* getterSetter)165 void setGetterSlot(JSObject* slotBase, unsigned attributes, GetterSetter* getterSetter) 149 166 { 150 167 ASSERT(getterSetter); 151 168 m_data.getter.getterSetter = getterSetter; 169 m_attributes = attributes; 152 170 153 171 ASSERT(slotBase); … … 157 175 } 158 176 159 void setCacheableGetterSlot(JSObject* slotBase, GetterSetter* getterSetter, PropertyOffset offset)177 void setCacheableGetterSlot(JSObject* slotBase, unsigned attributes, GetterSetter* getterSetter, PropertyOffset offset) 160 178 { 161 179 ASSERT(getterSetter); 162 180 m_data.getter.getterSetter = getterSetter; 181 m_attributes = attributes; 163 182 164 183 ASSERT(slotBase); … … 180 199 JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const; 181 200 201 unsigned m_attributes; 182 202 union { 183 203 EncodedJSValue value; -
trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp
r154038 r154253 94 94 if (propertyName == exec->propertyNames().lastIndex) { 95 95 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()); 97 98 return true; 98 99 } -
trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
r154113 r154253 129 129 130 130 if (LIKELY(!value.isGetterSetter())) { 131 slot.setValue(thisObject, value);131 slot.setValue(thisObject, attributes, value); 132 132 return; 133 133 } 134 134 135 slot.setGetterSlot(thisObject, jsCast<GetterSetter*>(value));135 slot.setGetterSlot(thisObject, attributes, jsCast<GetterSetter*>(value)); 136 136 } 137 137 -
trunk/Source/WebCore/ChangeLog
r154252 r154253 1 2013-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 1 43 2013-08-18 Ryosuke Niwa <rniwa@webkit.org> 2 44 -
trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
r154038 r154253 331 331 332 332 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); 334 334 else 335 slot.setCustomIndex(this, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterCallback);335 slot.setCustomIndex(this, ReadOnly | DontDelete | DontEnum, static_cast<unsigned>(propertyInfo.propertyID), cssPropertyGetterCallback); 336 336 return true; 337 337 } -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r154219 r154253 127 127 entry = s_info.propHashTable(exec)->entry(exec, propertyName); 128 128 if (entry && !(entry->attributes() & JSC::Function) && entry->propertyGetter() == jsDOMWindowClosed) { 129 slot.setCustom(thisObject, entry->propertyGetter());129 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, entry->propertyGetter()); 130 130 return true; 131 131 } 132 132 entry = JSDOMWindowPrototype::info()->propHashTable(exec)->entry(exec, propertyName); 133 133 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>); 135 135 return true; 136 136 } … … 162 162 if (entry->function() == jsDOMWindowPrototypeFunctionBlur) { 163 163 if (!allowsAccess) { 164 slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionBlur, 0>);164 slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionBlur, 0>); 165 165 return true; 166 166 } 167 167 } else if (entry->function() == jsDOMWindowPrototypeFunctionClose) { 168 168 if (!allowsAccess) { 169 slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);169 slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>); 170 170 return true; 171 171 } 172 172 } else if (entry->function() == jsDOMWindowPrototypeFunctionFocus) { 173 173 if (!allowsAccess) { 174 slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionFocus, 0>);174 slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionFocus, 0>); 175 175 return true; 176 176 } 177 177 } else if (entry->function() == jsDOMWindowPrototypeFunctionPostMessage) { 178 178 if (!allowsAccess) { 179 slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionPostMessage, 2>);179 slot.setCustom(thisObject, entry->attributes(), nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionPostMessage, 2>); 180 180 return true; 181 181 } … … 191 191 if (propertyName == exec->propertyNames().toString) { 192 192 if (!allowsAccess) { 193 slot.setCustom(thisObject, objectToStringFunctionGetter);193 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter); 194 194 return true; 195 195 } … … 199 199 entry = JSDOMWindow::info()->propHashTable(exec)->entry(exec, propertyName); 200 200 if (entry) { 201 slot.setCustom(thisObject, entry-> propertyGetter());201 slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); 202 202 return true; 203 203 } … … 209 209 // it the Moz way. 210 210 if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) { 211 slot.setCustom(thisObject, childFrameGetter);211 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter); 212 212 return true; 213 213 } … … 233 233 if (i < thisObject->impl()->frame()->tree()->scopedChildCount()) { 234 234 ASSERT(i != PropertyName::NotAnIndex); 235 slot.setCustomIndex(thisObject, i, indexGetter);235 slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, i, indexGetter); 236 236 return true; 237 237 } … … 248 248 AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName); 249 249 if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) { 250 slot.setCustom(thisObject, namedItemGetter);250 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter); 251 251 return true; 252 252 } … … 286 286 // it the Moz way. 287 287 if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) { 288 slot.setCustom(thisObject, childFrameGetter);288 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter); 289 289 return true; 290 290 } … … 309 309 if (index < thisObject->impl()->frame()->tree()->scopedChildCount()) { 310 310 ASSERT(index != PropertyName::NotAnIndex); 311 slot.setCustomIndex(thisObject, index, indexGetter);311 slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, index, indexGetter); 312 312 return true; 313 313 } … … 324 324 AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName); 325 325 if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) { 326 slot.setCustom(thisObject, namedItemGetter);326 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter); 327 327 return true; 328 328 } … … 353 353 if (entry && (entry->attributes() & JSC::Function) && entry->function() == jsDOMWindowPrototypeFunctionClose) { 354 354 PropertySlot slot(thisObject); 355 slot.setCustom(thisObject, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>);355 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowPrototypeFunctionClose, 0>); 356 356 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 357 357 return true; … … 364 364 if (entry) { 365 365 PropertySlot slot(thisObject); 366 slot.setCustom(thisObject, entry-> propertyGetter());366 slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); 367 367 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 368 368 return true; … … 376 376 if (thisObject->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))) { 377 377 PropertySlot slot(thisObject); 378 slot.setCustom(thisObject, childFrameGetter);378 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter); 379 379 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 380 380 return true; … … 385 385 ASSERT(i != PropertyName::NotAnIndex); 386 386 PropertySlot slot(thisObject); 387 slot.setCustomIndex(thisObject, i, indexGetter);387 slot.setCustomIndex(thisObject, ReadOnly | DontDelete | DontEnum, i, indexGetter); 388 388 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 389 389 return true; … … 396 396 if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) { 397 397 PropertySlot slot(thisObject); 398 slot.setCustom(thisObject, namedItemGetter);398 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter); 399 399 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 400 400 return true; -
trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp
r154038 r154253 71 71 if (entry->attributes() & JSC::Function) { 72 72 if (entry->function() == jsHistoryPrototypeFunctionBack) { 73 slot.setCustom(this, nonCachingStaticBackFunctionGetter);73 slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter); 74 74 return true; 75 75 } else if (entry->function() == jsHistoryPrototypeFunctionForward) { 76 slot.setCustom(this, nonCachingStaticForwardFunctionGetter);76 slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter); 77 77 return true; 78 78 } else if (entry->function() == jsHistoryPrototypeFunctionGo) { 79 slot.setCustom(this, nonCachingStaticGoFunctionGetter);79 slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter); 80 80 return true; 81 81 } … … 84 84 // Allow access to toString() cross-domain, but always Object.toString. 85 85 if (propertyName == exec->propertyNames().toString) { 86 slot.setCustom(this, objectToStringFunctionGetter);86 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter); 87 87 return true; 88 88 } … … 112 112 if (entry->attributes() & JSC::Function) { 113 113 if (entry->function() == jsHistoryPrototypeFunctionBack) { 114 slot.setCustom(this, nonCachingStaticBackFunctionGetter);114 slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter); 115 115 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 116 116 return true; 117 117 } else if (entry->function() == jsHistoryPrototypeFunctionForward) { 118 slot.setCustom(this, nonCachingStaticForwardFunctionGetter);118 slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter); 119 119 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 120 120 return true; 121 121 } else if (entry->function() == jsHistoryPrototypeFunctionGo) { 122 slot.setCustom(this, nonCachingStaticGoFunctionGetter);122 slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter); 123 123 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 124 124 return true; … … 129 129 if (propertyName == exec->propertyNames().toString) { 130 130 PropertySlot slot(this); 131 slot.setCustom(this, objectToStringFunctionGetter);131 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter); 132 132 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 133 133 return true; -
trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp
r154038 r154253 67 67 if (entry && (entry->attributes() & JSC::Function)) { 68 68 if (entry->function() == jsLocationPrototypeFunctionReplace) { 69 slot.setCustom(this, nonCachingStaticReplaceFunctionGetter);69 slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter); 70 70 return true; 71 71 } else if (entry->function() == jsLocationPrototypeFunctionReload) { 72 slot.setCustom(this, nonCachingStaticReloadFunctionGetter);72 slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter); 73 73 return true; 74 74 } else if (entry->function() == jsLocationPrototypeFunctionAssign) { 75 slot.setCustom(this, nonCachingStaticAssignFunctionGetter);75 slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter); 76 76 return true; 77 77 } … … 104 104 if (entry && (entry->attributes() & JSC::Function)) { 105 105 if (entry->function() == jsLocationPrototypeFunctionReplace) { 106 slot.setCustom(this, nonCachingStaticReplaceFunctionGetter);106 slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter); 107 107 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 108 108 return true; 109 109 } else if (entry->function() == jsLocationPrototypeFunctionReload) { 110 slot.setCustom(this, nonCachingStaticReloadFunctionGetter);110 slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter); 111 111 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 112 112 return true; 113 113 } else if (entry->function() == jsLocationPrototypeFunctionAssign) { 114 slot.setCustom(this, nonCachingStaticAssignFunctionGetter);114 slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter); 115 115 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 116 116 return true; -
trunk/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
r153677 r154253 119 119 if (!scriptObject->hasProperty(exec, propertyName)) 120 120 return false; 121 slot.setCustom(element, runtimeObjectPropertyGetter);121 slot.setCustom(element, DontDelete | DontEnum, runtimeObjectPropertyGetter); 122 122 return true; 123 123 } … … 131 131 return false; 132 132 PropertySlot slot(element); 133 slot.setCustom(element, runtimeObjectPropertyGetter);133 slot.setCustom(element, DontDelete | DontEnum, runtimeObjectPropertyGetter); 134 134 // While we don't know what the plugin allows, we do know that we prevent 135 135 // enumeration or deletion of properties, so we mark plugin properties -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r154219 r154253 362 362 push(@getOwnPropertySlotImpl, " const ${namespaceMaybe}HashEntry* entry = getStaticValueSlotEntryWithoutCaching<$className>(exec, propertyName);\n"); 363 363 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"); 365 365 push(@getOwnPropertySlotImpl, " return true;\n"); 366 366 push(@getOwnPropertySlotImpl, " }\n"); … … 382 382 push(@getOwnPropertySlotImpl, " if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n"); 383 383 } 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 } 384 390 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"); 386 392 } else { 387 push(@getOwnPropertySlotImpl, " slot.setCustomIndex(thisObject, index, indexGetter);\n");393 push(@getOwnPropertySlotImpl, " slot.setCustomIndex(thisObject, attributes, index, indexGetter);\n"); 388 394 } 389 395 push(@getOwnPropertySlotImpl, " return true;\n"); … … 393 399 if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) { 394 400 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"); 396 402 push(@getOwnPropertySlotImpl, " return true;\n"); 397 403 push(@getOwnPropertySlotImpl, " }\n"); … … 459 465 push(@getOwnPropertyDescriptorImpl, " if (entry) {\n"); 460 466 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"); 462 468 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());\n"); 463 469 push(@getOwnPropertyDescriptorImpl, " return true;\n"); … … 473 479 push(@getOwnPropertyDescriptorImpl, " unsigned index = propertyName.asIndex();\n"); 474 480 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 } 475 487 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"); 482 489 } else { 483 490 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"); 491 493 } 492 494 push(@getOwnPropertyDescriptorImpl, " return true;\n"); … … 497 499 push(@getOwnPropertyDescriptorImpl, " if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n"); 498 500 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"); 500 502 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);\n"); 501 503 push(@getOwnPropertyDescriptorImpl, " return true;\n"); … … 1935 1937 push(@implContent, " if (index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n"); 1936 1938 } 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 } 1937 1945 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"); 1939 1947 } else { 1940 push(@implContent, " slot.setCustomIndex(thisObject, index, thisObject->indexGetter);\n");1948 push(@implContent, " slot.setCustomIndex(thisObject, attributes, index, thisObject->indexGetter);\n"); 1941 1949 } 1942 1950 push(@implContent, " return true;\n"); … … 1947 1955 &$propertyNameGeneration(); 1948 1956 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"); 1950 1958 push(@implContent, " return true;\n"); 1951 1959 push(@implContent, " }\n"); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
r154038 r154253 138 138 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 139 139 if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) { 140 slot.setCustom(thisObject, thisObject->nameGetter);140 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); 141 141 return true; 142 142 } … … 150 150 if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) { 151 151 PropertySlot slot(thisObject); 152 slot.setCustom(thisObject, nameGetter);152 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter); 153 153 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 154 154 return true; … … 163 163 PropertyName propertyName = Identifier::from(exec, index); 164 164 if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) { 165 slot.setCustom(thisObject, thisObject->nameGetter);165 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); 166 166 return true; 167 167 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
r154038 r154253 148 148 const HashEntry* entry = getStaticValueSlotEntryWithoutCaching<JSTestEventTarget>(exec, propertyName); 149 149 if (entry) { 150 slot.setCustom(thisObject, entry-> propertyGetter());150 slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); 151 151 return true; 152 152 } 153 153 unsigned index = propertyName.asIndex(); 154 154 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); 156 157 return true; 157 158 } 158 159 if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) { 159 slot.setCustom(thisObject, thisObject->nameGetter);160 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); 160 161 return true; 161 162 } … … 170 171 if (entry) { 171 172 PropertySlot slot(thisObject); 172 slot.setCustom(thisObject, entry-> propertyGetter());173 slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); 173 174 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 174 175 return true; … … 176 177 unsigned index = propertyName.asIndex(); 177 178 if (index != PropertyName::NotAnIndex && index < static_cast<TestEventTarget*>(thisObject->impl())->length()) { 179 unsigned attributes = DontDelete | ReadOnly; 178 180 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); 181 183 return true; 182 184 } 183 185 if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) { 184 186 PropertySlot slot(thisObject); 185 slot.setCustom(thisObject, nameGetter);187 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter); 186 188 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 187 189 return true; … … 195 197 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 196 198 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); 198 201 return true; 199 202 } 200 203 PropertyName propertyName = Identifier::from(exec, index); 201 204 if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) { 202 slot.setCustom(thisObject, thisObject->nameGetter);205 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); 203 206 return true; 204 207 } -
trunk/Source/WebCore/bridge/runtime_array.cpp
r154038 r154253 90 90 RuntimeArray* thisObject = jsCast<RuntimeArray*>(object); 91 91 if (propertyName == exec->propertyNames().length) { 92 slot.setCacheableCustom(thisObject, thisObject->lengthGetter);92 slot.setCacheableCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->lengthGetter); 93 93 return true; 94 94 } … … 97 97 if (index < thisObject->getLength()) { 98 98 ASSERT(index != PropertyName::NotAnIndex); 99 slot.setCustomIndex(thisObject, index, thisObject->indexGetter);99 slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, thisObject->indexGetter); 100 100 return true; 101 101 } … … 109 109 if (propertyName == exec->propertyNames().length) { 110 110 PropertySlot slot(thisObject); 111 slot.setCustom(thisObject, lengthGetter);111 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter); 112 112 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 113 113 return true; … … 118 118 ASSERT(index != PropertyName::NotAnIndex); 119 119 PropertySlot slot(thisObject); 120 slot.setCustomIndex(thisObject, index, indexGetter);120 slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, indexGetter); 121 121 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum); 122 122 return true; … … 130 130 RuntimeArray* thisObject = jsCast<RuntimeArray*>(object); 131 131 if (index < thisObject->getLength()) { 132 slot.setCustomIndex(thisObject, index, thisObject->indexGetter);132 slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, thisObject->indexGetter); 133 133 return true; 134 134 } -
trunk/Source/WebCore/bridge/runtime_method.cpp
r154038 r154253 66 66 RuntimeMethod* thisObject = jsCast<RuntimeMethod*>(object); 67 67 if (propertyName == exec->propertyNames().length) { 68 slot.setCacheableCustom(thisObject, thisObject->lengthGetter);68 slot.setCacheableCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->lengthGetter); 69 69 return true; 70 70 } … … 78 78 if (propertyName == exec->propertyNames().length) { 79 79 PropertySlot slot(thisObject); 80 slot.setCustom(thisObject, lengthGetter);80 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter); 81 81 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 82 82 return true; -
trunk/Source/WebCore/bridge/runtime_object.cpp
r154038 r154253 135 135 Field *aField = aClass->fieldNamed(propertyName, instance.get()); 136 136 if (aField) { 137 slot.setCustom(thisObject, thisObject->fieldGetter);137 slot.setCustom(thisObject, DontDelete, thisObject->fieldGetter); 138 138 instance->end(); 139 139 return true; … … 142 142 // that method. 143 143 if (aClass->methodNamed(propertyName, instance.get())) { 144 slot.setCustom(thisObject, thisObject->methodGetter);144 slot.setCustom(thisObject, DontDelete | ReadOnly, thisObject->methodGetter); 145 145 146 146 instance->end(); … … 151 151 // Try a fallback object. 152 152 if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) { 153 slot.setCustom(thisObject, thisObject->fallbackObjectGetter);153 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, thisObject->fallbackObjectGetter); 154 154 instance->end(); 155 155 return true; … … 180 180 if (aField) { 181 181 PropertySlot slot(thisObject); 182 slot.setCustom(thisObject, fieldGetter);182 slot.setCustom(thisObject, DontDelete, fieldGetter); 183 183 instance->end(); 184 184 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete); … … 189 189 if (aClass->methodNamed(propertyName, instance.get())) { 190 190 PropertySlot slot(thisObject); 191 slot.setCustom(thisObject, methodGetter);191 slot.setCustom(thisObject, DontDelete | ReadOnly, methodGetter); 192 192 instance->end(); 193 193 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); … … 199 199 if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) { 200 200 PropertySlot slot(thisObject); 201 slot.setCustom(thisObject, fallbackObjectGetter);201 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, fallbackObjectGetter); 202 202 instance->end(); 203 203 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); -
trunk/Source/WebKit2/ChangeLog
r154251 r154253 1 2013-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 1 17 2013-08-16 Sam Weinig <sam@webkit.org> 2 18 -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp
r154038 r154253 277 277 // First, check if the NPObject has a property with this name. 278 278 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); 280 280 return true; 281 281 } … … 283 283 // Second, check if the NPObject has a method with this name. 284 284 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); 286 286 return true; 287 287 } … … 309 309 if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) { 310 310 PropertySlot slot(thisObject); 311 slot.setCustom(thisObject, propertyGetter);311 slot.setCustom(thisObject, DontDelete, propertyGetter); 312 312 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete); 313 313 return true; … … 317 317 if (thisObject->m_npObject->_class->hasMethod && thisObject->m_npObject->_class->hasMethod(thisObject->m_npObject, npIdentifier)) { 318 318 PropertySlot slot(thisObject); 319 slot.setCustom(thisObject, methodGetter);319 slot.setCustom(thisObject, DontDelete | ReadOnly, methodGetter); 320 320 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); 321 321 return true;
Note:
See TracChangeset
for help on using the changeset viewer.