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

Side by Side Diff: test/cctest/compiler/test-run-jsexceptions.cc

Issue 969533004: [turbofan] Implement throwing exceptions into TurboFan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix code lookup. Created 5 years, 9 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/x64/code-stubs-x64.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 using namespace v8::internal; 9 using namespace v8::internal;
10 using namespace v8::internal::compiler; 10 using namespace v8::internal::compiler;
11 11
12 TEST(Throw) { 12 TEST(Throw) {
13 i::FLAG_turbo_exceptions = true; 13 i::FLAG_turbo_exceptions = true;
14 FunctionTester T("(function(a,b) { if (a) { throw b; } else { return b; }})"); 14 FunctionTester T("(function(a,b) { if (a) { throw b; } else { return b; }})");
15 15
16 T.CheckThrows(T.true_value(), T.NewObject("new Error")); 16 T.CheckThrows(T.true_value(), T.NewObject("new Error"));
17 T.CheckCall(T.Val(23), T.false_value(), T.Val(23)); 17 T.CheckCall(T.Val(23), T.false_value(), T.Val(23));
18 } 18 }
19 19
20 20
21 TEST(ThrowSourcePosition) { 21 TEST(ThrowSourcePosition) {
22 i::FLAG_turbo_exceptions = true;
22 static const char* src = 23 static const char* src =
23 "(function(a, b) { \n" 24 "(function(a, b) { \n"
24 " if (a == 1) throw 1; \n" 25 " if (a == 1) throw 1; \n"
25 " if (a == 2) {throw 2} \n" 26 " if (a == 2) {throw 2} \n"
26 " if (a == 3) {0;throw 3}\n" 27 " if (a == 3) {0;throw 3}\n"
27 " throw 4; \n" 28 " throw 4; \n"
28 "}) "; 29 "}) ";
29 FunctionTester T(src); 30 FunctionTester T(src);
30 v8::Handle<v8::Message> message; 31 v8::Handle<v8::Message> message;
31 32
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 " r += 'A-';" 128 " r += 'A-';"
128 " return r + 'B-' + fun();" 129 " return r + 'B-' + fun();"
129 " } catch (e) {" 130 " } catch (e) {"
130 " r += e;" 131 " r += e;"
131 " }" 132 " }"
132 " return r;" 133 " return r;"
133 "})"; 134 "})";
134 FunctionTester T(src); 135 FunctionTester T(src);
135 136
136 CompileRun("function thrower() { throw 'T-'; }"); 137 CompileRun("function thrower() { throw 'T-'; }");
137 #if 0 // TODO(mstarzinger): Enable once we have exception handlers.
138 T.CheckCall(T.Val("-A-T-"), T.NewFunction("thrower")); 138 T.CheckCall(T.Val("-A-T-"), T.NewFunction("thrower"));
139 #endif
140 CompileRun("function returner() { return 'R-'; }"); 139 CompileRun("function returner() { return 'R-'; }");
141 T.CheckCall(T.Val("-A-B-R-"), T.NewFunction("returner")); 140 T.CheckCall(T.Val("-A-B-R-"), T.NewFunction("returner"));
142 } 141 }
143 142
144 143
145 TEST(Finally) { 144 TEST(Finally) {
146 i::FLAG_turbo_exceptions = true; 145 i::FLAG_turbo_exceptions = true;
147 const char* src = 146 const char* src =
148 "(function(a,b) {" 147 "(function(a,b) {"
149 " var r = '-';" 148 " var r = '-';"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 " } finally {" 251 " } finally {"
253 " %DeoptimizeFunction(f);" 252 " %DeoptimizeFunction(f);"
254 " }" 253 " }"
255 "})"; 254 "})";
256 FunctionTester T(src); 255 FunctionTester T(src);
257 256
258 #if 0 // TODO(mstarzinger): Enable once we can. 257 #if 0 // TODO(mstarzinger): Enable once we can.
259 T.CheckThrows(T.NewObject("new Error"), T.Val(1)); 258 T.CheckThrows(T.NewObject("new Error"), T.Val(1));
260 #endif 259 #endif
261 } 260 }
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698