Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (95675 => 95676)
--- trunk/Source/_javascript_Core/ChangeLog 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-09-21 22:43:11 UTC (rev 95676)
@@ -1,3 +1,28 @@
+2011-09-21 Gavin Barraclough <barraclo...@apple.com>
+
+ Should support value profiling on CPU(X86)
+ https://bugs.webkit.org/show_bug.cgi?id=68575
+
+ Reviewed by Sam Weinig.
+
+ Fix verbose profiling in ToT (SlowCaseProfile had been
+ partially renamed to RareCaseProfile), add in-memory
+ bucket counter for CPU(X86), move JIT::m_canBeOptimized
+ out of the DFG_JIT ifdef.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::resetRareCaseProfiles):
+ (JSC::CodeBlock::dumpValueProfiles):
+ * bytecode/CodeBlock.h:
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::makeSafe):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileSlowCases):
+ (JSC::JIT::privateCompile):
+ * jit/JIT.h:
+ * jit/JITInlineMethods.h:
+ (JSC::JIT::emitValueProfilingSite):
+
2011-09-21 Filip Pizlo <fpi...@apple.com>
DFG does not support compiling functions as constructors
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (95675 => 95676)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2011-09-21 22:43:11 UTC (rev 95676)
@@ -1987,8 +1987,8 @@
#if ENABLE(VALUE_PROFILER)
void CodeBlock::resetRareCaseProfiles()
{
- for (unsigned i = 0; i < numberOfSlowCaseProfiles(); ++i)
- slowCaseProfile(i)->m_counter = 0;
+ for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i)
+ rareCaseProfile(i)->m_counter = 0;
for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i)
specialFastCaseProfile(i)->m_counter = 0;
}
@@ -2012,9 +2012,9 @@
profile->dump(stderr);
fprintf(stderr, "\n");
}
- fprintf(stderr, "SlowCaseProfile for %p:\n", this);
- for (unsigned i = 0; i < numberOfSlowCaseProfiles(); ++i) {
- SlowCaseProfile* profile = ""
+ fprintf(stderr, "RareCaseProfile for %p:\n", this);
+ for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) {
+ RareCaseProfile* profile = ""
fprintf(stderr, " bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
}
}
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (95675 => 95676)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2011-09-21 22:43:11 UTC (rev 95676)
@@ -489,22 +489,22 @@
return result;
}
- RareCaseProfile* addSlowCaseProfile(int bytecodeOffset)
+ RareCaseProfile* addRareCaseProfile(int bytecodeOffset)
{
- m_slowCaseProfiles.append(RareCaseProfile(bytecodeOffset));
- return &m_slowCaseProfiles.last();
+ m_rareCaseProfiles.append(RareCaseProfile(bytecodeOffset));
+ return &m_rareCaseProfiles.last();
}
- unsigned numberOfSlowCaseProfiles() { return m_slowCaseProfiles.size(); }
- RareCaseProfile* slowCaseProfile(int index) { return &m_slowCaseProfiles[index]; }
- RareCaseProfile* slowCaseProfileForBytecodeOffset(int bytecodeOffset)
+ unsigned numberOfRareCaseProfiles() { return m_rareCaseProfiles.size(); }
+ RareCaseProfile* rareCaseProfile(int index) { return &m_rareCaseProfiles[index]; }
+ RareCaseProfile* rareCaseProfileForBytecodeOffset(int bytecodeOffset)
{
- return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_slowCaseProfiles, m_slowCaseProfiles.size(), bytecodeOffset);
+ return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_rareCaseProfiles, m_rareCaseProfiles.size(), bytecodeOffset);
}
static uint32_t slowCaseThreshold() { return 100; }
bool likelyToTakeSlowCase(int bytecodeOffset)
{
- return slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold();
+ return rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold();
}
RareCaseProfile* addSpecialFastCaseProfile(int bytecodeOffset)
@@ -521,7 +521,7 @@
bool likelyToTakeDeepestSlowCase(int bytecodeOffset)
{
- unsigned slowCaseCount = slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
+ unsigned slowCaseCount = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
unsigned specialFastCaseCount = specialFastCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
return (slowCaseCount - specialFastCaseCount) >= slowCaseThreshold();
}
@@ -830,7 +830,7 @@
#endif
#if ENABLE(VALUE_PROFILER)
SegmentedVector<ValueProfile, 8> m_valueProfiles;
- SegmentedVector<RareCaseProfile, 8> m_slowCaseProfiles;
+ SegmentedVector<RareCaseProfile, 8> m_rareCaseProfiles;
SegmentedVector<RareCaseProfile, 8> m_specialFastCaseProfiles;
#endif
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (95675 => 95676)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2011-09-21 22:43:11 UTC (rev 95676)
@@ -513,7 +513,7 @@
return nodeIndex;
#if ENABLE(DFG_DEBUG_VERBOSE)
- printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock->slowCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
+ printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
#endif
switch (m_graph[nodeIndex].op) {
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (95675 => 95676)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2011-09-21 22:43:11 UTC (rev 95676)
@@ -415,9 +415,9 @@
Instruction* currentInstruction = instructionsBegin + m_bytecodeOffset;
#if ENABLE(VALUE_PROFILER)
- RareCaseProfile* slowCaseProfile = 0;
+ RareCaseProfile* rareCaseProfile = 0;
if (m_canBeOptimized)
- slowCaseProfile = m_codeBlock->addSlowCaseProfile(m_bytecodeOffset);
+ rareCaseProfile = m_codeBlock->addRareCaseProfile(m_bytecodeOffset);
#endif
switch (m_interpreter->getOpcodeID(currentInstruction->u.opcode)) {
@@ -494,7 +494,7 @@
#if ENABLE(VALUE_PROFILER)
if (m_canBeOptimized)
- add32(Imm32(1), AbsoluteAddress(&slowCaseProfile->m_counter));
+ add32(Imm32(1), AbsoluteAddress(&rareCaseProfile->m_counter));
#endif
emitJumpSlowToHot(jump(), 0);
@@ -514,8 +514,10 @@
JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck)
{
+#if ENABLE(VALUE_PROFILER)
+ m_canBeOptimized = m_codeBlock->canCompileWithDFG();
+#endif
#if ENABLE(DFG_JIT)
- m_canBeOptimized = m_codeBlock->canCompileWithDFG();
if (m_canBeOptimized)
m_startOfCode = label();
#endif
Modified: trunk/Source/_javascript_Core/jit/JIT.h (95675 => 95676)
--- trunk/Source/_javascript_Core/jit/JIT.h 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/jit/JIT.h 2011-09-21 22:43:11 UTC (rev 95676)
@@ -1074,9 +1074,11 @@
#endif
WeakRandom m_randomGenerator;
static CodeRef stringGetByValStubGenerator(JSGlobalData*);
-
+
+#if ENABLE(VALUE_PROFILER)
+ bool m_canBeOptimized;
+#endif
#if ENABLE(DFG_JIT)
- bool m_canBeOptimized;
Label m_startOfCode;
CompactJITCodeMap::Encoder m_jitCodeMapEncoder;
#endif
Modified: trunk/Source/_javascript_Core/jit/JITInlineMethods.h (95675 => 95676)
--- trunk/Source/_javascript_Core/jit/JITInlineMethods.h 2011-09-21 22:41:11 UTC (rev 95675)
+++ trunk/Source/_javascript_Core/jit/JITInlineMethods.h 2011-09-21 22:43:11 UTC (rev 95676)
@@ -446,6 +446,10 @@
#endif
}
+#if CPU(X86)
+static int bucketCounter;
+#endif
+
#if ENABLE(VALUE_PROFILER)
inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind)
{
@@ -465,13 +469,25 @@
ASSERT(valueProfile);
+#if CPU(X86)
if (m_randomGenerator.getUint32() & 1)
+ add32(Imm32(1), AbsoluteAddress(&bucketCounter));
+ else
+ add32(Imm32(3), AbsoluteAddress(&bucketCounter));
+ and32(Imm32(ValueProfile::bucketIndexMask), AbsoluteAddress(&bucketCounter));
+ load32(&bucketCounter, scratch);
+ lshift32(TrustedImm32(3), scratch);
+ addPtr(ImmPtr(valueProfile->m_buckets), scratch);
+ storePtr(value, scratch);
+#else
+ if (m_randomGenerator.getUint32() & 1)
add32(Imm32(1), bucketCounterRegister);
else
add32(Imm32(3), bucketCounterRegister);
and32(Imm32(ValueProfile::bucketIndexMask), bucketCounterRegister);
move(ImmPtr(valueProfile->m_buckets), scratch);
storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
+#endif
}
#endif