+2012-02-23 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ Zero out CopiedBlocks on initialization
+ https://bugs.webkit.org/show_bug.cgi?id=79199
+
+ Reviewed by Filip Pizlo.
+
+ Made CopyBlocks zero their payloads during construction. This allows
+ JSArray to avoid having to manually clear its backing store upon allocation
+ and also alleviates any future pain with regard to the garbage collector trying
+ to mark what it thinks are values in what is actually uninitialized memory.
+
+ * heap/CopiedBlock.h:
+ (JSC::CopiedBlock::CopiedBlock):
+ * runtime/JSArray.cpp:
+ (JSC::JSArray::finishCreation):
+ (JSC::JSArray::tryFinishCreationUninitialized):
+ (JSC::JSArray::increaseVectorLength):
+ (JSC::JSArray::unshiftCountSlowCase):
+
2012-02-23 Oliver Hunt <oliver@apple.com>
Make Interpreter::getStackTrace be able to generate the line number for the top callframe if none is provided
#define CopiedBlock_h
#include "HeapBlock.h"
+#include "JSValue.h"
+#include "JSValueInlineMethods.h"
namespace JSC {
, m_offset(m_payload)
, m_isPinned(false)
{
+ ASSERT(is8ByteAligned(static_cast<void*>(m_payload)));
+#if USE(JSVALUE64)
+ memset(static_cast<void*>(m_payload), 0, static_cast<size_t>((reinterpret_cast<char*>(this) + allocation.size()) - m_payload));
+#else
+ JSValue emptyValue;
+ JSValue* limit = reinterpret_cast<JSValue*>(reinterpret_cast<char*>(this) + allocation.size());
+ for (JSValue* currentValue = reinterpret_cast<JSValue*>(m_payload); currentValue < limit; currentValue++)
+ *currentValue = emptyValue;
+#endif
}
private:
m_storage->m_inCompactInitialization = false;
#endif
- WriteBarrier<Unknown>* vector = m_storage->m_vector;
- for (size_t i = 0; i < initialVectorLength; ++i)
- vector[i].clear();
-
checkConsistency();
}
m_storage->m_inCompactInitialization = true;
#endif
- WriteBarrier<Unknown>* vector = m_storage->m_vector;
- for (size_t i = initialLength; i < initialVectorLength; ++i)
- vector[i].clear();
-
return this;
}
m_storage->m_allocBase = newStorage;
ASSERT(m_storage->m_allocBase);
- WriteBarrier<Unknown>* vector = storage->m_vector;
- for (unsigned i = vectorLength; i < newVectorLength; ++i)
- vector[i].clear();
-
m_vectorLength = newVectorLength;
return true;
m_indexBias = newIndexBias;
m_storage = reinterpret_cast_ptr<ArrayStorage*>(reinterpret_cast<WriteBarrier<Unknown>*>(newAllocBase) + m_indexBias);
- // Copy the ArrayStorage header & current contents of the vector, clear the new post-capacity.
+ // Copy the ArrayStorage header & current contents of the vector.
memmove(m_storage, storage, storageSize(vectorLength));
- for (unsigned i = vectorLength; i < m_vectorLength; ++i)
- m_storage->m_vector[i].clear();
// Free the old allocation, update m_allocBase.
m_storage->m_allocBase = newAllocBase;
if (newAllocBase != m_storage->m_allocBase) {
// Free the old allocation, update m_allocBase.
m_storage->m_allocBase = newAllocBase;
-
- // We need to clear any entries in the vector beyond length. We only need to
- // do this if this was a new allocation, because if we're using an existing
- // allocation the post-capacity will already be cleared, and in an existing
- // allocation we can only beshrinking the amount of post capacity.
- for (unsigned i = requiredVectorLength; i < m_vectorLength; ++i)
- m_storage->m_vector[i].clear();
}
return true;