Changeset 139491 in webkit
- Timestamp:
- Jan 11, 2013, 1:33:47 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r139488 r139491 1 2013-01-11 Geoffrey Garen <ggaren@apple.com> 2 3 Removed getDirectLocation and offsetForLocation and all their uses 4 https://bugs.webkit.org/show_bug.cgi?id=106692 5 6 Reviewed by Filip Pizlo. 7 8 getDirectLocation() and its associated offsetForLocation() relied on 9 detailed knowledge of the rules of PropertyOffset, JSObject, and 10 Structure, which is a hard thing to reverse-engineer reliably. Luckily, 11 it wasn't needed, and all clients either wanted a true value or a 12 PropertyOffset. So, I refactored accordingly. 13 14 * dfg/DFGOperations.cpp: Renamed putDirectOffset to putDirect, to clarify 15 that we are not putting an offset. 16 17 * runtime/JSActivation.cpp: 18 (JSC::JSActivation::getOwnPropertySlot): Get a value instead of a value 19 pointer, since we never wanted a pointer to begin with. 20 21 * runtime/JSFunction.cpp: 22 (JSC::JSFunction::getOwnPropertySlot): Use a PropertyOffset instead of a pointer, 23 so we don't have to reverse-engineer the offset from the pointer. 24 25 * runtime/JSObject.cpp: 26 (JSC::JSObject::put): 27 (JSC::JSObject::resetInheritorID): 28 (JSC::JSObject::inheritorID): 29 (JSC::JSObject::removeDirect): 30 (JSC::JSObject::fillGetterPropertySlot): 31 (JSC::JSObject::getOwnPropertyDescriptor): Renamed getDirectOffset and 32 putDirectOffset, as explaind above. We want to use the name "getDirectOffset" 33 for when the thing you're getting is the offset. 34 35 * runtime/JSObject.h: 36 (JSC::JSObject::getDirect): 37 (JSC::JSObject::getDirectOffset): Changed getDirectLocation to getDirectOffset, 38 since clients really wants PropertyOffsets and not locations. 39 40 (JSObject::offsetForLocation): Removed this function because it was hard 41 to get right. 42 43 (JSC::JSObject::putDirect): 44 (JSC::JSObject::putDirectUndefined): 45 (JSC::JSObject::inlineGetOwnPropertySlot): 46 (JSC::JSObject::putDirectInternal): 47 (JSC::JSObject::putDirectWithoutTransition): 48 * runtime/JSScope.cpp: 49 (JSC::executeResolveOperations): 50 (JSC::JSScope::resolvePut): 51 * runtime/JSValue.cpp: 52 (JSC::JSValue::putToPrimitive): Updated for renames. 53 54 * runtime/Lookup.cpp: 55 (JSC::setUpStaticFunctionSlot): Use a PropertyOffset instead of a pointer, 56 so we don't have to reverse-engineer the offset from the pointer. 57 58 * runtime/Structure.cpp: 59 (JSC::Structure::flattenDictionaryStructure): Updated for renames. 60 1 61 2013-01-11 Geoffrey Garen <ggaren@apple.com> 2 62 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r139145 r139491 1442 1442 ASSERT(!globalData.heap.storageAllocator().fastPathShouldSucceed(structure->outOfLineCapacity() * sizeof(JSValue))); 1443 1443 base->setStructureAndReallocateStorageIfNecessary(globalData, structure); 1444 base->putDirect Offset(globalData, offset, JSValue::decode(value));1444 base->putDirect(globalData, offset, JSValue::decode(value)); 1445 1445 } 1446 1446 -
trunk/Source/JavaScriptCore/runtime/JSActivation.cpp
r131088 r139491 157 157 return true; 158 158 159 if ( WriteBarrierBase<Unknown>* location = thisObject->getDirectLocation(exec->globalData(), propertyName)) {160 slot.setValue( location->get());159 if (JSValue value = thisObject->getDirect(exec->globalData(), propertyName)) { 160 slot.setValue(value); 161 161 return true; 162 162 } -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r134555 r139491 219 219 220 220 if (propertyName == exec->propertyNames().prototype) { 221 WriteBarrierBase<Unknown>* location = thisObject->getDirectLocation(exec->globalData(), propertyName); 222 223 if (!location) { 221 PropertyOffset offset = thisObject->getDirectOffset(exec->globalData(), propertyName); 222 if (!isValidOffset(offset)) { 224 223 JSObject* prototype = constructEmptyObject(exec, thisObject->globalObject()->emptyObjectStructure()); 225 224 prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, thisObject, DontEnum); 226 225 thisObject->putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum); 227 location = thisObject->getDirectLocation(exec->globalData(), exec->propertyNames().prototype); 228 } 229 230 slot.setValue(thisObject, location->get(), thisObject->offsetForLocation(location)); 226 offset = thisObject->getDirectOffset(exec->globalData(), exec->propertyNames().prototype); 227 ASSERT(isValidOffset(offset)); 228 } 229 230 slot.setValue(thisObject, thisObject->getDirect(offset), offset); 231 231 } 232 232 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r138201 r139491 380 380 } 381 381 382 JSValue gs = obj->getDirect Offset(offset);382 JSValue gs = obj->getDirect(offset); 383 383 if (gs.isGetterSetter()) { 384 384 ASSERT(attributes & Accessor); … … 1194 1194 return; 1195 1195 1196 putDirect Offset(globalData, offset, jsUndefined());1196 putDirect(globalData, offset, jsUndefined()); 1197 1197 } 1198 1198 1199 1199 Structure* JSObject::inheritorID(JSGlobalData& globalData) 1200 1200 { 1201 if (WriteBarrierBase<Unknown>* location = getDirectLocation(globalData, globalData.m_inheritorIDKey)) { 1202 JSValue value = location->get(); 1201 if (JSValue value = getDirect(globalData, globalData.m_inheritorIDKey)) { 1203 1202 if (value.isCell()) { 1204 1203 Structure* inheritorID = jsCast<Structure*>(value); … … 1643 1642 if (offset == invalidOffset) 1644 1643 return false; 1645 put UndefinedAtDirectOffset(offset);1644 putDirectUndefined(offset); 1646 1645 return true; 1647 1646 } … … 1650 1649 if (offset == invalidOffset) 1651 1650 return false; 1652 put UndefinedAtDirectOffset(offset);1651 putDirectUndefined(offset); 1653 1652 return true; 1654 1653 } … … 1656 1655 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, PropertyOffset offset) 1657 1656 { 1658 if (JSObject* getterFunction = asGetterSetter(getDirect Offset(offset))->getter()) {1657 if (JSObject* getterFunction = asGetterSetter(getDirect(offset))->getter()) { 1659 1658 if (!structure()->isDictionary()) 1660 1659 slot.setCacheableGetterSlot(this, getterFunction, offset); … … 2429 2428 PropertyOffset offset = object->structure()->get(exec->globalData(), propertyName, attributes, cell); 2430 2429 if (isValidOffset(offset)) { 2431 descriptor.setDescriptor(object->getDirect Offset(offset), attributes);2430 descriptor.setDescriptor(object->getDirect(offset), attributes); 2432 2431 return true; 2433 2432 } -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r139488 r139491 506 506 PropertyOffset offset = structure()->get(globalData, propertyName); 507 507 checkOffset(offset, structure()->inlineCapacity()); 508 return offset != invalidOffset ? getDirect Offset(offset) : JSValue();509 } 510 511 WriteBarrierBase<Unknown>* getDirectLocation(JSGlobalData& globalData, PropertyName propertyName)508 return offset != invalidOffset ? getDirect(offset) : JSValue(); 509 } 510 511 PropertyOffset getDirectOffset(JSGlobalData& globalData, PropertyName propertyName) 512 512 { 513 513 PropertyOffset offset = structure()->get(globalData, propertyName); 514 514 checkOffset(offset, structure()->inlineCapacity()); 515 return isValidOffset(offset) ? locationForOffset(offset) : 0;515 return offset; 516 516 } 517 517 … … 554 554 return &inlineStorage()[offsetInInlineStorage(offset)]; 555 555 return &outOfLineStorage()[offsetInOutOfLineStorage(offset)]; 556 }557 558 PropertyOffset offsetForLocation(WriteBarrierBase<Unknown>* location) const559 {560 PropertyOffset result;561 size_t offsetInInlineStorage = location - inlineStorageUnsafe();562 if (offsetInInlineStorage < static_cast<size_t>(firstOutOfLineOffset))563 result = offsetInInlineStorage;564 else565 result = outOfLineStorage() - location + (firstOutOfLineOffset - 1);566 validateOffset(result, structure()->inlineCapacity());567 return result;568 556 } 569 557 … … 582 570 583 571 // Fast access to known property offsets. 584 JSValue getDirect Offset(PropertyOffset offset) const { return locationForOffset(offset)->get(); }585 void putDirect Offset(JSGlobalData& globalData, PropertyOffset offset, JSValue value) { locationForOffset(offset)->set(globalData, this, value); }586 void put UndefinedAtDirectOffset(PropertyOffset offset) { locationForOffset(offset)->setUndefined(); }572 JSValue getDirect(PropertyOffset offset) const { return locationForOffset(offset)->get(); } 573 void putDirect(JSGlobalData& globalData, PropertyOffset offset, JSValue value) { locationForOffset(offset)->set(globalData, this, value); } 574 void putDirectUndefined(PropertyOffset offset) { locationForOffset(offset)->setUndefined(); } 587 575 588 576 JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool shouldThrow); … … 1190 1178 PropertyOffset offset = structure()->get(exec->globalData(), propertyName); 1191 1179 if (LIKELY(isValidOffset(offset))) { 1192 JSValue value = getDirect Offset(offset);1180 JSValue value = getDirect(offset); 1193 1181 if (structure()->hasGetterSetterProperties() && value.isGetterSetter()) 1194 1182 fillGetterPropertySlot(slot, offset); … … 1298 1286 return false; 1299 1287 1300 putDirect Offset(globalData, offset, value);1288 putDirect(globalData, offset, value); 1301 1289 // At this point, the objects structure only has a specific value set if previously there 1302 1290 // had been one set, and if the new value being specified is the same (otherwise we would … … 1321 1309 validateOffset(offset); 1322 1310 ASSERT(structure()->isValidOffset(offset)); 1323 putDirect Offset(globalData, offset, value);1311 putDirect(globalData, offset, value); 1324 1312 // See comment on setNewProperty call below. 1325 1313 if (!specificFunction) … … 1340 1328 ASSERT(structure->isValidOffset(offset)); 1341 1329 setButterfly(globalData, newButterfly, structure); 1342 putDirect Offset(globalData, offset, value);1330 putDirect(globalData, offset, value); 1343 1331 // This is a new property; transitions with specific values are not currently cachable, 1344 1332 // so leave the slot in an uncachable state. … … 1367 1355 // case (1) Do the put, then return leaving the slot uncachable. 1368 1356 if (specificFunction == currentSpecificFunction) { 1369 putDirect Offset(globalData, offset, value);1357 putDirect(globalData, offset, value); 1370 1358 return true; 1371 1359 } … … 1376 1364 // case (3) set the slot, do the put, return. 1377 1365 slot.setExistingProperty(this, offset); 1378 putDirect Offset(globalData, offset, value);1366 putDirect(globalData, offset, value); 1379 1367 return true; 1380 1368 } … … 1389 1377 setStructureAndReallocateStorageIfNecessary(globalData, structure); 1390 1378 1391 putDirect Offset(globalData, offset, value);1379 putDirect(globalData, offset, value); 1392 1380 // This is a new property; transitions with specific values are not currently cachable, 1393 1381 // so leave the slot in an uncachable state. … … 1449 1437 PropertyOffset offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, getCallableObject(value)); 1450 1438 setButterfly(globalData, newButterfly, structure()); 1451 putDirect Offset(globalData, offset, value);1439 putDirect(globalData, offset, value); 1452 1440 } 1453 1441 -
trunk/Source/JavaScriptCore/runtime/JSScope.cpp
r132546 r139491 167 167 JSGlobalObject* globalObject = scope->globalObject(); 168 168 if (globalObject->structure() == pc->m_structure.get()) { 169 result.setValue(globalObject->getDirect Offset(pc->m_offset));169 result.setValue(globalObject->getDirect(pc->m_offset)); 170 170 return true; 171 171 } … … 582 582 if (operation->m_structure.get() != object->structure()) 583 583 break; 584 object->putDirect Offset(callFrame->globalData(), operation->m_offset, value);584 object->putDirect(callFrame->globalData(), operation->m_offset, value); 585 585 return; 586 586 } -
trunk/Source/JavaScriptCore/runtime/JSValue.cpp
r139145 r139491 145 145 } 146 146 147 JSValue gs = obj->getDirect Offset(offset);147 JSValue gs = obj->getDirect(offset); 148 148 if (gs.isGetterSetter()) { 149 149 JSObject* setterFunc = asGetterSetter(gs)->setter(); -
trunk/Source/JavaScriptCore/runtime/Lookup.cpp
r117859 r139491 69 69 ASSERT(thisObj->globalObject()); 70 70 ASSERT(entry->attributes() & Function); 71 WriteBarrierBase<Unknown>* location = thisObj->getDirectLocation(exec->globalData(), propertyName);71 PropertyOffset offset = thisObj->getDirectOffset(exec->globalData(), propertyName); 72 72 73 if (! location) {73 if (!isValidOffset(offset)) { 74 74 // If a property is ever deleted from an object with a static table, then we reify 75 75 // all static functions at that time - after this we shouldn't be re-adding anything. … … 82 82 JSFunction* function = JSFunction::create(exec, thisObj->globalObject(), entry->functionLength(), name, entry->function(), entry->intrinsic()); 83 83 thisObj->putDirect(exec->globalData(), propertyName, function, entry->attributes()); 84 location = thisObj->getDirectLocation(exec->globalData(), propertyName); 84 offset = thisObj->getDirectOffset(exec->globalData(), propertyName); 85 ASSERT(isValidOffset(offset)); 85 86 } 86 87 87 slot.setValue(thisObj, location->get(), thisObj->offsetForLocation(location));88 slot.setValue(thisObj, thisObj->getDirect(offset), offset); 88 89 return true; 89 90 } -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r139482 r139491 635 635 PropertyTable::iterator end = m_propertyTable->end(); 636 636 for (PropertyTable::iterator iter = m_propertyTable->begin(); iter != end; ++iter, ++i) { 637 values[i] = object->getDirect Offset(iter->offset);637 values[i] = object->getDirect(iter->offset); 638 638 iter->offset = offsetForPropertyNumber(i, m_inlineCapacity); 639 639 } … … 641 641 // Copies in our values to their compacted locations. 642 642 for (unsigned i = 0; i < propertyCount; i++) 643 object->putDirect Offset(globalData, offsetForPropertyNumber(i, m_inlineCapacity), values[i]);643 object->putDirect(globalData, offsetForPropertyNumber(i, m_inlineCapacity), values[i]); 644 644 645 645 m_propertyTable->clearDeletedOffsets();
Note:
See TracChangeset
for help on using the changeset viewer.