| 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/cctest.h" | 7 #include "test/cctest/cctest.h" |
| 8 #include "test/cctest/compiler/function-tester.h" | 8 #include "test/cctest/compiler/function-tester.h" |
| 9 | 9 |
| 10 using namespace v8; | 10 using namespace v8; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { | 23 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { |
| 24 Local<v8::Context> context = isolate->GetCurrentContext(); | 24 Local<v8::Context> context = isolate->GetCurrentContext(); |
| 25 Local<v8::FunctionTemplate> t = FunctionTemplate::New(isolate, IsOptimized); | 25 Local<v8::FunctionTemplate> t = FunctionTemplate::New(isolate, IsOptimized); |
| 26 context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); | 26 context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 TEST(TurboSimpleDeopt) { | 30 TEST(TurboSimpleDeopt) { |
| 31 FLAG_allow_natives_syntax = true; | 31 FLAG_allow_natives_syntax = true; |
| 32 FLAG_turbo_deoptimization = true; | |
| 33 | 32 |
| 34 FunctionTester T( | 33 FunctionTester T( |
| 35 "(function f(a) {" | 34 "(function f(a) {" |
| 36 "var b = 1;" | 35 "var b = 1;" |
| 37 "if (!IsOptimized()) return 0;" | 36 "if (!IsOptimized()) return 0;" |
| 38 "%DeoptimizeFunction(f);" | 37 "%DeoptimizeFunction(f);" |
| 39 "if (IsOptimized()) return 0;" | 38 "if (IsOptimized()) return 0;" |
| 40 "return a + b; })"); | 39 "return a + b; })"); |
| 41 | 40 |
| 42 InstallIsOptimizedHelper(CcTest::isolate()); | 41 InstallIsOptimizedHelper(CcTest::isolate()); |
| 43 T.CheckCall(T.Val(2), T.Val(1)); | 42 T.CheckCall(T.Val(2), T.Val(1)); |
| 44 } | 43 } |
| 45 | 44 |
| 46 | 45 |
| 47 TEST(TurboSimpleDeoptInExpr) { | 46 TEST(TurboSimpleDeoptInExpr) { |
| 48 FLAG_allow_natives_syntax = true; | 47 FLAG_allow_natives_syntax = true; |
| 49 FLAG_turbo_deoptimization = true; | |
| 50 | 48 |
| 51 FunctionTester T( | 49 FunctionTester T( |
| 52 "(function f(a) {" | 50 "(function f(a) {" |
| 53 "var b = 1;" | 51 "var b = 1;" |
| 54 "var c = 2;" | 52 "var c = 2;" |
| 55 "if (!IsOptimized()) return 0;" | 53 "if (!IsOptimized()) return 0;" |
| 56 "var d = b + (%DeoptimizeFunction(f), c);" | 54 "var d = b + (%DeoptimizeFunction(f), c);" |
| 57 "if (IsOptimized()) return 0;" | 55 "if (IsOptimized()) return 0;" |
| 58 "return d + a; })"); | 56 "return d + a; })"); |
| 59 | 57 |
| 60 InstallIsOptimizedHelper(CcTest::isolate()); | 58 InstallIsOptimizedHelper(CcTest::isolate()); |
| 61 T.CheckCall(T.Val(6), T.Val(3)); | 59 T.CheckCall(T.Val(6), T.Val(3)); |
| 62 } | 60 } |
| 63 | 61 |
| 64 #endif | 62 #endif |
| 65 | 63 |
| 66 TEST(TurboTrivialDeopt) { | 64 TEST(TurboTrivialDeopt) { |
| 67 FLAG_allow_natives_syntax = true; | 65 FLAG_allow_natives_syntax = true; |
| 68 FLAG_turbo_deoptimization = true; | |
| 69 | 66 |
| 70 FunctionTester T( | 67 FunctionTester T( |
| 71 "(function foo() {" | 68 "(function foo() {" |
| 72 "%DeoptimizeFunction(foo);" | 69 "%DeoptimizeFunction(foo);" |
| 73 "return 1; })"); | 70 "return 1; })"); |
| 74 | 71 |
| 75 T.CheckCall(T.Val(1)); | 72 T.CheckCall(T.Val(1)); |
| 76 } | 73 } |
| OLD | NEW |