OLD | NEW |
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 | 12 |
13 TEST(TurboSimpleDeopt) { | 13 TEST(TurboSimpleDeopt) { |
14 FLAG_allow_natives_syntax = true; | 14 FLAG_allow_natives_syntax = true; |
15 FLAG_turbo_deoptimization = true; | 15 FLAG_turbo_deoptimization = true; |
16 | 16 |
17 FunctionTester T( | 17 FunctionTester T( |
18 "(function f(a) {" | 18 "(function f(a) {" |
19 "var b = 1;" | 19 "var b = 1;" |
20 "if (!%IsOptimized()) return 0;" | 20 "if (!%IsOptimized()) return 0;" |
21 "%DeoptimizeFunction(f);" | 21 "%DeoptimizeFunction(f);" |
22 "if (%IsOptimized()) return 0;" | 22 "if (%IsOptimized()) return 0;" |
23 "return a + b; })"); | 23 "return a + b; })"); |
24 | 24 |
25 T.CheckCall(T.Val(2), T.Val(1)); | 25 T.CheckCall(T.Val(2), T.Val(1)); |
26 } | 26 } |
27 | 27 |
28 | 28 |
| 29 TEST(TurboSimpleDeoptInExpr) { |
| 30 FLAG_allow_natives_syntax = true; |
| 31 FLAG_turbo_deoptimization = true; |
| 32 |
| 33 FunctionTester T( |
| 34 "(function f(a) {" |
| 35 "var b = 1;" |
| 36 "var c = 2;" |
| 37 "if (!%IsOptimized()) return 0;" |
| 38 "var d = b + (%DeoptimizeFunction(f), c);" |
| 39 "if (%IsOptimized()) return 0;" |
| 40 "return d + a; })"); |
| 41 |
| 42 T.CheckCall(T.Val(6), T.Val(3)); |
| 43 } |
| 44 |
| 45 |
29 TEST(TurboTrivialDeopt) { | 46 TEST(TurboTrivialDeopt) { |
30 FLAG_allow_natives_syntax = true; | 47 FLAG_allow_natives_syntax = true; |
31 FLAG_turbo_deoptimization = true; | 48 FLAG_turbo_deoptimization = true; |
32 | 49 |
33 FunctionTester T( | 50 FunctionTester T( |
34 "(function foo() {" | 51 "(function foo() {" |
35 "%DeoptimizeFunction(foo);" | 52 "%DeoptimizeFunction(foo);" |
36 "return 1; })"); | 53 "return 1; })"); |
37 | 54 |
38 T.CheckCall(T.Val(1)); | 55 T.CheckCall(T.Val(1)); |
39 } | 56 } |
OLD | NEW |