Ignore:
Timestamp:
Aug 14, 2014, 4:59:44 PM (11 years ago)
Author:
[email protected]
Message:

Allow high fidelity type profiling to be enabled and disabled.
https://bugs.webkit.org/show_bug.cgi?id=135423

Patch by Saam Barati <[email protected]> on 2014-08-14
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • Merged op_put_to_scope_with_profile and op_get_from_scope_with_profile into op_profile_types_with_high_fidelity by adding extra arguments to the opcode.
  • Altered SymbolTable to use less memory by adding a rare data structure for type profiling.
  • Created an interface to turn on and off type profiling from the Web Inspector.
  • Refactored how entries are written to HighFidelityLog to make it easier to inline when generating machine code.
  • Implemented op_profile_types_with_high_fidelity in the baseline JIT by inlining the process of writing to the log and doing a small amount of type inference optimizations.
  • bytecode/BytecodeList.json:
  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::finalizeUnconditionally):
(JSC::CodeBlock::scopeDependentProfile): Deleted.

  • bytecode/CodeBlock.h:
  • bytecode/TypeLocation.h:

(JSC::TypeLocation::TypeLocation):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::emitMove):
(JSC::BytecodeGenerator::emitProfileTypesWithHighFidelity):
(JSC::BytecodeGenerator::emitGetFromScopeWithProfile): Deleted.
(JSC::BytecodeGenerator::emitPutToScopeWithProfile): Deleted.

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::ThisNode::emitBytecode):
(JSC::ResolveNode::emitBytecode):
(JSC::BracketAccessorNode::emitBytecode):
(JSC::DotAccessorNode::emitBytecode):
(JSC::FunctionCallValueNode::emitBytecode):
(JSC::FunctionCallResolveNode::emitBytecode):
(JSC::FunctionCallBracketNode::emitBytecode):
(JSC::FunctionCallDotNode::emitBytecode):
(JSC::CallFunctionCallDotNode::emitBytecode):
(JSC::ApplyFunctionCallDotNode::emitBytecode):
(JSC::PostfixNode::emitResolve):
(JSC::PostfixNode::emitBracket):
(JSC::PostfixNode::emitDot):
(JSC::PrefixNode::emitResolve):
(JSC::PrefixNode::emitBracket):
(JSC::PrefixNode::emitDot):
(JSC::ReadModifyResolveNode::emitBytecode):
(JSC::AssignResolveNode::emitBytecode):
(JSC::AssignDotNode::emitBytecode):
(JSC::ReadModifyDotNode::emitBytecode):
(JSC::AssignBracketNode::emitBytecode):
(JSC::ReadModifyBracketNode::emitBytecode):
(JSC::ReturnNode::emitBytecode):
(JSC::FunctionBodyNode::emitBytecode):

  • inspector/agents/InspectorRuntimeAgent.cpp:

(Inspector::InspectorRuntimeAgent::InspectorRuntimeAgent):
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
(Inspector::TypeRecompiler::operator()):
(Inspector::recompileAllJSFunctionsForTypeProfiling):
(Inspector::InspectorRuntimeAgent::willDestroyFrontendAndBackend):
(Inspector::InspectorRuntimeAgent::enableHighFidelityTypeProfiling):
(Inspector::InspectorRuntimeAgent::disableHighFidelityTypeProfiling):
(Inspector::InspectorRuntimeAgent::setHighFidelityTypeProfilingEnabledState):

  • inspector/agents/InspectorRuntimeAgent.h:
  • inspector/agents/JSGlobalObjectRuntimeAgent.cpp:

(Inspector::JSGlobalObjectRuntimeAgent::willDestroyFrontendAndBackend):

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

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompile):

  • jit/JIT.h:
  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_profile_types_with_high_fidelity):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_profile_types_with_high_fidelity):

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::getFromScopeCommon): Deleted.
(JSC::LLInt::putToScopeCommon): Deleted.

  • llint/LLIntSlowPaths.h:
  • llint/LowLevelInterpreter.asm:
  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:
  • runtime/HighFidelityLog.cpp:

(JSC::HighFidelityLog::initializeHighFidelityLog):
(JSC::HighFidelityLog::~HighFidelityLog):
(JSC::HighFidelityLog::processHighFidelityLog):

  • runtime/HighFidelityLog.h:

(JSC::HighFidelityLog::LogEntry::structureIDOffset):
(JSC::HighFidelityLog::LogEntry::valueOffset):
(JSC::HighFidelityLog::LogEntry::locationOffset):
(JSC::HighFidelityLog::recordTypeInformationForLocation):
(JSC::HighFidelityLog::logEndPtr):
(JSC::HighFidelityLog::logStartOffset):
(JSC::HighFidelityLog::currentLogEntryOffset):

  • runtime/HighFidelityTypeProfiler.cpp:

(JSC::HighFidelityTypeProfiler::logTypesForTypeLocation):
(JSC::descriptorMatchesTypeLocation):

  • runtime/HighFidelityTypeProfiler.h:
  • runtime/SymbolTable.cpp:

