JSC profiler should have an at-a-glance report of the success of DFG optimization
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2013 01:17:09 +0000 (01:17 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2013 01:17:09 +0000 (01:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112988

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleGetById):
(JSC::DFG::ByteCodeParser::parseBlock):
* profiler/ProfilerCompilation.cpp:
(JSC::Profiler::Compilation::Compilation):
(JSC::Profiler::Compilation::toJS):
* profiler/ProfilerCompilation.h:
(JSC::Profiler::Compilation::noticeInlinedGetById):
(JSC::Profiler::Compilation::noticeInlinedPutById):
(JSC::Profiler::Compilation::noticeInlinedCall):
(Compilation):
* runtime/CommonIdentifiers.h:

Tools:

* Scripts/display-profiler-output:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/profiler/ProfilerCompilation.cpp
Source/JavaScriptCore/profiler/ProfilerCompilation.h
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Tools/ChangeLog
Tools/Scripts/display-profiler-output

index ca977b2..06171fa 100644 (file)
@@ -1,3 +1,24 @@
+2013-03-21  Filip Pizlo  <fpizlo@apple.com>
+
+        JSC profiler should have an at-a-glance report of the success of DFG optimization
+        https://bugs.webkit.org/show_bug.cgi?id=112988
+
+        Reviewed by Geoffrey Garen.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleCall):
+        (JSC::DFG::ByteCodeParser::handleGetById):
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * profiler/ProfilerCompilation.cpp:
+        (JSC::Profiler::Compilation::Compilation):
+        (JSC::Profiler::Compilation::toJS):
+        * profiler/ProfilerCompilation.h:
+        (JSC::Profiler::Compilation::noticeInlinedGetById):
+        (JSC::Profiler::Compilation::noticeInlinedPutById):
+        (JSC::Profiler::Compilation::noticeInlinedCall):
+        (Compilation):
+        * runtime/CommonIdentifiers.h:
+
 2013-03-21  Mark Lam  <mark.lam@apple.com>
 
         Fix lexer charPosition computation when "rewind"ing the lexer.
index f01036d..69b80b8 100644 (file)
@@ -1230,10 +1230,15 @@ void ByteCodeParser::handleCall(Interpreter* interpreter, Instruction* currentIn
             // the inputs must be kept alive whatever exits the intrinsic may do.
             addToGraph(Phantom, callTarget);
             emitArgumentPhantoms(registerOffset, argumentCountIncludingThis, kind);
+            if (m_graph.m_compilation)
+                m_graph.m_compilation->noticeInlinedCall();
             return;
         }
-    } else if (handleInlining(usesResult, callTarget, resultOperand, callLinkStatus, registerOffset, argumentCountIncludingThis, nextOffset, kind))
+    } else if (handleInlining(usesResult, callTarget, resultOperand, callLinkStatus, registerOffset, argumentCountIncludingThis, nextOffset, kind)) {
+        if (m_graph.m_compilation)
+            m_graph.m_compilation->noticeInlinedCall();
         return;
+    }
     
     addCall(interpreter, currentInstruction, op);
 }
@@ -1717,6 +1722,8 @@ void ByteCodeParser::handleGetById(
     // execution if it doesn't have a prediction, so we do it manually.
     if (prediction == SpecNone)
         addToGraph(ForceOSRExit);
+    else if (m_graph.m_compilation)
+        m_graph.m_compilation->noticeInlinedGetById();
     
     Node* originalBaseForBaselineJIT = base;
                 
@@ -2595,8 +2602,11 @@ bool ByteCodeParser::parseBlock(unsigned limit)
                 m_inlineStackTop->m_profiledBlock,
                 m_currentIndex,
                 m_codeBlock->identifier(identifierNumber));
-            if (!putByIdStatus.isSet())
+            bool canCountAsInlined = true;
+            if (!putByIdStatus.isSet()) {
                 addToGraph(ForceOSRExit);
+                canCountAsInlined = false;
+            }
             
             bool hasExitSite = m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache);
             
@@ -2684,7 +2694,11 @@ bool ByteCodeParser::parseBlock(unsigned limit)
                     addToGraph(PutByIdDirect, OpInfo(identifierNumber), base, value);
                 else
                     addToGraph(PutById, OpInfo(identifierNumber), base, value);
+                canCountAsInlined = false;
             }
+            
+            if (canCountAsInlined && m_graph.m_compilation)
+                m_graph.m_compilation->noticeInlinedPutById();
 
             NEXT_OPCODE(op_put_by_id);
         }
