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

Side by Side Diff: test/mjsunit/compiler/try-catch-deopt.js

Issue 1416543006: [turbofan] Unwind and jump to the catch handler in the deoptimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase, review comments Created 4 years, 10 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/isolate.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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax
6
7 (function LazyDeoptFromTryBlock() {
8 function g(dummy) {
9 %DeoptimizeFunction(f);
10 throw 42;
11 }
12
13 function f() {
14 var a = 1;
15 try {
16 var dummy = 2; // perturb the stack height.
17 g(dummy);
18 } catch (e) {
19 return e + a;
20 }
21 }
22
23 assertEquals(43, f());
24 assertEquals(43, f());
25 %NeverOptimizeFunction(g);
26 %OptimizeFunctionOnNextCall(f);
27 assertEquals(43, f());
28 })();
29
30
31 (function LazyDeoptDoublyNestedTryBlock() {
32 function g(dummy) {
33 %DeoptimizeFunction(f);
34 throw 42;
35 }
36
37 function f() {
38 var b;
39 try {
40 var a = 1;
41 try {
42 var dummy = 2; // perturb the stack height.
43 g(dummy);
44 } catch (e) {
45 b = e + a;
46 }
47 } catch (e) {
48 return 0;
49 }
50 return b;
51 }
52
53 assertEquals(43, f());
54 assertEquals(43, f());
55 %NeverOptimizeFunction(g);
56 %OptimizeFunctionOnNextCall(f);
57 assertEquals(43, f());
58 })();
59
60 (function LazyDeoptInlinedTry() {
61 function g(dummy) {
62 %DeoptimizeFunction(f);
63 %DeoptimizeFunction(h);
64 throw 42;
65 }
66
67 function h() {
68 var a = 1;
69 try {
70 var dummy = 2; // perturb the stack height.
71 g(dummy);
72 } catch (e) {
73 b = e + a;
74 }
75 return b;
76 }
77
78 function f() {
79 var c = 1;
80 return h() + 1;
81 }
82
83 assertEquals(44, f());
84 assertEquals(44, f());
85 %NeverOptimizeFunction(g);
86 %OptimizeFunctionOnNextCall(f);
87 assertEquals(44, f());
88 })();
89
90 (function LazyDeoptInlinedIntoTry() {
91 function g(c) {
92 %DeoptimizeFunction(f);
93 %DeoptimizeFunction(h);
94 throw c;
95 }
96
97 function h(c) {
98 return g(c);
99 }
100
101 function f() {
102 var a = 1;
103 try {
104 var c = 42; // perturb the stack height.
105 h(c);
106 } catch (e) {
107 a += e;
108 }
109 return a;
110 }
111
112 assertEquals(43, f());
113 assertEquals(43, f());
114 %NeverOptimizeFunction(g);
115 %OptimizeFunctionOnNextCall(f);
116 assertEquals(43, f());
117 })();
118
119 (function LazyDeoptTryBlockContextCatch() {
120 var global = 0;
121
122 function g() {
123 %DeoptimizeFunction(f);
124 throw "boom!";
125 }
126
127 function f(a) {
128 var x = a + 23
129 try {
130 let y = a + 42;
131 function capture() { return x + y }
132 g();
133 } catch(e) {
134 global = x;
135 }
136 return x;
137 }
138 assertEquals(23, f(0));
139 assertEquals(24, f(1));
140 %OptimizeFunctionOnNextCall(f);
141 assertEquals(25, f(2));
142 assertEquals(25, global);
143 })();
144
145 (function LazyDeoptTryBlockFinally() {
146 var global = 0;
147
148 function g() {
149 %DeoptimizeFunction(f);
150 throw "boom!";
151 }
152
153 function f(a) {
154 var x = a + 23
155 try {
156 let y = a + 42;
157 function capture() { return x + y }
158 g();
159 } finally {
160 global = x;
161 }
162 return x;
163 }
164 assertThrows(function() { f(0) });
165 assertThrows(function() { f(1) });
166 %OptimizeFunctionOnNextCall(f);
167 assertThrowsEquals(function() { f(2) }, "boom!");
168 assertEquals(25, global);
169 })();
170
171 (function LazyDeoptTryCatchContextCatch() {
172 var global = 0;
173
174 function g() {
175 %DeoptimizeFunction(f);
176 throw 5;
177 }
178
179 function f(a) {
180 var x = a + 23
181 try {
182 try {
183 throw 1;
184 } catch(e2) {
185 function capture() { return x + y }
186 g();
187 }
188 } catch(e) {
189 global = x + e;
190 }
191 return x;
192 }
193 assertEquals(23, f(0));
194 assertEquals(24, f(1));
195 %OptimizeFunctionOnNextCall(f);
196 assertEquals(25, f(2));
197 assertEquals(30, global);
198 })();
199
200 (function LazyDeoptTryWithContextCatch() {
201 var global = 0;
202
203 function g() {
204 %DeoptimizeFunction(f);
205 throw 5;
206 }
207
208 function f(a) {
209 var x = a + 23
210 try {
211 with ({ y : a + 42 }) {
212 function capture() { return x + y }
213 g();
214 }
215 } catch(e) {
216 global = x + e;
217 }
218 return x;
219 }
220 assertEquals(23, f(0));
221 assertEquals(24, f(1));
222 %OptimizeFunctionOnNextCall(f);
223 assertEquals(25, f(2));
224 assertEquals(30, global);
225 })();
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698