Ignore:
Timestamp:
Nov 6, 2015, 7:18:32 PM (10 years ago)
Author:
[email protected]
Message:

Control Flow Profiler should keep execution counts of basic blocks
https://bugs.webkit.org/show_bug.cgi?id=146099

Reviewed by Mark Lam.

This patch changes the control flow profiler to now
keep track of execution counts for each basic block
instead of a boolean indicating if the basic block has
executed at all. This has the consequence of us having to
always compile all op_profile_control_flows in the baseline and DFG.

This patch adds a new "executionCount" field to the inspector protocol
corresponding to the execution of a basic block. This patch, for now,
still maintains the previous field of "hasExecuted" even though this is
redundant with "executionCount".

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • inspector/agents/InspectorRuntimeAgent.cpp:

(Inspector::InspectorRuntimeAgent::getBasicBlocks):

  • inspector/protocol/Runtime.json:
  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_profile_control_flow):
(JSC::JIT::emit_op_create_direct_arguments):

  • jsc.cpp:

(GlobalObject::finishCreation):
(functionHasBasicBlockExecuted):
(functionBasicBlockExecutionCount):
(functionEnableExceptionFuzz):
(functionDrainMicrotasks):
(functionIs32BitPlatform):
(functionLoadWebAssembly):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/BasicBlockLocation.cpp:

(JSC::BasicBlockLocation::BasicBlockLocation):
(JSC::BasicBlockLocation::dumpData):
(JSC::BasicBlockLocation::emitExecuteCode):

  • runtime/BasicBlockLocation.h:

(JSC::BasicBlockLocation::endOffset):
(JSC::BasicBlockLocation::setStartOffset):
(JSC::BasicBlockLocation::setEndOffset):
(JSC::BasicBlockLocation::hasExecuted):
(JSC::BasicBlockLocation::executionCount):

  • runtime/ControlFlowProfiler.cpp:

(JSC::ControlFlowProfiler::getBasicBlocksForSourceID):
(JSC::findBasicBlockAtTextOffset):
(JSC::ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted):
(JSC::ControlFlowProfiler::basicBlockExecutionCountAtTextOffset):

  • runtime/ControlFlowProfiler.h:

(JSC::ControlFlowProfiler::dummyBasicBlock):

  • tests/controlFlowProfiler/execution-count.js: Added.

(noop):
(foo):
(a):
(b):
(baz):
(jaz):
(testWhile):
(is32BitPlatform.testMax):
(is32BitPlatform):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r191840 r192125  
    545545static EncodedJSValue JSC_HOST_CALL functionDumpBasicBlockExecutionRanges(ExecState*);
    546546static EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState*);
     547static EncodedJSValue JSC_HOST_CALL functionBasicBlockExecutionCount(ExecState*);
    547548static EncodedJSValue JSC_HOST_CALL functionEnableExceptionFuzz(ExecState*);
    548549static EncodedJSValue JSC_HOST_CALL functionDrainMicrotasks(ExecState*);
     550static EncodedJSValue JSC_HOST_CALL functionIs32BitPlatform(ExecState*);
    549551#if ENABLE(WEBASSEMBLY)
    550552static EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState*);
     
    725727        addFunction(vm, "dumpBasicBlockExecutionRanges", functionDumpBasicBlockExecutionRanges , 0);
    726728        addFunction(vm, "hasBasicBlockExecuted", functionHasBasicBlockExecuted, 2);
     729        addFunction(vm, "basicBlockExecutionCount", functionBasicBlockExecutionCount, 2);
    727730
    728731        addFunction(vm, "enableExceptionFuzz", functionEnableExceptionFuzz, 0);
    729732
    730733        addFunction(vm, "drainMicrotasks", functionDrainMicrotasks, 0);
     734
     735        addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0);
    731736
    732737#if ENABLE(WEBASSEMBLY)
     
    15061511}
    15071512
     1513EncodedJSValue JSC_HOST_CALL functionBasicBlockExecutionCount(ExecState* exec)
     1514{
     1515    RELEASE_ASSERT(exec->vm().controlFlowProfiler());
     1516
     1517    JSValue functionValue = exec->argument(0);
     1518    RELEASE_ASSERT(functionValue.isFunction());
     1519    FunctionExecutable* executable = (jsDynamicCast<JSFunction*>(functionValue.asCell()->getObject()))->jsExecutable();
     1520
     1521    RELEASE_ASSERT(exec->argument(1).isString());
     1522    String substring = exec->argument(1).getString(exec);
     1523    String sourceCodeText = executable->source().toString();
     1524    RELEASE_ASSERT(sourceCodeText.contains(substring));
     1525    int offset = sourceCodeText.find(substring) + executable->source().startOffset();
     1526   
     1527    size_t executionCount = exec->vm().controlFlowProfiler()->basicBlockExecutionCountAtTextOffset(offset, executable->sourceID(), exec->vm());
     1528    return JSValue::encode(JSValue(executionCount));
     1529}
     1530
    15081531EncodedJSValue JSC_HOST_CALL functionEnableExceptionFuzz(ExecState*)
    15091532{
     
    15161539    exec->vm().drainMicrotasks();
    15171540    return JSValue::encode(jsUndefined());
     1541}
     1542
     1543EncodedJSValue JSC_HOST_CALL functionIs32BitPlatform(ExecState*)
     1544{
     1545#if USE(JSVALUE64)
     1546    return JSValue::encode(JSValue(JSC::JSValue::JSFalse));
     1547#else
     1548    return JSValue::encode(JSValue(JSC::JSValue::JSTrue));
     1549#endif
    15181550}
    15191551
Note: See TracChangeset for help on using the changeset viewer.