Commit ab08d670 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com
Browse files

Rename/refactor setButterfly/setStructure

https://bugs.webkit.org/show_bug.cgi?id=120138

Reviewed by Geoffrey Garen.

setButterfly becomes setStructureAndButterfly.

Also removed the Butterfly* argument from setStructure and just implicitly
used m_butterfly internally since that's what every single client of setStructure
was doing already.

* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/JSObject.cpp:
(JSC::JSObject::notifyPresenceOfIndexedAccessors):
(JSC::JSObject::createInitialUndecided):
(JSC::JSObject::createInitialInt32):
(JSC::JSObject::createInitialDouble):
(JSC::JSObject::createInitialContiguous):
(JSC::JSObject::createArrayStorage):
(JSC::JSObject::convertUndecidedToInt32):
(JSC::JSObject::convertUndecidedToDouble):
(JSC::JSObject::convertUndecidedToContiguous):
(JSC::JSObject::convertUndecidedToArrayStorage):
(JSC::JSObject::convertInt32ToDouble):
(JSC::JSObject::convertInt32ToContiguous):
(JSC::JSObject::convertInt32ToArrayStorage):
(JSC::JSObject::genericConvertDoubleToContiguous):
(JSC::JSObject::convertDoubleToArrayStorage):
(JSC::JSObject::convertContiguousToArrayStorage):
(JSC::JSObject::switchToSlowPutArrayStorage):
(JSC::JSObject::setPrototype):
(JSC::JSObject::putDirectAccessor):
(JSC::JSObject::seal):
(JSC::JSObject::freeze):
(JSC::JSObject::preventExtensions):
(JSC::JSObject::reifyStaticFunctionsForDelete):
(JSC::JSObject::removeDirect):
* runtime/JSObject.h:
(JSC::JSObject::setStructureAndButterfly):
(JSC::JSObject::setStructure):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::setStructureAndReallocateStorageIfNecessary):
(JSC::JSObject::putDirectWithoutTransition):
* runtime/Structure.cpp:
(JSC::Structure::flattenDictionaryStructure):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154426 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dc3f1794
2013-08-21 Mark Hahnenberg <mhahnenberg@apple.com>
Rename/refactor setButterfly/setStructure
https://bugs.webkit.org/show_bug.cgi?id=120138
Reviewed by Geoffrey Garen.
setButterfly becomes setStructureAndButterfly.
Also removed the Butterfly* argument from setStructure and just implicitly
used m_butterfly internally since that's what every single client of setStructure
was doing already.
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/JSObject.cpp:
(JSC::JSObject::notifyPresenceOfIndexedAccessors):
(JSC::JSObject::createInitialUndecided):
(JSC::JSObject::createInitialInt32):
(JSC::JSObject::createInitialDouble):
(JSC::JSObject::createInitialContiguous):
(JSC::JSObject::createArrayStorage):
(JSC::JSObject::convertUndecidedToInt32):
(JSC::JSObject::convertUndecidedToDouble):
(JSC::JSObject::convertUndecidedToContiguous):
(JSC::JSObject::convertUndecidedToArrayStorage):
(JSC::JSObject::convertInt32ToDouble):
(JSC::JSObject::convertInt32ToContiguous):
(JSC::JSObject::convertInt32ToArrayStorage):
(JSC::JSObject::genericConvertDoubleToContiguous):
(JSC::JSObject::convertDoubleToArrayStorage):
(JSC::JSObject::convertContiguousToArrayStorage):
(JSC::JSObject::switchToSlowPutArrayStorage):
(JSC::JSObject::setPrototype):
(JSC::JSObject::putDirectAccessor):
(JSC::JSObject::seal):
(JSC::JSObject::freeze):
(JSC::JSObject::preventExtensions):
(JSC::JSObject::reifyStaticFunctionsForDelete):
(JSC::JSObject::removeDirect):
* runtime/JSObject.h:
(JSC::JSObject::setStructureAndButterfly):
(JSC::JSObject::setStructure):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::setStructureAndReallocateStorageIfNecessary):
(JSC::JSObject::putDirectWithoutTransition):
* runtime/Structure.cpp:
(JSC::Structure::flattenDictionaryStructure):
2013-08-21 Gavin Barraclough <barraclough@apple.com>
 
