Ignore:
Timestamp:
Jan 11, 2013, 1:33:47 PM (12 years ago)
Author:
[email protected]
Message:

Removed getDirectLocation and offsetForLocation and all their uses
https://bugs.webkit.org/show_bug.cgi?id=106692

Reviewed by Filip Pizlo.

getDirectLocation() and its associated offsetForLocation() relied on
detailed knowledge of the rules of PropertyOffset, JSObject, and
Structure, which is a hard thing to reverse-engineer reliably. Luckily,
it wasn't needed, and all clients either wanted a true value or a
PropertyOffset. So, I refactored accordingly.

  • dfg/DFGOperations.cpp: Renamed putDirectOffset to putDirect, to clarify

that we are not putting an offset.

  • runtime/JSActivation.cpp:

(JSC::JSActivation::getOwnPropertySlot): Get a value instead of a value
pointer, since we never wanted a pointer to begin with.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnPropertySlot): Use a PropertyOffset instead of a pointer,
so we don't have to reverse-engineer the offset from the pointer.

  • runtime/JSObject.cpp:

(JSC::JSObject::put):
(JSC::JSObject::resetInheritorID):
(JSC::JSObject::inheritorID):
(JSC::JSObject::removeDirect):
(JSC::JSObject::fillGetterPropertySlot):
(JSC::JSObject::getOwnPropertyDescriptor): Renamed getDirectOffset and
putDirectOffset, as explaind above. We want to use the name "getDirectOffset"
for when the thing you're getting is the offset.

  • runtime/JSObject.h:

(JSC::JSObject::getDirect):
(JSC::JSObject::getDirectOffset): Changed getDirectLocation to getDirectOffset,
since clients really wants PropertyOffsets and not locations.

(JSObject::offsetForLocation): Removed this function because it was hard
to get right.

(JSC::JSObject::putDirect):
(JSC::JSObject::putDirectUndefined):
(JSC::JSObject::inlineGetOwnPropertySlot):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::putDirectWithoutTransition):

  • runtime/JSScope.cpp:

(JSC::executeResolveOperations):
(JSC::JSScope::resolvePut):

  • runtime/JSValue.cpp:

(JSC::JSValue::putToPrimitive): Updated for renames.

  • runtime/Lookup.cpp:

(JSC::setUpStaticFunctionSlot): Use a PropertyOffset instead of a pointer,
so we don't have to reverse-engineer the offset from the pointer.

  • runtime/Structure.cpp:

(JSC::Structure::flattenDictionaryStructure): Updated for renames.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r134555 r139491  
    219219
    220220    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)) {
    224223            JSObject* prototype = constructEmptyObject(exec, thisObject->globalObject()->emptyObjectStructure());
    225224            prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, thisObject, DontEnum);
    226225            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);
    231231    }
    232232
Note: See TracChangeset for help on using the changeset viewer.