mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1438121: Add jit-test async-livecache.js. r=fitzgen
MozReview-Commit-ID: Jbe1GMPGwKj --HG-- extra : rebase_source : 60ff2bd3f06bf6cb7b0056efe187a6e2c9bb4c1a extra : amend_source : 7af0b2cf8165ef689e2ed8248763b64ee5183141
This commit is contained in:
parent
280c6da8b0
commit
2e586e022b
43
js/src/jit-test/tests/saved-stacks/async-livecache.js
Normal file
43
js/src/jit-test/tests/saved-stacks/async-livecache.js
Normal file
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user