Changeset 182294 in webkit


Ignore:
Timestamp:
Apr 2, 2015 3:46:52 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Add Options::dumpSourceAtDFGTime().
<https://webkit.org/b/143349>

Reviewed by Oliver Hunt, and Michael Saboff.

Sometimes, we will want to see the JS source code that we're compiling, and it
would be nice to be able to do this without having to jump thru a lot of hoops.
So, let's add a Options::dumpSourceAtDFGTime() option just like we have a
Options::dumpBytecodeAtDFGTime() option.

Also added versions of CodeBlock::dumpSource() and CodeBlock::dumpBytecode()
that explicitly take no arguments (instead of relying on the version that takes
the default argument). These versions are friendlier to use when we want to call
them from an interactive debugging session.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpSource):
(JSC::CodeBlock::dumpBytecode):

  • bytecode/CodeBlock.h:
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseCodeBlock):

  • runtime/Options.h:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r182280 r182294  
     12015-04-02  Mark Lam  <mark.lam@apple.com>
     2
     3        Add Options::dumpSourceAtDFGTime().
     4        <https://webkit.org/b/143349>
     5
     6        Reviewed by Oliver Hunt, and Michael Saboff.
     7
     8        Sometimes, we will want to see the JS source code that we're compiling, and it
     9        would be nice to be able to do this without having to jump thru a lot of hoops.
     10        So, let's add a Options::dumpSourceAtDFGTime() option just like we have a
     11        Options::dumpBytecodeAtDFGTime() option.
     12
     13        Also added versions of CodeBlock::dumpSource() and CodeBlock::dumpBytecode()
     14        that explicitly take no arguments (instead of relying on the version that takes
     15        the default argument).  These versions are friendlier to use when we want to call
     16        them from an interactive debugging session.
     17
     18        * bytecode/CodeBlock.cpp:
     19        (JSC::CodeBlock::dumpSource):
     20        (JSC::CodeBlock::dumpBytecode):
     21        * bytecode/CodeBlock.h:
     22        * dfg/DFGByteCodeParser.cpp:
     23        (JSC::DFG::ByteCodeParser::parseCodeBlock):
     24        * runtime/Options.h:
     25
    1262015-04-02  Yusuke Suzuki  <utatane.tea@gmail.com>
    227
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r182038 r182294  
    551551    out.printf("%s, %s, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), registerName(r1).data());
    552552    it += 5;
     553}
     554
     555void CodeBlock::dumpSource()
     556{
     557    dumpSource(WTF::dataFile());
     558}
     559
     560void CodeBlock::dumpSource(PrintStream& out)
     561{
     562    ScriptExecutable* executable = ownerExecutable();
     563    if (executable->isFunctionExecutable()) {
     564        FunctionExecutable* functionExecutable = reinterpret_cast<FunctionExecutable*>(executable);
     565        String source = functionExecutable->source().provider()->getRange(
     566            functionExecutable->parametersStartOffset(),
     567            functionExecutable->typeProfilingEndOffset() + 1); // Type profiling end offset is the character before the '}'.
     568       
     569        out.print("function ", inferredName(), source);
     570        return;
     571    }
     572    out.print(executable->source().toString());
     573}
     574
     575void CodeBlock::dumpBytecode()
     576{
     577    dumpBytecode(WTF::dataFile());
    553578}
    554579
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r181993 r182294  
    156156    void visitAggregate(SlotVisitor&);
    157157
    158     void dumpBytecode(PrintStream& = WTF::dataFile());
     158    void dumpSource();
     159    void dumpSource(PrintStream&);
     160
     161    void dumpBytecode();
     162    void dumpBytecode(PrintStream&);
    159163    void dumpBytecode(
    160164        PrintStream&, unsigned bytecodeOffset,
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r182167 r182294  
    39713971    }
    39723972   
     3973    bool shouldDumpSource = Options::dumpSourceAtDFGTime();
    39733974    bool shouldDumpBytecode = Options::dumpBytecodeAtDFGTime();
    3974     if (shouldDumpBytecode) {
     3975    if (shouldDumpSource || shouldDumpBytecode) {
    39753976        dataLog("Parsing ", *codeBlock);
    39763977        if (inlineCallFrame()) {
     
    39823983            ": needsActivation = ", codeBlock->needsActivation(),
    39833984            ", isStrictMode = ", codeBlock->ownerExecutable()->isStrictMode(), "\n");
     3985    }
     3986
     3987    if (shouldDumpSource) {
     3988        dataLog("==== begin source ====\n");
     3989        codeBlock->baselineVersion()->dumpSource();
     3990        dataLog("\n==== end source ====\n\n");
     3991    }
     3992   
     3993    if (shouldDumpBytecode)
    39843994        codeBlock->baselineVersion()->dumpBytecode();
    3985     }
    39863995   
    39873996    Vector<unsigned, 32> jumpTargets;
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r181993 r182294  
    125125    v(optionRange, bytecodeRangeToDFGCompile, 0) \
    126126    v(optionString, dfgFunctionWhitelistFile, nullptr) \
     127    v(bool, dumpSourceAtDFGTime, false) \
    127128    v(bool, dumpBytecodeAtDFGTime, false) \
    128129    v(bool, dumpGraphAfterParsing, false) \
Note: See TracChangeset for help on using the changeset viewer.