diff --git a/js/src/jit-test/lib/wasm.js b/js/src/jit-test/lib/wasm.js index 056fe82a8206..cb0c49314abd 100644 --- a/js/src/jit-test/lib/wasm.js +++ b/js/src/jit-test/lib/wasm.js @@ -190,6 +190,12 @@ const WasmHelpers = {}; WasmHelpers.isSingleStepProfilingEnabled = enabled; })(); +// The cache of matched and unmatched strings seriously speeds up matching on +// the emulators and makes tests time out less often. + +var matched = {}; +var unmatched = {}; + WasmHelpers._normalizeStack = (stack, preciseStacks) => { var wasmFrameTypes = [ {re:/^jit call to int64 wasm function$/, sub:"i64>"}, @@ -215,13 +221,24 @@ WasmHelpers._normalizeStack = (stack, preciseStacks) => { var framesIn = stack.split(','); var framesOut = []; + outer: for (let frame of framesIn) { + if (unmatched[frame]) + continue; + let probe = matched[frame]; + if (probe !== undefined) { + framesOut.push(probe); + continue; + } for (let {re, sub} of wasmFrameTypes) { if (re.test(frame)) { - framesOut.push(frame.replace(re, sub)); - break; + let repr = frame.replace(re, sub); + framesOut.push(repr); + matched[frame] = repr; + continue outer; } } + unmatched[frame] = true; } return framesOut.join(',');