Changeset 261930 in webkit
- Timestamp:
- May 20, 2020 10:48:22 AM (4 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r261895 r261930 1 2020-05-20 Michael Saboff <msaboff@apple.com> 2 3 [Wasm] Limit the size of Wasm function we optimize in OMG mode 4 https://bugs.webkit.org/show_bug.cgi?id=212105 5 6 Reviewed by Filip Pizlo. 7 8 Given that memory grows O(N^2) compiling Wasm code through the OMG path, 9 we can run out of memory when compiling large Wasm functions. This change adds 10 a limit option, webAssemblyBBQFallbackSize, When the Wasm function size is 11 equal to or greater than this limit we always compile using BBQ optimization 12 parameters. 13 14 As part of this change, we still go through the OMG loop entry OSR code 15 generation path for functions that are at or above the threshold, but we 16 compile such functions with BBQ compilation optimization levels. 17 Also for Wasm functions at or above the threashold, we don't tier up to an 18 OMG compiled normal entry function. Instead we stay with the BBQ compiled version. 19 20 * runtime/OptionsList.h: 21 * wasm/WasmAirIRGenerator.cpp: 22 (JSC::Wasm::AirIRGenerator::AirIRGenerator): 23 * wasm/WasmB3IRGenerator.cpp: 24 (JSC::Wasm::B3IRGenerator::B3IRGenerator): 25 (JSC::Wasm::parseAndCompile): 26 * wasm/WasmCompilationMode.cpp: 27 (JSC::Wasm::wasmFunctionSizeCanBeOMGCompiled): 28 * wasm/WasmCompilationMode.h: 29 * wasm/WasmOperations.cpp: 30 (JSC::Wasm::operationWasmTriggerOSREntryNow): 31 1 32 2020-05-19 Ross Kirsling <ross.kirsling@sony.com> 2 33 -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r261728 r261930 454 454 v(Unsigned, webAssemblyBBQB3OptimizationLevel, 1, Normal, "B3 Optimization level for BBQ Web Assembly module compilations.") \ 455 455 v(Unsigned, webAssemblyOMGOptimizationLevel, Options::defaultB3OptLevel(), Normal, "B3 Optimization level for OMG Web Assembly module compilations.") \ 456 v(Unsigned, webAssemblyBBQFallbackSize, 50000, Normal, "Limit of Wasm function size above which we fallback to BBQ compilation mode.") \ 456 457 \ 457 458 v(Bool, useBBQTierUpChecks, true, Normal, "Enables tier up checks for our BBQ code.") \ -
trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
r261755 r261930 894 894 } 895 895 896 emitEntryTierUpCheck(); 896 if (wasmFunctionSizeCanBeOMGCompiled(m_info.functions[m_functionIndex].data.size())) 897 emitEntryTierUpCheck(); 897 898 } 898 899 -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r261755 r261930 538 538 } 539 539 540 emitEntryTierUpCheck(); 540 if (wasmFunctionSizeCanBeOMGCompiled(m_info.functions[m_functionIndex].data.size())) 541 emitEntryTierUpCheck(); 541 542 542 543 if (m_compilationMode == CompilationMode::OMGForOSREntryMode) … … 1974 1975 procedure.setNeedsUsedRegisters(false); 1975 1976 1976 procedure.setOptLevel(compilationMode == CompilationMode::BBQMode 1977 procedure.setOptLevel(compilationMode == CompilationMode::BBQMode || !wasmFunctionSizeCanBeOMGCompiled(function.data.size()) 1977 1978 ? Options::webAssemblyBBQB3OptimizationLevel() 1978 1979 : Options::webAssemblyOMGOptimizationLevel()); -
trunk/Source/JavaScriptCore/wasm/WasmCompilationMode.cpp
r251886 r261930 27 27 #include "WasmCompilationMode.h" 28 28 29 #include "Options.h" 29 30 #include <wtf/Assertions.h> 30 31 … … 49 50 } 50 51 52 bool wasmFunctionSizeCanBeOMGCompiled(size_t size) 53 { 54 return size < Options::webAssemblyBBQFallbackSize(); 55 } 56 51 57 } } // namespace JSC::Wasm -
trunk/Source/JavaScriptCore/wasm/WasmCompilationMode.h
r251886 r261930 37 37 38 38 const char* makeString(CompilationMode); 39 bool wasmFunctionSizeCanBeOMGCompiled(size_t); 39 40 40 41 } } // namespace JSC::Wasm -
trunk/Source/JavaScriptCore/wasm/WasmOperations.cpp
r261755 r261930 271 271 272 272 if (!Options::useWebAssemblyOSR()) { 273 if (!wasmFunctionSizeCanBeOMGCompiled(instance->module().moduleInformation().functions[functionIndex].data.size())) { 274 tierUp.deferIndefinitely(); 275 return returnWithoutOSREntry(); 276 } 277 273 278 if (shouldTriggerOMGCompile(tierUp, callee.replacement(), functionIndex)) 274 279 triggerOMGReplacementCompile(tierUp, callee.replacement(), instance, codeBlock, functionIndex); … … 337 342 338 343 if (!triggeredSlowPathToStartCompilation) { 344 if (!wasmFunctionSizeCanBeOMGCompiled(instance->module().moduleInformation().functions[functionIndex].data.size())) 345 return returnWithoutOSREntry(); 346 339 347 triggerOMGReplacementCompile(tierUp, callee.replacement(), instance, codeBlock, functionIndex); 340 348
Note: See TracChangeset
for help on using the changeset viewer.