Ignore:
Timestamp:
Jan 16, 2020, 3:24:38 PM (5 years ago)
Author:
[email protected]
Message:

Use dataLogIf more regularly
https://bugs.webkit.org/show_bug.cgi?id=206332

Reviewed by Keith Miller.

Source/JavaScriptCore:

There is lots of code that reads

if (Options::foobar())

dataLogLn("...")

There are a couple of benefits to replacing those by dataLogLnIf(Options::foobar(), "..."):

  • Readability, by reducing the number of lines taken by logging
  • Less lines appearing as not-taken in test coverage wrongly (wrongly because we probably don't care for the coverage of logging code)
  • possibly a tiny perf benefit since dataLogIf correctly uses UNLIKELY.

This patch is a fairly trivial refactoring where I looked for that pattern and replaced it everywhere it appeared in JSC.

  • bytecode/BytecodeGeneratorification.cpp:

(JSC::performGeneratorification):

  • bytecode/BytecodeLivenessAnalysis.cpp:

(JSC::BytecodeLivenessAnalysis::BytecodeLivenessAnalysis):

  • bytecode/CallLinkInfo.cpp:

(JSC::CallLinkInfo::visitWeak):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finalizeLLIntInlineCaches):
(JSC::CodeBlock::noticeIncomingCall):
(JSC::CodeBlock::optimizationThresholdScalingFactor):
(JSC::CodeBlock::optimizeNextInvocation):
(JSC::CodeBlock::dontOptimizeAnytimeSoon):
(JSC::CodeBlock::optimizeAfterWarmUp):
(JSC::CodeBlock::optimizeAfterLongWarmUp):
(JSC::CodeBlock::optimizeSoon):
(JSC::CodeBlock::forceOptimizationSlowPathConcurrently):
(JSC::CodeBlock::setOptimizationThresholdBasedOnCompilationResult):
(JSC::CodeBlock::shouldOptimizeNow):

  • bytecode/DFGExitProfile.cpp:

(JSC::DFG::ExitProfile::add):

  • dfg/DFGByteCodeParser.cpp:

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

  • dfg/DFGCFAPhase.cpp:
  • dfg/DFGJITCode.cpp:

(JSC::DFG::JITCode::optimizeNextInvocation):
(JSC::DFG::JITCode::dontOptimizeAnytimeSoon):
(JSC::DFG::JITCode::optimizeAfterWarmUp):
(JSC::DFG::JITCode::optimizeSoon):
(JSC::DFG::JITCode::forceOptimizationSlowPathConcurrently):
(JSC::DFG::JITCode::setOSREntryBlock):

  • dfg/DFGJumpReplacement.cpp:

(JSC::DFG::JumpReplacement::fire):

  • dfg/DFGOSREntry.cpp:

(JSC::DFG::prepareOSREntry):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::compileExit):

  • dfg/DFGObjectAllocationSinkingPhase.cpp:
  • dfg/DFGOperations.cpp:
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::compileInThreadImpl):

  • dfg/DFGToFTLDeferredCompilationCallback.cpp:

(JSC::DFG::ToFTLDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously):
(JSC::DFG::ToFTLDeferredCompilationCallback::compilationDidComplete):

  • dfg/DFGToFTLForOSREntryDeferredCompilationCallback.cpp:

(JSC::DFG::ToFTLForOSREntryDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously):
(JSC::DFG::ToFTLForOSREntryDeferredCompilationCallback::compilationDidComplete):

  • dfg/DFGWorklist.cpp:

(JSC::DFG::Worklist::completeAllReadyPlansForVM):

  • ftl/FTLOSREntry.cpp:

(JSC::FTL::prepareOSREntry):

  • heap/Heap.cpp:

(JSC::Heap::lastChanceToFinalize):
(JSC::Heap::sweepSynchronously):
(JSC::Heap::collectNow):
(JSC::Heap::runBeginPhase):
(JSC::Heap::runFixpointPhase):
(JSC::Heap::runReloopPhase):
(JSC::Heap::runEndPhase):
(JSC::Heap::finalize):
(JSC::Heap::willStartCollection):
(JSC::Heap::updateAllocationLimits):
(JSC::Heap::notifyIsSafeToCollect):

  • heap/MarkStackMergingConstraint.cpp:

(JSC::MarkStackMergingConstraint::prepareToExecuteImpl):

  • heap/MarkedSpace.cpp:
  • heap/MarkingConstraint.cpp:

(JSC::MarkingConstraint::prepareToExecute):

  • heap/MarkingConstraintSet.cpp:

(JSC::MarkingConstraintSet::executeConvergence):
(JSC::MarkingConstraintSet::executeConvergenceImpl):
(JSC::MarkingConstraintSet::executeAll):

  • heap/MarkingConstraintSolver.cpp:

(JSC::MarkingConstraintSolver::execute):

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::appendToMarkStack):
(JSC::SlotVisitor::visitChildren):
(JSC::SlotVisitor::didRace):

  • heap/StochasticSpaceTimeMutatorScheduler.cpp:

