2008-09-24 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
- https://bugs.webkit.org/show_bug.cgi?id=21047
speed up ret_activation with inlining
About 1% on v8-raytrace.
* JavaScriptCore.exp: Removed JSVariableObject::setRegisters.
* kjs/JSActivation.cpp: Moved copyRegisters to the header to make it inline.
* kjs/JSActivation.h:
(JSC::JSActivation::copyRegisters): Moved here. Also removed the registerArraySize
argument to setRegisters, since the object doesn't need to store the number of
registers.
* kjs/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset): Removed unnecessary clearing left over from when we
used this on objects that weren't brand new. These days, this function is really
just part of the constructor.
* kjs/JSGlobalObject.h: Added registerArraySize to JSGlobalObjectData, since
JSVariableObjectData no longer needs it. Added a setRegisters override here
that handles storing the size.
* kjs/JSStaticScopeObject.h: Removed code to set registerArraySize, since it
no longer exists.
* kjs/JSVariableObject.cpp: Moved copyRegisterArray and setRegisters to the
header to make them inline.
* kjs/JSVariableObject.h: Removed registerArraySize from JSVariableObjectData,
since it was only used for the global object.
(JSC::JSVariableObject::copyRegisterArray): Moved here ot make it inline.
(JSC::JSVariableObject::setRegisters): Moved here to make it inline. Also
removed the code to set registerArraySize and changed an if statement into
an assert to save an unnnecessary branch.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36851 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 78c6a70..0a3e9e0 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,41 @@
+2008-09-24 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ - https://bugs.webkit.org/show_bug.cgi?id=21047
+ speed up ret_activation with inlining
+
+ About 1% on v8-raytrace.
+
+ * JavaScriptCore.exp: Removed JSVariableObject::setRegisters.
+
+ * kjs/JSActivation.cpp: Moved copyRegisters to the header to make it inline.
+ * kjs/JSActivation.h:
+ (JSC::JSActivation::copyRegisters): Moved here. Also removed the registerArraySize
+ argument to setRegisters, since the object doesn't need to store the number of
+ registers.
+
+ * kjs/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset): Removed unnecessary clearing left over from when we
+ used this on objects that weren't brand new. These days, this function is really
+ just part of the constructor.
+
+ * kjs/JSGlobalObject.h: Added registerArraySize to JSGlobalObjectData, since
+ JSVariableObjectData no longer needs it. Added a setRegisters override here
+ that handles storing the size.
+
+ * kjs/JSStaticScopeObject.h: Removed code to set registerArraySize, since it
+ no longer exists.
+
+ * kjs/JSVariableObject.cpp: Moved copyRegisterArray and setRegisters to the
+ header to make them inline.
+ * kjs/JSVariableObject.h: Removed registerArraySize from JSVariableObjectData,
+ since it was only used for the global object.
+ (JSC::JSVariableObject::copyRegisterArray): Moved here ot make it inline.
+ (JSC::JSVariableObject::setRegisters): Moved here to make it inline. Also
+ removed the code to set registerArraySize and changed an if statement into
+ an assert to save an unnnecessary branch.
+
2008-09-24 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver Hunt.
@@ -127,7 +165,7 @@
13.5% speedup on empty call benchmark for bytecode; 23.6% speedup on
empty call benchmark for CTI.
- SunSpider says no change. SunSpider --v8 says 1% faster.
+ SunSpider says no change. SunSpider --v8 says 1% faster.v8
* VM/CTI.cpp:
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index d48d6e3..8fd9ec20 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -152,7 +152,6 @@
__ZN3JSC15JSWrapperObject4markEv
__ZN3JSC16InternalFunction4infoE
__ZN3JSC16InternalFunctionC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_11StructureIDEEERKNS_10IdentifierE
-__ZN3JSC16JSVariableObject12setRegistersEPNS_8RegisterES2_m
__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3JSC16ParserRefCounted3refEv
diff --git a/JavaScriptCore/kjs/JSActivation.cpp b/JavaScriptCore/kjs/JSActivation.cpp
index 0f12759..68b0840 100644
--- a/JavaScriptCore/kjs/JSActivation.cpp
+++ b/JavaScriptCore/kjs/JSActivation.cpp
@@ -30,9 +30,7 @@
#include "JSActivation.h"
#include "Arguments.h"
-#include "CodeBlock.h"
#include "Machine.h"
-#include "Register.h"
#include "JSFunction.h"
namespace JSC {
@@ -85,25 +83,6 @@
}
}
-void JSActivation::copyRegisters()
-{
- ASSERT(!d()->registerArray);
- ASSERT(!d()->registerArraySize);
-
- size_t numParametersMinusThis = d()->functionBody->generatedByteCode().numParameters - 1;
- size_t numVars = d()->functionBody->generatedByteCode().numVars;
- size_t numLocals = numVars + numParametersMinusThis;
-
- if (!numLocals)
- return;
-
- int registerOffset = numParametersMinusThis + RegisterFile::CallFrameHeaderSize;
- size_t registerArraySize = numLocals + RegisterFile::CallFrameHeaderSize;
-
- Register* registerArray = copyRegisterArray(d()->registers - registerOffset, registerArraySize);
- setRegisters(registerArray + registerOffset, registerArray, registerArraySize);
-}
-
bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (symbolTableGet(propertyName, slot))
diff --git a/JavaScriptCore/kjs/JSActivation.h b/JavaScriptCore/kjs/JSActivation.h
index f40bf47..917c8dc 100644
--- a/JavaScriptCore/kjs/JSActivation.h
+++ b/JavaScriptCore/kjs/JSActivation.h
@@ -29,7 +29,9 @@
#ifndef JSActivation_h
#define JSActivation_h
+#include "CodeBlock.h"
#include "JSVariableObject.h"
+#include "RegisterFile.h"
#include "SymbolTable.h"
#include "nodes.h"
@@ -98,6 +100,24 @@
JSActivationData* d() const { return static_cast<JSActivationData*>(JSVariableObject::d); }
};
+ inline void JSActivation::copyRegisters()
+ {
+ ASSERT(!d()->registerArray);
+
+ size_t numParametersMinusThis = d()->functionBody->generatedByteCode().numParameters - 1;
+ size_t numVars = d()->functionBody->generatedByteCode().numVars;
+ size_t numLocals = numVars + numParametersMinusThis;
+
+ if (!numLocals)
+ return;
+
+ int registerOffset = numParametersMinusThis + RegisterFile::CallFrameHeaderSize;
+ size_t registerArraySize = numLocals + RegisterFile::CallFrameHeaderSize;
+
+ Register* registerArray = copyRegisterArray(d()->registers - registerOffset, registerArraySize);
+ setRegisters(registerArray + registerOffset, registerArray);
+ }
+
} // namespace JSC
#endif // JSActivation_h
diff --git a/JavaScriptCore/kjs/JSGlobalObject.cpp b/JavaScriptCore/kjs/JSGlobalObject.cpp
index d902580..c592bb4 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.cpp
+++ b/JavaScriptCore/kjs/JSGlobalObject.cpp
@@ -195,14 +195,6 @@
void JSGlobalObject::reset(JSValue* prototype)
{
- // Clear before inititalizing, to avoid calling mark() on stale pointers --
- // which would be wasteful -- or uninitialized pointers -- which would be
- // dangerous. (The allocations below may cause a GC.)
-
- ASSERT(!hasCustomProperties());
- symbolTable().clear();
- setRegisters(0, 0, 0);
-
ExecState* exec = d()->globalExec.get();
// Prototypes
diff --git a/JavaScriptCore/kjs/JSGlobalObject.h b/JavaScriptCore/kjs/JSGlobalObject.h
index 14140d2..cdfe467 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.h
+++ b/JavaScriptCore/kjs/JSGlobalObject.h
@@ -56,6 +56,7 @@
struct JSGlobalObjectData : public JSVariableObjectData {
JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
: JSVariableObjectData(&symbolTable, 0)
+ , registerArraySize(0)
, globalScopeChain(globalObject, thisValue)
, regExpConstructor(0)
, errorConstructor(0)
@@ -81,6 +82,8 @@
{
}
+ size_t registerArraySize;
+
JSGlobalObject* next;
JSGlobalObject* prev;
@@ -269,9 +272,17 @@
void init(JSObject* thisValue);
void reset(JSValue* prototype);
+ void setRegisters(Register* registers, Register* registerArray, size_t count);
+
void* operator new(size_t); // can only be allocated with JSGlobalData
};
+ inline void JSGlobalObject::setRegisters(Register* registers, Register* registerArray, size_t count)
+ {
+ JSVariableObject::setRegisters(registers, registerArray);
+ d()->registerArraySize = count;
+ }
+
inline void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
{
size_t oldSize = d()->registerArraySize;
@@ -323,6 +334,7 @@
return exec->lexicalGlobalObject()->numberPrototype();
}
+
} // namespace JSC
#endif // JSGlobalObject_h
diff --git a/JavaScriptCore/kjs/JSStaticScopeObject.h b/JavaScriptCore/kjs/JSStaticScopeObject.h
index a78c2f5..cc3bf02 100644
--- a/JavaScriptCore/kjs/JSStaticScopeObject.h
+++ b/JavaScriptCore/kjs/JSStaticScopeObject.h
@@ -37,7 +37,6 @@
JSStaticScopeObjectData()
: JSVariableObjectData(&symbolTable, ®isterStore + 1)
{
- registerArraySize = 1;
}
SymbolTable symbolTable;
Register registerStore;
diff --git a/JavaScriptCore/kjs/JSVariableObject.cpp b/JavaScriptCore/kjs/JSVariableObject.cpp
index 8efb9ab..3d81c19 100644
--- a/JavaScriptCore/kjs/JSVariableObject.cpp
+++ b/JavaScriptCore/kjs/JSVariableObject.cpp
@@ -68,20 +68,4 @@
return true;
}
-Register* JSVariableObject::copyRegisterArray(Register* src, size_t count)
-{
- Register* registerArray = new Register[count];
- memcpy(registerArray, src, count * sizeof(Register));
-
- return registerArray;
-}
-
-void JSVariableObject::setRegisters(Register* r, Register* registerArray, size_t count)
-{
- if (registerArray != d->registerArray.get())
- d->registerArray.set(registerArray);
- d->registerArraySize = count;
- d->registers = r;
-}
-
} // namespace JSC
diff --git a/JavaScriptCore/kjs/JSVariableObject.h b/JavaScriptCore/kjs/JSVariableObject.h
index 20b225b..adfa02d 100644
--- a/JavaScriptCore/kjs/JSVariableObject.h
+++ b/JavaScriptCore/kjs/JSVariableObject.h
@@ -64,7 +64,6 @@
JSVariableObjectData(SymbolTable* symbolTable_, Register* registers_)
: symbolTable(symbolTable_)
, registers(registers_)
- , registerArraySize(0)
{
ASSERT(symbolTable_);
}
@@ -72,7 +71,6 @@
SymbolTable* symbolTable; // Maps name -> offset from "r" in register file.
Register* registers; // "r" in the register file.
OwnArrayPtr<Register> registerArray; // Independent copy of registers, used when a variable object copies its registers out of the register file.
- size_t registerArraySize;
static inline ptrdiff_t offsetOf_registers()
{
@@ -91,7 +89,7 @@
}
Register* copyRegisterArray(Register* src, size_t count);
- void setRegisters(Register* r, Register* registerArray, size_t count);
+ void setRegisters(Register* r, Register* registerArray);
bool symbolTableGet(const Identifier&, PropertySlot&);
bool symbolTableGet(const Identifier&, PropertySlot&, bool& slotIsWriteable);
@@ -160,6 +158,21 @@
return true;
}
+ inline Register* JSVariableObject::copyRegisterArray(Register* src, size_t count)
+ {
+ Register* registerArray = new Register[count];
+ memcpy(registerArray, src, count * sizeof(Register));
+
+ return registerArray;
+ }
+
+ inline void JSVariableObject::setRegisters(Register* registers, Register* registerArray)
+ {
+ ASSERT(registerArray != d->registerArray.get());
+ d->registerArray.set(registerArray);
+ d->registers = registers;
+ }
+
} // namespace JSC
#endif // JSVariableObject_h