Changeset 286790 in webkit
- Timestamp:
- Dec 9, 2021, 11:07:58 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 16 edited
-
ChangeLog (modified) (1 diff)
-
b3/B3Common.cpp (modified) (1 diff)
-
b3/B3Common.h (modified) (2 diffs)
-
b3/B3Generate.cpp (modified) (2 diffs)
-
b3/B3Procedure.cpp (modified) (2 diffs)
-
b3/B3Procedure.h (modified) (2 diffs)
-
b3/air/AirGenerate.cpp (modified) (3 diffs)
-
b3/testb3.h (modified) (3 diffs)
-
b3/testb3_6.cpp (modified) (5 diffs)
-
b3/testb3_7.cpp (modified) (2 diffs)
-
runtime/OptionsList.h (modified) (1 diff)
-
tools/FunctionAllowlist.cpp (modified) (1 diff)
-
tools/FunctionAllowlist.h (modified) (1 diff)
-
wasm/WasmB3IRGenerator.cpp (modified) (3 diffs)
-
wasm/WasmOMGForOSREntryPlan.cpp (modified) (1 diff)
-
wasm/WasmOMGPlan.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r286769 r286790 1 2021-12-09 Saam Barati <sbarati@apple.com> 2 3 Add an option to dump the B3 IR for an allowlist of Wasm function indices 4 https://bugs.webkit.org/show_bug.cgi?id=234028 5 6 Reviewed by Tadeu Zagallo. 7 8 * b3/B3Common.cpp: 9 (JSC::B3::shouldDumpIR): 10 * b3/B3Common.h: 11 * b3/B3Generate.cpp: 12 (JSC::B3::generateToAir): 13 * b3/B3Procedure.cpp: 14 (JSC::B3::Procedure::dump const): 15 (JSC::B3::Procedure::setShouldDumpIR): 16 * b3/B3Procedure.h: 17 (JSC::B3::Procedure::shouldDumpIR const): 18 * b3/air/AirGenerate.cpp: 19 (JSC::B3::Air::prepareForGeneration): 20 * b3/testb3.h: 21 (shouldBeVerbose): 22 (lowerToAirForTesting): 23 * b3/testb3_6.cpp: 24 (testInterpreter): 25 (testMoveConstants): 26 * b3/testb3_7.cpp: 27 (testReduceStrengthReassociation): 28 * runtime/OptionsList.h: 29 * tools/FunctionAllowlist.cpp: 30 (JSC::FunctionAllowlist::shouldDumpWasmFunction const): 31 * tools/FunctionAllowlist.h: 32 * wasm/WasmB3IRGenerator.cpp: 33 (JSC::Wasm::shouldDumpIRFor): 34 (JSC::Wasm::parseAndCompile): 35 * wasm/WasmOMGForOSREntryPlan.cpp: 36 (JSC::Wasm::OMGForOSREntryPlan::work): 37 * wasm/WasmOMGPlan.cpp: 38 (JSC::Wasm::OMGPlan::work): 39 1 40 2021-12-09 Yusuke Suzuki <ysuzuki@apple.com> 2 41 -
trunk/Source/JavaScriptCore/b3/B3Common.cpp
r280650 r286790 37 37 const char* const tierName = "b3 "; 38 38 39 bool shouldDumpIR( B3CompilationMode mode)39 bool shouldDumpIR(Procedure& procedure, B3CompilationMode mode) 40 40 { 41 if (procedure.shouldDumpIR()) 42 return true; 43 41 44 #if ENABLE(FTL_JIT) 42 45 return FTL::verboseCompilationEnabled() || FTL::shouldDumpDisassembly() || shouldDumpIRAtEachPhase(mode); -
trunk/Source/JavaScriptCore/b3/B3Common.h
r280650 r286790 35 35 namespace JSC { namespace B3 { 36 36 37 class Procedure; 38 37 39 extern const char* const tierName; 38 40 … … 42 44 }; 43 45 44 JS_EXPORT_PRIVATE bool shouldDumpIR( B3CompilationMode);46 JS_EXPORT_PRIVATE bool shouldDumpIR(Procedure&, B3CompilationMode); 45 47 bool shouldDumpIRAtEachPhase(B3CompilationMode); 46 48 bool shouldValidateIR(); -
trunk/Source/JavaScriptCore/b3/B3Generate.cpp
r281693 r286790 71 71 TimingScope timingScope("generateToAir"); 72 72 73 if (shouldDumpIR( B3Mode) && !shouldDumpIRAtEachPhase(B3Mode)) {73 if (shouldDumpIR(procedure, B3Mode) && !shouldDumpIRAtEachPhase(B3Mode)) { 74 74 dataLog(tierName, "Initial B3:\n"); 75 75 dataLog(procedure); … … 131 131 // If we're doing super verbose dumping, the phase scope of any phase will already do a dump. 132 132 // Note that lowerToAir() acts like a phase in this regard. 133 if (shouldDumpIR( B3Mode) && !shouldDumpIRAtEachPhase(B3Mode)) {133 if (shouldDumpIR(procedure, B3Mode) && !shouldDumpIRAtEachPhase(B3Mode)) { 134 134 dataLog("B3 after ", procedure.lastPhaseName(), ", before generation:\n"); 135 135 dataLog(procedure); -
trunk/Source/JavaScriptCore/b3/B3Procedure.cpp
r280198 r286790 229 229 void Procedure::dump(PrintStream& out) const 230 230 { 231 out.print("Opt Level: ", optLevel(), "\n"); 231 232 IndexSet<Value*> valuesInBlocks; 232 233 for (BasicBlock* block : *this) { … … 480 481 } 481 482 483 void Procedure::setShouldDumpIR() 484 { 485 m_shouldDumpIR = true; 486 m_code->forcePreservationOfB3Origins(); 487 } 488 482 489 } } // namespace JSC::B3 483 490 -
trunk/Source/JavaScriptCore/b3/B3Procedure.h
r280198 r286790 281 281 JS_EXPORT_PRIVATE void freeUnneededB3ValuesAfterLowering(); 282 282 283 bool shouldDumpIR() const { return m_shouldDumpIR; } 284 void setShouldDumpIR(); 285 283 286 private: 284 287 friend class BlockInsertionSet; … … 308 311 bool m_hasQuirks { false }; 309 312 bool m_needsPCToOriginMap { false }; 313 bool m_shouldDumpIR { false }; 310 314 }; 311 315 -
trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp
r278810 r286790 62 62 63 63 // If we're doing super verbose dumping, the phase scope of any phase will already do a dump. 64 if (shouldDumpIR( AirMode) && !shouldDumpIRAtEachPhase(AirMode)) {64 if (shouldDumpIR(code.proc(), AirMode) && !shouldDumpIRAtEachPhase(AirMode)) { 65 65 dataLog(tierName, "Initial air:\n"); 66 66 dataLog(code); … … 90 90 validate(code); 91 91 92 if (shouldDumpIR( AirMode)) {92 if (shouldDumpIR(code.proc(), AirMode)) { 93 93 dataLog("Air after ", code.lastPhaseName(), ", before generation:\n"); 94 94 dataLog(code); … … 184 184 // Do a final dump of Air. Note that we have to do this even if we are doing per-phase dumping, 185 185 // since the final generation is not a phase. 186 if (shouldDumpIR( AirMode)) {186 if (shouldDumpIR(code.proc(), AirMode)) { 187 187 dataLog("Air after ", code.lastPhaseName(), ", before generation:\n"); 188 188 dataLog(code); -
trunk/Source/JavaScriptCore/b3/testb3.h
r281910 r286790 98 98 using namespace JSC::B3; 99 99 100 inline bool shouldBeVerbose( )101 { 102 return shouldDumpIR( B3Mode);100 inline bool shouldBeVerbose(Procedure& procedure) 101 { 102 return shouldDumpIR(procedure, B3Mode); 103 103 } 104 104 … … 221 221 proc.resetReachability(); 222 222 223 if (shouldBeVerbose( ))223 if (shouldBeVerbose(proc)) 224 224 dataLog("B3 before lowering:\n", proc); 225 225 … … 227 227 lowerToAir(proc); 228 228 229 if (shouldBeVerbose( ))229 if (shouldBeVerbose(proc)) 230 230 dataLog("Air after lowering:\n", proc.code()); 231 231 -
trunk/Source/JavaScriptCore/b3/testb3_6.cpp
r281534 r286790 1797 1797 data.append(0); 1798 1798 1799 if (shouldBeVerbose( ))1799 if (shouldBeVerbose(proc)) 1800 1800 dataLog("data = ", listDump(data), "\n"); 1801 1801 … … 1833 1833 code.append(Stop); 1834 1834 1835 if (shouldBeVerbose( ))1835 if (shouldBeVerbose(proc)) 1836 1836 dataLog("code = ", listDump(code), "\n"); 1837 1837 … … 1842 1842 CHECK(stream[i] == i + 1); 1843 1843 1844 if (shouldBeVerbose( ))1844 if (shouldBeVerbose(proc)) 1845 1845 dataLog("stream = ", listDump(stream), "\n"); 1846 1846 } … … 2784 2784 proc.resetReachability(); 2785 2785 2786 if (shouldBeVerbose( )) {2786 if (shouldBeVerbose(proc)) { 2787 2787 dataLog("IR before:\n"); 2788 2788 dataLog(proc); … … 2791 2791 moveConstants(proc); 2792 2792 2793 if (shouldBeVerbose( )) {2793 if (shouldBeVerbose(proc)) { 2794 2794 dataLog("IR after:\n"); 2795 2795 dataLog(proc); -
trunk/Source/JavaScriptCore/b3/testb3_7.cpp
r281910 r286790 360 360 proc.resetReachability(); 361 361 362 if (shouldBeVerbose( )) {362 if (shouldBeVerbose(proc)) { 363 363 dataLog("IR before reduceStrength:\n"); 364 364 dataLog(proc); … … 367 367 reduceStrength(proc); 368 368 369 if (shouldBeVerbose( )) {369 if (shouldBeVerbose(proc)) { 370 370 dataLog("IR after reduceStrength:\n"); 371 371 dataLog(proc); -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r286111 r286790 134 134 v(Bool, dumpRegExpDisassembly, false, Normal, "dumps disassembly of RegExp upon compilation") \ 135 135 v(Bool, dumpWasmDisassembly, false, Normal, "dumps disassembly of all Wasm code upon compilation") \ 136 v(OptionString, wasmB3FunctionsToDump, nullptr, Normal, "file with newline separated list of function indices to dump IR/disassembly for, if no such file exists, the function index itself") \ 136 137 v(Bool, dumpBBQDisassembly, false, Normal, "dumps disassembly of BBQ Wasm code upon compilation") \ 137 138 v(Bool, dumpOMGDisassembly, false, Normal, "dumps disassembly of OMG Wasm code upon compilation") \ -
trunk/Source/JavaScriptCore/tools/FunctionAllowlist.cpp
r284533 r286790 97 97 } 98 98 99 bool FunctionAllowlist::shouldDumpWasmFunction(uint32_t index) const 100 { 101 if (!m_hasActiveAllowlist) 102 return false; 103 if (m_entries.isEmpty()) 104 return false; 105 return m_entries.contains(String::number(index)); 106 } 107 99 108 } // namespace JSC 100 109 -
trunk/Source/JavaScriptCore/tools/FunctionAllowlist.h
r262928 r286790 38 38 39 39 bool contains(CodeBlock*) const; 40 bool shouldDumpWasmFunction(uint32_t) const; 40 41 41 42 private: -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r286092 r286790 47 47 #include "B3WasmAddressValue.h" 48 48 #include "B3WasmBoundsCheckValue.h" 49 #include "FunctionAllowlist.h" 49 50 #include "JSCJSValueInlines.h" 50 51 #include "JSWebAssemblyInstance.h" … … 3229 3230 } 3230 3231 3232 static bool shouldDumpIRFor(uint32_t functionIndex) 3233 { 3234 static LazyNeverDestroyed<FunctionAllowlist> dumpAllowlist; 3235 static std::once_flag initializeAllowlistFlag; 3236 std::call_once(initializeAllowlistFlag, [] { 3237 const char* functionAllowlistFile = Options::wasmB3FunctionsToDump(); 3238 dumpAllowlist.construct(functionAllowlistFile); 3239 }); 3240 return dumpAllowlist->shouldDumpWasmFunction(functionIndex); 3241 } 3242 3231 3243 Expected<std::unique_ptr<InternalFunction>, String> parseAndCompile(CompilationContext& compilationContext, const FunctionData& function, const Signature& signature, Vector<UnlinkedWasmToWasmCall>& unlinkedWasmToWasmCalls, unsigned& osrEntryScratchBufferSize, const ModuleInformation& info, MemoryMode mode, CompilationMode compilationMode, uint32_t functionIndex, uint32_t loopIndexForOSREntry, TierUpCount* tierUp) 3232 3244 { … … 3238 3250 3239 3251 Procedure& procedure = *compilationContext.procedure; 3252 if (shouldDumpIRFor(functionIndex + info.importFunctionCount())) 3253 procedure.setShouldDumpIR(); 3240 3254 3241 3255 compilationContext.wasmEntrypointJIT = makeUnique<CCallHelpers>(); -
trunk/Source/JavaScriptCore/wasm/WasmOMGForOSREntryPlan.cpp
r285149 r286790 97 97 98 98 omgEntrypoint.compilation = makeUnique<Compilation>( 99 FINALIZE_ WASM_CODE_FOR_MODE(CompilationMode::OMGForOSREntryMode, linkBuffer, JITCompilationPtrTag, "WebAssembly OMGForOSREntry function[%i] %s name %s", m_functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()),99 FINALIZE_CODE_IF(context.procedure->shouldDumpIR() || shouldDumpDisassemblyFor(CompilationMode::OMGForOSREntryMode), linkBuffer, JITCompilationPtrTag, "WebAssembly OMGForOSREntry function[%i] %s name %s", m_functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()), 100 100 WTFMove(context.wasmEntrypointByproducts)); 101 101 -
trunk/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp
r285149 r286790 94 94 95 95 omgEntrypoint.compilation = makeUnique<Compilation>( 96 FINALIZE_ WASM_CODE_FOR_MODE(CompilationMode::OMGMode, linkBuffer, JITCompilationPtrTag, "WebAssembly OMG function[%i] %s name %s", m_functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()),96 FINALIZE_CODE_IF(context.procedure->shouldDumpIR() || shouldDumpDisassemblyFor(CompilationMode::OMGMode), linkBuffer, JITCompilationPtrTag, "WebAssembly OMG function[%i] %s name %s", m_functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()), 97 97 WTFMove(context.wasmEntrypointByproducts)); 98 98
Note:
See TracChangeset
for help on using the changeset viewer.