diff --git a/js/moz.configure b/js/moz.configure index 438872030978..dbbf3c5b38dd 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -515,3 +515,14 @@ js_option('--enable-cranelift', set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True)) set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True)) + + +# Support for debugging code generated by wasm backends +# ===================================================== + +js_option('--enable-wasm-codegen-debug', + default=depends(when=moz_debug)(lambda: True), + help='{Enable|Disable} debugging for wasm codegen') + +set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True)) +set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True)) diff --git a/js/src/jit/JitOptions.cpp b/js/src/jit/JitOptions.cpp index f9805a7191c4..c550ca67fb10 100644 --- a/js/src/jit/JitOptions.cpp +++ b/js/src/jit/JitOptions.cpp @@ -273,6 +273,12 @@ DefaultJitOptions::DefaultJitOptions() { // the traceLogger will not be recording any events. SET_DEFAULT(enableTraceLogger, false); #endif + +#ifdef WASM_CODEGEN_DEBUG + SET_DEFAULT(enableWasmJitExit, true); + SET_DEFAULT(enableWasmJitEntry, true); + SET_DEFAULT(enableWasmIonFastCalls, true); +#endif } bool DefaultJitOptions::isSmallFunction(JSScript* script) const { diff --git a/js/src/jit/JitOptions.h b/js/src/jit/JitOptions.h index 69fd7a417d07..9b2fc5672459 100644 --- a/js/src/jit/JitOptions.h +++ b/js/src/jit/JitOptions.h @@ -74,6 +74,11 @@ struct DefaultJitOptions { bool wasmDelayTier2; #ifdef JS_TRACE_LOGGING bool enableTraceLogger; +#endif +#ifdef WASM_CODEGEN_DEBUG + bool enableWasmJitExit; + bool enableWasmJitEntry; + bool enableWasmIonFastCalls; #endif uint32_t baselineWarmUpThreshold; uint32_t exceptionBailoutThreshold; diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 7f0680d50d75..42da06398b0d 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -4054,7 +4054,12 @@ IonBuilder::InliningResult IonBuilder::inlineWasmCall(CallInfo& callInfo, // Check that the function doesn't take or return non-compatible JS // argument types before adding nodes to the MIR graph, otherwise they'd be // dead code. - if (sig.hasI64ArgOrRet() || sig.temporarilyUnsupportedAnyRef()) { + if (sig.hasI64ArgOrRet() || + sig.temporarilyUnsupportedAnyRef() +#ifdef WASM_CODEGEN_DEBUG + || !JitOptions.enableWasmIonFastCalls +#endif + ) { return InliningStatus_NotInlined; } diff --git a/js/src/wasm/WasmInstance.cpp b/js/src/wasm/WasmInstance.cpp index 32ffdfe56bb4..d34daf9239c3 100644 --- a/js/src/wasm/WasmInstance.cpp +++ b/js/src/wasm/WasmInstance.cpp @@ -154,6 +154,12 @@ bool Instance::callImport(JSContext* cx, uint32_t funcImportIndex, return false; } +#ifdef WASM_CODEGEN_DEBUG + if (!JitOptions.enableWasmJitEntry) { + return true; + } +#endif + // The import may already have become optimized. for (auto t : code().tiers()) { void* jitExitCode = codeBase(t) + fi.jitExitCodeOffset(); diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index c28da513fff2..54498a699c63 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -1490,10 +1490,16 @@ static bool EnsureLazyEntryStub(const Instance& instance, return false; } + bool disableJitEntry = funcType.temporarilyUnsupportedAnyRef() +#ifdef WASM_CODEGEN_DEBUG + || !JitOptions.enableWasmJitEntry; +#endif + ; + // Functions with anyref don't have jit entries yet, so they should // mostly behave like asm.js functions. Pretend it's the case, until // jit entries are implemented. - JSFunction::Flags flags = funcType.temporarilyUnsupportedAnyRef() + JSFunction::Flags flags = disableJitEntry ? JSFunction::ASMJS_NATIVE : JSFunction::WASM_FUN; @@ -1504,7 +1510,7 @@ static bool EnsureLazyEntryStub(const Instance& instance, return false; } - if (funcType.temporarilyUnsupportedAnyRef()) { + if (disableJitEntry) { fun->setAsmJSIndex(funcIndex); } else { fun->setWasmJitEntry(instance.code().getAddressOfJitEntry(funcIndex));