Changeset 183161 in webkit
- Timestamp:
- Apr 22, 2015, 7:29:14 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r183072 r183161 81 81 bytecode/DFGExitProfile.cpp 82 82 bytecode/DeferredCompilationCallback.cpp 83 bytecode/DeferredSourceDump.cpp 83 84 bytecode/ExecutionCounter.cpp 84 85 bytecode/ExitKind.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r183141 r183161 1 2015-04-22 Mark Lam <mark.lam@apple.com> 2 3 Fix assertion failure and race condition in Options::dumpSourceAtDFGTime(). 4 https://bugs.webkit.org/show_bug.cgi?id=143898 5 6 Reviewed by Filip Pizlo. 7 8 CodeBlock::dumpSource() will access SourceCode strings in a way that requires 9 ref'ing of the underlying StringImpls. This is unsafe to do from arbitrary 10 compilation threads because StringImpls are not thread safe. As a result, we get 11 an assertion failure when we run with JSC_dumpSourceAtDFGTime=true on a debug 12 build. 13 14 This patch fixes the issue by only collecting the CodeBlock (and associated info) 15 into a DeferredSourceDump record while compiling, and stashing it away in a 16 deferredSourceDump list in the DeferredCompilationCallback object to be dumped 17 later. 18 19 When compilation is done, the callback object will be notified that 20 compilationDidComplete(). We will dump the SourceCode strings from there. 21 Since compilationDidComplete() is guaranteed to only be called on the thread 22 doing JS execution, it is safe to access the SourceCode strings there and ref 23 their underlying StringImpls as needed. 24 25 * CMakeLists.txt: 26 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 27 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 28 * JavaScriptCore.xcodeproj/project.pbxproj: 29 * bytecode/DeferredCompilationCallback.cpp: 30 (JSC::DeferredCompilationCallback::compilationDidComplete): 31 (JSC::DeferredCompilationCallback::sourceDumpInfo): 32 (JSC::DeferredCompilationCallback::dumpCompiledSources): 33 * bytecode/DeferredCompilationCallback.h: 34 * bytecode/DeferredSourceDump.cpp: Added. 35 (JSC::DeferredSourceDump::DeferredSourceDump): 36 (JSC::DeferredSourceDump::dump): 37 * bytecode/DeferredSourceDump.h: Added. 38 * dfg/DFGByteCodeParser.cpp: 39 (JSC::DFG::ByteCodeParser::parseCodeBlock): 40 * dfg/DFGDriver.cpp: 41 (JSC::DFG::compileImpl): 42 1 43 2015-04-22 Benjamin Poulain <benjamin@webkit.org> 2 44 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r183124 r183161 327 327 <ClCompile Include="..\bytecode\ConstantStructureCheck.cpp" /> 328 328 <ClCompile Include="..\bytecode\DeferredCompilationCallback.cpp" /> 329 <ClCompile Include="..\bytecode\DeferredSourceDump.cpp" /> 329 330 <ClCompile Include="..\bytecode\DFGExitProfile.cpp" /> 330 331 <ClCompile Include="..\bytecode\ExecutionCounter.cpp" /> … … 978 979 <ClInclude Include="..\bytecode\DataFormat.h" /> 979 980 <ClInclude Include="..\bytecode\DeferredCompilationCallback.h" /> 981 <ClInclude Include="..\bytecode\DeferredSourceDump.h" /> 980 982 <ClInclude Include="..\bytecode\DFGExitProfile.h" /> 981 983 <ClInclude Include="..\bytecode\EvalCodeCache.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r183124 r183161 1048 1048 <Filter>bytecode</Filter> 1049 1049 </ClCompile> 1050 <ClCompile Include="..\bytecode\DeferredSourceDump.cpp"> 1051 <Filter>bytecode</Filter> 1052 </ClCompile> 1050 1053 <ClCompile Include="..\dfg\DFGCompilationKey.cpp"> 1051 1054 <Filter>dfg</Filter> … … 3317 3320 </ClInclude> 3318 3321 <ClInclude Include="..\bytecode\DeferredCompilationCallback.h"> 3322 <Filter>bytecode</Filter> 3323 </ClInclude> 3324 <ClInclude Include="..\bytecode\DeferredSourceDump.h"> 3319 3325 <Filter>bytecode</Filter> 3320 3326 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r183124 r183161 1662 1662 FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */; }; 1663 1663 FE4D55B81AE716CA0052E459 /* IterationStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4D55B71AE716CA0052E459 /* IterationStatus.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1664 FE5068651AE246390009DAB7 /* DeferredSourceDump.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5068641AE246390009DAB7 /* DeferredSourceDump.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1665 FE5068671AE25E280009DAB7 /* DeferredSourceDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5068661AE25E280009DAB7 /* DeferredSourceDump.cpp */; }; 1664 1666 FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */; }; 1665 1667 FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 3183 3185 A7C1EAEA17987AB600299DB2 /* CallFrameInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallFrameInlines.h; sourceTree = "<group>"; }; 3184 3186 A7C1EAEB17987AB600299DB2 /* JSStackInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStackInlines.h; sourceTree = "<group>"; }; 3185 A7C1EAEC17987AB600299DB2 /* StackVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = StackVisitor.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp;};3187 A7C1EAEC17987AB600299DB2 /* StackVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = StackVisitor.cpp; sourceTree = "<group>"; }; 3186 3188 A7C1EAED17987AB600299DB2 /* StackVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackVisitor.h; sourceTree = "<group>"; }; 3187 3189 A7C225CC139981F100FF1662 /* KeywordLookupGenerator.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = KeywordLookupGenerator.py; sourceTree = "<group>"; }; … … 3455 3457 FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionOverrides.h; sourceTree = "<group>"; }; 3456 3458 FE4D55B71AE716CA0052E459 /* IterationStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IterationStatus.h; sourceTree = "<group>"; }; 3459 FE5068641AE246390009DAB7 /* DeferredSourceDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeferredSourceDump.h; sourceTree = "<group>"; }; 3460 FE5068661AE25E280009DAB7 /* DeferredSourceDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeferredSourceDump.cpp; sourceTree = "<group>"; }; 3457 3461 FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMEntryScope.cpp; sourceTree = "<group>"; }; 3458 3462 FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMEntryScope.h; sourceTree = "<group>"; }; … … 5307 5311 1429D8830ED21C3D00B89619 /* SamplingTool.cpp */, 5308 5312 1429D8840ED21C3D00B89619 /* SamplingTool.h */, 5313 FE5068661AE25E280009DAB7 /* DeferredSourceDump.cpp */, 5314 FE5068641AE246390009DAB7 /* DeferredSourceDump.h */, 5309 5315 0F5541AF1613C1FB00CE3E25 /* SpecialPointer.cpp */, 5310 5316 0F5541B01613C1FB00CE3E25 /* SpecialPointer.h */, … … 5593 5599 52C0611F1AA51E1C00B4ADBA /* RuntimeType.h in Headers */, 5594 5600 FE4D55B81AE716CA0052E459 /* IterationStatus.h in Headers */, 5601 FE5068651AE246390009DAB7 /* DeferredSourceDump.h in Headers */, 5595 5602 C442CB251A6CDB8C005D3D7C /* JSInputs.json in Headers */, 5596 5603 52678F911A04177C006A306D /* ControlFlowProfiler.h in Headers */, … … 7123 7130 0FD82E56141DAF0800179C94 /* DFGOSREntry.cpp in Sources */, 7124 7131 0FD8A32517D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.cpp in Sources */, 7132 FE5068671AE25E280009DAB7 /* DeferredSourceDump.cpp in Sources */, 7125 7133 0FC09791146A6F7100CF2442 /* DFGOSRExit.cpp in Sources */, 7126 7134 0F235BEB17178E7300690C7F /* DFGOSRExitBase.cpp in Sources */, -
trunk/Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp
r165005 r183161 36 36 void DeferredCompilationCallback::compilationDidComplete(CodeBlock* codeBlock, CompilationResult result) 37 37 { 38 dumpCompiledSourcesIfNeeded(); 39 38 40 switch (result) { 39 41 case CompilationFailed: … … 48 50 } 49 51 52 Vector<DeferredSourceDump>& DeferredCompilationCallback::ensureDeferredSourceDump() 53 { 54 if (!m_deferredSourceDump) 55 m_deferredSourceDump = std::make_unique<Vector<DeferredSourceDump>>(); 56 return *m_deferredSourceDump; 57 } 58 59 void DeferredCompilationCallback::dumpCompiledSourcesIfNeeded() 60 { 61 if (!m_deferredSourceDump) 62 return; 63 64 ASSERT(Options::dumpSourceAtDFGTime()); 65 unsigned index = 0; 66 for (auto& info : *m_deferredSourceDump) { 67 dataLog("[", ++index, "] "); 68 info.dump(); 69 } 70 } 71 50 72 } // JSC 51 73 -
trunk/Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h
r165005 r183161 28 28 29 29 #include "CompilationResult.h" 30 #include "DeferredSourceDump.h" 30 31 #include <wtf/RefCounted.h> 32 #include <wtf/Vector.h> 31 33 32 34 namespace JSC { … … 43 45 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*) = 0; 44 46 virtual void compilationDidComplete(CodeBlock*, CompilationResult); 47 48 Vector<DeferredSourceDump>& ensureDeferredSourceDump(); 49 50 private: 51 void dumpCompiledSourcesIfNeeded(); 52 53 std::unique_ptr<Vector<DeferredSourceDump>> m_deferredSourceDump; 45 54 }; 46 55 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r183094 r183161 4052 4052 } 4053 4053 4054 bool shouldDumpSource = Options::dumpSourceAtDFGTime(); 4055 bool shouldDumpBytecode = Options::dumpBytecodeAtDFGTime(); 4056 if (shouldDumpSource || shouldDumpBytecode) { 4054 if (UNLIKELY(Options::dumpSourceAtDFGTime())) { 4055 Vector<DeferredSourceDump>& deferredSourceDump = m_graph.m_plan.callback->ensureDeferredSourceDump(); 4056 if (inlineCallFrame()) { 4057 DeferredSourceDump dump(codeBlock->baselineVersion(), m_codeBlock, JITCode::DFGJIT, inlineCallFrame()->caller); 4058 deferredSourceDump.append(dump); 4059 } else 4060 deferredSourceDump.append(DeferredSourceDump(codeBlock->baselineVersion())); 4061 } 4062 4063 if (Options::dumpBytecodeAtDFGTime()) { 4057 4064 dataLog("Parsing ", *codeBlock); 4058 4065 if (inlineCallFrame()) { … … 4064 4071 ": needsActivation = ", codeBlock->needsActivation(), 4065 4072 ", isStrictMode = ", codeBlock->ownerExecutable()->isStrictMode(), "\n"); 4066 }4067 4068 if (shouldDumpSource) {4069 dataLog("==== begin source ====\n");4070 codeBlock->baselineVersion()->dumpSource();4071 dataLog("\n==== end source ====\n\n");4072 }4073 4074 if (shouldDumpBytecode)4075 4073 codeBlock->baselineVersion()->dumpBytecode(); 4074 } 4076 4075 4077 4076 Vector<unsigned, 32> jumpTargets; -
trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp
r180956 r183161 102 102 new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues)); 103 103 104 plan->callback = callback; 104 105 if (Options::enableConcurrentJIT()) { 105 106 Worklist* worklist = ensureGlobalWorklistFor(mode); 106 plan->callback = callback;107 107 if (logCompilationChanges(mode)) 108 108 dataLog("Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist->queueLength(), ".\n");
Note:
See TracChangeset
for help on using the changeset viewer.