(JSC::SymbolTable::SymbolTable):
(JSC::SymbolTable::cloneCapturedNames):
(JSC::SymbolTable::prepareForHighFidelityTypeProfiling):
(JSC::SymbolTable::uniqueIDForVariable):
(JSC::SymbolTable::uniqueIDForRegister):
(JSC::SymbolTable::globalTypeSetForRegister):
(JSC::SymbolTable::globalTypeSetForVariable):

  • runtime/SymbolTable.h:

(JSC::SymbolTable::add):
(JSC::SymbolTable::set):

  • runtime/TypeLocationCache.cpp:

(JSC::TypeLocationCache::getTypeLocation):

  • runtime/TypeSet.cpp:

(JSC::TypeSet::getRuntimeTypeForValue):
(JSC::TypeSet::addTypeInformation):
(JSC::TypeSet::allPrimitiveTypeNames):
(JSC::TypeSet::addTypeForValue): Deleted.

  • runtime/TypeSet.h:
  • runtime/VM.cpp:

(JSC::VM::VM):
(JSC::VM::nextTypeLocation):
(JSC::VM::enableHighFidelityTypeProfiling):
(JSC::VM::disableHighFidelityTypeProfiling):
(JSC::VM::dumpHighFidelityProfilingTypes):

  • runtime/VM.h:

(JSC::VM::nextLocation): Deleted.

Source/WebCore:

PageRuntimeAgent and WorkerRuntimeAgent now call their super
class's (InspectorRuntimeAgent) implementation of willDestroyFrontendAndBackend
to give InspectorRuntimeAgent a chance to recompile all JavaScript
functions, if necessary, for type profiling.

  • inspector/PageRuntimeAgent.cpp:

(WebCore::PageRuntimeAgent::willDestroyFrontendAndBackend):

  • inspector/WorkerRuntimeAgent.cpp:

(WebCore::WorkerRuntimeAgent::willDestroyFrontendAndBackend):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r172372 r172614  
    192192    , m_builtinExecutables(BuiltinExecutables::create(*this))
    193193    , m_nextUniqueVariableID(1)
     194    , m_highFidelityTypeProfilingEnabledCount(0)
    194195{
    195196    interpreter = new Interpreter(*this);
     
    284285    m_typedArrayController = adoptRef(new SimpleTypedArrayController());
    285286
    286     // FIXME: conditionally allocate this stuff based on whether or not the inspector is running OR this flag is enabled (not just if the flag is enabled).
    287     if (Options::profileTypesWithHighFidelity()) {
    288         m_highFidelityTypeProfiler = std::make_unique<HighFidelityTypeProfiler>();
    289         m_highFidelityLog = std::make_unique<HighFidelityLog>();
    290     }
     287    if (Options::profileTypesWithHighFidelity())
     288        enableHighFidelityTypeProfiling();
    291289}
    292290
     
    859857}
    860858
     859TypeLocation* VM::nextTypeLocation()
     860{
     861    RELEASE_ASSERT(!!m_typeLocationInfo);
     862
     863    return m_typeLocationInfo->add();
     864}
     865
     866bool VM::enableHighFidelityTypeProfiling()
     867{
     868    bool needsToRecompile = false;
     869    if (!m_highFidelityTypeProfilingEnabledCount) {
     870        m_highFidelityTypeProfiler = std::make_unique<HighFidelityTypeProfiler>();
     871        m_highFidelityLog = std::make_unique<HighFidelityLog>();
     872        m_typeLocationInfo = std::make_unique<Bag<TypeLocation>>();
     873        needsToRecompile = true;
     874    }
     875    m_highFidelityTypeProfilingEnabledCount++;
     876
     877    return needsToRecompile;
     878}
     879
     880bool VM::disableHighFidelityTypeProfiling()
     881{
     882    RELEASE_ASSERT(m_highFidelityTypeProfilingEnabledCount > 0);
     883
     884    bool needsToRecompile = false;
     885    m_highFidelityTypeProfilingEnabledCount--;
     886    if (!m_highFidelityTypeProfilingEnabledCount) {
     887        m_highFidelityTypeProfiler.reset(nullptr);
     888        m_highFidelityLog.reset(nullptr);
     889        m_typeLocationInfo.reset(nullptr);
     890        needsToRecompile = true;
     891    }
     892
     893    return needsToRecompile;
     894}
     895
    861896void VM::dumpHighFidelityProfilingTypes()
    862897{
     
    866901    highFidelityLog()->processHighFidelityLog("VM Dump Types");
    867902    HighFidelityTypeProfiler* profiler = m_highFidelityTypeProfiler.get();
    868     for (Bag<TypeLocation>::iterator iter = m_locationInfo.begin(); !!iter; ++iter) {
     903    for (Bag<TypeLocation>::iterator iter = m_typeLocationInfo->begin(); !!iter; ++iter) {
    869904        TypeLocation* location = *iter;
    870905        profiler->logTypesForTypeLocation(location);
Note: See TracChangeset for help on using the changeset viewer.