index 5ff49d4..affbbb8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,6 +37,9 @@ namespace JSC { namespace Profiler {
 Compilation::Compilation(Bytecodes* bytecodes, CompilationKind kind)
     : m_bytecodes(bytecodes)
     , m_kind(kind)
+    , m_numInlinedGetByIds(0)
+    , m_numInlinedPutByIds(0)
+    , m_numInlinedCalls(0)
 {
 }
 
@@ -124,6 +127,10 @@ JSValue Compilation::toJS(ExecState* exec) const
         exits->putDirectIndex(exec, i, m_osrExits[i].toJS(exec));
     result->putDirect(exec->globalData(), exec->propertyNames().osrExits, exits);
     
+    result->putDirect(exec->globalData(), exec->propertyNames().numInlinedGetByIds, jsNumber(m_numInlinedGetByIds));
+    result->putDirect(exec->globalData(), exec->propertyNames().numInlinedPutByIds, jsNumber(m_numInlinedPutByIds));
+    result->putDirect(exec->globalData(), exec->propertyNames().numInlinedCalls, jsNumber(m_numInlinedCalls));
+    
     return result;
 }
 
index 607060e..b3183fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,6 +55,10 @@ public:
     unsigned profiledBytecodesSize() const { return m_profiledBytecodes.size(); }
     const ProfiledBytecodes& profiledBytecodesAt(unsigned i) const { return m_profiledBytecodes[i]; }
     
+    void noticeInlinedGetById() { m_numInlinedGetByIds++; }
+    void noticeInlinedPutById() { m_numInlinedPutByIds++; }
+    void noticeInlinedCall() { m_numInlinedCalls++; }
+    
     Bytecodes* bytecodes() const { return m_bytecodes; }
     CompilationKind kind() const { return m_kind; }
     
@@ -73,6 +77,9 @@ private:
     HashMap<OriginStack, OwnPtr<ExecutionCounter> > m_counters;
     Vector<OSRExitSite> m_osrExitSites;
     SegmentedVector<OSRExit> m_osrExits;
+    unsigned m_numInlinedGetByIds;
+    unsigned m_numInlinedPutByIds;
+    unsigned m_numInlinedCalls;
 };
 
 } } // namespace JSC::Profiler
index fa9eeb0..baa5746 100644 (file)
@@ -73,6 +73,9 @@
     macro(multiline) \
     macro(name) \
     macro(now) \
+    macro(numInlinedGetByIds) \
+    macro(numInlinedPutByIds) \
+    macro(numInlinedCalls) \
     macro(Object) \
     macro(opcode) \
     macro(origin) \
index 03c8342..e7df69d 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-21  Filip Pizlo  <fpizlo@apple.com>
+
+        JSC profiler should have an at-a-glance report of the success of DFG optimization
+        https://bugs.webkit.org/show_bug.cgi?id=112988
+
+        Reviewed by Geoffrey Garen.
+
+        * Scripts/display-profiler-output:
+
 2013-03-21  Dirk Pranke  <dpranke@chromium.org>
 
         [chromium] Linux ASAN WebKit canary is running out of memory
index 24df014..1a1deee 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-# Copyright (C) 2012 Apple Inc. All rights reserved.
+# Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -325,7 +325,9 @@ class OSRExit
 end
 
 class Compilation
-    attr_accessor :bytecode, :engine, :descriptions, :counters, :compilationIndex, :osrExits, :profiledBytecodes
+    attr_accessor :bytecode, :engine, :descriptions, :counters, :compilationIndex
+    attr_accessor :osrExits, :profiledBytecodes, :numInlinedGetByIds, :numInlinedPutByIds
+    attr_accessor :numInlinedCalls
     
     def initialize(json)
         @bytecode = $bytecodes[json["bytecodesID"].to_i]
@@ -375,6 +377,9 @@ class Compilation
             | subJson |
             @profiledBytecodes << ProfiledBytecodes.new(subJson)
         }
+        @numInlinedGetByIds = json["numInlinedGetByIds"]
+        @numInlinedPutByIds = json["numInlinedPutByIds"]
+        @numInlinedCalls = json["numInlinedCalls"]
     end
     
     def counter(origin)
@@ -507,6 +512,9 @@ def summary(mode)
         
         exitCountCols = 7
         remaining -= exitCountCols + 1
+        
+        recentOptsCols = 12
+        remaining -= recentOptsCols + 1
     end
     
     if remaining > 0
@@ -525,6 +533,7 @@ def summary(mode)
         print(" " + center("#Compil", compilationsCols))
         print(" " + center("Inlines", inlinesCols))
         print(" " + center("#Exits", exitCountCols))
+        print(" " + center("Last Opts", recentOptsCols))
     end
     if sourceCols
         print(" " + center("Source", sourceCols))
@@ -540,6 +549,8 @@ def summary(mode)
         print(" " + center("Base/DFG", machineCountCols))
         print(" " + (" " * compilationsCols))
         print(" " + center("Src/Total", inlinesCols))
+        print(" " + (" " * exitCountCols))
+        print(" " + center("Get/Put/Call", recentOptsCols))
     end
     puts
     $bytecodes.sort {
@@ -564,6 +575,15 @@ def summary(mode)
             print(" " + center(bytecode.compilations.size.to_s, compilationsCols))
             print(" " + center(bytecode.sourceMachineInlineSites.to_s + "/" + bytecode.totalMachineInlineSites.to_s, inlinesCols))
             print(" " + center(bytecode.totalExitCount.to_s, exitCountCols))
+            lastCompilation = bytecode.compilations[-1]
+            if lastCompilation
+                optData = [lastCompilation.numInlinedGetByIds,
+                           lastCompilation.numInlinedPutByIds,
+                           lastCompilation.numInlinedCalls]
+            else
+                optData = ["N/A"]
+            end
+            print(" " + center(optData.join('/'), recentOptsCols))
         end
         if sourceCols
             print(" " + sourceOnOneLine(bytecode.source, sourceCols))
@@ -826,6 +846,7 @@ def executeCommand(*commandArray)
             end
             
             puts("Compilation #{compilation}:")
+            puts("    Num inlined: GetByIds: #{compilation.numInlinedGetByIds}  PutByIds: #{compilation.numInlinedPutByIds}  Calls: #{compilation.numInlinedCalls}")
             puts(center("Actual Counts", actualCountCols) + " " + center("Source Counts", sourceCountCols) + " " + center("Disassembly in #{compilation.engine}", screenWidth - 1 - sourceCountCols - 1 - actualCountCols))
             puts((" " * actualCountCols) + " " + center("Base/DFG", sourceCountCols))