|
| 1 | +2016-01-29 Saam barati <sbarati@apple.com> |
| 2 | + |
| 3 | + JSC Sampling Profiler: Come up with a (program counter => CodeOrigin) mapping |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=152629 |
| 5 | + |
| 6 | + Reviewed by Filip Pizlo. |
| 7 | + |
| 8 | + This patch implements a mapping from PC to CodeOrigin |
| 9 | + that lives off of JITed CodeBlocks. We build this mapping |
| 10 | + while JITing code, and then we compress it and store |
| 11 | + it on the CodeBlock. We only build the mapping if a debugger |
| 12 | + has ever been attached to any global object. |
| 13 | + |
| 14 | + CodeBlock consults this mapping when searching for a CodeOrigin |
| 15 | + for a given PC, but it also consults other code ranges |
| 16 | + off the main path that may own the PC. Specifically, it searches |
| 17 | + through inline caches, OSRExits, and LazySlowPaths. |
| 18 | + |
| 19 | + To find PC info for the LLInt, we also save the LLInt pc when |
| 20 | + taking a stack trace where the top frame is in LLInt code. |
| 21 | + |
| 22 | + This patch also cleans up code inside the SamplingProfier. |
| 23 | + I realized a bug in the SamplingProfiler's implementation. |
| 24 | + We used to walk the inline stack while gathering a stack |
| 25 | + trace. This is wrong. It's super dangerous to do this because |
| 26 | + we might pause the JSC process while it's modifying its |
| 27 | + CodeOrigin table. We used to walk the inline stack while |
| 28 | + taking a stack trace because doing so could save us from |
| 29 | + having to verify a particular stack trace. This patch changes that. |
| 30 | + We now have to verify all stack traces taken. This verification step |
| 31 | + includes walking the inline stack. |
| 32 | + |
| 33 | + Because we have a PC=>CodeOrigin map, we can now gather more |
| 34 | + detailed information about the top-frame we pause. This allows |
| 35 | + us to correctly observe inlining. It also allows us to observe |
| 36 | + expression-level line/column information for the top frame. |
| 37 | + The reason we don't consult this mapping for parent frames is |
| 38 | + that all parent frames should set the CallSiteIndex on the call |
| 39 | + frame header, which means we can consult that value to get inlining |
| 40 | + and expression-level line/column information. |
| 41 | + |
| 42 | + * CMakeLists.txt: |
| 43 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: |
| 44 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: |
| 45 | + * JavaScriptCore.xcodeproj/project.pbxproj: |
| 46 | + * assembler/AbstractMacroAssembler.h: |
| 47 | + (JSC::AbstractMacroAssembler::Label::Label): |
| 48 | + (JSC::AbstractMacroAssembler::Label::operator==): |
| 49 | + (JSC::AbstractMacroAssembler::Label::isSet): |
| 50 | + * assembler/AssemblerBuffer.h: |
| 51 | + (JSC::AssemblerLabel::labelAtOffset): |
| 52 | + (JSC::AssemblerLabel::operator==): |
| 53 | + * b3/B3Generate.cpp: |
| 54 | + * b3/B3Origin.h: |
| 55 | + (JSC::B3::Origin::data): |
| 56 | + (JSC::B3::Origin::operator==): |
| 57 | + * b3/B3PCToOriginMap.h: Added. |
| 58 | + (JSC::B3::PCToOriginMap::PCToOriginMap): |
| 59 | + (JSC::B3::PCToOriginMap::appendItem): |
| 60 | + (JSC::B3::PCToOriginMap::ranges): |
| 61 | + * b3/B3Procedure.h: |
| 62 | + (JSC::B3::Procedure::pcToOriginMap): |
| 63 | + (JSC::B3::Procedure::releasePCToOriginMap): |
| 64 | + * b3/air/AirGenerate.cpp: |
| 65 | + (JSC::B3::Air::generate): |
| 66 | + * bytecode/CodeBlock.cpp: |
| 67 | + (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): |
| 68 | + (JSC::CodeBlock::setPCToCodeOriginMap): |
| 69 | + (JSC::CodeBlock::findPC): |
| 70 | + * bytecode/CodeBlock.h: |
| 71 | + (JSC::CodeBlock::jitCodeMap): |
| 72 | + (JSC::CodeBlock::bytecodeOffset): |
| 73 | + * bytecode/CodeOrigin.h: |
| 74 | + (JSC::CodeOrigin::operator==): |
| 75 | + (JSC::CodeOriginHash::hash): |
| 76 | + (JSC::CodeOriginHash::equal): |
| 77 | + * bytecode/InlineCallFrame.h: |
| 78 | + (JSC::baselineCodeBlockForOriginAndBaselineCodeBlock): |
| 79 | + (JSC::CodeOrigin::walkUpInlineStack): |
| 80 | + * bytecode/PolymorphicAccess.h: |
| 81 | + (JSC::PolymorphicAccess::containsPC): |
| 82 | + * bytecode/StructureStubInfo.cpp: |
| 83 | + (JSC::StructureStubInfo::visitWeakReferences): |
| 84 | + (JSC::StructureStubInfo::containsPC): |
| 85 | + * bytecode/StructureStubInfo.h: |
| 86 | + * bytecode/UnlinkedCodeBlock.h: |
| 87 | + (JSC::UnlinkedCodeBlock::hasExpressionInfo): |
| 88 | + (JSC::UnlinkedCodeBlock::expressionInfo): |
| 89 | + (JSC::UnlinkedCodeBlock::setThisRegister): |
| 90 | + * debugger/Debugger.cpp: |
| 91 | + (JSC::Debugger::attach): |
| 92 | + * dfg/DFGJITCode.cpp: |
| 93 | + (JSC::DFG::JITCode::validateReferences): |
| 94 | + (JSC::DFG::JITCode::findPC): |
| 95 | + * dfg/DFGJITCode.h: |
| 96 | + (JSC::DFG::JITCode::commonDataOffset): |
| 97 | + * dfg/DFGJITCompiler.cpp: |
| 98 | + (JSC::DFG::JITCompiler::JITCompiler): |
| 99 | + (JSC::DFG::JITCompiler::link): |
| 100 | + (JSC::DFG::JITCompiler::compile): |
| 101 | + (JSC::DFG::JITCompiler::compileFunction): |
| 102 | + (JSC::DFG::JITCompiler::recordCallSiteAndGenerateExceptionHandlingOSRExitIfNeeded): |
| 103 | + (JSC::DFG::JITCompiler::setEndOfMainPath): |
| 104 | + (JSC::DFG::JITCompiler::setEndOfCode): |
| 105 | + * dfg/DFGJITCompiler.h: |
| 106 | + (JSC::DFG::JITCompiler::setStartOfCode): |
| 107 | + (JSC::DFG::JITCompiler::setForNode): |
| 108 | + (JSC::DFG::JITCompiler::addCallSite): |
| 109 | + (JSC::DFG::JITCompiler::pcToCodeOriginMapBuilder): |
| 110 | + (JSC::DFG::JITCompiler::setEndOfMainPath): Deleted. |
| 111 | + (JSC::DFG::JITCompiler::setEndOfCode): Deleted. |
| 112 | + * dfg/DFGSlowPathGenerator.h: |
| 113 | + (JSC::DFG::SlowPathGenerator::call): |
| 114 | + (JSC::DFG::SlowPathGenerator::origin): |
| 115 | + * dfg/DFGSpeculativeJIT.cpp: |
| 116 | + (JSC::DFG::SpeculativeJIT::addSlowPathGenerator): |
| 117 | + (JSC::DFG::SpeculativeJIT::runSlowPathGenerators): |
| 118 | + (JSC::DFG::SpeculativeJIT::compileCurrentBlock): |
| 119 | + * dfg/DFGSpeculativeJIT.h: |
| 120 | + * ftl/FTLB3Compile.cpp: |
| 121 | + (JSC::FTL::compile): |
| 122 | + * ftl/FTLJITCode.cpp: |
| 123 | + (JSC::FTL::JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite): |
| 124 | + (JSC::FTL::JITCode::findPC): |
| 125 | + * ftl/FTLJITCode.h: |
| 126 | + (JSC::FTL::JITCode::b3Code): |
| 127 | + * heap/MachineStackMarker.cpp: |
| 128 | + (JSC::MachineThreads::Thread::Registers::instructionPointer): |
| 129 | + (JSC::MachineThreads::Thread::Registers::llintPC): |
| 130 | + (JSC::MachineThreads::Thread::freeRegisters): |
| 131 | + * heap/MachineStackMarker.h: |
| 132 | + * inspector/agents/InspectorScriptProfilerAgent.cpp: |
| 133 | + (Inspector::InspectorScriptProfilerAgent::addEvent): |
| 134 | + (Inspector::buildSamples): |
| 135 | + (Inspector::InspectorScriptProfilerAgent::trackingComplete): |
| 136 | + * jit/JIT.cpp: |
| 137 | + (JSC::JIT::JIT): |
| 138 | + (JSC::JIT::privateCompileMainPass): |
| 139 | + (JSC::JIT::privateCompileSlowCases): |
| 140 | + (JSC::JIT::privateCompile): |
| 141 | + * jit/JIT.h: |
| 142 | + * jit/JITCode.h: |
| 143 | + (JSC::JITCode::findPC): |
| 144 | + * jit/PCToCodeOriginMap.cpp: Added. |
| 145 | + (JSC::PCToCodeOriginMapBuilder::PCToCodeOriginMapBuilder): |
| 146 | + (JSC::PCToCodeOriginMapBuilder::appendItem): |
| 147 | + (JSC::PCToCodeOriginMap::PCToCodeOriginMap): |
| 148 | + (JSC::PCToCodeOriginMap::~PCToCodeOriginMap): |
| 149 | + (JSC::PCToCodeOriginMap::memorySize): |
| 150 | + (JSC::PCToCodeOriginMap::findPC): |
| 151 | + * jit/PCToCodeOriginMap.h: Added. |
| 152 | + (JSC::PCToCodeOriginMapBuilder::defaultCodeOrigin): |
| 153 | + (JSC::PCToCodeOriginMapBuilder::didBuildMapping): |
| 154 | + * jsc.cpp: |
| 155 | + (functionSamplingProfilerStackTraces): |
| 156 | + * llint/LLIntPCRanges.h: |
| 157 | + (JSC::LLInt::isLLIntPC): |
| 158 | + * llint/LowLevelInterpreter.asm: |
| 159 | + * runtime/Options.h: |
| 160 | + * runtime/SamplingProfiler.cpp: |
| 161 | + (JSC::reportStats): |
| 162 | + (JSC::FrameWalker::FrameWalker): |
| 163 | + (JSC::FrameWalker::walk): |
| 164 | + (JSC::FrameWalker::resetAtMachineFrame): |
| 165 | + (JSC::FrameWalker::isValidFramePointer): |
| 166 | + (JSC::SamplingProfiler::SamplingProfiler): |
| 167 | + (JSC::SamplingProfiler::~SamplingProfiler): |
| 168 | + (JSC::tryGetBytecodeIndex): |
| 169 | + (JSC::SamplingProfiler::processUnverifiedStackTraces): |
| 170 | + (JSC::SamplingProfiler::visit): |
| 171 | + (JSC::SamplingProfiler::noticeVMEntry): |
| 172 | + (JSC::SamplingProfiler::clearData): |
| 173 | + (JSC::SamplingProfiler::StackFrame::displayName): |
| 174 | + (JSC::SamplingProfiler::StackFrame::displayNameForJSONTests): |
| 175 | + (JSC::SamplingProfiler::StackFrame::functionStartLine): |
| 176 | + (JSC::SamplingProfiler::StackFrame::functionStartColumn): |
| 177 | + (JSC::SamplingProfiler::StackFrame::sourceID): |
| 178 | + (JSC::SamplingProfiler::StackFrame::url): |
| 179 | + (JSC::SamplingProfiler::releaseStackTraces): |
| 180 | + (JSC::SamplingProfiler::stackTracesAsJSON): |
| 181 | + (WTF::printInternal): |
| 182 | + (JSC::SamplingProfiler::StackFrame::startLine): Deleted. |
| 183 | + (JSC::SamplingProfiler::StackFrame::startColumn): Deleted. |
| 184 | + (JSC::SamplingProfiler::stackTraces): Deleted. |
| 185 | + * runtime/SamplingProfiler.h: |
| 186 | + (JSC::SamplingProfiler::UnprocessedStackFrame::UnprocessedStackFrame): |
| 187 | + (JSC::SamplingProfiler::StackFrame::StackFrame): |
| 188 | + (JSC::SamplingProfiler::StackTrace::StackTrace): |
| 189 | + (JSC::SamplingProfiler::totalTime): |
| 190 | + (JSC::SamplingProfiler::setStopWatch): |
| 191 | + * runtime/VM.cpp: |
| 192 | + (JSC::VM::VM): |
| 193 | + * runtime/VM.h: |
| 194 | + (JSC::VM::setShouldBuildPCToCodeOriginMapping): |
| 195 | + (JSC::VM::shouldBuilderPCToCodeOriginMapping): |
| 196 | + * tests/stress/sampling-profiler-basic.js: |
| 197 | + (platformSupportsSamplingProfiler.top): |
| 198 | + (platformSupportsSamplingProfiler.jaz): |
| 199 | + (platformSupportsSamplingProfiler.kaz): |
| 200 | + |
1 | 201 | 2016-01-29 Saam barati <sbarati@apple.com> |
2 | 202 |
|
3 | 203 | Remove our notion of having a single activation register |
|
0 commit comments