From f3cd1e86e70e516610187954aee3f45ab5625641 Mon Sep 17 00:00:00 2001 From: Mark Lam Date: Mon, 14 Aug 2017 09:38:30 +0000 Subject: [PATCH] Merge r220556 - Apply the UNLIKELY macro to some unlikely things. https://bugs.webkit.org/show_bug.cgi?id=175440 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): --- Source/JavaScriptCore/ChangeLog | 44 +++++++++++++++++++ Source/JavaScriptCore/bytecode/CodeBlock.cpp | 5 ++- .../JavaScriptCore/dfg/DFGByteCodeParser.cpp | 22 +++++----- Source/JavaScriptCore/dfg/DFGJITCompiler.cpp | 8 ++-- Source/JavaScriptCore/dfg/DFGJITFinalizer.cpp | 2 +- Source/JavaScriptCore/dfg/DFGOSRExit.cpp | 2 +- Source/JavaScriptCore/dfg/DFGPlan.cpp | 2 +- Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp | 2 +- Source/JavaScriptCore/ftl/FTLLink.cpp | 3 +- .../JavaScriptCore/ftl/FTLOSRExitCompiler.cpp | 2 +- Source/JavaScriptCore/jit/JIT.cpp | 8 ++-- .../runtime/ScriptExecutable.cpp | 7 +-- Source/JavaScriptCore/runtime/VM.cpp | 2 +- Source/WebKit/ChangeLog | 11 +++++ Source/WebKit/WebProcess/WebPage/WebPage.cpp | 2 +- 15 files changed, 90 insertions(+), 32 deletions(-) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 5f8858957bdc..9c4c27a87edc 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,47 @@ +2017-08-10 Mark Lam + + Apply the UNLIKELY macro to some unlikely things. + https://bugs.webkit.org/show_bug.cgi?id=175440 + + + 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 [WTF] ThreadSpecific should not introduce additional indirection diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp index e123ff8f09f8..8057058cf6eb 100644 --- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp @@ -839,7 +839,7 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink 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 @@ void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mod #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. diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp index 54866680d136..b68b5af0ae86 100644 --- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp +++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp @@ -1316,7 +1316,7 @@ ByteCodeParser::Terminality ByteCodeParser::handleCall( 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 @@ ByteCodeParser::Terminality ByteCodeParser::handleVarargsCall(Instruction* pc, N 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 @@ void ByteCodeParser::handleGetById( 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 @@ void ByteCodeParser::handleGetById( 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 @@ void ByteCodeParser::handleGetById( 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 @@ void ByteCodeParser::handleGetById( return; } - if (m_graph.compilation()) + if (UNLIKELY(m_graph.compilation())) m_graph.compilation()->noticeInlinedGetById(); ASSERT(type == AccessType::Get || !variant.callLinkStatus()); @@ -3903,7 +3903,7 @@ void ByteCodeParser::handlePutById( } } - if (m_graph.compilation()) + if (UNLIKELY(m_graph.compilation())) m_graph.compilation()->noticeInlinedPutById(); for (const PutByIdVariant& variant : putByIdStatus.variants()) { @@ -3927,7 +3927,7 @@ void ByteCodeParser::handlePutById( 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 @@ void ByteCodeParser::handlePutById( // 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 @@ bool ByteCodeParser::parseBlock(unsigned limit) 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 @@ void ByteCodeParser::parseCodeBlock() 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); } diff --git a/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp b/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp index c5885c650167..6d2b187002e4 100644 --- a/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp +++ b/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp @@ -56,7 +56,7 @@ JITCompiler::JITCompiler(Graph& dfg) , 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(dfg); #if ENABLE(FTL_JIT) m_jitCode->tierUpInLoopHierarchy = WTFMove(m_graph.m_plan.tierUpInLoopHierarchy); @@ -72,7 +72,7 @@ JITCompiler::~JITCompiler() 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