https://bugs.webkit.org/show_bug.cgi?id=120127
......
......@@ -607,7 +607,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_put_by_id_transition_realloc)
JSObject* base = asObject(baseValue);
VM& vm = *stackFrame.vm;
Butterfly* butterfly = base->growOutOfLineStorage(vm, oldSize, newSize);
base->setButterfly(vm, butterfly, newStructure);
base->setStructureAndButterfly(vm, newStructure, butterfly);
return base;
}
......
......@@ -583,7 +583,7 @@ void JSObject::notifyPresenceOfIndexedAccessors(VM& vm)
if (mayInterceptIndexedAccesses())
return;
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AddIndexedAccessors), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AddIndexedAccessors));
if (!vm.prototypeMap.isPrototype(this))
return;
......@@ -611,7 +611,7 @@ Butterfly* JSObject::createInitialUndecided(VM& vm, unsigned length)
{
Butterfly* newButterfly = createInitialIndexedStorage(vm, length, sizeof(EncodedJSValue));
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), AllocateUndecided);
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
return newButterfly;
}
......@@ -619,7 +619,7 @@ ContiguousJSValues JSObject::createInitialInt32(VM& vm, unsigned length)
{
Butterfly* newButterfly = createInitialIndexedStorage(vm, length, sizeof(EncodedJSValue));
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), AllocateInt32);
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
return newButterfly->contiguousInt32();
}
......@@ -629,7 +629,7 @@ ContiguousDoubles JSObject::createInitialDouble(VM& vm, unsigned length)
for (unsigned i = newButterfly->vectorLength(); i--;)
newButterfly->contiguousDouble()[i] = QNaN;
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), AllocateDouble);
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
return newButterfly->contiguousDouble();
}
......@@ -637,7 +637,7 @@ ContiguousJSValues JSObject::createInitialContiguous(VM& vm, unsigned length)
{
Butterfly* newButterfly = createInitialIndexedStorage(vm, length, sizeof(EncodedJSValue));
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), AllocateContiguous);
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
return newButterfly->contiguous();
}
......@@ -657,7 +657,7 @@ ArrayStorage* JSObject::createArrayStorage(VM& vm, unsigned length, unsigned vec
result->m_numValuesInVector = 0;
result->m_indexBias = 0;
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), structure()->suggestedArrayStorageTransition());
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
return result;
}
......@@ -669,7 +669,7 @@ ArrayStorage* JSObject::createInitialArrayStorage(VM& vm)
ContiguousJSValues JSObject::convertUndecidedToInt32(VM& vm)
{
ASSERT(hasUndecided(structure()->indexingType()));
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateInt32), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateInt32));
return m_butterfly->contiguousInt32();
}
......@@ -680,14 +680,14 @@ ContiguousDoubles JSObject::convertUndecidedToDouble(VM& vm)
for (unsigned i = m_butterfly->vectorLength(); i--;)
m_butterfly->contiguousDouble()[i] = QNaN;
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble));
return m_butterfly->contiguousDouble();
}
ContiguousJSValues JSObject::convertUndecidedToContiguous(VM& vm)
{
ASSERT(hasUndecided(structure()->indexingType()));
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous));
return m_butterfly->contiguous();
}
......@@ -723,7 +723,7 @@ ArrayStorage* JSObject::convertUndecidedToArrayStorage(VM& vm, NonPropertyTransi
// No need to copy elements.
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), transition);
setButterfly(vm, storage->butterfly(), newStructure);
setStructureAndButterfly(vm, newStructure, storage->butterfly());
return storage;
}
......@@ -753,7 +753,7 @@ ContiguousDoubles JSObject::convertInt32ToDouble(VM& vm)
*currentAsDouble = v.asInt32();
}
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateDouble));
return m_butterfly->contiguousDouble();
}
......@@ -761,7 +761,7 @@ ContiguousJSValues JSObject::convertInt32ToContiguous(VM& vm)
{
ASSERT(hasInt32(structure()->indexingType()));
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous));
return m_butterfly->contiguous();
}
......@@ -779,7 +779,7 @@ ArrayStorage* JSObject::convertInt32ToArrayStorage(VM& vm, NonPropertyTransition
}
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), transition);
setButterfly(vm, newStorage->butterfly(), newStructure);
setStructureAndButterfly(vm, newStructure, newStorage->butterfly());
return newStorage;
}
......@@ -819,7 +819,7 @@ ContiguousJSValues JSObject::genericConvertDoubleToContiguous(VM& vm)
currentAsValue->setWithoutWriteBarrier(v);
}
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous), m_butterfly);
setStructure(vm, Structure::nonPropertyTransition(vm, structure(), AllocateContiguous));
return m_butterfly->contiguous();
}
......@@ -847,7 +847,7 @@ ArrayStorage* JSObject::convertDoubleToArrayStorage(VM& vm, NonPropertyTransitio
}
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), transition);
setButterfly(vm, newStorage->butterfly(), newStructure);
setStructureAndButterfly(vm, newStructure, newStorage->butterfly());
return newStorage;
}
......@@ -875,7 +875,7 @@ ArrayStorage* JSObject::convertContiguousToArrayStorage(VM& vm, NonPropertyTrans
}
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), transition);
setButterfly(vm, newStorage->butterfly(), newStructure);
setStructureAndButterfly(vm, newStructure, newStorage->butterfly());
return newStorage;
}
......@@ -1117,7 +1117,7 @@ void JSObject::switchToSlowPutArrayStorage(VM& vm)
case NonArrayWithArrayStorage:
case ArrayWithArrayStorage: {
Structure* newStructure = Structure::nonPropertyTransition(vm, structure(), SwitchToSlowPutArrayStorage);
setStructure(vm, newStructure, m_butterfly);
setStructure(vm, newStructure);
break;
}
......@@ -1141,7 +1141,7 @@ void JSObject::setPrototype(VM& vm, JSValue prototype)
vm.prototypeMap.addPrototype(asObject(prototype));
Structure* newStructure = Structure::changePrototypeTransition(vm, structure(), prototype);
setStructure(vm, newStructure, m_butterfly);
setStructure(vm, newStructure);
if (!newStructure->anyObjectInChainMayInterceptIndexedAccesses())
return;
......@@ -1198,7 +1198,7 @@ void JSObject::putDirectAccessor(ExecState* exec, PropertyName propertyName, JSV
// getters and setters, though, we also need to change our Structure
// if we override an existing non-getter or non-setter.
if (slot.type() != PutPropertySlot::NewProperty)
setStructure(vm, Structure::attributeChangeTransition(vm, structure(), propertyName, attributes), m_butterfly);
setStructure(vm, Structure::attributeChangeTransition(vm, structure(), propertyName, attributes));
if (attributes & ReadOnly)
structure()->setContainsReadOnlyProperties();
......@@ -1547,7 +1547,7 @@ void JSObject::seal(VM& vm)
if (isSealed(vm))
return;
preventExtensions(vm);
setStructure(vm, Structure::sealTransition(vm, structure()), m_butterfly);
setStructure(vm, Structure::sealTransition(vm, structure()));
}
void JSObject::freeze(VM& vm)
......@@ -1555,14 +1555,14 @@ void JSObject::freeze(VM& vm)
if (isFrozen(vm))
return;
preventExtensions(vm);
setStructure(vm, Structure::freezeTransition(vm, structure()), m_butterfly);
setStructure(vm, Structure::freezeTransition(vm, structure()));
}
void JSObject::preventExtensions(VM& vm)
{
enterDictionaryIndexingMode(vm);
if (isExtensible())
setStructure(vm, Structure::preventExtensionsTransition(vm, structure()), m_butterfly);
setStructure(vm, Structure::preventExtensionsTransition(vm, structure()));
}
// This presently will flatten to an uncachable dictionary; this is suitable
......@@ -1580,7 +1580,7 @@ void JSObject::reifyStaticFunctionsForDelete(ExecState* exec)
}
if (!structure()->isUncacheableDictionary())
setStructure(vm, Structure::toUncacheableDictionaryTransition(vm, structure()), m_butterfly);
setStructure(vm, Structure::toUncacheableDictionaryTransition(vm, structure()));
for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
const HashTable* hashTable = info->propHashTable(globalObject()->globalExec());
......@@ -1610,7 +1610,7 @@ bool JSObject::removeDirect(VM& vm, PropertyName propertyName)
return true;
}
setStructure(vm, Structure::removePropertyTransition(vm, structure(), propertyName, offset), m_butterfly);
setStructure(vm, Structure::removePropertyTransition(vm, structure(), propertyName, offset));
if (offset == invalidOffset)
return false;
putDirectUndefined(offset);
......
......@@ -604,10 +604,10 @@ public:
void reifyStaticFunctionsForDelete(ExecState* exec);
JS_EXPORT_PRIVATE Butterfly* growOutOfLineStorage(VM&, size_t oldSize, size_t newSize);
void setButterfly(VM&, Butterfly*, Structure*);
void setButterflyWithoutChangingStructure(Butterfly*); // You probably don't want to call this.
void setStructure(VM&, Structure*, Butterfly* = 0);
void setStructure(VM&, Structure*);
void setStructureAndButterfly(VM&, Structure*, Butterfly*);
void setStructureAndReallocateStorageIfNecessary(VM&, unsigned oldCapacity, Structure*);
void setStructureAndReallocateStorageIfNecessary(VM&, Structure*);
......@@ -1123,12 +1123,17 @@ inline bool JSObject::isErrorInstance() const
return structure()->typeInfo().type() == ErrorInstanceType;
}
inline void JSObject::setButterfly(VM& vm, Butterfly* butterfly, Structure* structure)
inline void JSObject::setStructureAndButterfly(VM& vm, Structure* structure, Butterfly* butterfly)
{
ASSERT(structure);
ASSERT(!butterfly == (!structure->outOfLineCapacity() && !structure->hasIndexingHeader(this)));
setStructure(vm, structure, butterfly);
m_butterfly = butterfly;
setStructure(vm, structure);
}
inline void JSObject::setStructure(VM& vm, Structure* structure)
{
ASSERT(structure);
ASSERT(!m_butterfly == !(structure->outOfLineCapacity() || structure->hasIndexingHeader(this)));
JSCell::setStructure(vm, structure);
}
inline void JSObject::setButterflyWithoutChangingStructure(Butterfly* butterfly)
......@@ -1290,7 +1295,7 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal
if (structure()->putWillGrowOutOfLineStorage())
newButterfly = growOutOfLineStorage(vm, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());
offset = structure()->addPropertyWithoutTransition(vm, propertyName, attributes, specificFunction);
setButterfly(vm, newButterfly, structure());
setStructureAndButterfly(vm, structure(), newButterfly);
validateOffset(offset);
ASSERT(structure()->isValidOffset(offset));
......@@ -1312,7 +1317,7 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal
validateOffset(offset);
ASSERT(structure->isValidOffset(offset));
setButterfly(vm, newButterfly, structure);
setStructureAndButterfly(vm, structure, newButterfly);
putDirect(vm, offset, value);
// This is a new property; transitions with specific values are not currently cachable,
// so leave the slot in an uncachable state.
......@@ -1344,7 +1349,7 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal
return true;
}
// case (2) Despecify, fall through to (3).
setStructure(vm, Structure::despecifyFunctionTransition(vm, structure(), propertyName), m_butterfly);
setStructure(vm, Structure::despecifyFunctionTransition(vm, structure(), propertyName));
}
// case (3) set the slot, do the put, return.
......@@ -1372,24 +1377,18 @@ inline bool JSObject::putDirectInternal(VM& vm, PropertyName propertyName, JSVal
return true;
}
inline void JSObject::setStructure(VM& vm, Structure* structure, Butterfly* butterfly)
{
JSCell::setStructure(vm, structure);
ASSERT_UNUSED(butterfly, !butterfly == !(structure->outOfLineCapacity() || structure->hasIndexingHeader(this)));
}
inline void JSObject::setStructureAndReallocateStorageIfNecessary(VM& vm, unsigned oldCapacity, Structure* newStructure)
{
ASSERT(oldCapacity <= newStructure->outOfLineCapacity());
if (oldCapacity == newStructure->outOfLineCapacity()) {
setStructure(vm, newStructure, m_butterfly);
setStructure(vm, newStructure);
return;
}
Butterfly* newButterfly = growOutOfLineStorage(
vm, oldCapacity, newStructure->outOfLineCapacity());
setButterfly(vm, newButterfly, newStructure);
setStructureAndButterfly(vm, newStructure, newButterfly);
}
inline void JSObject::setStructureAndReallocateStorageIfNecessary(VM& vm, Structure* newStructure)
......@@ -1427,7 +1426,7 @@ inline void JSObject::putDirectWithoutTransition(VM& vm, PropertyName propertyNa
if (structure()->putWillGrowOutOfLineStorage())
newButterfly = growOutOfLineStorage(vm, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());
PropertyOffset offset = structure()->addPropertyWithoutTransition(vm, propertyName, attributes, getCallableObject(value));
setButterfly(vm, newButterfly, structure());
setStructureAndButterfly(vm, structure(), newButterfly);
putDirect(vm, offset, value);
}
......
......@@ -706,7 +706,7 @@ Structure* Structure::flattenDictionaryStructure(VM& vm, JSObject* object)
// If the object had a Butterfly but after flattening/compacting we no longer have need of it,
// we need to zero it out because the collector depends on the Structure to know the size for copying.
if (object->butterfly() && !this->outOfLineCapacity() && !this->hasIndexingHeader(object))
object->setButterfly(vm, 0, this);
object->setStructureAndButterfly(vm, this, 0);
return this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment