Replace SpecialFastCase profiles with ResultProfiles.
https://bugs.webkit.org/show_bug.cgi?id=152433
Reviewed by Saam Barati.
This is in preparation for upcoming work to enhance the DFG predictions to deal
with untyped operands.
This patch also enhances some of the arithmetic slow paths (for the LLINT and
baseline JIT) to collect result profiling info. This profiling info is not put
to use yet.
* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpRareCaseProfile):
(JSC::CodeBlock::dumpResultProfile):
(JSC::CodeBlock::printLocationAndOp):
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::shrinkToFit):
(JSC::CodeBlock::dumpValueProfiles):
(JSC::CodeBlock::rareCaseProfileCountForBytecodeOffset):
(JSC::CodeBlock::resultProfileForBytecodeOffset):
(JSC::CodeBlock::updateResultProfileForBytecodeOffset):
(JSC::CodeBlock::capabilityLevel):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::couldTakeSlowCase):
(JSC::CodeBlock::addResultProfile):
(JSC::CodeBlock::numberOfResultProfiles):
(JSC::CodeBlock::specialFastCaseProfileCountForBytecodeOffset):
(JSC::CodeBlock::couldTakeSpecialFastCase):
(JSC::CodeBlock::addSpecialFastCaseProfile): Deleted.
(JSC::CodeBlock::numberOfSpecialFastCaseProfiles): Deleted.
(JSC::CodeBlock::specialFastCaseProfile): Deleted.
(JSC::CodeBlock::specialFastCaseProfileForBytecodeOffset): Deleted.
* bytecode/ValueProfile.cpp: Added.
(WTF::printInternal):
* bytecode/ValueProfile.h:
(JSC::getRareCaseProfileBytecodeOffset):
(JSC::ResultProfile::ResultProfile):
(JSC::ResultProfile::bytecodeOffset):
(JSC::ResultProfile::specialFastPathCount):
(JSC::ResultProfile::didObserveNonInt32):
(JSC::ResultProfile::didObserveDouble):
(JSC::ResultProfile::didObserveNonNegZeroDouble):
(JSC::ResultProfile::didObserveNegZeroDouble):
(JSC::ResultProfile::didObserveNonNumber):
(JSC::ResultProfile::didObserveInt32Overflow):
(JSC::ResultProfile::setObservedNonNegZeroDouble):
(JSC::ResultProfile::setObservedNegZeroDouble):
(JSC::ResultProfile::setObservedNonNumber):
(JSC::ResultProfile::setObservedInt32Overflow):
(JSC::ResultProfile::addressOfFlags):
(JSC::ResultProfile::addressOfSpecialFastPathCount):
(JSC::ResultProfile::hasBits):
(JSC::ResultProfile::setBit):
(JSC::getResultProfileBytecodeOffset):
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_div):
(JSC::JIT::emit_op_mul):
* jit/JITDivGenerator.cpp:
(JSC::JITDivGenerator::generateFastPath):
* jit/JITDivGenerator.h:
(JSC::JITDivGenerator::JITDivGenerator):
* jit/JITMulGenerator.cpp:
(JSC::JITMulGenerator::generateFastPath):
* jit/JITMulGenerator.h:
(JSC::JITMulGenerator::JITMulGenerator):
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@194294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
index 879e418..c0979f3 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -741,6 +741,15 @@
out.print(name, profile->m_counter);
}
+void CodeBlock::dumpResultProfile(PrintStream& out, ResultProfile* profile, bool& hasPrintedProfiling)
+{
+ if (!profile)
+ return;
+
+ beginDumpProfiling(out, hasPrintedProfiling);
+ out.print("results: ", *profile);
+}
+
void CodeBlock::printLocationAndOp(PrintStream& out, ExecState*, int location, const Instruction*&, const char* op)
{
out.printf("[%4d] %-17s ", location, op);
@@ -1651,7 +1660,7 @@
}
dumpRareCaseProfile(out, "rare case: ", rareCaseProfileForBytecodeOffset(location), hasPrintedProfiling);
- dumpRareCaseProfile(out, "special fast case: ", specialFastCaseProfileForBytecodeOffset(location), hasPrintedProfiling);
+ dumpResultProfile(out, resultProfileForBytecodeOffset(location), hasPrintedProfiling);
#if ENABLE(DFG_JIT)
Vector<DFG::FrequentExitSite> exitSites = exitProfile().exitSitesFor(location);
@@ -3131,7 +3140,7 @@
void CodeBlock::shrinkToFit(ShrinkMode shrinkMode)
{
m_rareCaseProfiles.shrinkToFit();
- m_specialFastCaseProfiles.shrinkToFit();
+ m_resultProfiles.shrinkToFit();
if (shrinkMode == EarlyShrink) {
m_constantRegisters.shrinkToFit();
@@ -3976,10 +3985,10 @@
RareCaseProfile* profile = rareCaseProfile(i);
dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
}
- dataLog("SpecialFastCaseProfile for ", *this, ":\n");
- for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) {
- RareCaseProfile* profile = specialFastCaseProfile(i);
- dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
+ dataLog("ResultProfile for ", *this, ":\n");
+ for (unsigned i = 0; i < numberOfResultProfiles(); ++i) {
+ const ResultProfile& profile = *resultProfile(i);
+ dataLog(" bc = ", profile.bytecodeOffset(), ": ", profile, "\n");
}
}
#endif // ENABLE(VERBOSE_VALUE_PROFILE)
@@ -4177,6 +4186,36 @@
return 0;
}
+ResultProfile* CodeBlock::resultProfileForBytecodeOffset(int bytecodeOffset)
+{
+ return tryBinarySearch<ResultProfile, int>(
+ m_resultProfiles, m_resultProfiles.size(), bytecodeOffset,
+ getResultProfileBytecodeOffset);
+}
+
+void CodeBlock::updateResultProfileForBytecodeOffset(int bytecodeOffset, JSValue result)
+{
+#if ENABLE(DFG_JIT)
+ ResultProfile* profile = resultProfileForBytecodeOffset(bytecodeOffset);
+ if (!profile)
+ profile = addResultProfile(bytecodeOffset);
+
+ if (result.isNumber()) {
+ if (!result.isInt32()) {
+ double doubleVal = result.asNumber();
+ if (!doubleVal && std::signbit(doubleVal))
+ profile->setObservedNegZeroDouble();
+ else
+ profile->setObservedNonNegZeroDouble();
+ }
+ } else
+ profile->setObservedNonNumber();
+#else
+ UNUSED_PARAM(bytecodeOffset);
+ UNUSED_PARAM(result);
+#endif
+}
+
#if ENABLE(JIT)
DFG::CapabilityLevel CodeBlock::capabilityLevel()
{