Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(907)

Side by Side Diff: test/mjsunit/harmony/debug-async-function-async-task-event.js

Issue 2357423002: Improve stack traces for async functions (Closed)
Patch Set: REbase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-async-await --expose-debug-as debug --allow-natives-syntax 5 // Flags: --harmony-async-await --expose-debug-as debug --allow-natives-syntax
6 6
7 // The test observes the callbacks that async/await makes to the inspector 7 // The test observes the callbacks that async/await makes to the inspector
8 // to make accurate stack traces. The limited number of events is an 8 // to make accurate stack traces. The pattern is based on saving a stack once
9 // indirect indication that we are not doing extra Promise processing that 9 // with enqueueRecurring and restoring it multiple times.
10 // could be associated with memory leaks (v8:5380). 10
11 // Additionally, the limited number of events is an indirect indication that
12 // we are not doing extra Promise processing that could be associated with memor y
13 // leaks (v8:5380). In particular, no stacks are saved and restored for extra
14 // Promise handling on throwaway Promises.
15
11 // TODO(littledan): Write a test that demonstrates that the memory leak in 16 // TODO(littledan): Write a test that demonstrates that the memory leak in
12 // the exception case is fixed. 17 // the exception case is fixed.
13 18
14 Debug = debug.Debug; 19 Debug = debug.Debug;
15 20
16 var base_id = -1; 21 var base_id = -1;
17 var exception = null; 22 var exception = null;
18 var expected = [ 23 var expected = [
19 'enqueue #1', 24 'enqueueRecurring #1',
20 'willHandle #1', 25 'willHandle #1',
21 'then #1', 26 'then #1',
22 'enqueue #2',
23 'didHandle #1', 27 'didHandle #1',
24 'willHandle #2', 28 'willHandle #1',
25 'then #2', 29 'then #2',
26 'didHandle #2', 30 'cancel #1',
31 'didHandle #1',
27 ]; 32 ];
28 33
29 function assertLog(msg) { 34 function assertLog(msg) {
30 print(msg); 35 print(msg);
31 assertTrue(expected.length > 0); 36 assertTrue(expected.length > 0);
32 assertEquals(expected.shift(), msg); 37 assertEquals(expected.shift(), msg);
33 if (!expected.length) { 38 if (!expected.length) {
34 Debug.setListener(null); 39 Debug.setListener(null);
35 } 40 }
36 } 41 }
37 42
38 function listener(event, exec_state, event_data, data) { 43 function listener(event, exec_state, event_data, data) {
39 if (event != Debug.DebugEvent.AsyncTaskEvent) return; 44 if (event != Debug.DebugEvent.AsyncTaskEvent) return;
40 try { 45 try {
41 if (base_id < 0) 46 if (base_id < 0)
42 base_id = event_data.id(); 47 base_id = event_data.id();
43 var id = event_data.id() - base_id + 1; 48 var id = event_data.id() - base_id + 1;
44 assertTrue("Promise.resolve" == event_data.name() || 49 assertTrue("async function" == event_data.name());
45 "PromiseResolveThenableJob" == event_data.name());
46 assertLog(event_data.type() + " #" + id); 50 assertLog(event_data.type() + " #" + id);
47 } catch (e) { 51 } catch (e) {
48 print(e + e.stack) 52 print(e + e.stack)
49 exception = e; 53 exception = e;
50 } 54 }
51 } 55 }
52 56
53 Debug.setListener(listener); 57 Debug.setListener(listener);
54 58
55 var resolver; 59 var resolver;
56 var p = new Promise(function(resolve, reject) { 60 var p = new Promise(function(resolve, reject) {
57 resolver = resolve; 61 resolver = resolve;
58 }); 62 });
59 63
60 async function main() { 64 async function main() {
61 await p; 65 await p;
62 assertLog("then #1"); 66 assertLog("then #1");
63 await undefined; 67 await undefined;
64 assertLog("then #2"); 68 assertLog("then #2");
65 } 69 }
66 main(); 70 main();
67 resolver(); 71 resolver();
68 72
69 %RunMicrotasks(); 73 %RunMicrotasks();
70 74
71 assertNull(exception); 75 assertNull(exception);
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698