Commit 01a43ea1 authored by benjamin@webkit.org's avatar benjamin@webkit.org

Remove m_subclassData from JSArray, move the attribute to subclass as needed

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

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-04-18
Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

JSArray's m_subclassData is only used by WebCore's RuntimeArray. This patch moves
the attribute to RuntimeArray to avoid allocating memory for the pointer in the common
case.

This gives ~1% improvement in JSArray creation microbenchmark thanks to fewer allocations
of CopiedSpace.

* jit/JITInlineMethods.h:
(JSC::JIT::emitAllocateJSArray):
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
* runtime/JSArray.h:

Source/WebCore: 

* bridge/runtime_array.cpp:
(JSC::RuntimeArray::RuntimeArray):
(JSC::RuntimeArray::finishCreation):
* bridge/runtime_array.h:
(JSC::RuntimeArray::getLength):
(JSC::RuntimeArray::getConcreteArray):
(RuntimeArray):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ef75e9e9
2012-04-18 Benjamin Poulain <bpoulain@apple.com>
Remove m_subclassData from JSArray, move the attribute to subclass as needed
https://bugs.webkit.org/show_bug.cgi?id=84249
Reviewed by Geoffrey Garen.
JSArray's m_subclassData is only used by WebCore's RuntimeArray. This patch moves
the attribute to RuntimeArray to avoid allocating memory for the pointer in the common
case.
This gives ~1% improvement in JSArray creation microbenchmark thanks to fewer allocations
of CopiedSpace.
* jit/JITInlineMethods.h:
(JSC::JIT::emitAllocateJSArray):
* runtime/JSArray.cpp:
(JSC::JSArray::JSArray):
* runtime/JSArray.h:
2012-04-18 Benjamin Poulain <bpoulain@apple.com>
replaceUsingStringSearch: delay the creation of the replace string until needed
......@@ -503,8 +503,7 @@ inline void JIT::emitAllocateJSArray(unsigned valuesRegister, unsigned length, R
store32(Imm32(initialLength), Address(cellResult, JSArray::vectorLengthOffset()));
store32(TrustedImm32(0), Address(cellResult, JSArray::indexBiasOffset()));
// Initialize the subclass data and the sparse value map.
storePtr(TrustedImmPtr(0), Address(cellResult, JSArray::subclassDataOffset()));
// Initialize the sparse value map.
storePtr(TrustedImmPtr(0), Address(cellResult, JSArray::sparseValueMapOffset()));
// Store the values we have.
......
......@@ -130,7 +130,6 @@ JSArray::JSArray(JSGlobalData& globalData, Structure* structure)
, m_indexBias(0)
, m_storage(0)
, m_sparseValueMap(0)
, m_subclassData(0)
{
}
......@@ -1810,16 +1809,6 @@ unsigned JSArray::compactForSorting(JSGlobalData& globalData)
return numDefined;
}
void* JSArray::subclassData() const
{
return m_subclassData;
}
void JSArray::setSubclassData(void* d)
{
m_subclassData = d;
}
#if CHECK_ARRAY_CONSISTENCY
void JSArray::checkConsistency(ConsistencyCheckType type)
......
......@@ -317,10 +317,8 @@ namespace JSC {
// FIXME: Maybe SparseArrayValueMap should be put into its own JSCell?
SparseArrayValueMap* m_sparseValueMap;
void* m_subclassData; // A JSArray subclass can use this to fill the vector lazily.
static ptrdiff_t sparseValueMapOffset() { return OBJECT_OFFSETOF(JSArray, m_sparseValueMap); }
static ptrdiff_t subclassDataOffset() { return OBJECT_OFFSETOF(JSArray, m_subclassData); }
static ptrdiff_t indexBiasOffset() { return OBJECT_OFFSETOF(JSArray, m_indexBias); }
};
......
2012-04-18 Benjamin Poulain <bpoulain@apple.com>
Remove m_subclassData from JSArray, move the attribute to subclass as needed
https://bugs.webkit.org/show_bug.cgi?id=84249
Reviewed by Geoffrey Garen.
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::RuntimeArray):
(JSC::RuntimeArray::finishCreation):
* bridge/runtime_array.h:
(JSC::RuntimeArray::getLength):
(JSC::RuntimeArray::getConcreteArray):
(RuntimeArray):
2012-04-18 Luiz Agostini <luiz.agostini@palm.com>
matchMedia() MediaQueryList not updating
......@@ -39,6 +39,7 @@ const ClassInfo RuntimeArray::s_info = { "RuntimeArray", &JSArray::s_info, 0, 0,
RuntimeArray::RuntimeArray(ExecState* exec, Structure* structure)
: JSArray(exec->globalData(), structure)
, m_array(0)
{
}
......@@ -46,7 +47,7 @@ void RuntimeArray::finishCreation(JSGlobalData& globalData, Bindings::Array* arr
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
setSubclassData(array);
m_array = array;
}
RuntimeArray::~RuntimeArray()
......
......@@ -60,9 +60,9 @@ public:
static bool deleteProperty(JSCell*, ExecState*, const Identifier &propertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
unsigned getLength() const { return getConcreteArray()->getLength(); }
unsigned getLength() const { return m_array->getLength(); }
Bindings::Array* getConcreteArray() const { return static_cast<BindingsArray*>(subclassData()); }
Bindings::Array* getConcreteArray() const { return m_array; }
static const ClassInfo s_info;
......@@ -85,6 +85,8 @@ private:
RuntimeArray(ExecState*, Structure*);
static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
static JSValue indexGetter(ExecState*, JSValue, unsigned);
BindingsArray* m_array;
};
} // namespace JSC
......
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