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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95676
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-21 Gavin Barraclough <barraclough@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 <fpizlo@apple.com>
DFG does not support compiling functions as constructors
#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;
}
profile->dump(stderr);
fprintf(stderr, "\n");
}
- fprintf(stderr, "SlowCaseProfile for %p:\n", this);
- for (unsigned i = 0; i < numberOfSlowCaseProfiles(); ++i) {
- SlowCaseProfile* profile = slowCaseProfile(i);
+ fprintf(stderr, "RareCaseProfile for %p:\n", this);
+ for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) {
+ RareCaseProfile* profile = rareCaseProfile(i);
fprintf(stderr, " bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
}
}
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)
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();
}
#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
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) {
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)) {
#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);
JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck)
{
-#if ENABLE(DFG_JIT)
+#if ENABLE(VALUE_PROFILER)
m_canBeOptimized = m_codeBlock->canCompileWithDFG();
+#endif
+#if ENABLE(DFG_JIT)
if (m_canBeOptimized)
m_startOfCode = label();
#endif
#endif
WeakRandom m_randomGenerator;
static CodeRef stringGetByValStubGenerator(JSGlobalData*);
-
-#if ENABLE(DFG_JIT)
+
+#if ENABLE(VALUE_PROFILER)
bool m_canBeOptimized;
+#endif
+#if ENABLE(DFG_JIT)
Label m_startOfCode;
CompactJITCodeMap::Encoder m_jitCodeMapEncoder;
#endif
#endif
}
+#if CPU(X86)
+static int bucketCounter;
+#endif
+
#if ENABLE(VALUE_PROFILER)
inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind)
{
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
and32(Imm32(ValueProfile::bucketIndexMask), bucketCounterRegister);
move(ImmPtr(valueProfile->m_buckets), scratch);
storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
+#endif
}
#endif