diff --git a/src/mono/browser/runtime/jiterpreter-support.ts b/src/mono/browser/runtime/jiterpreter-support.ts index b1c81b257b5d8e..ef7591c0d6a3bf 100644 --- a/src/mono/browser/runtime/jiterpreter-support.ts +++ b/src/mono/browser/runtime/jiterpreter-support.ts @@ -1246,12 +1246,14 @@ class Cfg { this.overheadBytes += 11; } - // Account for the size of the safepoint - if ( - (branchType === CfgBranchType.SafepointConditional) || - (branchType === CfgBranchType.SafepointUnconditional) - ) { - this.overheadBytes += 17; + if (WasmEnableThreads) { + // Account for the size of the safepoint + if ( + (branchType === CfgBranchType.SafepointConditional) || + (branchType === CfgBranchType.SafepointUnconditional) + ) { + this.overheadBytes += 17; + } } } @@ -1505,6 +1507,9 @@ export const _now = (globalThis.performance && globalThis.performance.now) let scratchBuffer: NativePointer = 0; export function append_safepoint(builder: WasmBuilder, ip: MintOpcodePtr) { + // safepoints are never triggered in a single-threaded build + if (!WasmEnableThreads) + return; // Check whether a safepoint is required builder.ptr_const(cwraps.mono_jiterp_get_polling_required_address()); builder.appendU8(WasmOpcode.i32_load);