Title: [220556] trunk/Source
Revision
220556
Author
mark....@apple.com
Date
2017-08-10 16:00:06 -0700 (Thu, 10 Aug 2017)

Log 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/_javascript_Core:

* 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (220555 => 220556)


--- trunk/Source/_javascript_Core/ChangeLog	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-08-10 23:00:06 UTC (rev 220556)
@@ -1,3 +1,47 @@
+2017-08-10  Mark Lam  <mark....@apple.com>
+
+        Apply the UNLIKELY macro to some unlikely things.
+        https://bugs.webkit.org/show_bug.cgi?id=175440
+        <rdar://problem/33834767>
+
+        Reviewed by Yusuke Suzuki.
+
+        * 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):
+
 2017-08-09  Yusuke Suzuki  <utatane....@gmail.com>
 
         [WTF] ThreadSpecific should not introduce additional indirection

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -839,7 +839,7 @@
 
 CodeBlock::~CodeBlock()
 {
-    if (m_vm->m_perBytecodeProfiler)
+    if (UNLIKELY(m_vm->m_perBytecodeProfiler))
         m_vm->m_perBytecodeProfiler->notifyDestruction(this);
 
     if (unlinkedCodeBlock()->didOptimize() == MixedTriState)
@@ -1917,7 +1917,8 @@
 
 #if ENABLE(DFG_JIT)
     if (reason != Profiler::JettisonDueToOldAge) {
-        if (Profiler::Compilation* compilation = jitCode()->dfgCommon()->compilation.get())
+        Profiler::Compilation* compilation = jitCode()->dfgCommon()->compilation.get();
+        if (UNLIKELY(compilation))
             compilation->setJettisonReason(reason, detail);
         
         // This accomplishes (1), and does its own book-keeping about whether it has already happened.

Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -1316,7 +1316,7 @@
     unsigned nextOffset = m_currentIndex + instructionSize;
     
     if (handleInlining(callTarget, result, callLinkStatus, registerOffset, virtualRegisterForArgument(0, registerOffset), VirtualRegister(), 0, argumentCountIncludingThis, nextOffset, op, kind, prediction)) {
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedCall();
         return NonTerminal;
     }
@@ -1354,7 +1354,7 @@
     
     if (callLinkStatus.canOptimize()
         && handleInlining(callTarget, result, callLinkStatus, firstFreeReg, VirtualRegister(thisReg), VirtualRegister(arguments), firstVarArgOffset, 0, m_currentIndex + OPCODE_LENGTH(op_call_varargs), op, InlineCallFrame::varargsKindFor(callMode), prediction)) {
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedCall();
         return NonTerminal;
     }
@@ -3717,7 +3717,7 @@
 
     if (getById != TryGetById && getByIdStatus.isModuleNamespace()) {
         if (handleModuleNamespaceLoad(destinationOperand, prediction, base, getByIdStatus)) {
-            if (m_graph.compilation())
+            if (UNLIKELY(m_graph.compilation()))
                 m_graph.compilation()->noticeInlinedGetById();
             return;
         }
@@ -3731,7 +3731,7 @@
         GetByIdVariant variant = getByIdStatus[0];
         ASSERT(variant.domAttribute());
         if (handleDOMJITGetter(destinationOperand, variant, base, identifierNumber, prediction)) {
-            if (m_graph.compilation())
+            if (UNLIKELY(m_graph.compilation()))
                 m_graph.compilation()->noticeInlinedGetById();
             return;
         }
@@ -3782,7 +3782,7 @@
             cases.append(MultiGetByOffsetCase(*m_graph.addStructureSet(variant.structureSet()), method));
         }
 
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedGetById();
     
         // 2) Emit a MultiGetByOffset
@@ -3804,7 +3804,7 @@
         return;
     }
 
-    if (m_graph.compilation())
+    if (UNLIKELY(m_graph.compilation()))
         m_graph.compilation()->noticeInlinedGetById();
 
     ASSERT(type == AccessType::Get || !variant.callLinkStatus());
@@ -3903,7 +3903,7 @@
             }
         }
         
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedPutById();
 
         for (const PutByIdVariant& variant : putByIdStatus.variants()) {
@@ -3927,7 +3927,7 @@
     switch (variant.kind()) {
     case PutByIdVariant::Replace: {
         store(base, identifierNumber, variant, value);
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedPutById();
         return;
     }
@@ -3994,7 +3994,7 @@
         // https://bugs.webkit.org/show_bug.cgi?id=142924.
         addToGraph(PutStructure, OpInfo(transition), base);
 
-        if (m_graph.compilation())
+        if (UNLIKELY(m_graph.compilation()))
             m_graph.compilation()->noticeInlinedPutById();
         return;
     }
@@ -4124,7 +4124,7 @@
         if (Options::verboseDFGByteCodeParsing())
             dataLog("    parsing ", currentCodeOrigin(), ": ", opcodeID, "\n");
         
-        if (m_graph.compilation()) {
+        if (UNLIKELY(m_graph.compilation())) {
             addToGraph(CountExecution, OpInfo(m_graph.compilation()->executionCounterFor(
                 Profiler::OriginStack(*m_vm->m_perBytecodeProfiler, m_codeBlock, currentCodeOrigin()))));
         }
@@ -6061,7 +6061,7 @@
     
     CodeBlock* codeBlock = m_inlineStackTop->m_codeBlock;
     
-    if (m_graph.compilation()) {
+    if (UNLIKELY(m_graph.compilation())) {
         m_graph.compilation()->addProfiledBytecodes(
             *m_vm->m_perBytecodeProfiler, m_inlineStackTop->m_profiledBlock);
     }

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -56,7 +56,7 @@
     , m_blockHeads(dfg.numBlocks())
     , m_pcToCodeOriginMapBuilder(dfg.m_vm)
 {
-    if (shouldDumpDisassembly() || m_graph.m_vm.m_perBytecodeProfiler)
+    if (UNLIKELY(shouldDumpDisassembly() || m_graph.m_vm.m_perBytecodeProfiler))
         m_disassembler = std::make_unique<Disassembler>(dfg);
 #if ENABLE(FTL_JIT)
     m_jitCode->tierUpInLoopHierarchy = WTFMove(m_graph.m_plan.tierUpInLoopHierarchy);
@@ -72,7 +72,7 @@
 void JITCompiler::linkOSRExits()
 {
     ASSERT(m_jitCode->osrExit.size() == m_exitCompilationInfo.size());
-    if (m_graph.compilation()) {
+    if (UNLIKELY(m_graph.compilation())) {
         for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
             OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
             Vector<Label> labels;
@@ -317,7 +317,7 @@
         }
     }
     
-    if (m_graph.compilation()) {
+    if (UNLIKELY(m_graph.compilation())) {
         ASSERT(m_exitSiteLabels.size() == m_jitCode->osrExit.size());
         for (unsigned i = 0; i < m_exitSiteLabels.size(); ++i) {
             Vector<Label>& labels = m_exitSiteLabels[i];
@@ -528,7 +528,7 @@
         linkBuffer.didAlreadyDisassemble();
     }
     
-    if (m_graph.m_plan.compilation)
+    if (UNLIKELY(m_graph.m_plan.compilation))
         m_disassembler->reportToProfiler(m_graph.m_plan.compilation.get(), linkBuffer);
 }
 

Modified: trunk/Source/_javascript_Core/dfg/DFGJITFinalizer.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/dfg/DFGJITFinalizer.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/dfg/DFGJITFinalizer.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -90,7 +90,7 @@
     m_jitCode->optimizeAfterWarmUp(m_plan.codeBlock);
 #endif // ENABLE(FTL_JIT)
     
-    if (m_plan.compilation)
+    if (UNLIKELY(m_plan.compilation))
         m_plan.vm->m_perBytecodeProfiler->addCompilation(m_plan.codeBlock, *m_plan.compilation);
     
     if (!m_plan.willTryToTierUp)

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -196,7 +196,7 @@
 
         jit.jitAssertHasValidCallFrame();
 
-        if (vm->m_perBytecodeProfiler && codeBlock->jitCode()->dfgCommon()->compilation) {
+        if (UNLIKELY(vm->m_perBytecodeProfiler && codeBlock->jitCode()->dfgCommon()->compilation)) {
             Profiler::Database& database = *vm->m_perBytecodeProfiler;
             Profiler::Compilation* compilation = codeBlock->jitCode()->dfgCommon()->compilation.get();
 

Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/dfg/DFGPlan.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -144,7 +144,7 @@
     , mode(mode)
     , osrEntryBytecodeIndex(osrEntryBytecodeIndex)
     , mustHandleValues(mustHandleValues)
-    , compilation(vm->m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(vm->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock), profilerCompilationKindForMode(mode))) : 0)
+    , compilation(UNLIKELY(vm->m_perBytecodeProfiler) ? adoptRef(new Profiler::Compilation(vm->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock), profilerCompilationKindForMode(mode))) : nullptr)
     , inlineCallFrames(adoptRef(new InlineCallFrameSet()))
     , identifiers(codeBlock)
     , weakReferences(codeBlock)

Modified: trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/ftl/FTLJITFinalizer.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -89,7 +89,7 @@
     
     m_plan.codeBlock->setJITCode(*jitCode);
 
-    if (m_plan.compilation)
+    if (UNLIKELY(m_plan.compilation))
         m_plan.vm->m_perBytecodeProfiler->addCompilation(m_plan.codeBlock, *m_plan.compilation);
     
     return true;

Modified: trunk/Source/_javascript_Core/ftl/FTLLink.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/ftl/FTLLink.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/ftl/FTLLink.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -68,7 +68,8 @@
     CCallHelpers::Address frame = CCallHelpers::Address(
         CCallHelpers::stackPointerRegister, -static_cast<int32_t>(AssemblyHelpers::prologueStackPointerDelta()));
     
-    if (Profiler::Compilation* compilation = graph.compilation()) {
+    Profiler::Compilation* compilation = graph.compilation();
+    if (UNLIKELY(compilation)) {
         compilation->addDescription(
             Profiler::OriginStack(),
             toCString("Generated FTL JIT code for ", CodeBlockWithJITType(codeBlock, JITCode::FTLJIT), ", instruction count = ", graph.m_codeBlock->instructionCount(), ":\n"));

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -248,7 +248,7 @@
     jit.popToRestore(GPRInfo::regT0);
     jit.checkStackPointerAlignment();
     
-    if (vm->m_perBytecodeProfiler && jitCode->dfgCommon()->compilation) {
+    if (UNLIKELY(vm->m_perBytecodeProfiler && jitCode->dfgCommon()->compilation)) {
         Profiler::Database& database = *vm->m_perBytecodeProfiler;
         Profiler::Compilation* compilation = jitCode->dfgCommon()->compilation.get();
         

Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/jit/JIT.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -243,7 +243,7 @@
         
         OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode);
 
-        if (m_compilation) {
+        if (UNLIKELY(m_compilation)) {
             add64(
                 TrustedImm32(1),
                 AbsoluteAddress(m_compilation->executionCounterFor(Profiler::OriginStack(Profiler::Origin(
@@ -611,9 +611,9 @@
         break;
     }
 
-    if (Options::dumpDisassembly() || (m_vm->m_perBytecodeProfiler && Options::disassembleBaselineForProfiler()))
+    if (UNLIKELY(Options::dumpDisassembly() || (m_vm->m_perBytecodeProfiler && Options::disassembleBaselineForProfiler())))
         m_disassembler = std::make_unique<JITDisassembler>(m_codeBlock);
-    if (m_vm->m_perBytecodeProfiler) {
+    if (UNLIKELY(m_vm->m_perBytecodeProfiler)) {
         m_compilation = adoptRef(
             new Profiler::Compilation(
                 m_vm->m_perBytecodeProfiler->ensureBytecodesFor(m_codeBlock),
@@ -841,7 +841,7 @@
         m_disassembler->dump(patchBuffer);
         patchBuffer.didAlreadyDisassemble();
     }
-    if (m_compilation) {
+    if (UNLIKELY(m_compilation)) {
         if (Options::disassembleBaselineForProfiler())
             m_disassembler->reportToProfiler(m_compilation.get(), patchBuffer);
         m_vm->m_perBytecodeProfiler->addCompilation(m_codeBlock, *m_compilation);

Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -151,13 +151,14 @@
         RELEASE_ASSERT(genericCodeBlock->ownerExecutable() == this);
         RELEASE_ASSERT(JITCode::isExecutableScript(genericCodeBlock->jitType()));
         
-        if (Options::verboseOSR())
+        if (UNLIKELY(Options::verboseOSR()))
             dataLog("Installing ", *genericCodeBlock, "\n");
         
-        if (vm.m_perBytecodeProfiler)
+        if (UNLIKELY(vm.m_perBytecodeProfiler))
             vm.m_perBytecodeProfiler->ensureBytecodesFor(genericCodeBlock);
         
-        if (Debugger* debugger = genericCodeBlock->globalObject()->debugger())
+        Debugger* debugger = genericCodeBlock->globalObject()->debugger();
+        if (UNLIKELY(debugger))
             debugger->registerCodeBlock(genericCodeBlock);
     }
 

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (220555 => 220556)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -300,7 +300,7 @@
     
     LLInt::Data::performAssertions(*this);
     
-    if (Options::useProfiler()) {
+    if (UNLIKELY(Options::useProfiler())) {
         m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this);
 
         StringPrintStream pathOut;

Modified: trunk/Source/WebKit/ChangeLog (220555 => 220556)


--- trunk/Source/WebKit/ChangeLog	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/WebKit/ChangeLog	2017-08-10 23:00:06 UTC (rev 220556)
@@ -1,3 +1,14 @@
+2017-08-10  Mark Lam  <mark....@apple.com>
+
+        Apply the UNLIKELY macro to some unlikely things.
+        https://bugs.webkit.org/show_bug.cgi?id=175440
+        <rdar://problem/33834767>
+
+        Reviewed by Yusuke Suzuki.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::getBytecodeProfile):
+
 2017-08-10  Chris Dumez  <cdu...@apple.com>
 
         Turn on support for Beacon API by default in STP

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (220555 => 220556)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-10 22:57:33 UTC (rev 220555)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-10 23:00:06 UTC (rev 220556)
@@ -5709,7 +5709,7 @@
 
 void WebPage::getBytecodeProfile(CallbackID callbackID)
 {
-    if (!commonVM().m_perBytecodeProfiler) {
+    if (LIKELY(!commonVM().m_perBytecodeProfiler)) {
         send(Messages::WebPageProxy::StringCallback(String(), callbackID));
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to