- Revision
- 202098
- Author
- [email protected]
- Date
- 2016-06-15 12:20:23 -0700 (Wed, 15 Jun 2016)
Log Message
compilation policy should adapt to past behavior
https://bugs.webkit.org/show_bug.cgi?id=158759
Reviewed by Saam Barati.
This looks like a ~9% speedup on JSBench.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::~CodeBlock): Record when a CodeBlock dies without ever
making it to DFG.
(JSC::CodeBlock::thresholdForJIT): CodeBlocks that make it to DFG should
compile sooner; CodeBlocks that don't should compile later. The goal is
to use past behavior, in addition to execution counts, to determine
whether compilation is profitable.
(JSC::CodeBlock::jitAfterWarmUp):
(JSC::CodeBlock::jitSoon): Apply the thresholdForJIT rule.
* bytecode/CodeBlock.h: Moved some code into the .cpp file so I could
change stuff without recompiling.
(JSC::CodeBlock::jitAfterWarmUp): Deleted.
(JSC::CodeBlock::jitSoon): Deleted.
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::didOptimize):
(JSC::UnlinkedCodeBlock::setDidOptimize): Added a piece of data to track
whether we made it to DFG.
* jit/JITOperations.cpp: Record when we make it to DFG.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (202097 => 202098)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-15 19:20:23 UTC (rev 202098)
@@ -1,3 +1,38 @@
+2016-06-14 Geoffrey Garen <[email protected]>
+
+ compilation policy should adapt to past behavior
+ https://bugs.webkit.org/show_bug.cgi?id=158759
+
+ Reviewed by Saam Barati.
+
+ This looks like a ~9% speedup on JSBench.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::~CodeBlock): Record when a CodeBlock dies without ever
+ making it to DFG.
+
+ (JSC::CodeBlock::thresholdForJIT): CodeBlocks that make it to DFG should
+ compile sooner; CodeBlocks that don't should compile later. The goal is
+ to use past behavior, in addition to execution counts, to determine
+ whether compilation is profitable.
+
+ (JSC::CodeBlock::jitAfterWarmUp):
+ (JSC::CodeBlock::jitSoon): Apply the thresholdForJIT rule.
+
+ * bytecode/CodeBlock.h: Moved some code into the .cpp file so I could
+ change stuff without recompiling.
+ (JSC::CodeBlock::jitAfterWarmUp): Deleted.
+ (JSC::CodeBlock::jitSoon): Deleted.
+
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
+ * bytecode/UnlinkedCodeBlock.h:
+ (JSC::UnlinkedCodeBlock::didOptimize):
+ (JSC::UnlinkedCodeBlock::setDidOptimize): Added a piece of data to track
+ whether we made it to DFG.
+
+ * jit/JITOperations.cpp: Record when we make it to DFG.
+
2016-06-15 Konstantin Tokarev <[email protected]>
Only Mac port needs ObjC API for JSC.
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (202097 => 202098)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-06-15 19:20:23 UTC (rev 202098)
@@ -2418,7 +2418,10 @@
{
if (m_vm->m_perBytecodeProfiler)
m_vm->m_perBytecodeProfiler->notifyDestruction(this);
-
+
+ if (unlinkedCodeBlock()->didOptimize() == MixedTriState)
+ unlinkedCodeBlock()->setDidOptimize(FalseTriState);
+
#if ENABLE(VERBOSE_VALUE_PROFILE)
dumpValueProfiles();
#endif
@@ -4435,4 +4438,26 @@
return bytecodeOffset;
}
+int32_t CodeBlock::thresholdForJIT(int32_t threshold)
+{
+ switch (unlinkedCodeBlock()->didOptimize()) {
+ case MixedTriState:
+ return threshold;
+ case FalseTriState:
+ return threshold * 4;
+ case TrueTriState:
+ return threshold / 2;
+ }
+}
+
+void CodeBlock::jitAfterWarmUp()
+{
+ m_llintExecuteCounter.setNewThreshold(thresholdForJIT(Options::thresholdForJITAfterWarmUp()), this);
+}
+
+void CodeBlock::jitSoon()
+{
+ m_llintExecuteCounter.setNewThreshold(thresholdForJIT(Options::thresholdForJITSoon()), this);
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (202097 => 202098)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-06-15 19:20:23 UTC (rev 202098)
@@ -664,16 +664,10 @@
m_llintExecuteCounter.deferIndefinitely();
}
- void jitAfterWarmUp()
- {
- m_llintExecuteCounter.setNewThreshold(Options::thresholdForJITAfterWarmUp(), this);
- }
+ int32_t thresholdForJIT(int32_t threshold);
+ void jitAfterWarmUp();
+ void jitSoon();
- void jitSoon()
- {
- m_llintExecuteCounter.setNewThreshold(Options::thresholdForJITSoon(), this);
- }
-
const BaselineExecutionCounter& llintExecuteCounter() const
{
return m_llintExecuteCounter;
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (202097 => 202098)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2016-06-15 19:20:23 UTC (rev 202098)
@@ -72,6 +72,7 @@
, m_firstLine(0)
, m_lineCount(0)
, m_endColumn(UINT_MAX)
+ , m_didOptimize(MixedTriState)
, m_parseMode(info.parseMode())
, m_features(0)
, m_codeType(codeType)
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (202097 => 202098)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2016-06-15 19:20:23 UTC (rev 202098)
@@ -43,6 +43,7 @@
#include "VirtualRegister.h"
#include <wtf/FastBitVector.h>
#include <wtf/RefCountedArray.h>
+#include <wtf/TriState.h>
#include <wtf/Vector.h>
namespace JSC {
@@ -370,6 +371,9 @@
bool wasCompiledWithDebuggingOpcodes() const { return m_wasCompiledWithDebuggingOpcodes; }
+ TriState didOptimize() const { return m_didOptimize; }
+ void setDidOptimize(TriState didOptimize) { m_didOptimize = didOptimize; }
+
protected:
UnlinkedCodeBlock(VM*, Structure*, CodeType, const ExecutableInfo&, DebuggerMode);
~UnlinkedCodeBlock();
@@ -416,6 +420,7 @@
unsigned m_lineCount;
unsigned m_endColumn;
+ TriState m_didOptimize;
SourceParseMode m_parseMode;
CodeFeatures m_features;
CodeType m_codeType;
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (202097 => 202098)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-06-15 19:17:51 UTC (rev 202097)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-06-15 19:20:23 UTC (rev 202098)
@@ -1388,6 +1388,7 @@
}
codeBlock->optimizeSoon();
+ codeBlock->unlinkedCodeBlock()->setDidOptimize(TrueTriState);
return encodeResult(vm.getCTIStub(DFG::osrEntryThunkGenerator).code().executableAddress(), dataBuffer);
}