Changeset 104886 in webkit
- Timestamp:
- Jan 12, 2012 5:40:22 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r104871 r104886 1 2012-01-12 Gavin Barraclough <barraclough@apple.com> 2 3 Clean up putDirect (part 1) 4 https://bugs.webkit.org/show_bug.cgi?id=76232 5 6 Reviewed by Sam Weinig. 7 8 putDirect has ambiguous semantics, clean these up a bit. 9 10 putDirect generally behaves a bit like a fast defineOwnProperty, but one that 11 always creates the property, with no checking to validate the put it permitted. 12 13 It also encompasses two slightly different behaviors. 14 (1) a fast form of put for JSActivation, which doesn't have to handle searching 15 the prototype chain, getter/setter properties, or the magic __proto__ value. 16 Break this out as a new method, 'putOwnDataProperty'. 17 (2) the version of putDirect on JSValue will also check for overwriting ReadOnly 18 values, in strict mode. This is, however, not so smart on a few level, since 19 it is only called from op_put_by_id with direct set, which is only used with 20 an object as the base, and is only used to put new properties onto objects. 21 22 * dfg/DFGOperations.cpp: 23 * interpreter/Interpreter.cpp: 24 (JSC::Interpreter::privateExecute): 25 * jit/JITStubs.cpp: 26 (JSC::DEFINE_STUB_FUNCTION): 27 * runtime/JSActivation.cpp: 28 (JSC::JSActivation::put): 29 * runtime/JSFunction.cpp: 30 (JSC::JSFunction::getOwnPropertySlot): 31 * runtime/JSObject.h: 32 (JSC::JSObject::putOwnDataProperty): 33 * runtime/JSValue.h: 34 1 35 2012-01-12 Gavin Barraclough <barraclough@apple.com> 2 36 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r104630 r104886 432 432 { 433 433 PutPropertySlot slot(true); 434 JSValue(base).putDirect(exec, *propertyName, JSValue::decode(encodedValue), slot); 434 ASSERT(base->isObject()); 435 asObject(base)->putDirect(exec->globalData(), *propertyName, JSValue::decode(encodedValue), slot); 435 436 } 436 437 … … 438 439 { 439 440 PutPropertySlot slot(false); 440 JSValue(base).putDirect(exec, *propertyName, JSValue::decode(encodedValue), slot); 441 ASSERT(base->isObject()); 442 asObject(base)->putDirect(exec->globalData(), *propertyName, JSValue::decode(encodedValue), slot); 441 443 } 442 444 … … 477 479 { 478 480 JSValue value = JSValue::decode(encodedValue); 479 JSValue baseValue(base);480 481 PutPropertySlot slot(true); 481 482 482 baseValue.putDirect(exec, *propertyName, value, slot); 483 ASSERT(base->isObject()); 484 asObject(base)->putDirect(exec->globalData(), *propertyName, value, slot); 483 485 484 486 StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); 485 487 if (stubInfo.seen) 486 dfgRepatchPutByID(exec, base Value, *propertyName, slot, stubInfo, Direct);488 dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, Direct); 487 489 else 488 490 stubInfo.seen = true; … … 493 495 { 494 496 JSValue value = JSValue::decode(encodedValue); 495 JSValue baseValue(base);496 497 PutPropertySlot slot(false); 497 498 498 baseValue.putDirect(exec, *propertyName, value, slot); 499 ASSERT(base->isObject()); 500 asObject(base)->putDirect(exec->globalData(), *propertyName, value, slot); 499 501 500 502 StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); 501 503 if (stubInfo.seen) 502 dfgRepatchPutByID(exec, base Value, *propertyName, slot, stubInfo, Direct);504 dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, Direct); 503 505 else 504 506 stubInfo.seen = true; -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r104630 r104886 3309 3309 3310 3310 JSValue baseValue = callFrame->r(base).jsValue(); 3311 ASSERT(baseValue.isObject()); 3312 JSObject* baseObject = asObject(baseValue); 3311 3313 Identifier& ident = codeBlock->identifier(property); 3312 3314 PutPropertySlot slot(codeBlock->isStrictMode()); 3313 3315 if (direct) 3314 base Value.putDirect(callFrame, ident, callFrame->r(value).jsValue(), slot);3316 baseObject->putDirect(*globalData, ident, callFrame->r(value).jsValue(), slot); 3315 3317 else 3316 3318 baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot); … … 3427 3429 3428 3430 JSValue baseValue = callFrame->r(base).jsValue(); 3431 ASSERT(baseValue.isObject()); 3432 JSObject* baseObject = asObject(baseValue); 3429 3433 Identifier& ident = codeBlock->identifier(property); 3430 3434 PutPropertySlot slot(codeBlock->isStrictMode()); 3431 3435 if (direct) 3432 base Value.putDirect(callFrame, ident, callFrame->r(value).jsValue(), slot);3436 baseObject->putDirect(*globalData, ident, callFrame->r(value).jsValue(), slot); 3433 3437 else 3434 3438 baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot); -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r104630 r104886 1383 1383 1384 1384 PutPropertySlot slot(stackFrame.callFrame->codeBlock()->isStrictMode()); 1385 stackFrame.args[0].jsValue().putDirect(stackFrame.callFrame, stackFrame.args[1].identifier(), stackFrame.args[2].jsValue(), slot); 1385 JSValue baseValue = stackFrame.args[0].jsValue(); 1386 ASSERT(baseValue.isObject()); 1387 asObject(baseValue)->putDirect(stackFrame.callFrame->globalData(), stackFrame.args[1].identifier(), stackFrame.args[2].jsValue(), slot); 1386 1388 CHECK_FOR_EXCEPTION_AT_END(); 1387 1389 } … … 1428 1430 1429 1431 PutPropertySlot slot(callFrame->codeBlock()->isStrictMode()); 1430 stackFrame.args[0].jsValue().putDirect(callFrame, ident, stackFrame.args[2].jsValue(), slot); 1432 JSValue baseValue = stackFrame.args[0].jsValue(); 1433 ASSERT(baseValue.isObject()); 1434 asObject(baseValue)->putDirect(callFrame->globalData(), ident, stackFrame.args[2].jsValue(), slot); 1431 1435 1432 1436 CodeBlock* codeBlock = stackFrame.callFrame->codeBlock(); … … 1461 1465 1462 1466 PutPropertySlot slot(callFrame->codeBlock()->isStrictMode()); 1463 stackFrame.args[0].jsValue().putDirect(callFrame, ident, stackFrame.args[2].jsValue(), slot); 1467 JSValue baseValue = stackFrame.args[0].jsValue(); 1468 ASSERT(baseValue.isObject()); 1469 asObject(baseValue)->putDirect(callFrame->globalData(), ident, stackFrame.args[2].jsValue(), slot); 1464 1470 1465 1471 CHECK_FOR_EXCEPTION_AT_END(); -
trunk/Source/JavaScriptCore/runtime/JSActivation.cpp
r103697 r104886 185 185 // expose in the activation object. 186 186 ASSERT(!thisObject->hasGetterSetterProperties()); 187 thisObject->put Direct(exec->globalData(), propertyName, value, 0, true, slot);187 thisObject->putOwnDataProperty(exec->globalData(), propertyName, value, slot); 188 188 } 189 189 -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r104784 r104886 205 205 JSObject* prototype = constructEmptyObject(exec, thisObject->globalObject()->emptyObjectStructure()); 206 206 prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, thisObject, DontEnum); 207 PutPropertySlot slot; 208 thisObject->putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum, false, slot); 207 thisObject->putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum); 209 208 location = thisObject->getDirectLocation(exec->globalData(), exec->propertyNames().prototype); 210 209 } -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r104784 r104886 108 108 static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue); 109 109 110 // putWithAttributes is effectively an unchecked vesion of 'defineOwnProperty': 111 // - the prototype chain is not consulted 112 // - accessors are not called. 113 // - attributes will be respected (after the call the property will exist with the given attributes) 110 114 static void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes); 111 115 void putWithAttributes(JSGlobalData*, const Identifier& propertyName, JSValue, unsigned attributes); … … 171 175 bool hasGetterSetterProperties() { return structure()->hasGetterSetterProperties(); } 172 176 173 bool putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, bool checkReadOnly, PutPropertySlot&); 177 // putOwnDataProperty has 'put' like semantics, however this method: 178 // - assumes the object contains no own getter/setter properties. 179 // - provides no special handling for __proto__ 180 // - does not walk the prototype chain (to check for accessors or non-writable properties). 181 // This is used by JSActivation. 182 bool putOwnDataProperty(JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&); 183 174 184 void putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0); 175 185 bool putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&); … … 739 749 } 740 750 741 inline bool JSObject::put Direct(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)751 inline bool JSObject::putOwnDataProperty(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) 742 752 { 743 753 ASSERT(value); 744 754 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 745 746 return putDirectInternal(globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction(value)); 755 ASSERT(!structure()->hasGetterSetterProperties()); 756 757 return putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value)); 747 758 } 748 759 … … 841 852 } 842 853 843 inline void JSValue::putDirect(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)844 {845 ASSERT(isCell() && isObject());846 if (!asObject(asCell())->putDirect(exec->globalData(), propertyName, value, slot) && slot.isStrictMode())847 throwTypeError(exec, StrictModeReadonlyPropertyWriteError);848 }849 850 854 inline void JSValue::put(ExecState* exec, unsigned propertyName, JSValue value) 851 855 { -
trunk/Source/JavaScriptCore/runtime/JSValue.h
r99629 r104886 219 219 JSValue get(ExecState*, unsigned propertyName, PropertySlot&) const; 220 220 void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); 221 void putDirect(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);222 221 void put(ExecState*, unsigned propertyName, JSValue); 223 222
Note: See TracChangeset
for help on using the changeset viewer.