(JSC::StochasticSpaceTimeMutatorScheduler::beginCollection):
(JSC::StochasticSpaceTimeMutatorScheduler::didExecuteConstraints):

  • jit/JIT.cpp:

(JSC::JIT::link):

  • jit/JITExceptions.cpp:

(JSC::genericUnwind):

  • jit/JITOperations.cpp:
  • jit/JITToDFGDeferredCompilationCallback.cpp:

(JSC::JITToDFGDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously):
(JSC::JITToDFGDeferredCompilationCallback::compilationDidComplete):

  • jit/JITWorklist.cpp:

(JSC::JITWorklist::Plan::finalize):

  • jit/PolymorphicCallStubRoutine.cpp:

(JSC::PolymorphicCallNode::unlink):

  • jit/Repatch.cpp:

(JSC::unlinkFor):
(JSC::linkVirtualFor):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::entryOSR):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • parser/ModuleAnalyzer.cpp:

(JSC::ModuleAnalyzer::analyze):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::importModule):
(JSC::JSModuleLoader::resolveSync):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::evaluate):
(JSC::moduleLoaderModuleDeclarationInstantiation):

  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::installCode):

  • runtime/VM.cpp:

(JSC::VM::throwException):

  • tools/CompilerTimingScope.cpp:

(JSC::CompilerTimingScope::CompilerTimingScope):
(JSC::CompilerTimingScope::~CompilerTimingScope):

  • wasm/WasmMemory.cpp:
  • wasm/js/JSWebAssembly.cpp:

(JSC::resolve):

  • yarr/YarrJIT.cpp:

(JSC::Yarr::jitCompile):

  • yarr/YarrPattern.cpp:

(JSC::Yarr::YarrPattern::compile):

Source/WTF:

  • wtf/DataLog.h:

