diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
commit | d6a599dbc9d824a462b2b206316e102bf8136446 (patch) | |
tree | ecb257a5e55b2239d74b90fdad62fccd661cf286 /Source/JavaScriptCore/runtime/Structure.cpp | |
parent | 3ccc3a85f09a83557b391aae380d3bf5f81a2911 (diff) | |
download | qtwebkit-d6a599dbc9d824a462b2b206316e102bf8136446.tar.gz |
Imported WebKit commit 8ff1f22783a32de82fee915abd55bd1b298f2644 (http://svn.webkit.org/repository/webkit/trunk@122325)
New snapshot that should work with the latest Qt build system changes
Diffstat (limited to 'Source/JavaScriptCore/runtime/Structure.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Structure.cpp | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/Source/JavaScriptCore/runtime/Structure.cpp b/Source/JavaScriptCore/runtime/Structure.cpp index 569126147..509ff3d45 100644 --- a/Source/JavaScriptCore/runtime/Structure.cpp +++ b/Source/JavaScriptCore/runtime/Structure.cpp @@ -156,8 +156,8 @@ Structure::Structure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSV , m_prototype(globalData, this, prototype) , m_classInfo(classInfo) , m_transitionWatchpointSet(InitializedWatching) - , m_propertyStorageCapacity(typeInfo.isFinalObject() ? JSFinalObject_inlineStorageCapacity : JSNonFinalObject_inlineStorageCapacity) - , m_offset(noOffset) + , m_outOfLineCapacity(0) + , m_offset(invalidOffset) , m_dictionaryKind(NoneDictionaryKind) , m_isPinnedPropertyTable(false) , m_hasGetterSetterProperties(false) @@ -179,8 +179,8 @@ Structure::Structure(JSGlobalData& globalData) , m_prototype(globalData, this, jsNull()) , m_classInfo(&s_info) , m_transitionWatchpointSet(InitializedWatching) - , m_propertyStorageCapacity(0) - , m_offset(noOffset) + , m_outOfLineCapacity(0) + , m_offset(invalidOffset) , m_dictionaryKind(NoneDictionaryKind) , m_isPinnedPropertyTable(false) , m_hasGetterSetterProperties(false) @@ -200,8 +200,8 @@ Structure::Structure(JSGlobalData& globalData, const Structure* previous) , m_prototype(globalData, this, previous->storedPrototype()) , m_classInfo(previous->m_classInfo) , m_transitionWatchpointSet(InitializedWatching) - , m_propertyStorageCapacity(previous->m_propertyStorageCapacity) - , m_offset(noOffset) + , m_outOfLineCapacity(previous->m_outOfLineCapacity) + , m_offset(invalidOffset) , m_dictionaryKind(previous->m_dictionaryKind) , m_isPinnedPropertyTable(false) , m_hasGetterSetterProperties(previous->m_hasGetterSetterProperties) @@ -239,7 +239,7 @@ void Structure::materializePropertyMap(JSGlobalData& globalData) ASSERT(structure->m_propertyTable); ASSERT(!structure->m_previous); - m_propertyTable = structure->m_propertyTable->copy(globalData, 0, m_offset + 1); + m_propertyTable = structure->m_propertyTable->copy(globalData, 0, numberOfSlotsForLastOffset(m_offset, m_typeInfo.type())); break; } @@ -247,7 +247,7 @@ void Structure::materializePropertyMap(JSGlobalData& globalData) } if (!m_propertyTable) - createPropertyMap(m_offset + 1); + createPropertyMap(numberOfSlotsForLastOffset(m_offset, m_typeInfo.type())); for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) { structure = structures[i]; @@ -256,19 +256,21 @@ void Structure::materializePropertyMap(JSGlobalData& globalData) } } -void Structure::growPropertyStorageCapacity() +inline size_t nextOutOfLineStorageCapacity(size_t currentCapacity) { - if (isUsingInlineStorage()) - m_propertyStorageCapacity = JSObject::baseExternalStorageCapacity; - else - m_propertyStorageCapacity *= 2; + if (!currentCapacity) + return 4; + return currentCapacity * 2; } -size_t Structure::suggestedNewPropertyStorageSize() +void Structure::growOutOfLineCapacity() { - if (isUsingInlineStorage()) - return JSObject::baseExternalStorageCapacity; - return m_propertyStorageCapacity * 2; + m_outOfLineCapacity = nextOutOfLineStorageCapacity(m_outOfLineCapacity); +} + +size_t Structure::suggestedNewOutOfLineStorageCapacity() +{ + return nextOutOfLineStorageCapacity(m_outOfLineCapacity); } void Structure::despecifyDictionaryFunction(JSGlobalData& globalData, PropertyName propertyName) @@ -285,7 +287,7 @@ void Structure::despecifyDictionaryFunction(JSGlobalData& globalData, PropertyNa entry->specificValue.clear(); } -Structure* Structure::addPropertyTransitionToExistingStructure(Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, size_t& offset) +Structure* Structure::addPropertyTransitionToExistingStructure(Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, PropertyOffset& offset) { ASSERT(!structure->isDictionary()); ASSERT(structure->isObject()); @@ -294,7 +296,7 @@ Structure* Structure::addPropertyTransitionToExistingStructure(Structure* struct JSCell* specificValueInPrevious = existingTransition->m_specificValueInPrevious.get(); if (specificValueInPrevious && specificValueInPrevious != specificValue) return 0; - ASSERT(existingTransition->m_offset != noOffset); + validateOffset(existingTransition->m_offset, structure->m_typeInfo.type()); offset = existingTransition->m_offset; return existingTransition; } @@ -302,7 +304,7 @@ Structure* Structure::addPropertyTransitionToExistingStructure(Structure* struct return 0; } -Structure* Structure::addPropertyTransition(JSGlobalData& globalData, Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, size_t& offset) +Structure* Structure::addPropertyTransition(JSGlobalData& globalData, Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, PropertyOffset& offset) { // If we have a specific function, we may have got to this point if there is // already a transition with the correct property name and attributes, but @@ -325,8 +327,8 @@ Structure* Structure::addPropertyTransition(JSGlobalData& globalData, Structure* Structure* transition = toCacheableDictionaryTransition(globalData, structure); ASSERT(structure != transition); offset = transition->putSpecificValue(globalData, propertyName, attributes, specificValue); - if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) - transition->growPropertyStorageCapacity(); + if (transition->outOfLineSize() > transition->outOfLineCapacity()) + transition->growOutOfLineCapacity(); return transition; } @@ -351,15 +353,15 @@ Structure* Structure::addPropertyTransition(JSGlobalData& globalData, Structure* } offset = transition->putSpecificValue(globalData, propertyName, attributes, specificValue); - if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) - transition->growPropertyStorageCapacity(); + if (transition->outOfLineSize() > transition->outOfLineCapacity()) + transition->growOutOfLineCapacity(); transition->m_offset = offset; structure->m_transitionTable.add(globalData, transition); return transition; } -Structure* Structure::removePropertyTransition(JSGlobalData& globalData, Structure* structure, PropertyName propertyName, size_t& offset) +Structure* Structure::removePropertyTransition(JSGlobalData& globalData, Structure* structure, PropertyName propertyName, PropertyOffset& offset) { ASSERT(!structure->isUncacheableDictionary()); @@ -546,18 +548,19 @@ Structure* Structure::flattenDictionaryStructure(JSGlobalData& globalData, JSObj size_t propertyCount = m_propertyTable->size(); Vector<JSValue> values(propertyCount); - + unsigned i = 0; + PropertyOffset firstOffset = firstPropertyOffsetFor(m_typeInfo.type()); PropertyTable::iterator end = m_propertyTable->end(); for (PropertyTable::iterator iter = m_propertyTable->begin(); iter != end; ++iter, ++i) { values[i] = object->getDirectOffset(iter->offset); // Update property table to have the new property offsets - iter->offset = i; + iter->offset = i + firstOffset; } // Copy the original property values into their final locations for (unsigned i = 0; i < propertyCount; i++) - object->putDirectOffset(globalData, i, values[i]); + object->putDirectOffset(globalData, firstOffset + i, values[i]); m_propertyTable->clearDeletedOffsets(); } @@ -566,7 +569,7 @@ Structure* Structure::flattenDictionaryStructure(JSGlobalData& globalData, JSObj return this; } -size_t Structure::addPropertyWithoutTransition(JSGlobalData& globalData, PropertyName propertyName, unsigned attributes, JSCell* specificValue) +PropertyOffset Structure::addPropertyWithoutTransition(JSGlobalData& globalData, PropertyName propertyName, unsigned attributes, JSCell* specificValue) { ASSERT(!m_enumerationCache); @@ -577,13 +580,13 @@ size_t Structure::addPropertyWithoutTransition(JSGlobalData& globalData, Propert pin(); - size_t offset = putSpecificValue(globalData, propertyName, attributes, specificValue); - if (propertyStorageSize() > propertyStorageCapacity()) - growPropertyStorageCapacity(); + PropertyOffset offset = putSpecificValue(globalData, propertyName, attributes, specificValue); + if (outOfLineSize() > outOfLineCapacity()) + growOutOfLineCapacity(); return offset; } -size_t Structure::removePropertyWithoutTransition(JSGlobalData& globalData, PropertyName propertyName) +PropertyOffset Structure::removePropertyWithoutTransition(JSGlobalData& globalData, PropertyName propertyName) { ASSERT(isUncacheableDictionary()); ASSERT(!m_enumerationCache); @@ -591,8 +594,7 @@ size_t Structure::removePropertyWithoutTransition(JSGlobalData& globalData, Prop materializePropertyMapIfNecessaryForPinning(globalData); pin(); - size_t offset = remove(propertyName); - return offset; + return remove(propertyName); } void Structure::pin() @@ -637,20 +639,20 @@ PassOwnPtr<PropertyTable> Structure::copyPropertyTable(JSGlobalData& globalData, PassOwnPtr<PropertyTable> Structure::copyPropertyTableForPinning(JSGlobalData& globalData, Structure* owner) { - return adoptPtr(m_propertyTable ? new PropertyTable(globalData, owner, *m_propertyTable) : new PropertyTable(m_offset == noOffset ? 0 : m_offset)); + return adoptPtr(m_propertyTable ? new PropertyTable(globalData, owner, *m_propertyTable) : new PropertyTable(numberOfSlotsForLastOffset(m_offset, m_typeInfo.type()))); } -size_t Structure::get(JSGlobalData& globalData, PropertyName propertyName, unsigned& attributes, JSCell*& specificValue) +PropertyOffset Structure::get(JSGlobalData& globalData, PropertyName propertyName, unsigned& attributes, JSCell*& specificValue) { ASSERT(structure()->classInfo() == &s_info); materializePropertyMapIfNecessary(globalData); if (!m_propertyTable) - return WTF::notFound; + return invalidOffset; PropertyMapEntry* entry = m_propertyTable->find(propertyName.uid()).first; if (!entry) - return WTF::notFound; + return invalidOffset; attributes = entry->attributes; specificValue = entry->specificValue.get(); @@ -683,9 +685,9 @@ void Structure::despecifyAllFunctions(JSGlobalData& globalData) iter->specificValue.clear(); } -size_t Structure::putSpecificValue(JSGlobalData& globalData, PropertyName propertyName, unsigned attributes, JSCell* specificValue) +PropertyOffset Structure::putSpecificValue(JSGlobalData& globalData, PropertyName propertyName, unsigned attributes, JSCell* specificValue) { - ASSERT(get(globalData, propertyName) == notFound); + ASSERT(!JSC::isValidOffset(get(globalData, propertyName))); checkConsistency(); if (attributes & DontEnum) @@ -696,12 +698,7 @@ size_t Structure::putSpecificValue(JSGlobalData& globalData, PropertyName proper if (!m_propertyTable) createPropertyMap(); - unsigned newOffset; - - if (m_propertyTable->hasDeletedOffset()) - newOffset = m_propertyTable->getDeletedOffset(); - else - newOffset = m_propertyTable->size(); + PropertyOffset newOffset = m_propertyTable->nextOffset(m_typeInfo.type()); m_propertyTable->add(PropertyMapEntry(globalData, this, rep, newOffset, attributes, specificValue)); @@ -709,20 +706,20 @@ size_t Structure::putSpecificValue(JSGlobalData& globalData, PropertyName proper return newOffset; } -size_t Structure::remove(PropertyName propertyName) +PropertyOffset Structure::remove(PropertyName propertyName) { checkConsistency(); StringImpl* rep = propertyName.uid(); if (!m_propertyTable) - return notFound; + return invalidOffset; PropertyTable::find_iterator position = m_propertyTable->find(rep); if (!position.first) - return notFound; + return invalidOffset; - size_t offset = position.first->offset; + PropertyOffset offset = position.first->offset; m_propertyTable->remove(position); m_propertyTable->addDeletedOffset(offset); |