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