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; |
11 using namespace v8::internal; | 11 using namespace v8::internal; |
12 using namespace v8::internal::compiler; | 12 using namespace v8::internal::compiler; |
13 | 13 |
| 14 #if V8_TURBOFAN_TARGET |
| 15 |
14 static void IsOptimized(const FunctionCallbackInfo<v8::Value>& args) { | 16 static void IsOptimized(const FunctionCallbackInfo<v8::Value>& args) { |
15 JavaScriptFrameIterator it(CcTest::i_isolate()); | 17 JavaScriptFrameIterator it(CcTest::i_isolate()); |
16 JavaScriptFrame* frame = it.frame(); | 18 JavaScriptFrame* frame = it.frame(); |
17 return args.GetReturnValue().Set(frame->is_optimized()); | 19 return args.GetReturnValue().Set(frame->is_optimized()); |
18 } | 20 } |
19 | 21 |
20 | 22 |
21 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { | 23 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { |
22 Local<v8::Context> context = isolate->GetCurrentContext(); | 24 Local<v8::Context> context = isolate->GetCurrentContext(); |
23 Local<v8::FunctionTemplate> t = FunctionTemplate::New(isolate, IsOptimized); | 25 Local<v8::FunctionTemplate> t = FunctionTemplate::New(isolate, IsOptimized); |
24 context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); | 26 context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); |
25 } | 27 } |
26 | 28 |
27 #if V8_TURBOFAN_TARGET | |
28 | 29 |
29 TEST(TurboSimpleDeopt) { | 30 TEST(TurboSimpleDeopt) { |
30 FLAG_allow_natives_syntax = true; | 31 FLAG_allow_natives_syntax = true; |
31 FLAG_turbo_deoptimization = true; | 32 FLAG_turbo_deoptimization = true; |
32 | 33 |
33 FunctionTester T( | 34 FunctionTester T( |
34 "(function f(a) {" | 35 "(function f(a) {" |
35 "var b = 1;" | 36 "var b = 1;" |
36 "if (!IsOptimized()) return 0;" | 37 "if (!IsOptimized()) return 0;" |
37 "%DeoptimizeFunction(f);" | 38 "%DeoptimizeFunction(f);" |
(...skipping 28 matching lines...) Expand all Loading... |
66 FLAG_allow_natives_syntax = true; | 67 FLAG_allow_natives_syntax = true; |
67 FLAG_turbo_deoptimization = true; | 68 FLAG_turbo_deoptimization = true; |
68 | 69 |
69 FunctionTester T( | 70 FunctionTester T( |
70 "(function foo() {" | 71 "(function foo() {" |
71 "%DeoptimizeFunction(foo);" | 72 "%DeoptimizeFunction(foo);" |
72 "return 1; })"); | 73 "return 1; })"); |
73 | 74 |
74 T.CheckCall(T.Val(1)); | 75 T.CheckCall(T.Val(1)); |
75 } | 76 } |
OLD | NEW |