OLD | NEW |
| (Empty) |
1 // Copyright 2015 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 | |
6 // This test ensures that IC learning doesn't interfere with stepping into | |
7 // property accessor. f1()'s ICs are allowed to learn to a monomorphic state, | |
8 // and the breakpoints flooding get() are allowed to expire, then we ensure | |
9 // that we can step into get() again later (when k == 1). | |
10 function f1() { | |
11 for (var k = 0; k < 2; k++) { // Break 1 | |
12 var v10 = 0; // Line 2 | |
13 for (var i = 0; i < 10; i++) { // Line 3 | |
14 var v12 = o.slappy; // Line 4 | |
15 var v13 = 3 // Line 5 | |
16 } // Line 6 | |
17 print("break here"); // Break 3 | |
18 } // Line 8 | |
19 print("exiting f1"); // Line 9 (dummy break) | |
20 } | |
21 | |
22 function get() { | |
23 var g0 = 0; // Break 2 | |
24 var g1 = 1; | |
25 return 3; | |
26 } | |
27 | |
28 | |
29 var o = {}; | |
30 Object.defineProperty(o, "slappy", { get : get }); | |
31 | |
32 Debug = debug.Debug; | |
33 var break_count = 0 | |
34 var exception = null; | |
35 var bp_f1_line7; | |
36 var bp_f1_line9; | |
37 | |
38 function listener(event, exec_state, event_data, data) { | |
39 if (event != Debug.DebugEvent.Break) return; | |
40 try { | |
41 var line = exec_state.frame(0).sourceLineText(); | |
42 print(line); | |
43 var match = line.match(/\/\/ Break (\d+)$/); | |
44 assertEquals(2, match.length); | |
45 var match_value = parseInt(match[1]); | |
46 | |
47 if (break_count >= 0 && break_count < 2) { | |
48 // 0, 1: Keep stepping through frames. | |
49 assertEquals(break_count, match_value); | |
50 exec_state.prepareStep(Debug.StepAction.StepFrame); | |
51 } else if (break_count === 2) { | |
52 // 2: let the code run to a breakpoint we set. The load should | |
53 // go monomorphic. | |
54 assertEquals(break_count, match_value); | |
55 } else if (break_count === 3) { | |
56 // 3: back to frame stepping. Does the monomorphic slappy accessor | |
57 // call still have the ability to break like before? | |
58 assertEquals(break_count, match_value); | |
59 Debug.clearBreakPoint(bp_f1_line7); | |
60 exec_state.prepareStep(Debug.StepAction.StepFrame); | |
61 } else { | |
62 assertEquals(4, break_count); | |
63 assertEquals(2, match_value); | |
64 // Apparently we can still stop in the accessor even though we cleared | |
65 // breakpoints earlier and there was a monomorphic step. | |
66 // Allow running to completion now. | |
67 Debug.clearBreakPoint(bp_f1_line9); | |
68 } | |
69 | |
70 break_count++; | |
71 } catch (e) { | |
72 print(e + e.stack); | |
73 exception = e; | |
74 } | |
75 } | |
76 | |
77 for (var j = 1; j < 3; j++) { | |
78 break_count = 0; | |
79 Debug.setListener(listener); | |
80 | |
81 // Breakpoints are added here rather than in the listener because their | |
82 // addition causes a full (clearing) gc that clears type feedback when we | |
83 // want to let it build up. Also, bp_f1_line9 is set simply because if we | |
84 // handled then deleted bp_f1_line7, then the debugger clears DebugInfo from | |
85 // f1 while we are still using it, again, resetting type feedback which is | |
86 // undesirable. | |
87 bp_f1_line7 = Debug.setBreakPoint(f1, 7); | |
88 bp_f1_line9 = Debug.setBreakPoint(f1, 9); | |
89 | |
90 debugger; // Break 0 | |
91 f1(); | |
92 Debug.setListener(null); | |
93 assertTrue(break_count === 5); | |
94 } | |
95 | |
96 assertNull(exception); | |
OLD | NEW |