[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
eric at webkit.org
eric at webkit.org
Wed Dec 22 11:49:12 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 29a10d7c251db77f758e72b5254f057cf8912dbe
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Aug 8 05:29:38 2010 +0000
2010-08-07 Michael Saboff <msaboff at apple.com>
Reviewed by Geoffrey Garen.
Revert JSArray to point to the beginning of the contained ArrayStorage
struct. This is described in
https://bugs.webkit.org/show_bug.cgi?id=43526.
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emit_op_put_by_val):
(JSC::JIT::privateCompilePatchGetArrayLength):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emit_op_put_by_val):
(JSC::JIT::privateCompilePatchGetArrayLength):
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
(JSC::JSArray::~JSArray):
(JSC::JSArray::getOwnPropertySlot):
(JSC::JSArray::getOwnPropertyDescriptor):
(JSC::JSArray::put):
(JSC::JSArray::putSlowCase):
(JSC::JSArray::deleteProperty):
(JSC::JSArray::getOwnPropertyNames):
(JSC::JSArray::getNewVectorLength):
(JSC::JSArray::increaseVectorLength):
(JSC::JSArray::increaseVectorPrefixLength):
(JSC::JSArray::setLength):
(JSC::JSArray::pop):
(JSC::JSArray::push):
(JSC::JSArray::shiftCount):
(JSC::JSArray::unshiftCount):
(JSC::JSArray::sortNumeric):
(JSC::JSArray::sort):
(JSC::JSArray::fillArgList):
(JSC::JSArray::copyToRegisters):
(JSC::JSArray::compactForSorting):
(JSC::JSArray::subclassData):
(JSC::JSArray::setSubclassData):
(JSC::JSArray::checkConsistency):
* runtime/JSArray.h:
(JSC::JSArray::length):
(JSC::JSArray::canGetIndex):
(JSC::JSArray::getIndex):
(JSC::JSArray::setIndex):
(JSC::JSArray::uncheckedSetIndex):
(JSC::JSArray::markChildrenDirect):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6bea3a4..321a2f1 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-08-07 Michael Saboff <msaboff at apple.com>
+
+ Reviewed by Geoffrey Garen.
+
+ Revert JSArray to point to the beginning of the contained ArrayStorage
+ struct. This is described in
+ https://bugs.webkit.org/show_bug.cgi?id=43526.
+
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::emit_op_get_by_val):
+ (JSC::JIT::emit_op_put_by_val):
+ (JSC::JIT::privateCompilePatchGetArrayLength):
+ * jit/JITPropertyAccess32_64.cpp:
+ (JSC::JIT::emit_op_get_by_val):
+ (JSC::JIT::emit_op_put_by_val):
+ (JSC::JIT::privateCompilePatchGetArrayLength):
+ * runtime/JSArray.cpp:
+ (JSC::JSArray::JSArray):
+ (JSC::JSArray::~JSArray):
+ (JSC::JSArray::getOwnPropertySlot):
+ (JSC::JSArray::getOwnPropertyDescriptor):
+ (JSC::JSArray::put):
+ (JSC::JSArray::putSlowCase):
+ (JSC::JSArray::deleteProperty):
+ (JSC::JSArray::getOwnPropertyNames):
+ (JSC::JSArray::getNewVectorLength):
+ (JSC::JSArray::increaseVectorLength):
+ (JSC::JSArray::increaseVectorPrefixLength):
+ (JSC::JSArray::setLength):
+ (JSC::JSArray::pop):
+ (JSC::JSArray::push):
+ (JSC::JSArray::shiftCount):
+ (JSC::JSArray::unshiftCount):
+ (JSC::JSArray::sortNumeric):
+ (JSC::JSArray::sort):
+ (JSC::JSArray::fillArgList):
+ (JSC::JSArray::copyToRegisters):
+ (JSC::JSArray::compactForSorting):
+ (JSC::JSArray::subclassData):
+ (JSC::JSArray::setSubclassData):
+ (JSC::JSArray::checkConsistency):
+ * runtime/JSArray.h:
+ (JSC::JSArray::length):
+ (JSC::JSArray::canGetIndex):
+ (JSC::JSArray::getIndex):
+ (JSC::JSArray::setIndex):
+ (JSC::JSArray::uncheckedSetIndex):
+ (JSC::JSArray::markChildrenDirect):
+
2010-08-07 Kwang Yul Seo <skyul at company100.net>
Reviewed by Eric Seidel.
diff --git a/JavaScriptCore/jit/JITPropertyAccess.cpp b/JavaScriptCore/jit/JITPropertyAccess.cpp
index 95b9980..540e079 100644
--- a/JavaScriptCore/jit/JITPropertyAccess.cpp
+++ b/JavaScriptCore/jit/JITPropertyAccess.cpp
@@ -106,10 +106,10 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction)
emitJumpSlowCaseIfNotJSCell(regT0, base);
addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr)));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT2);
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT2);
addSlowCase(branch32(AboveOrEqual, regT1, Address(regT0, OBJECT_OFFSETOF(JSArray, m_vectorLength))));
- loadPtr(BaseIndex(regT2, regT1, ScalePtr), regT0);
+ loadPtr(BaseIndex(regT2, regT1, ScalePtr, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])), regT0);
addSlowCase(branchTestPtr(Zero, regT0));
emitPutVirtualRegister(dst);
@@ -217,21 +217,21 @@ void JIT::emit_op_put_by_val(Instruction* currentInstruction)
addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr)));
addSlowCase(branch32(AboveOrEqual, regT1, Address(regT0, OBJECT_OFFSETOF(JSArray, m_vectorLength))));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT2);
- Jump empty = branchTestPtr(Zero, BaseIndex(regT2, regT1, ScalePtr));
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT2);
+ Jump empty = branchTestPtr(Zero, BaseIndex(regT2, regT1, ScalePtr, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
Label storeResult(this);
emitGetVirtualRegister(value, regT0);
- storePtr(regT0, BaseIndex(regT2, regT1, ScalePtr));
+ storePtr(regT0, BaseIndex(regT2, regT1, ScalePtr, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
Jump end = jump();
empty.link(this);
- add32(Imm32(1), Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_numValuesInVector)-OBJECT_OFFSETOF(ArrayStorage, m_vector)));
- branch32(Below, regT1, Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector))).linkTo(storeResult, this);
+ add32(Imm32(1), Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_numValuesInVector)));
+ branch32(Below, regT1, Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length))).linkTo(storeResult, this);
move(regT1, regT0);
add32(Imm32(1), regT0);
- store32(regT0, Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector)));
+ store32(regT0, Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length)));
jump().linkTo(storeResult, this);
end.link(this);
@@ -736,8 +736,8 @@ bool JIT::privateCompilePatchGetArrayLength(StructureStubInfo* stubInfo, ReturnA
Jump failureCases1 = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr));
// Checks out okay! - get the length from the storage
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT3);
- load32(Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector)), regT2);
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT3);
+ load32(Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length)), regT2);
Jump failureCases2 = branch32(Above, regT2, Imm32(JSImmediate::maxImmediateInt));
emitFastArithIntToImmNoCheck(regT2, regT0);
diff --git a/JavaScriptCore/jit/JITPropertyAccess32_64.cpp b/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
index 8ec8bf7..bbffd7d 100644
--- a/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
+++ b/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
@@ -314,11 +314,11 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction)
emitJumpSlowCaseIfNotJSCell(base, regT1);
addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr)));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT3);
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT3);
addSlowCase(branch32(AboveOrEqual, regT2, Address(regT0, OBJECT_OFFSETOF(JSArray, m_vectorLength))));
- load32(BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag)), regT1); // tag
- load32(BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT0); // payload
+ load32(BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0]) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), regT1); // tag
+ load32(BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0]) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT0); // payload
addSlowCase(branch32(Equal, regT1, Imm32(JSValue::EmptyValueTag)));
emitStore(dst, regT1, regT0);
@@ -367,22 +367,22 @@ void JIT::emit_op_put_by_val(Instruction* currentInstruction)
addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr)));
addSlowCase(branch32(AboveOrEqual, regT2, Address(regT0, OBJECT_OFFSETOF(JSArray, m_vectorLength))));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT3);
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT3);
- Jump empty = branch32(Equal, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag)), Imm32(JSValue::EmptyValueTag));
+ Jump empty = branch32(Equal, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0]) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), Imm32(JSValue::EmptyValueTag));
Label storeResult(this);
emitLoad(value, regT1, regT0);
- store32(regT0, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload))); // payload
- store32(regT1, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag))); // tag
+ store32(regT0, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0]) + OBJECT_OFFSETOF(JSValue, u.asBits.payload))); // payload
+ store32(regT1, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0]) + OBJECT_OFFSETOF(JSValue, u.asBits.tag))); // tag
Jump end = jump();
empty.link(this);
- add32(Imm32(1), Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_numValuesInVector)-OBJECT_OFFSETOF(ArrayStorage, m_vector)));
- branch32(Below, regT2, Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector))).linkTo(storeResult, this);
+ add32(Imm32(1), Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_numValuesInVector)));
+ branch32(Below, regT2, Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length))).linkTo(storeResult, this);
add32(Imm32(1), regT2, regT0);
- store32(regT0, Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector)));
+ store32(regT0, Address(regT3, OBJECT_OFFSETOF(ArrayStorage, m_length)));
jump().linkTo(storeResult, this);
end.link(this);
@@ -744,8 +744,8 @@ bool JIT::privateCompilePatchGetArrayLength(StructureStubInfo* stubInfo, ReturnA
Jump failureCases1 = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsArrayVPtr));
// Checks out okay! - get the length from the storage
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_vector)), regT2);
- load32(Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length)-OBJECT_OFFSETOF(ArrayStorage, m_vector)), regT2);
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSArray, m_storage)), regT2);
+ load32(Address(regT2, OBJECT_OFFSETOF(ArrayStorage, m_length)), regT2);
Jump failureCases2 = branch32(Above, regT2, Imm32(INT_MAX));
move(regT2, regT0);
diff --git a/JavaScriptCore/runtime/JSArray.cpp b/JavaScriptCore/runtime/JSArray.cpp
index 98ea37f..0db0a63 100644
--- a/JavaScriptCore/runtime/JSArray.cpp
+++ b/JavaScriptCore/runtime/JSArray.cpp
@@ -131,10 +131,9 @@ JSArray::JSArray(VPtrStealingHackType)
{
unsigned initialCapacity = 0;
- ArrayStorage* storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
- storage->m_allocBase = storage;
+ m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
+ m_storage->m_allocBase = m_storage;
m_indexBias = 0;
- setArrayStorage(storage);
m_vectorLength = initialCapacity;
checkConsistency();
@@ -149,10 +148,9 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure)
{
unsigned initialCapacity = 0;
- ArrayStorage* storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
- storage->m_allocBase = storage;
+ m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
+ m_storage->m_allocBase = m_storage;
m_indexBias = 0;
- setArrayStorage(storage);
m_vectorLength = initialCapacity;
checkConsistency();
@@ -169,29 +167,28 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure, unsigned initialLength,
else
initialCapacity = min(BASE_VECTOR_LEN, MIN_SPARSE_ARRAY_INDEX);
- ArrayStorage* storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
- storage->m_allocBase = storage;
- storage->m_length = initialLength;
+ m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
+ m_storage->m_allocBase = m_storage;
+ m_storage->m_length = initialLength;
m_indexBias = 0;
m_vectorLength = initialCapacity;
- setArrayStorage(storage);
- storage->m_sparseValueMap = 0;
- storage->subclassData = 0;
- storage->reportedMapCapacity = 0;
+ m_storage->m_sparseValueMap = 0;
+ m_storage->subclassData = 0;
+ m_storage->reportedMapCapacity = 0;
if (creationMode == CreateCompact) {
#if CHECK_ARRAY_CONSISTENCY
- storage->m_inCompactInitialization = !!initialCapacity;
+ m_storage->m_inCompactInitialization = !!initialCapacity;
#endif
- storage->m_length = 0;
- storage->m_numValuesInVector = initialCapacity;
+ m_storage->m_length = 0;
+ m_storage->m_numValuesInVector = initialCapacity;
} else {
#if CHECK_ARRAY_CONSISTENCY
storage->m_inCompactInitialization = false;
#endif
- storage->m_length = initialLength;
- storage->m_numValuesInVector = 0;
- JSValue* vector = m_vector;
+ m_storage->m_length = initialLength;
+ m_storage->m_numValuesInVector = 0;
+ JSValue* vector = m_storage->m_vector;
for (size_t i = 0; i < initialCapacity; ++i)
vector[i] = JSValue();
}
@@ -206,22 +203,21 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure, const ArgList& list)
{
unsigned initialCapacity = list.size();
- ArrayStorage* storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
- storage->m_allocBase = storage;
+ m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity)));
+ m_storage->m_allocBase = m_storage;
m_indexBias = 0;
- storage->m_length = initialCapacity;
+ m_storage->m_length = initialCapacity;
m_vectorLength = initialCapacity;
- storage->m_numValuesInVector = initialCapacity;
- storage->m_sparseValueMap = 0;
- storage->subclassData = 0;
- storage->reportedMapCapacity = 0;
+ m_storage->m_numValuesInVector = initialCapacity;
+ m_storage->m_sparseValueMap = 0;
+ m_storage->subclassData = 0;
+ m_storage->reportedMapCapacity = 0;
#if CHECK_ARRAY_CONSISTENCY
- storage->m_inCompactInitialization = false;
+ m_storage->m_inCompactInitialization = false;
#endif
- setArrayStorage(storage);
size_t i = 0;
- JSValue* vector = m_vector;
+ JSValue* vector = m_storage->m_vector;
ArgList::const_iterator end = list.end();
for (ArgList::const_iterator it = list.begin(); it != end; ++it, ++i)
vector[i] = *it;
@@ -236,14 +232,13 @@ JSArray::~JSArray()
ASSERT(vptr() == JSGlobalData::jsArrayVPtr);
checkConsistency(DestructorConsistencyCheck);
- ArrayStorage* storage = arrayStorage();
- delete storage->m_sparseValueMap;
- fastFree(storage->m_allocBase);
+ delete m_storage->m_sparseValueMap;
+ fastFree(m_storage->m_allocBase);
}
bool JSArray::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
if (i >= storage->m_length) {
if (i > MAX_ARRAY_INDEX)
@@ -252,7 +247,7 @@ bool JSArray::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot
}
if (i < m_vectorLength) {
- JSValue& valueSlot = m_vector[i];
+ JSValue& valueSlot = storage->m_vector[i];
if (valueSlot) {
slot.setValueSlot(&valueSlot);
return true;
@@ -292,7 +287,7 @@ bool JSArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& proper
return true;
}
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
bool isArrayIndex;
unsigned i = propertyName.toArrayIndex(&isArrayIndex);
@@ -300,7 +295,7 @@ bool JSArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& proper
if (i >= storage->m_length)
return false;
if (i < m_vectorLength) {
- JSValue& value = m_vector[i];
+ JSValue& value = storage->m_vector[i];
if (value) {
descriptor.setDescriptor(value, 0);
return true;
@@ -345,7 +340,7 @@ void JSArray::put(ExecState* exec, unsigned i, JSValue value)
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned length = storage->m_length;
if (i >= length && i <= MAX_ARRAY_INDEX) {
@@ -354,7 +349,7 @@ void JSArray::put(ExecState* exec, unsigned i, JSValue value)
}
if (i < m_vectorLength) {
- JSValue& valueSlot = m_vector[i];
+ JSValue& valueSlot = storage->m_vector[i];
if (valueSlot) {
valueSlot = value;
checkConsistency();
@@ -371,7 +366,7 @@ void JSArray::put(ExecState* exec, unsigned i, JSValue value)
NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue value)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
SparseArrayValueMap* map = storage->m_sparseValueMap;
@@ -409,8 +404,9 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
// Fast case is when there is no sparse map, so we can increase the vector size without moving values from it.
if (!map || map->isEmpty()) {
if (increaseVectorLength(i + 1)) {
- m_vector[i] = value;
- ++arrayStorage()->m_numValuesInVector;
+ storage = m_storage;
+ storage->m_vector[i] = value;
+ ++storage->m_numValuesInVector;
checkConsistency();
} else
throwOutOfMemoryError(exec);
@@ -445,22 +441,23 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
return;
}
- storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
- storage->m_allocBase = baseStorage;
- setArrayStorage(storage);
+ m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
+ m_storage->m_allocBase = baseStorage;
+ storage = m_storage;
unsigned vectorLength = m_vectorLength;
+ JSValue* vector = storage->m_vector;
if (newNumValuesInVector == storage->m_numValuesInVector + 1) {
for (unsigned j = vectorLength; j < newVectorLength; ++j)
- m_vector[j] = JSValue();
+ vector[j] = JSValue();
if (i > MIN_SPARSE_ARRAY_INDEX)
map->remove(i);
} else {
for (unsigned j = vectorLength; j < max(vectorLength, MIN_SPARSE_ARRAY_INDEX); ++j)
- m_vector[j] = JSValue();
+ vector[j] = JSValue();
for (unsigned j = max(vectorLength, MIN_SPARSE_ARRAY_INDEX); j < newVectorLength; ++j)
- m_vector[j] = map->take(j);
+ vector[j] = map->take(j);
}
ASSERT(i < newVectorLength);
@@ -468,7 +465,7 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
m_vectorLength = newVectorLength;
storage->m_numValuesInVector = newNumValuesInVector;
- m_vector[i] = value;
+ storage->m_vector[i] = value;
checkConsistency();
@@ -492,10 +489,10 @@ bool JSArray::deleteProperty(ExecState* exec, unsigned i)
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
if (i < m_vectorLength) {
- JSValue& valueSlot = m_vector[i];
+ JSValue& valueSlot = storage->m_vector[i];
if (!valueSlot) {
checkConsistency();
return false;
@@ -531,11 +528,11 @@ void JSArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNa
// is incredibly inefficient for large arrays. We need a different approach,
// which almost certainly means a different structure for PropertyNameArray.
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned usedVectorLength = min(storage->m_length, m_vectorLength);
for (unsigned i = 0; i < usedVectorLength; ++i) {
- if (m_vector[i])
+ if (storage->m_vector[i])
propertyNames.add(Identifier::from(exec, i));
}
@@ -556,7 +553,7 @@ ALWAYS_INLINE unsigned JSArray::getNewVectorLength(unsigned desiredLength)
ASSERT(desiredLength <= MAX_STORAGE_VECTOR_LENGTH);
unsigned increasedLength;
- unsigned length = arrayStorage()->m_length;
+ unsigned length = m_storage->m_length;
if (desiredLength < length)
increasedLength = length;
@@ -583,7 +580,7 @@ bool JSArray::increaseVectorLength(unsigned newLength)
// This function leaves the array in an internally inconsistent state, because it does not move any values from sparse value map
// to the vector. Callers have to account for that, because they can do it more efficiently.
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned vectorLength = m_vectorLength;
ASSERT(newLength > vectorLength);
@@ -594,11 +591,10 @@ bool JSArray::increaseVectorLength(unsigned newLength)
if (!tryFastRealloc(baseStorage, storageSize(newVectorLength + m_indexBias)).getValue(baseStorage))
return false;
- storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
- storage->m_allocBase = baseStorage;
- setArrayStorage(storage);
+ storage = m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
+ m_storage->m_allocBase = baseStorage;
- JSValue* vector = m_vector;
+ JSValue* vector = storage->m_vector;
for (unsigned i = vectorLength; i < newVectorLength; ++i)
vector[i] = JSValue();
@@ -614,8 +610,7 @@ bool JSArray::increaseVectorPrefixLength(unsigned newLength)
// This function leaves the array in an internally inconsistent state, because it does not move any values from sparse value map
// to the vector. Callers have to account for that, because they can do it more efficiently.
- ArrayStorage* storage = arrayStorage();
- ArrayStorage* newStorage;
+ ArrayStorage* storage = m_storage;
unsigned vectorLength = m_vectorLength;
ASSERT(newLength > vectorLength);
@@ -628,18 +623,16 @@ bool JSArray::increaseVectorPrefixLength(unsigned newLength)
m_indexBias += newVectorLength - newLength;
- newStorage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue));
+ m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue));
- memcpy(newStorage, storage, storageSize(0));
- memcpy(&newStorage->m_vector[newLength - m_vectorLength], &storage->m_vector[0], vectorLength * sizeof(JSValue));
+ memcpy(m_storage, storage, storageSize(0));
+ memcpy(&m_storage->m_vector[newLength - m_vectorLength], &storage->m_vector[0], vectorLength * sizeof(JSValue));
- newStorage->m_allocBase = newBaseStorage;
+ m_storage->m_allocBase = newBaseStorage;
m_vectorLength = newLength;
fastFree(storage->m_allocBase);
- setArrayStorage(newStorage);
-
Heap::heap(this)->reportExtraMemoryCost(storageSize(newVectorLength) - storageSize(vectorLength));
return true;
@@ -648,21 +641,21 @@ bool JSArray::increaseVectorPrefixLength(unsigned newLength)
void JSArray::setLength(unsigned newLength)
{
+ ArrayStorage* storage = m_storage;
+
#if CHECK_ARRAY_CONSISTENCY
- if (!m_storage->m_inCompactInitialization)
+ if (!storage->m_inCompactInitialization)
checkConsistency();
else
- m_storage->m_inCompactInitialization = false;
+ storage->m_inCompactInitialization = false;
#endif
- ArrayStorage* storage = arrayStorage();
-
unsigned length = storage->m_length;
if (newLength < length) {
unsigned usedVectorLength = min(length, m_vectorLength);
for (unsigned i = newLength; i < usedVectorLength; ++i) {
- JSValue& valueSlot = m_vector[i];
+ JSValue& valueSlot = storage->m_vector[i];
bool hadValue = valueSlot;
valueSlot = JSValue();
storage->m_numValuesInVector -= hadValue;
@@ -691,7 +684,7 @@ JSValue JSArray::pop()
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned length = storage->m_length;
if (!length)
@@ -702,7 +695,7 @@ JSValue JSArray::pop()
JSValue result;
if (length < m_vectorLength) {
- JSValue& valueSlot = m_vector[length];
+ JSValue& valueSlot = storage->m_vector[length];
if (valueSlot) {
--storage->m_numValuesInVector;
result = valueSlot;
@@ -735,10 +728,10 @@ void JSArray::push(ExecState* exec, JSValue value)
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
if (storage->m_length < m_vectorLength) {
- m_vector[storage->m_length] = value;
+ storage->m_vector[storage->m_length] = value;
++storage->m_numValuesInVector;
++storage->m_length;
checkConsistency();
@@ -749,8 +742,8 @@ void JSArray::push(ExecState* exec, JSValue value)
SparseArrayValueMap* map = storage->m_sparseValueMap;
if (!map || map->isEmpty()) {
if (increaseVectorLength(storage->m_length + 1)) {
- storage = arrayStorage();
- m_vector[storage->m_length] = value;
+ storage = m_storage;
+ storage->m_vector[storage->m_length] = value;
++storage->m_numValuesInVector;
++storage->m_length;
checkConsistency();
@@ -769,7 +762,7 @@ void JSArray::shiftCount(ExecState* exec, int count)
{
ASSERT(count > 0);
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned oldLength = storage->m_length;
@@ -782,7 +775,7 @@ void JSArray::shiftCount(ExecState* exec, int count)
// slots and then fill them with possible properties. See ECMA spec.
// 15.4.4.9 steps 11 through 13.
for (unsigned i = count; i < oldLength; ++i) {
- if ((i >= m_vectorLength) || (!m_vector[i])) {
+ if ((i >= m_vectorLength) || (!m_storage->m_vector[i])) {
PropertySlot slot(this);
JSValue p = prototype();
if ((!p.isNull()) && (asObject(p)->getPropertySlot(exec, i, slot)))
@@ -790,11 +783,11 @@ void JSArray::shiftCount(ExecState* exec, int count)
}
}
- storage = arrayStorage(); // The put() above could have grown the vector and realloc'ed storage.
+ storage = m_storage; // The put() above could have grown the vector and realloc'ed storage.
// Need to decrement numValuesInvector based on number of real entries
for (unsigned i = 0; i < (unsigned)count; ++i)
- if ((i < m_vectorLength) && (m_vector[i]))
+ if ((i < m_vectorLength) && (storage->m_vector[i]))
--storage->m_numValuesInVector;
} else
storage->m_numValuesInVector -= count;
@@ -809,17 +802,16 @@ void JSArray::shiftCount(ExecState* exec, int count)
if (m_vectorLength) {
char* newBaseStorage = reinterpret_cast<char*>(storage) + count * sizeof(JSValue);
memmove(newBaseStorage, storage, storageSize(0));
- storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
+ m_storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
m_indexBias += count;
- setArrayStorage(storage);
}
}
}
void JSArray::unshiftCount(ExecState* exec, int count)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
ASSERT(m_indexBias >= 0);
ASSERT(count >= 0);
@@ -832,7 +824,7 @@ void JSArray::unshiftCount(ExecState* exec, int count)
// slots and then fill them with possible properties. See ECMA spec.
// 15.4.4.13 steps 8 through 10.
for (unsigned i = 0; i < length; ++i) {
- if ((i >= m_vectorLength) || (!m_vector[i])) {
+ if ((i >= m_vectorLength) || (!m_storage->m_vector[i])) {
PropertySlot slot(this);
JSValue p = prototype();
if ((!p.isNull()) && (asObject(p)->getPropertySlot(exec, i, slot)))
@@ -841,22 +833,22 @@ void JSArray::unshiftCount(ExecState* exec, int count)
}
}
- storage = arrayStorage(); // The put() above could have grown the vector and realloc'ed storage.
+ storage = m_storage; // The put() above could have grown the vector and realloc'ed storage.
if (m_indexBias >= count) {
m_indexBias -= count;
char* newBaseStorage = reinterpret_cast<char*>(storage) - count * sizeof(JSValue);
memmove(newBaseStorage, storage, storageSize(0));
- storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
- setArrayStorage(storage);
+ m_storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
m_vectorLength += count;
} else if (!increaseVectorPrefixLength(m_vectorLength + count)) {
throwOutOfMemoryError(exec);
return;
}
+ JSValue* vector = m_storage->m_vector;
for (int i = 0; i < count; i++)
- m_vector[i] = JSValue();
+ vector[i] = JSValue();
}
void JSArray::markChildren(MarkStack& markStack)
@@ -882,7 +874,7 @@ static int compareByStringPairForQSort(const void* a, const void* b)
void JSArray::sortNumeric(ExecState* exec, JSValue compareFunction, CallType callType, const CallData& callData)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned lengthNotIncludingUndefined = compactForSorting();
if (storage->m_sparseValueMap) {
@@ -896,7 +888,7 @@ void JSArray::sortNumeric(ExecState* exec, JSValue compareFunction, CallType cal
bool allValuesAreNumbers = true;
size_t size = storage->m_numValuesInVector;
for (size_t i = 0; i < size; ++i) {
- if (!m_vector[i].isNumber()) {
+ if (!storage->m_vector[i].isNumber()) {
allValuesAreNumbers = false;
break;
}
@@ -908,14 +900,14 @@ void JSArray::sortNumeric(ExecState* exec, JSValue compareFunction, CallType cal
// For numeric comparison, which is fast, qsort is faster than mergesort. We
// also don't require mergesort's stability, since there's no user visible
// side-effect from swapping the order of equal primitive values.
- qsort(m_vector, size, sizeof(JSValue), compareNumbersForQSort);
+ qsort(storage->m_vector, size, sizeof(JSValue), compareNumbersForQSort);
checkConsistency(SortConsistencyCheck);
}
void JSArray::sort(ExecState* exec)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned lengthNotIncludingUndefined = compactForSorting();
if (storage->m_sparseValueMap) {
@@ -938,7 +930,7 @@ void JSArray::sort(ExecState* exec)
}
for (size_t i = 0; i < lengthNotIncludingUndefined; i++) {
- JSValue value = m_vector[i];
+ JSValue value = storage->m_vector[i];
ASSERT(!value.isUndefined());
values[i].first = value;
}
@@ -970,7 +962,7 @@ void JSArray::sort(ExecState* exec)
// modifying the vector incorrectly.
for (size_t i = 0; i < lengthNotIncludingUndefined; i++)
- m_vector[i] = values[i].first;
+ storage->m_vector[i] = values[i].first;
checkConsistency(SortConsistencyCheck);
}
@@ -1057,7 +1049,7 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
// FIXME: This ignores exceptions raised in the compare function or in toNumber.
@@ -1096,14 +1088,14 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
// Iterate over the array, ignoring missing values, counting undefined ones, and inserting all other ones into the tree.
for (; numDefined < usedVectorLength; ++numDefined) {
- JSValue v = m_vector[numDefined];
+ JSValue v = storage->m_vector[numDefined];
if (!v || v.isUndefined())
break;
tree.abstractor().m_nodes[numDefined].value = v;
tree.insert(numDefined);
}
for (unsigned i = numDefined; i < usedVectorLength; ++i) {
- JSValue v = m_vector[i];
+ JSValue v = storage->m_vector[i];
if (v) {
if (v.isUndefined())
++numUndefined;
@@ -1127,7 +1119,7 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
}
}
- storage = arrayStorage();
+ storage = m_storage;
SparseArrayValueMap::iterator end = map->end();
for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) {
@@ -1149,17 +1141,17 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
AVLTree<AVLTreeAbstractorForArrayCompare, 44>::Iterator iter;
iter.start_iter_least(tree);
for (unsigned i = 0; i < numDefined; ++i) {
- m_vector[i] = tree.abstractor().m_nodes[*iter].value;
+ storage->m_vector[i] = tree.abstractor().m_nodes[*iter].value;
++iter;
}
// Put undefined values back in.
for (unsigned i = numDefined; i < newUsedVectorLength; ++i)
- m_vector[i] = jsUndefined();
+ storage->m_vector[i] = jsUndefined();
// Ensure that unused values in the vector are zeroed out.
for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i)
- m_vector[i] = JSValue();
+ storage->m_vector[i] = JSValue();
storage->m_numValuesInVector = newUsedVectorLength;
@@ -1168,7 +1160,7 @@ void JSArray::sort(ExecState* exec, JSValue compareFunction, CallType callType,
void JSArray::fillArgList(ExecState* exec, MarkedArgumentBuffer& args)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
JSValue* vector = storage->m_vector;
unsigned vectorEnd = min(storage->m_length, m_vectorLength);
@@ -1186,9 +1178,9 @@ void JSArray::fillArgList(ExecState* exec, MarkedArgumentBuffer& args)
void JSArray::copyToRegisters(ExecState* exec, Register* buffer, uint32_t maxSize)
{
- ASSERT(arrayStorage()->m_length >= maxSize);
+ ASSERT(m_storage->m_length >= maxSize);
UNUSED_PARAM(maxSize);
- JSValue* vector = m_vector;
+ JSValue* vector = m_storage->m_vector;
unsigned vectorEnd = min(maxSize, m_vectorLength);
unsigned i = 0;
for (; i < vectorEnd; ++i) {
@@ -1206,7 +1198,7 @@ unsigned JSArray::compactForSorting()
{
checkConsistency();
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned usedVectorLength = min(storage->m_length, m_vectorLength);
@@ -1214,17 +1206,17 @@ unsigned JSArray::compactForSorting()
unsigned numUndefined = 0;
for (; numDefined < usedVectorLength; ++numDefined) {
- JSValue v = m_vector[numDefined];
+ JSValue v = storage->m_vector[numDefined];
if (!v || v.isUndefined())
break;
}
for (unsigned i = numDefined; i < usedVectorLength; ++i) {
- JSValue v = m_vector[i];
+ JSValue v = storage->m_vector[i];
if (v) {
if (v.isUndefined())
++numUndefined;
else
- m_vector[numDefined++] = v;
+ storage->m_vector[numDefined++] = v;
}
}
@@ -1238,21 +1230,21 @@ unsigned JSArray::compactForSorting()
if ((newUsedVectorLength > MAX_STORAGE_VECTOR_LENGTH) || !increaseVectorLength(newUsedVectorLength))
return 0;
- storage = arrayStorage();
+ storage = m_storage;
}
SparseArrayValueMap::iterator end = map->end();
for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it)
- m_vector[numDefined++] = it->second;
+ storage->m_vector[numDefined++] = it->second;
delete map;
storage->m_sparseValueMap = 0;
}
for (unsigned i = numDefined; i < newUsedVectorLength; ++i)
- m_vector[i] = jsUndefined();
+ storage->m_vector[i] = jsUndefined();
for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i)
- m_vector[i] = JSValue();
+ storage->m_vector[i] = JSValue();
storage->m_numValuesInVector = newUsedVectorLength;
@@ -1263,19 +1255,19 @@ unsigned JSArray::compactForSorting()
void* JSArray::subclassData() const
{
- return arrayStorage()->subclassData;
+ return m_storage->subclassData;
}
void JSArray::setSubclassData(void* d)
{
- arrayStorage()->subclassData = d;
+ m_storage->subclassData = d;
}
#if CHECK_ARRAY_CONSISTENCY
void JSArray::checkConsistency(ConsistencyCheckType type)
{
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
ASSERT(storage);
if (type == SortConsistencyCheck)
@@ -1283,7 +1275,7 @@ void JSArray::checkConsistency(ConsistencyCheckType type)
unsigned numValuesInVector = 0;
for (unsigned i = 0; i < m_vectorLength; ++i) {
- if (JSValue value = m_vector[i]) {
+ if (JSValue value = storage->m_vector[i]) {
ASSERT(i < storage->m_length);
if (type != DestructorConsistencyCheck)
value.isUndefined(); // Likely to crash if the object was deallocated.
@@ -1301,7 +1293,7 @@ void JSArray::checkConsistency(ConsistencyCheckType type)
for (SparseArrayValueMap::iterator it = storage->m_sparseValueMap->begin(); it != end; ++it) {
unsigned index = it->first;
ASSERT(index < storage->m_length);
- ASSERT(index >= m_vectorLength);
+ ASSERT(index >= storage->m_vectorLength);
ASSERT(index <= MAX_ARRAY_INDEX);
ASSERT(it->second);
if (type != DestructorConsistencyCheck)
diff --git a/JavaScriptCore/runtime/JSArray.h b/JavaScriptCore/runtime/JSArray.h
index 6ad823e..f718d7e 100644
--- a/JavaScriptCore/runtime/JSArray.h
+++ b/JavaScriptCore/runtime/JSArray.h
@@ -77,7 +77,7 @@ namespace JSC {
static JS_EXPORTDATA const ClassInfo info;
- unsigned length() const { return arrayStorage()->m_length; }
+ unsigned length() const { return m_storage->m_length; }
void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
void sort(ExecState*);
@@ -90,11 +90,11 @@ namespace JSC {
void shiftCount(ExecState*, int count);
void unshiftCount(ExecState*, int count);
- bool canGetIndex(unsigned i) { return i < m_vectorLength && m_vector[i]; }
+ bool canGetIndex(unsigned i) { return i < m_vectorLength && m_storage->m_vector[i]; }
JSValue getIndex(unsigned i)
{
ASSERT(canGetIndex(i));
- return m_vector[i];
+ return m_storage->m_vector[i];
}
bool canSetIndex(unsigned i) { return i < m_vectorLength; }
@@ -102,9 +102,9 @@ namespace JSC {
{
ASSERT(canSetIndex(i));
- JSValue& x = m_vector[i];
+ JSValue& x = m_storage->m_vector[i];
if (!x) {
- ArrayStorage *storage = arrayStorage();
+ ArrayStorage *storage = m_storage;
++storage->m_numValuesInVector;
if (i >= storage->m_length)
storage->m_length = i + 1;
@@ -115,7 +115,7 @@ namespace JSC {
void uncheckedSetIndex(unsigned i, JSValue v)
{
ASSERT(canSetIndex(i));
- ArrayStorage *storage = arrayStorage();
+ ArrayStorage *storage = m_storage;
#if CHECK_ARRAY_CONSISTENCY
ASSERT(storage->m_inCompactInitialization);
#endif
@@ -143,16 +143,6 @@ namespace JSC {
void* subclassData() const;
void setSubclassData(void*);
- inline ArrayStorage *arrayStorage() const
- {
- return reinterpret_cast<ArrayStorage*>(reinterpret_cast<char*>(m_vector) - (sizeof(ArrayStorage) - sizeof(JSValue)));
- }
-
- inline void setArrayStorage(ArrayStorage *storage)
- {
- m_vector = &storage->m_vector[0];
- }
-
private:
virtual const ClassInfo* classInfo() const { return &info; }
@@ -170,7 +160,7 @@ namespace JSC {
unsigned m_vectorLength; // The valid length of m_vector
int m_indexBias; // The number of JSValue sized blocks before ArrayStorage.
- JSValue* m_vector; // Copy of ArrayStorage.m_vector. Used for quick vector access and to materialize ArrayStorage ptr.
+ ArrayStorage *m_storage;
};
JSArray* asArray(JSValue);
@@ -196,7 +186,7 @@ namespace JSC {
{
JSObject::markChildrenDirect(markStack);
- ArrayStorage* storage = arrayStorage();
+ ArrayStorage* storage = m_storage;
unsigned usedVectorLength = std::min(storage->m_length, m_vectorLength);
markStack.appendValues(storage->m_vector, usedVectorLength, MayContainNullValues);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list