Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (186700 => 186701)
--- trunk/Source/_javascript_Core/ChangeLog 2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-07-11 02:30:04 UTC (rev 186701)
@@ -1,3 +1,33 @@
+2015-07-10 Filip Pizlo <[email protected]>
+
+ It should be easy to measure total compile times.
+ https://bugs.webkit.org/show_bug.cgi?id=146857
+
+ Reviewed by Sam Weinig.
+
+ This gives DFG::Plan the ability to track total compile times, and return them in a map
+ of stats that jsc.cpp can display.
+
+ I want to do some work to bring down DFG compile times. This will help me measure whether
+ I'm making a difference or not.
+
+ * dfg/DFGPlan.cpp:
+ (JSC::DFG::Plan::Plan):
+ (JSC::DFG::Plan::~Plan):
+ (JSC::DFG::Plan::computeCompileTimes):
+ (JSC::DFG::Plan::reportCompileTimes):
+ (JSC::DFG::Plan::compileInThread):
+ (JSC::DFG::Plan::compileInThreadImpl):
+ (JSC::DFG::Plan::cancel):
+ (JSC::DFG::Plan::compileTimeStats):
+ (JSC::DFG::dumpAndVerifyGraph): Deleted.
+ (JSC::DFG::profilerCompilationKindForMode): Deleted.
+ * dfg/DFGPlan.h:
+ (JSC::DFG::Plan::compileTimeStats):
+ * jsc.cpp:
+ (jscmain):
+ * runtime/Options.h:
+
2015-07-04 Filip Pizlo <[email protected]>
DFG fragile frozen values are fundamentally broken
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.cpp (186700 => 186701)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.cpp 2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.cpp 2015-07-11 02:30:04 UTC (rev 186701)
@@ -91,7 +91,14 @@
namespace JSC { namespace DFG {
-static void dumpAndVerifyGraph(Graph& graph, const char* text, bool forceDump = false)
+namespace {
+
+double totalDFGCompileTime;
+double totalFTLCompileTime;
+double totalFTLDFGCompileTime;
+double totalFTLLLVMCompileTime;
+
+void dumpAndVerifyGraph(Graph& graph, const char* text, bool forceDump = false)
{
GraphDumpMode modeForFinalValidate = DumpGraph;
if (verboseCompilationEnabled(graph.m_plan.mode) || forceDump) {
@@ -103,7 +110,7 @@
validate(graph, modeForFinalValidate);
}
-static Profiler::CompilationKind profilerCompilationKindForMode(CompilationMode mode)
+Profiler::CompilationKind profilerCompilationKindForMode(CompilationMode mode)
{
switch (mode) {
case InvalidCompilationMode:
@@ -120,6 +127,8 @@
return Profiler::DFG;
}
+} // anonymous namespace
+
Plan::Plan(PassRefPtr<CodeBlock> passedCodeBlock, CodeBlock* profiledDFGCodeBlock,
CompilationMode mode, unsigned osrEntryBytecodeIndex,
const Operands<JSValue>& mustHandleValues)
@@ -142,6 +151,12 @@
{
}
+bool Plan::computeCompileTimes() const
+{
+ return reportCompileTimes()
+ || Options::reportTotalCompileTimes();
+}
+
bool Plan::reportCompileTimes() const
{
return Options::reportCompileTimes()
@@ -154,10 +169,10 @@
double before = 0;
CString codeBlockName;
- if (reportCompileTimes()) {
+ if (computeCompileTimes())
before = monotonicallyIncreasingTimeMS();
+ if (reportCompileTimes())
codeBlockName = toCString(*codeBlock);
- }
SamplingRegion samplingRegion("DFG Compilation (Plan)");
CompilationScope compilationScope;
@@ -170,6 +185,19 @@
RELEASE_ASSERT(path == CancelPath || finalizer);
RELEASE_ASSERT((path == CancelPath) == (stage == Cancelled));
+ double after = 0;
+ if (computeCompileTimes())
+ after = monotonicallyIncreasingTimeMS();
+
+ if (Options::reportTotalCompileTimes()) {
+ if (isFTL(mode)) {
+ totalFTLCompileTime += after - before;
+ totalFTLDFGCompileTime += m_timeBeforeFTL - before;
+ totalFTLLLVMCompileTime += after - m_timeBeforeFTL;
+ } else
+ totalDFGCompileTime += after - before;
+ }
+
if (reportCompileTimes()) {
const char* pathName;
switch (path) {
@@ -192,10 +220,9 @@
#endif
break;
}
- double now = monotonicallyIncreasingTimeMS();
- dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", now - before, " ms");
+ dataLog("Optimized ", codeBlockName, " using ", mode, " with ", pathName, " into ", finalizer ? finalizer->codeSize() : 0, " bytes in ", after - before, " ms");
if (path == FTLPath)
- dataLog(" (DFG: ", m_timeBeforeFTL - before, ", LLVM: ", now - m_timeBeforeFTL, ")");
+ dataLog(" (DFG: ", m_timeBeforeFTL - before, ", LLVM: ", after - m_timeBeforeFTL, ")");
dataLog(".\n");
}
}
@@ -433,7 +460,7 @@
FTL::State state(dfg);
FTL::lowerDFGToLLVM(state);
- if (reportCompileTimes())
+ if (computeCompileTimes())
m_timeBeforeFTL = monotonicallyIncreasingTimeMS();
if (Options::llvmAlwaysFailsBeforeCompile()) {
@@ -612,6 +639,19 @@
stage = Cancelled;
}
+HashMap<CString, double> Plan::compileTimeStats()
+{
+ HashMap<CString, double> result;
+ if (Options::reportTotalCompileTimes()) {
+ result.add("Compile Time", totalDFGCompileTime + totalFTLCompileTime);
+ result.add("DFG Compile Time", totalDFGCompileTime);
+ result.add("FTL Compile Time", totalFTLCompileTime);
+ result.add("FTL (DFG) Compile Time", totalFTLDFGCompileTime);
+ result.add("FTL (LLVM) Compile Time", totalFTLLLVMCompileTime);
+ }
+ return result;
+}
+
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.h (186700 => 186701)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.h 2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.h 2015-07-11 02:30:04 UTC (rev 186701)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,7 +38,9 @@
#include "DeferredCompilationCallback.h"
#include "Operands.h"
#include "ProfilerCompilation.h"
+#include <wtf/HashMap.h>
#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/text/CString.h>
namespace JSC {
@@ -102,7 +104,10 @@
RefPtr<DeferredCompilationCallback> callback;
+ JS_EXPORT_PRIVATE static HashMap<CString, double> compileTimeStats();
+
private:
+ bool computeCompileTimes() const;
bool reportCompileTimes() const;
enum CompilationPath { FailPath, DFGPath, FTLPath, CancelPath };
@@ -118,6 +123,8 @@
class Plan : public RefCounted<Plan> {
// Dummy class to allow !ENABLE(DFG_JIT) to build.
+public:
+ static HashMap<CString, double> compileTimeStats() { return HashMap<CString, double>(); }
};
#endif // ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/jsc.cpp (186700 => 186701)
--- trunk/Source/_javascript_Core/jsc.cpp 2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/_javascript_Core/jsc.cpp 2015-07-11 02:30:04 UTC (rev 186701)
@@ -28,6 +28,7 @@
#include "CodeBlock.h"
#include "Completion.h"
#include "CopiedSpaceInlines.h"
+#include "DFGPlan.h"
#include "Disassembler.h"
#include "Exception.h"
#include "ExceptionHelpers.h"
@@ -1556,6 +1557,13 @@
printf("JSC OSR EXIT FUZZ: encountered %u dynamic checks.\n", numberOfOSRExitFuzzChecks());
}
#endif
+ auto compileTimeStats = DFG::Plan::compileTimeStats();
+ Vector<CString> compileTimeKeys;
+ for (auto& entry : compileTimeStats)
+ compileTimeKeys.append(entry.key);
+ std::sort(compileTimeKeys.begin(), compileTimeKeys.end());
+ for (CString key : compileTimeKeys)
+ printf("%40s: %.3lf ms\n", key.data(), compileTimeStats.get(key));
}
return result;
Modified: trunk/Source/_javascript_Core/runtime/Options.h (186700 => 186701)
--- trunk/Source/_javascript_Core/runtime/Options.h 2015-07-11 00:40:19 UTC (rev 186700)
+++ trunk/Source/_javascript_Core/runtime/Options.h 2015-07-11 02:30:04 UTC (rev 186701)
@@ -144,6 +144,7 @@
v(bool, verboseCompilationQueue, false, nullptr) \
v(bool, reportCompileTimes, false, "dumps JS function signature and the time it took to compile") \
v(bool, reportFTLCompileTimes, false, "dumps JS function signature and the time it took to FTL compile") \
+ v(bool, reportTotalCompileTimes, false, nullptr) \
v(bool, verboseCFA, false, nullptr) \
v(bool, verboseFTLToJSThunk, false, nullptr) \
v(bool, verboseFTLFailure, false, nullptr) \