Ignore:
Timestamp:
Dec 11, 2012, 4:21:43 PM (12 years ago)
Author:
[email protected]
Message:

Profiler should show bytecode dumps as they would have been visible to the JITs, including the profiling data that the JITs would see
https://bugs.webkit.org/show_bug.cgi?id=104647

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

Adds more profiling data to bytecode dumps, and adds the ability to do a secondary
bytecode dump for each JIT compilation of a code block. This is relevant because both
the bytecodes, and the profiling data, may change after some number of executions.

Also fixes some random dumping code to use PrintStream& rather than
static const char[thingy].

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/ArrayProfile.cpp:

(JSC::dumpArrayModes):
(JSC::ArrayProfile::briefDescription):

  • bytecode/ArrayProfile.h:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::printGetByIdOp):
(JSC::CodeBlock::printGetByIdCacheStatus):
(JSC::CodeBlock::printCallOp):
(JSC::CodeBlock::dumpValueProfiling):
(JSC::CodeBlock::dumpArrayProfiling):
(JSC::CodeBlock::dumpBytecode):

  • bytecode/CodeBlock.h:
  • bytecode/ValueProfile.h:

(JSC::ValueProfileBase::briefDescription):

  • dfg/DFGAbstractValue.h:

(JSC::DFG::AbstractValue::dump):

  • dfg/DFGByteCodeParser.cpp:

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

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • profiler/ProfilerBytecodeSequence.cpp: Added.

(JSC::Profiler::BytecodeSequence::BytecodeSequence):
(JSC::Profiler::BytecodeSequence::~BytecodeSequence):
(JSC::Profiler::BytecodeSequence::indexForBytecodeIndex):
(JSC::Profiler::BytecodeSequence::forBytecodeIndex):
(JSC::Profiler::BytecodeSequence::addSequenceProperties):

  • profiler/ProfilerBytecodeSequence.h: Added.

(JSC::Profiler::BytecodeSequence::size):
(JSC::Profiler::BytecodeSequence::at):

  • profiler/ProfilerBytecodes.cpp:

(JSC::Profiler::Bytecodes::Bytecodes):
(JSC::Profiler::Bytecodes::toJS):

  • profiler/ProfilerBytecodes.h:

(JSC::Profiler::Bytecodes::instructionCount):

  • profiler/ProfilerCompilation.cpp:

(JSC::Profiler::Compilation::addProfiledBytecodes):
(JSC::Profiler::Compilation::toJS):

  • profiler/ProfilerCompilation.h:

(JSC::Profiler::Compilation::profiledBytecodesSize):
(JSC::Profiler::Compilation::profiledBytecodesAt):

  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::ensureBytecodesFor):

  • profiler/ProfilerDatabase.h:
  • profiler/ProfilerProfiledBytecodes.cpp: Added.

(JSC::Profiler::ProfiledBytecodes::ProfiledBytecodes):
(JSC::Profiler::ProfiledBytecodes::~ProfiledBytecodes):
(JSC::Profiler::ProfiledBytecodes::toJS):

  • profiler/ProfilerProfiledBytecodes.h: Added.

(JSC::Profiler::ProfiledBytecodes::bytecodes):

  • runtime/CommonIdentifiers.h:

Tools:

Added a "profiling" (or "p") command to show the profiling data that the JITs saw
for each JIT compilation of a code block.

Also added instruction counts in the "full" display and made the "full" display the
default thing you see.

  • Scripts/display-profiler-output:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfilerBytecodes.cpp

    r137179 r137379  
    2727#include "ProfilerBytecodes.h"
    2828
     29#include "CodeBlock.h"
    2930#include "JSGlobalObject.h"
    3031#include <wtf/StringPrintStream.h>
     
    3233namespace JSC { namespace Profiler {
    3334
    34 Bytecodes::Bytecodes(
    35     size_t id, const String& inferredName, const String& sourceCode, CodeBlockHash hash)
    36     : m_id(id)
    37     , m_inferredName(inferredName)
    38     , m_sourceCode(sourceCode)
    39     , m_hash(hash)
     35Bytecodes::Bytecodes(size_t id, CodeBlock* codeBlock)
     36    : BytecodeSequence(codeBlock)
     37    , m_id(id)
     38    , m_inferredName(codeBlock->inferredName())
     39    , m_sourceCode(codeBlock->sourceCodeForTools())
     40    , m_hash(codeBlock->hash())
     41    , m_instructionCount(codeBlock->instructionCount())
    4042{
    4143}
    4244
    4345Bytecodes::~Bytecodes() { }
    44 
    45 unsigned Bytecodes::indexForBytecodeIndex(unsigned bytecodeIndex) const
    46 {
    47     return binarySearch<Bytecode, unsigned, getBytecodeIndexForBytecode>(const_cast<Bytecode*>(m_bytecode.begin()), m_bytecode.size(), bytecodeIndex) - m_bytecode.begin();
    48 }
    49 
    50 const Bytecode& Bytecodes::forBytecodeIndex(unsigned bytecodeIndex) const
    51 {
    52     return at(indexForBytecodeIndex(bytecodeIndex));
    53 }
    5446
    5547void Bytecodes::dump(PrintStream& out) const
     
    6658    result->putDirect(exec->globalData(), exec->propertyNames().sourceCode, jsString(exec, m_sourceCode));
    6759    result->putDirect(exec->globalData(), exec->propertyNames().hash, jsString(exec, String::fromUTF8(toCString(m_hash))));
    68    
    69     JSArray* stream = constructEmptyArray(exec, 0);
    70     for (unsigned i = 0; i < m_bytecode.size(); ++i)
    71         stream->putDirectIndex(exec, i, m_bytecode[i].toJS(exec));
    72     result->putDirect(exec->globalData(), exec->propertyNames().bytecode, stream);
     60    result->putDirect(exec->globalData(), exec->propertyNames().instructionCount, jsNumber(m_instructionCount));
     61    addSequenceProperties(exec, result);
    7362   
    7463    return result;
Note: See TracChangeset for help on using the changeset viewer.