(WTF::dataLog): Marked NEVER_INLINE, since it should never be perf-sensitive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r254687 r254714  
    36853685    sanitizeStackForVM(codeBlock->vm());
    36863686
    3687     if (Options::verboseOSR())
    3688         dataLog(*codeBlock, ": Entered reoptimize\n");
     3687    dataLogLnIf(Options::verboseOSR(), *codeBlock, ": Entered reoptimize");
    36893688    // We must be called with the baseline code block.
    36903689    ASSERT(JITCode::isBaselineCode(codeBlock->jitType()));
     
    36973696    CodeBlock* replacement = codeBlock->replacement();
    36983697    if (!replacement || replacement == codeBlock) {
    3699         if (Options::verboseOSR())
    3700             dataLog(*codeBlock, ": Not reoptimizing because we've already been jettisoned.\n");
     3698        dataLogLnIf(Options::verboseOSR(), *codeBlock, ": Not reoptimizing because we've already been jettisoned.");
    37013699        return;
    37023700    }
     
    37243722   
    37253723    if (!didExitABunch && !didGetStuckInLoop) {
    3726         if (Options::verboseOSR())
    3727             dataLog(*codeBlock, ": Not reoptimizing ", *optimizedCodeBlock, " because it either didn't exit enough or didn't loop enough after exit.\n");
     3724        dataLogLnIf(Options::verboseOSR(), *codeBlock, ": Not reoptimizing ", *optimizedCodeBlock, " because it either didn't exit enough or didn't loop enough after exit.");
    37283725        codeBlock->optimizeAfterLongWarmUp();
    37293726        return;
     
    37433740    if (codeBlock->baselineVersion()->m_didFailFTLCompilation) {
    37443741        CODEBLOCK_LOG_EVENT(codeBlock, "abortFTLCompile", ());
    3745         if (Options::verboseOSR())
    3746             dataLog("Deferring FTL-optimization of ", *codeBlock, " indefinitely because there was an FTL failure.\n");
     3742        dataLogLnIf(Options::verboseOSR(), "Deferring FTL-optimization of ", *codeBlock, " indefinitely because there was an FTL failure.");
    37473743        jitCode->dontOptimizeAnytimeSoon(codeBlock);
    37483744        return false;
     
    37523748        && !jitCode->checkIfOptimizationThresholdReached(codeBlock)) {
    37533749        CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("counter = ", jitCode->tierUpCounter));
    3754         if (Options::verboseOSR())
    3755             dataLog("Choosing not to FTL-optimize ", *codeBlock, " yet.\n");
     3750        dataLogLnIf(Options::verboseOSR(), "Choosing not to FTL-optimize ", *codeBlock, " yet.");
    37563751        return false;
    37573752    }
     
    37953790        // This means that we finished compiling, but failed somehow; in that case the
    37963791        // thresholds will be set appropriately.
    3797         if (Options::verboseOSR())
    3798             dataLog("Code block ", *codeBlock, " was compiled but it doesn't have an optimized replacement.\n");
     3792        dataLogLnIf(Options::verboseOSR(), "Code block ", *codeBlock, " was compiled but it doesn't have an optimized replacement.");
    37993793        return;
    38003794    }
     
    38283822    JITCode* jitCode = codeBlock->jitCode()->dfg();
    38293823   
    3830     if (Options::verboseOSR()) {
    3831         dataLog(
    3832             *codeBlock, ": Entered triggerTierUpNow with executeCounter = ",
    3833             jitCode->tierUpCounter, "\n");
    3834     }
     3824    dataLogLnIf(Options::verboseOSR(),
     3825        *codeBlock, ": Entered triggerTierUpNow with executeCounter = ", jitCode->tierUpCounter);
    38353826
    38363827    if (shouldTriggerFTLCompile(codeBlock, jitCode))
     
    39073898            unsigned streamIndex = iter->value;
    39083899            if (CodeBlock* entryBlock = jitCode->osrEntryBlock()) {
    3909                 if (Options::verboseOSR())
    3910                     dataLog("OSR entry: From ", RawPointer(jitCode), " got entry block ", RawPointer(entryBlock), "\n");
     3900                dataLogLnIf(Options::verboseOSR(), "OSR entry: From ", RawPointer(jitCode), " got entry block ", RawPointer(entryBlock));
    39113901                if (void* address = FTL::prepareOSREntry(vm, callFrame, codeBlock, entryBlock, originBytecodeIndex, streamIndex)) {
    39123902                    CODEBLOCK_LOG_EVENT(entryBlock, "osrEntry", ("at ", originBytecodeIndex));
     
    39203910        CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("compiled and failed"));
    39213911        // This means that compilation failed and we already set the thresholds.
    3922         if (Options::verboseOSR())
    3923             dataLog("Code block ", *codeBlock, " was compiled but it doesn't have an optimized replacement.\n");
     3912        dataLogLnIf(Options::verboseOSR(), "Code block ", *codeBlock, " was compiled but it doesn't have an optimized replacement.");
    39243913        return nullptr;
    39253914    }
     
    40063995                // This is where we ask the outer to loop to immediately compile itself if program
    40073996                // control reaches it.
    4008                 if (Options::verboseOSR())
    4009                     dataLog("Inner-loop ", originBytecodeIndex, " in ", *codeBlock, " setting parent loop ", osrEntryCandidate, "'s trigger and backing off.\n");
     3997                dataLogLnIf(Options::verboseOSR(), "Inner-loop ", originBytecodeIndex, " in ", *codeBlock, " setting parent loop ", osrEntryCandidate, "'s trigger and backing off.");
    40103998                jitCode->tierUpEntryTriggers.set(osrEntryCandidate, JITCode::TriggerReason::StartCompilation);
    40113999                return true;
     
    40614049    // entry will succeed unless we ran out of stack. It's not clear what we should do.
    40624050    // We signal to try again after a while if that happens.
    4063     if (Options::verboseOSR())
    4064         dataLog("Immediate OSR entry: From ", RawPointer(jitCode), " got entry block ", RawPointer(jitCode->osrEntryBlock()), "\n");
     4051    dataLogLnIf(Options::verboseOSR(), "Immediate OSR entry: From ", RawPointer(jitCode), " got entry block ", RawPointer(jitCode->osrEntryBlock()));
    40654052
    40664053    void* address = FTL::prepareOSREntry(vm, callFrame, codeBlock, jitCode->osrEntryBlock(), originBytecodeIndex, streamIndex);
     
    40824069
    40834070    if (codeBlock->jitType() != JITType::DFGJIT) {
    4084         dataLog("Unexpected code block in DFG->FTL trigger tier up now in loop: ", *codeBlock, "\n");
     4071        dataLogLn("Unexpected code block in DFG->FTL trigger tier up now in loop: ", *codeBlock);
    40854072        RELEASE_ASSERT_NOT_REACHED();
    40864073    }
     
    40884075    JITCode* jitCode = codeBlock->jitCode()->dfg();
    40894076
    4090     if (Options::verboseOSR()) {
    4091         dataLog(
    4092             *codeBlock, ": Entered triggerTierUpNowInLoop with executeCounter = ",
    4093             jitCode->tierUpCounter, "\n");
    4094     }
     4077    dataLogLnIf(Options::verboseOSR(), *codeBlock, ": Entered triggerTierUpNowInLoop with executeCounter = ", jitCode->tierUpCounter);
    40954078
    40964079    if (jitCode->tierUpInLoopHierarchy.contains(bytecodeIndex))
     
    41244107    JITCode* jitCode = codeBlock->jitCode()->dfg();
    41254108
    4126     if (Options::verboseOSR()) {
    4127         dataLog(
    4128             *codeBlock, ": Entered triggerOSREntryNow with executeCounter = ",
    4129             jitCode->tierUpCounter, "\n");
    4130     }
     4109    dataLogLnIf(Options::verboseOSR(), *codeBlock, ": Entered triggerOSREntryNow with executeCounter = ", jitCode->tierUpCounter);
    41314110
    41324111    return tierUpCommon(vm, callFrame, bytecodeIndex, true);
Note: See TracChangeset for help on using the changeset viewer.