Title: [103292] trunk/Source/_javascript_Core
- Revision
- 103292
- Author
- [email protected]
- Date
- 2011-12-19 18:42:06 -0800 (Mon, 19 Dec 2011)
Log Message
If we detect that we can use the JIT, don't use computed opcode lookups
https://bugs.webkit.org/show_bug.cgi?id=74899
<rdar://problem/10604551>
Reviewed by Gavin Barraclough.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
(JSC::Interpreter::initialize):
(JSC::Interpreter::privateExecute):
* interpreter/Interpreter.h:
(JSC::Interpreter::getOpcode):
(JSC::Interpreter::getOpcodeID):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (103291 => 103292)
--- trunk/Source/_javascript_Core/ChangeLog 2011-12-20 02:01:16 UTC (rev 103291)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-12-20 02:42:06 UTC (rev 103292)
@@ -1,3 +1,21 @@
+2011-12-19 Filip Pizlo <[email protected]>
+
+ If we detect that we can use the JIT, don't use computed opcode lookups
+ https://bugs.webkit.org/show_bug.cgi?id=74899
+ <rdar://problem/10604551>
+
+ Reviewed by Gavin Barraclough.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::Interpreter):
+ (JSC::Interpreter::initialize):
+ (JSC::Interpreter::privateExecute):
+ * interpreter/Interpreter.h:
+ (JSC::Interpreter::getOpcode):
+ (JSC::Interpreter::getOpcodeID):
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::JSGlobalData):
+
2011-12-19 Geoffrey Garen <[email protected]>
Try to fix the Qt build.
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (103291 => 103292)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-12-20 02:01:16 UTC (rev 103291)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-12-20 02:42:06 UTC (rev 103292)
@@ -540,13 +540,43 @@
Interpreter::Interpreter()
: m_sampleEntryDepth(0)
, m_reentryDepth(0)
+#if !ASSERT_DISABLED
+ , m_initialized(false)
+#endif
+ , m_enabled(false)
{
+}
+
+void Interpreter::initialize(bool canUseJIT)
+{
#if ENABLE(COMPUTED_GOTO_INTERPRETER)
- privateExecute(InitializeAndReturn, 0, 0);
-
- for (int i = 0; i < numOpcodeIDs; ++i)
- m_opcodeIDTable.add(m_opcodeTable[i], static_cast<OpcodeID>(i));
+ if (canUseJIT) {
+ // If the JIT is present, don't use jump destinations for opcodes.
+
+ for (int i = 0; i < numOpcodeIDs; ++i) {
+ Opcode opcode = bitwise_cast<void*>(static_cast<uintptr_t>(i));
+ m_opcodeTable[i] = opcode;
+ m_opcodeIDTable.add(opcode, static_cast<OpcodeID>(i));
+ }
+ } else {
+ privateExecute(InitializeAndReturn, 0, 0);
+
+ for (int i = 0; i < numOpcodeIDs; ++i)
+ m_opcodeIDTable.add(m_opcodeTable[i], static_cast<OpcodeID>(i));
+
+ m_enabled = true;
+ }
+#else
+ UNUSED_PARAM(canUseJIT);
+#if ENABLE(INTERPRETER)
+ m_enabled = true;
+#else
+ m_enabled = false;
+#endif
#endif // ENABLE(COMPUTED_GOTO_INTERPRETER)
+#if !ASSERT_DISABLED
+ m_initialized = true;
+#endif
#if ENABLE(OPCODE_SAMPLING)
enableSampler();
@@ -1653,6 +1683,9 @@
return JSValue();
}
+ ASSERT(m_initialized);
+ ASSERT(m_enabled);
+
#if ENABLE(JIT)
#if ENABLE(INTERPRETER)
// Mixing Interpreter + JIT is not supported.
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.h (103291 => 103292)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.h 2011-12-20 02:01:16 UTC (rev 103291)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.h 2011-12-20 02:42:06 UTC (rev 103292)
@@ -94,26 +94,35 @@
friend class CachedCall;
public:
Interpreter();
+
+ void initialize(bool canUseJIT);
RegisterFile& registerFile() { return m_registerFile; }
Opcode getOpcode(OpcodeID id)
{
- #if ENABLE(COMPUTED_GOTO_INTERPRETER)
- return m_opcodeTable[id];
- #else
- return id;
- #endif
+ ASSERT(m_initialized);
+#if ENABLE(COMPUTED_GOTO_INTERPRETER)
+ return m_opcodeTable[id];
+#else
+ return id;
+#endif
}
OpcodeID getOpcodeID(Opcode opcode)
{
- #if ENABLE(COMPUTED_GOTO_INTERPRETER)
- ASSERT(isOpcode(opcode));
- return m_opcodeIDTable.get(opcode);
- #else
- return opcode;
- #endif
+ ASSERT(m_initialized);
+#if ENABLE(COMPUTED_GOTO_INTERPRETER)
+ ASSERT(isOpcode(opcode));
+ if (!m_enabled) {
+ OpcodeID result = static_cast<OpcodeID>(bitwise_cast<uintptr_t>(opcode));
+ ASSERT(result == m_opcodeIDTable.get(opcode));
+ return result;
+ }
+ return m_opcodeIDTable.get(opcode);
+#else
+ return opcode;
+#endif
}
bool isOpcode(Opcode);
@@ -186,6 +195,11 @@
Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling
HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling
#endif
+
+#if !ASSERT_DISABLED
+ bool m_initialized;
+#endif
+ bool m_enabled;
};
// This value must not be an object that would require this conversion (WebCore's global object).
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp (103291 => 103292)
--- trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp 2011-12-20 02:01:16 UTC (rev 103291)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp 2011-12-20 02:42:06 UTC (rev 103292)
@@ -227,6 +227,8 @@
jitStubs = adoptPtr(new JITThunks(this));
#endif
+ interpreter->initialize(this->canUseJIT());
+
heap.notifyIsSafeToCollect();
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes