Changeset 220556 in webkit


Ignore:
Timestamp:
Aug 10, 2017 4:00:06 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Apply the UNLIKELY macro to some unlikely things.
https://bugs.webkit.org/show_bug.cgi?id=175440
<rdar://problem/33834767>

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::~CodeBlock):
(JSC::CodeBlock::jettison):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleVarargsCall):
(JSC::DFG::ByteCodeParser::handleGetById):
(JSC::DFG::ByteCodeParser::handlePutById):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::parseCodeBlock):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::JITCompiler):
(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::disassemble):

  • dfg/DFGJITFinalizer.cpp:

(JSC::DFG::JITFinalizer::finalizeCommon):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::compileOSRExit):

  • dfg/DFGPlan.cpp:

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

  • ftl/FTLJITFinalizer.cpp:

(JSC::FTL::JITFinalizer::finalizeCommon):

  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::compileWithoutLinking):
(JSC::JIT::link):

  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::installCode):

  • runtime/VM.cpp:

(JSC::VM::VM):

Source/WebKit:

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::getBytecodeProfile):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r220548 r220556  
     12017-08-10  Mark Lam  <mark.lam@apple.com>
     2
     3        Apply the UNLIKELY macro to some unlikely things.
     4        https://bugs.webkit.org/show_bug.cgi?id=175440
     5        <rdar://problem/33834767>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * bytecode/CodeBlock.cpp:
     10        (JSC::CodeBlock::~CodeBlock):
     11        (JSC::CodeBlock::jettison):
     12        * dfg/DFGByteCodeParser.cpp:
     13        (JSC::DFG::ByteCodeParser::handleCall):
     14        (JSC::DFG::ByteCodeParser::handleVarargsCall):
     15        (JSC::DFG::ByteCodeParser::handleGetById):
     16        (JSC::DFG::ByteCodeParser::handlePutById):
     17        (JSC::DFG::ByteCodeParser::parseBlock):
     18        (JSC::DFG::ByteCodeParser::parseCodeBlock):
     19        * dfg/DFGJITCompiler.cpp:
     20        (JSC::DFG::JITCompiler::JITCompiler):
     21        (JSC::DFG::JITCompiler::linkOSRExits):
     22        (JSC::DFG::JITCompiler::link):
     23        (JSC::DFG::JITCompiler::disassemble):
     24        * dfg/DFGJITFinalizer.cpp:
     25        (JSC::DFG::JITFinalizer::finalizeCommon):
     26        * dfg/DFGOSRExit.cpp:
     27        (JSC::DFG::OSRExit::compileOSRExit):
     28        * dfg/DFGPlan.cpp:
     29        (JSC::DFG::Plan::Plan):
     30        * ftl/FTLJITFinalizer.cpp:
     31        (JSC::FTL::JITFinalizer::finalizeCommon):
     32        * ftl/FTLLink.cpp:
     33        (JSC::FTL::link):
     34        * ftl/FTLOSRExitCompiler.cpp:
     35        (JSC::FTL::compileStub):
     36        * jit/JIT.cpp:
     37        (JSC::JIT::privateCompileMainPass):
     38        (JSC::JIT::compileWithoutLinking):
     39        (JSC::JIT::link):
     40        * runtime/ScriptExecutable.cpp:
     41        (JSC::ScriptExecutable::installCode):
     42        * runtime/VM.cpp:
     43        (JSC::VM::VM):
     44
    1452017-08-09  Yusuke Suzuki  <utatane.tea@gmail.com>
    246
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r220500 r220556  
    840840CodeBlock::~CodeBlock()
    841841{
    842     if (m_vm->m_perBytecodeProfiler)
     842    if (UNLIKELY(m_vm->m_perBytecodeProfiler))
    843843        m_vm->m_perBytecodeProfiler->notifyDestruction(this);
    844844
     
    19181918#if ENABLE(DFG_JIT)
    19191919    if (reason != Profiler::JettisonDueToOldAge) {
    1920         if (Profiler::Compilation* compilation = jitCode()->dfgCommon()->compilation.get())
     1920        Profiler::Compilation* compilation = jitCode()->dfgCommon()->compilation.get();
     1921        if (UNLIKELY(compilation))
    19211922            compilation->setJettisonReason(reason, detail);
    19221923       
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r219981 r220556  
    13171317   
    13181318    if (handleInlining(callTarget, result, callLinkStatus, registerOffset, virtualRegisterForArgument(0, registerOffset), VirtualRegister(), 0, argumentCountIncludingThis, nextOffset, op, kind, prediction)) {
    1319         if (m_graph.compilation())
     1319        if (UNLIKELY(m_graph.compilation()))
    13201320            m_graph.compilation()->noticeInlinedCall();
    13211321        return NonTerminal;
     
    13551355    if (callLinkStatus.canOptimize()
    13561356        && handleInlining(callTarget, result, callLinkStatus, firstFreeReg, VirtualRegister(thisReg), VirtualRegister(arguments), firstVarArgOffset, 0, m_currentIndex + OPCODE_LENGTH(op_call_varargs), op, InlineCallFrame::varargsKindFor(callMode), prediction)) {
    1357         if (m_graph.compilation())
     1357        if (UNLIKELY(m_graph.compilation()))
    13581358            m_graph.compilation()->noticeInlinedCall();
    13591359        return NonTerminal;
     
    37183718    if (getById != TryGetById && getByIdStatus.isModuleNamespace()) {
    37193719        if (handleModuleNamespaceLoad(destinationOperand, prediction, base, getByIdStatus)) {
    3720             if (m_graph.compilation())
     3720            if (UNLIKELY(m_graph.compilation()))
    37213721                m_graph.compilation()->noticeInlinedGetById();
    37223722            return;
     
    37323732        ASSERT(variant.domAttribute());
    37333733        if (handleDOMJITGetter(destinationOperand, variant, base, identifierNumber, prediction)) {
    3734             if (m_graph.compilation())
     3734            if (UNLIKELY(m_graph.compilation()))
    37353735                m_graph.compilation()->noticeInlinedGetById();
    37363736            return;
     
    37833783        }
    37843784
    3785         if (m_graph.compilation())
     3785        if (UNLIKELY(m_graph.compilation()))
    37863786            m_graph.compilation()->noticeInlinedGetById();
    37873787   
     
    38053805    }
    38063806
    3807     if (m_graph.compilation())
     3807    if (UNLIKELY(m_graph.compilation()))
    38083808        m_graph.compilation()->noticeInlinedGetById();
    38093809
     
    39043904        }
    39053905       
    3906         if (m_graph.compilation())
     3906        if (UNLIKELY(m_graph.compilation()))
    39073907            m_graph.compilation()->noticeInlinedPutById();
    39083908
     
    39283928    case PutByIdVariant::Replace: {
    39293929        store(base, identifierNumber, variant, value);
    3930         if (m_graph.compilation())
     3930        if (UNLIKELY(m_graph.compilation()))
    39313931            m_graph.compilation()->noticeInlinedPutById();
    39323932        return;
     
    39953995        addToGraph(PutStructure, OpInfo(transition), base);
    39963996
    3997         if (m_graph.compilation())
     3997        if (UNLIKELY(m_graph.compilation()))
    39983998            m_graph.compilation()->noticeInlinedPutById();
    39993999        return;
     
    41254125            dataLog("    parsing ", currentCodeOrigin(), ": ", opcodeID, "\n");
    41264126       
    4127         if (m_graph.compilation()) {
     4127        if (UNLIKELY(m_graph.compilation())) {
    41284128            addToGraph(CountExecution, OpInfo(m_graph.compilation()->executionCounterFor(
    41294129                Profiler::OriginStack(*m_vm->m_perBytecodeProfiler, m_codeBlock, currentCodeOrigin()))));
     
    60626062    CodeBlock* codeBlock = m_inlineStackTop->m_codeBlock;
    60636063   
    6064     if (m_graph.compilation()) {
     6064    if (UNLIKELY(m_graph.compilation())) {
    60656065        m_graph.compilation()->addProfiledBytecodes(
    60666066            *m_vm->m_perBytecodeProfiler, m_inlineStackTop->m_profiledBlock);
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp

    r220306 r220556  
    5757    , m_pcToCodeOriginMapBuilder(dfg.m_vm)
    5858{
    59     if (shouldDumpDisassembly() || m_graph.m_vm.m_perBytecodeProfiler)
     59    if (UNLIKELY(shouldDumpDisassembly() || m_graph.m_vm.m_perBytecodeProfiler))
    6060        m_disassembler = std::make_unique<Disassembler>(dfg);
    6161#if ENABLE(FTL_JIT)
     
    7373{
    7474    ASSERT(m_jitCode->osrExit.size() == m_exitCompilationInfo.size());
    75     if (m_graph.compilation()) {
     75    if (UNLIKELY(m_graph.compilation())) {
    7676        for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
    7777            OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
     
    318318    }
    319319   
    320     if (m_graph.compilation()) {
     320    if (UNLIKELY(m_graph.compilation())) {
    321321        ASSERT(m_exitSiteLabels.size() == m_jitCode->osrExit.size());
    322322        for (unsigned i = 0; i < m_exitSiteLabels.size(); ++i) {
     
    529529    }
    530530   
    531     if (m_graph.m_plan.compilation)
     531    if (UNLIKELY(m_graph.m_plan.compilation))
    532532        m_disassembler->reportToProfiler(m_graph.m_plan.compilation.get(), linkBuffer);
    533533}
  • trunk/Source/JavaScriptCore/dfg/DFGJITFinalizer.cpp

    r212365 r220556  
    9191#endif // ENABLE(FTL_JIT)
    9292   
    93     if (m_plan.compilation)
     93    if (UNLIKELY(m_plan.compilation))
    9494        m_plan.vm->m_perBytecodeProfiler->addCompilation(m_plan.codeBlock, *m_plan.compilation);
    9595   
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp

    r220318 r220556  
    197197        jit.jitAssertHasValidCallFrame();
    198198
    199         if (vm->m_perBytecodeProfiler && codeBlock->jitCode()->dfgCommon()->compilation) {
     199        if (UNLIKELY(vm->m_perBytecodeProfiler && codeBlock->jitCode()->dfgCommon()->compilation)) {
    200200            Profiler::Database& database = *vm->m_perBytecodeProfiler;
    201201            Profiler::Compilation* compilation = codeBlock->jitCode()->dfgCommon()->compilation.get();
  • trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp

    r220118 r220556  
    145145    , osrEntryBytecodeIndex(osrEntryBytecodeIndex)
    146146    , mustHandleValues(mustHandleValues)
    147     , compilation(vm->m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(vm->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock), profilerCompilationKindForMode(mode))) : 0)
     147    , compilation(UNLIKELY(vm->m_perBytecodeProfiler) ? adoptRef(new Profiler::Compilation(vm->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock), profilerCompilationKindForMode(mode))) : nullptr)
    148148    , inlineCallFrames(adoptRef(new InlineCallFrameSet()))
    149149    , identifiers(codeBlock)
  • trunk/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp

    r214069 r220556  
    9090    m_plan.codeBlock->setJITCode(*jitCode);
    9191
    92     if (m_plan.compilation)
     92    if (UNLIKELY(m_plan.compilation))
    9393        m_plan.vm->m_perBytecodeProfiler->addCompilation(m_plan.codeBlock, *m_plan.compilation);
    9494   
  • trunk/Source/JavaScriptCore/ftl/FTLLink.cpp

    r218794 r220556  
    6969        CCallHelpers::stackPointerRegister, -static_cast<int32_t>(AssemblyHelpers::prologueStackPointerDelta()));
    7070   
    71     if (Profiler::Compilation* compilation = graph.compilation()) {
     71    Profiler::Compilation* compilation = graph.compilation();
     72    if (UNLIKELY(compilation)) {
    7273        compilation->addDescription(
    7374            Profiler::OriginStack(),
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp

    r214645 r220556  
    249249    jit.checkStackPointerAlignment();
    250250   
    251     if (vm->m_perBytecodeProfiler && jitCode->dfgCommon()->compilation) {
     251    if (UNLIKELY(vm->m_perBytecodeProfiler && jitCode->dfgCommon()->compilation)) {
    252252        Profiler::Database& database = *vm->m_perBytecodeProfiler;
    253253        Profiler::Compilation* compilation = jitCode->dfgCommon()->compilation.get();
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r219043 r220556  
    244244        OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode);
    245245
    246         if (m_compilation) {
     246        if (UNLIKELY(m_compilation)) {
    247247            add64(
    248248                TrustedImm32(1),
     
    612612    }
    613613
    614     if (Options::dumpDisassembly() || (m_vm->m_perBytecodeProfiler && Options::disassembleBaselineForProfiler()))
     614    if (UNLIKELY(Options::dumpDisassembly() || (m_vm->m_perBytecodeProfiler && Options::disassembleBaselineForProfiler())))
    615615        m_disassembler = std::make_unique<JITDisassembler>(m_codeBlock);
    616     if (m_vm->m_perBytecodeProfiler) {
     616    if (UNLIKELY(m_vm->m_perBytecodeProfiler)) {
    617617        m_compilation = adoptRef(
    618618            new Profiler::Compilation(
     
    842842        patchBuffer.didAlreadyDisassemble();
    843843    }
    844     if (m_compilation) {
     844    if (UNLIKELY(m_compilation)) {
    845845        if (Options::disassembleBaselineForProfiler())
    846846            m_disassembler->reportToProfiler(m_compilation.get(), patchBuffer);
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp

    r220432 r220556  
    152152        RELEASE_ASSERT(JITCode::isExecutableScript(genericCodeBlock->jitType()));
    153153       
    154         if (Options::verboseOSR())
     154        if (UNLIKELY(Options::verboseOSR()))
    155155            dataLog("Installing ", *genericCodeBlock, "\n");
    156156       
    157         if (vm.m_perBytecodeProfiler)
     157        if (UNLIKELY(vm.m_perBytecodeProfiler))
    158158            vm.m_perBytecodeProfiler->ensureBytecodesFor(genericCodeBlock);
    159159       
    160         if (Debugger* debugger = genericCodeBlock->globalObject()->debugger())
     160        Debugger* debugger = genericCodeBlock->globalObject()->debugger();
     161        if (UNLIKELY(debugger))
    161162            debugger->registerCodeBlock(genericCodeBlock);
    162163    }
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r220352 r220556  
    301301    LLInt::Data::performAssertions(*this);
    302302   
    303     if (Options::useProfiler()) {
     303    if (UNLIKELY(Options::useProfiler())) {
    304304        m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this);
    305305
  • trunk/Source/WebKit/ChangeLog

    r220553 r220556  
     12017-08-10  Mark Lam  <mark.lam@apple.com>
     2
     3        Apply the UNLIKELY macro to some unlikely things.
     4        https://bugs.webkit.org/show_bug.cgi?id=175440
     5        <rdar://problem/33834767>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * WebProcess/WebPage/WebPage.cpp:
     10        (WebKit::WebPage::getBytecodeProfile):
     11
    1122017-08-10  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r220507 r220556  
    57105710void WebPage::getBytecodeProfile(CallbackID callbackID)
    57115711{
    5712     if (!commonVM().m_perBytecodeProfiler) {
     5712    if (LIKELY(!commonVM().m_perBytecodeProfiler)) {
    57135713        send(Messages::WebPageProxy::StringCallback(String(), callbackID));
    57145714        return;
Note: See TracChangeset for help on using the changeset viewer.