Changeset 164734 in webkit


Ignore:
Timestamp:
Feb 26, 2014 12:13:22 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Compilation policy management belongs in operationOptimize(), not the DFG Driver.
<https://webkit.org/b/129355>

Reviewed by Filip Pizlo.

By compilation policy, I mean the rules for determining whether to
compile, when to compile, when to attempt compilation again, etc. The
few of these policy decisions that were previously being made in the
DFG driver are now moved to operationOptimize() where we keep the rest
of the policy logic. Decisions that are based on the capabilities
supported by the DFG are moved to DFG capabiliityLevel().

I've run the following benchmarks:

  1. the collection of jsc benchmarks on the jsc executable vs. its baseline.
  2. Octane 2.0 in browser without the WebInspector.
  3. Octane 2.0 in browser with the WebInspector open and a breakpoint set somewhere where it won't break.

In all of these, the results came out to be a wash as expected.

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::isSupported):
(JSC::DFG::mightCompileEval):
(JSC::DFG::mightCompileProgram):
(JSC::DFG::mightCompileFunctionForCall):
(JSC::DFG::mightCompileFunctionForConstruct):
(JSC::DFG::mightInlineFunctionForCall):
(JSC::DFG::mightInlineFunctionForClosureCall):
(JSC::DFG::mightInlineFunctionForConstruct):

  • dfg/DFGCapabilities.h:
  • dfg/DFGDriver.cpp:

(JSC::DFG::compileImpl):

  • jit/JITOperations.cpp:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r164732 r164734  
     12014-02-26  Mark Lam  <mark.lam@apple.com>
     2
     3        Compilation policy management belongs in operationOptimize(), not the DFG Driver.
     4        <https://webkit.org/b/129355>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        By compilation policy, I mean the rules for determining whether to
     9        compile, when to compile, when to attempt compilation again, etc.  The
     10        few of these policy decisions that were previously being made in the
     11        DFG driver are now moved to operationOptimize() where we keep the rest
     12        of the policy logic.  Decisions that are based on the capabilities
     13        supported by the DFG are moved to DFG capabiliityLevel().
     14
     15        I've run the following benchmarks:
     16        1. the collection of jsc benchmarks on the jsc executable vs. its
     17           baseline.
     18        2. Octane 2.0 in browser without the WebInspector.
     19        3. Octane 2.0 in browser with the WebInspector open and a breakpoint
     20           set somewhere where it won't break.
     21
     22        In all of these, the results came out to be a wash as expected.
     23
     24        * dfg/DFGCapabilities.cpp:
     25        (JSC::DFG::isSupported):
     26        (JSC::DFG::mightCompileEval):
     27        (JSC::DFG::mightCompileProgram):
     28        (JSC::DFG::mightCompileFunctionForCall):
     29        (JSC::DFG::mightCompileFunctionForConstruct):
     30        (JSC::DFG::mightInlineFunctionForCall):
     31        (JSC::DFG::mightInlineFunctionForClosureCall):
     32        (JSC::DFG::mightInlineFunctionForConstruct):
     33        * dfg/DFGCapabilities.h:
     34        * dfg/DFGDriver.cpp:
     35        (JSC::DFG::compileImpl):
     36        * jit/JITOperations.cpp:
     37
    1382014-02-26  Michael Saboff  <msaboff@apple.com>
    239
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r164229 r164734  
    3333#include "Interpreter.h"
    3434#include "JSCInlines.h"
     35#include "Options.h"
    3536
    3637namespace JSC { namespace DFG {
    3738
     39bool isSupported(CodeBlock* codeBlock)
     40{
     41    return Options::useDFGJIT()
     42        && MacroAssembler::supportsFloatingPoint()
     43        && Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount());
     44}
     45
    3846bool mightCompileEval(CodeBlock* codeBlock)
    3947{
    40     return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
     48    return isSupported(codeBlock)
     49        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
    4150}
    4251bool mightCompileProgram(CodeBlock* codeBlock)
    4352{
    44     return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
     53    return isSupported(codeBlock)
     54        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
    4555}
    4656bool mightCompileFunctionForCall(CodeBlock* codeBlock)
    4757{
    48     return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
     58    return isSupported(codeBlock)
     59        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
    4960}
    5061bool mightCompileFunctionForConstruct(CodeBlock* codeBlock)
    5162{
    52     return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
     63    return isSupported(codeBlock)
     64        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
    5365}
    5466
    5567bool mightInlineFunctionForCall(CodeBlock* codeBlock)
    5668{
    57     return codeBlock->instructionCount() <= Options::maximumFunctionForCallInlineCandidateInstructionCount()
     69    return isSupported(codeBlock)
     70        && codeBlock->instructionCount() <= Options::maximumFunctionForCallInlineCandidateInstructionCount()
    5871        && !codeBlock->ownerExecutable()->needsActivation()
    5972        && codeBlock->ownerExecutable()->isInliningCandidate();
     
    6174bool mightInlineFunctionForClosureCall(CodeBlock* codeBlock)
    6275{
    63     return codeBlock->instructionCount() <= Options::maximumFunctionForClosureCallInlineCandidateInstructionCount()
     76    return isSupported(codeBlock)
     77        && codeBlock->instructionCount() <= Options::maximumFunctionForClosureCallInlineCandidateInstructionCount()
    6478        && !codeBlock->ownerExecutable()->needsActivation()
    6579        && codeBlock->ownerExecutable()->isInliningCandidate();
     
    6781bool mightInlineFunctionForConstruct(CodeBlock* codeBlock)
    6882{
    69     return codeBlock->instructionCount() <= Options::maximumFunctionForConstructInlineCandidateInstructionCount()
     83    return isSupported(codeBlock)
     84        && codeBlock->instructionCount() <= Options::maximumFunctionForConstructInlineCandidateInstructionCount()
    7085        && !codeBlock->ownerExecutable()->needsActivation()
    7186        && codeBlock->ownerExecutable()->isInliningCandidate();
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.h

    r164558 r164734  
    4040// Fast check functions; if they return true it is still necessary to
    4141// check opcodes.
     42bool isSupported(CodeBlock*);
    4243bool mightCompileEval(CodeBlock*);
    4344bool mightCompileProgram(CodeBlock*);
  • trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp

    r164207 r164734  
    3535#include "DFGThunks.h"
    3636#include "DFGWorklist.h"
    37 #include "Debugger.h"
    3837#include "JITCode.h"
    3938#include "JSCInlines.h"
     
    7069    ASSERT(!profiledDFGCodeBlock || profiledDFGCodeBlock->jitType() == JITCode::DFGJIT);
    7170   
    72     if (!Options::useDFGJIT() || !MacroAssembler::supportsFloatingPoint())
    73         return CompilationFailed;
    74 
    75     if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount()))
    76         return CompilationFailed;
    77    
    78     if (vm.enabledProfiler())
    79         return CompilationInvalidated;
    80 
    81     Debugger* debugger = codeBlock->globalObject()->debugger();
    82     if (debugger && (debugger->isStepping() || codeBlock->baselineAlternative()->hasDebuggerRequests()))
    83         return CompilationInvalidated;
    84 
    8571    if (logCompilationChanges(mode))
    8672        dataLog("DFG(Driver) compiling ", *codeBlock, " with ", mode, ", number of instructions = ", codeBlock->instructionCount(), "\n");
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r164630 r164734  
    3636#include "DFGThunks.h"
    3737#include "DFGWorklist.h"
     38#include "Debugger.h"
    3839#include "Error.h"
    3940#include "ErrorHandlingScope.h"
     
    10081009
    10091010#if ENABLE(DFG_JIT)
     1011static void updateAllPredictionsAndOptimizeAfterWarmUp(CodeBlock* codeBlock)
     1012{
     1013    codeBlock->updateAllPredictions();
     1014    codeBlock->optimizeAfterWarmUp();
     1015}
     1016
    10101017SlowPathReturnType JIT_OPERATION operationOptimize(ExecState* exec, int32_t bytecodeIndex)
    10111018{
     
    10611068    }
    10621069   
     1070    if (vm.enabledProfiler()) {
     1071        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
     1072        return encodeResult(0, 0);
     1073    }
     1074
     1075    Debugger* debugger = codeBlock->globalObject()->debugger();
     1076    if (debugger && (debugger->isStepping() || codeBlock->baselineAlternative()->hasDebuggerRequests())) {
     1077        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
     1078        return encodeResult(0, 0);
     1079    }
     1080
    10631081    if (codeBlock->m_shouldAlwaysBeInlined) {
    1064         codeBlock->updateAllPredictions();
    1065         codeBlock->optimizeAfterWarmUp();
     1082        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
    10661083        if (Options::verboseOSR())
    10671084            dataLog("Choosing not to optimize ", *codeBlock, " yet, because m_shouldAlwaysBeInlined == true.\n");
Note: See TracChangeset for help on using the changeset viewer.