Ignore:
Timestamp:
Feb 2, 2015, 11:05:46 AM (10 years ago)
Author:
[email protected]
Message:

Create tests for JSC's Control Flow Profiler
https://bugs.webkit.org/show_bug.cgi?id=141123

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

This patch creates a control flow profiler testing API in jsc.cpp
that accepts a function and a string as arguments. The string must
be a substring of the text of the function argument. The API returns
a boolean indicating whether or not the basic block that encloses the
substring has executed.

This patch uses this API to test that the control flow profiler
behaves as expected on basic block boundaries. These tests do not
provide full coverage for all JavaScript statements that can create
basic blocks boundaries. Full coverage will come in a later patch.

  • jsc.cpp:

(GlobalObject::finishCreation):
(functionHasBasicBlockExecuted):

  • runtime/ControlFlowProfiler.cpp:

(JSC::ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted):

  • runtime/ControlFlowProfiler.h:
  • tests/controlFlowProfiler: Added.
  • tests/controlFlowProfiler.yaml: Added.
  • tests/controlFlowProfiler/driver: Added.
  • tests/controlFlowProfiler/driver/driver.js: Added.

(assert):

  • tests/controlFlowProfiler/if-statement.js: Added.

(testIf):
(noMatches):

  • tests/controlFlowProfiler/loop-statements.js: Added.

(forRegular):
(forIn):
(forOf):
(whileLoop):

  • tests/controlFlowProfiler/switch-statements.js: Added.

(testSwitch):

  • tests/controlFlowProfiler/test-jit.js: Added.

(tierUpToBaseline):
(tierUpToDFG):
(baselineTest):
(dfgTest):

Tools:

  • Scripts/run-javascriptcore-tests:

(runJSCStressTests):

  • Scripts/run-jsc-stress-tests:
File:
1 edited

Legend:

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

    r178928 r179479  
    483483static EncodedJSValue JSC_HOST_CALL functionReturnTypeFor(ExecState*);
    484484static EncodedJSValue JSC_HOST_CALL functionDumpBasicBlockExecutionRanges(ExecState*);
     485static EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState*);
    485486
    486487#if ENABLE(SAMPLING_FLAGS)
     
    639640
    640641        addFunction(vm, "dumpBasicBlockExecutionRanges", functionDumpBasicBlockExecutionRanges , 0);
     642        addFunction(vm, "hasBasicBlockExecuted", functionHasBasicBlockExecuted, 2);
    641643       
    642644        JSArray* array = constructEmptyArray(globalExec(), 0);
     
    11131115    exec->vm().controlFlowProfiler()->dumpData();
    11141116    return JSValue::encode(jsUndefined());
     1117}
     1118
     1119EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState* exec)
     1120{
     1121    RELEASE_ASSERT(exec->vm().controlFlowProfiler());
     1122
     1123    JSValue functionValue = exec->argument(0);
     1124    RELEASE_ASSERT(functionValue.isFunction());
     1125    FunctionExecutable* executable = (jsDynamicCast<JSFunction*>(functionValue.asCell()->getObject()))->jsExecutable();
     1126
     1127    RELEASE_ASSERT(exec->argument(1).isString());
     1128    String substring = exec->argument(1).getString(exec);
     1129    String sourceCodeText = executable->source().toString();
     1130    int offset = sourceCodeText.find(substring) + executable->source().startOffset();
     1131   
     1132    bool hasExecuted = exec->vm().controlFlowProfiler()->hasBasicBlockAtTextOffsetBeenExecuted(offset, executable->sourceID(), exec->vm());
     1133    return JSValue::encode(jsBoolean(hasExecuted));
    11151134}
    11161135
Note: See TracChangeset for help on using the changeset viewer.