From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../jit-test/tests/saved-stacks/async-livecache.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 js/src/jit-test/tests/saved-stacks/async-livecache.js (limited to 'js/src/jit-test/tests/saved-stacks/async-livecache.js') diff --git a/js/src/jit-test/tests/saved-stacks/async-livecache.js b/js/src/jit-test/tests/saved-stacks/async-livecache.js new file mode 100644 index 0000000000..1034b5fc49 --- /dev/null +++ b/js/src/jit-test/tests/saved-stacks/async-livecache.js @@ -0,0 +1,43 @@ +// Async stacks should not supplant LiveSavedFrameCache hits. + +top(); + +// An ordinary function, to give the frame a convenient name. +function top() { + // Perform an async call. F will run in an activation that has an async stack + // supplied. + f().catch(catchError); +} + +async function f() { + // Perform an ordinary call. Its parent frame will be a LiveSavedFrameCache + // hit. + g(); +} + +function g() { + // Populate the LiveSavedFrameCache. + saveStack(); + + // Capturing the stack again should find f (if not g) in the cache. The async + // stack supplied below the call to f should not supplant f's own frame. + let frame = saveStack(); + + assertEq(frame.functionDisplayName, 'g'); + assertEq(parent(frame).functionDisplayName, 'f'); + assertEq(parent(parent(frame)).functionDisplayName, 'top'); +} + +// Return the parent of |frame|, skipping self-hosted code and following async +// parent links. +function parent(frame) { + do { + frame = frame.parent || frame.asyncParent; + } while (frame.source.match(/self-hosted/)); + return frame; +} + +function catchError(e) { + print(`${e}\n${e.stack}`); + quit(1) +} -- cgit v1.2.3