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 // TODO(jochen): Remove this after the setting is turned on globally. |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 |
5 #include "src/v8.h" | 8 #include "src/v8.h" |
6 | 9 |
7 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
8 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
9 #include "test/cctest/compiler/function-tester.h" | 12 #include "test/cctest/compiler/function-tester.h" |
10 | 13 |
11 using namespace v8::internal; | 14 using namespace v8::internal; |
12 using namespace v8::internal::compiler; | 15 using namespace v8::internal::compiler; |
13 | 16 |
14 static void IsOptimized(const v8::FunctionCallbackInfo<v8::Value>& args) { | 17 static void IsOptimized(const v8::FunctionCallbackInfo<v8::Value>& args) { |
15 JavaScriptFrameIterator it(CcTest::i_isolate()); | 18 JavaScriptFrameIterator it(CcTest::i_isolate()); |
16 JavaScriptFrame* frame = it.frame(); | 19 JavaScriptFrame* frame = it.frame(); |
17 return args.GetReturnValue().Set(frame->is_optimized()); | 20 return args.GetReturnValue().Set(frame->is_optimized()); |
18 } | 21 } |
19 | 22 |
20 | 23 |
21 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { | 24 static void InstallIsOptimizedHelper(v8::Isolate* isolate) { |
22 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 25 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
23 v8::Local<v8::FunctionTemplate> t = | 26 v8::Local<v8::FunctionTemplate> t = |
24 v8::FunctionTemplate::New(isolate, IsOptimized); | 27 v8::FunctionTemplate::New(isolate, IsOptimized); |
25 context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); | 28 CHECK(context->Global() |
| 29 ->Set(context, v8_str("IsOptimized"), |
| 30 t->GetFunction(context).ToLocalChecked()) |
| 31 .FromJust()); |
26 } | 32 } |
27 | 33 |
28 | 34 |
29 TEST(DeoptSimple) { | 35 TEST(DeoptSimple) { |
30 FLAG_allow_natives_syntax = true; | 36 FLAG_allow_natives_syntax = true; |
31 | 37 |
32 FunctionTester T( | 38 FunctionTester T( |
33 "(function f(a) {" | 39 "(function f(a) {" |
34 " var b = 1;" | 40 " var b = 1;" |
35 " if (!IsOptimized()) return 0;" | 41 " if (!IsOptimized()) return 0;" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 FLAG_allow_natives_syntax = true; | 112 FLAG_allow_natives_syntax = true; |
107 | 113 |
108 FunctionTester T( | 114 FunctionTester T( |
109 "(function foo() {" | 115 "(function foo() {" |
110 " %DeoptimizeFunction(foo);" | 116 " %DeoptimizeFunction(foo);" |
111 " return 1;" | 117 " return 1;" |
112 "})"); | 118 "})"); |
113 | 119 |
114 T.CheckCall(T.Val(1)); | 120 T.CheckCall(T.Val(1)); |
115 } | 121 } |
OLD | NEW |