OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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(rmcilroy): Remove this define after this flag 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/execution.h" | 10 #include "src/execution.h" |
8 #include "src/handles.h" | 11 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 12 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 13 #include "src/interpreter/interpreter.h" |
11 #include "test/cctest/cctest.h" | 14 #include "test/cctest/cctest.h" |
12 #include "test/cctest/test-feedback-vector.h" | 15 #include "test/cctest/test-feedback-vector.h" |
13 | 16 |
14 namespace v8 { | 17 namespace v8 { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 Isolate* isolate_; | 122 Isolate* isolate_; |
120 const char* source_; | 123 const char* source_; |
121 MaybeHandle<BytecodeArray> bytecode_; | 124 MaybeHandle<BytecodeArray> bytecode_; |
122 MaybeHandle<TypeFeedbackVector> feedback_vector_; | 125 MaybeHandle<TypeFeedbackVector> feedback_vector_; |
123 | 126 |
124 template <class... A> | 127 template <class... A> |
125 Handle<JSFunction> GetBytecodeFunction() { | 128 Handle<JSFunction> GetBytecodeFunction() { |
126 Handle<JSFunction> function; | 129 Handle<JSFunction> function; |
127 if (source_) { | 130 if (source_) { |
128 CompileRun(source_); | 131 CompileRun(source_); |
| 132 v8::Local<v8::Context> context = |
| 133 v8::Isolate::GetCurrent()->GetCurrentContext(); |
129 Local<Function> api_function = | 134 Local<Function> api_function = |
130 Local<Function>::Cast(CcTest::global()->Get(v8_str(kFunctionName))); | 135 Local<Function>::Cast(CcTest::global() |
| 136 ->Get(context, v8_str(kFunctionName)) |
| 137 .ToLocalChecked()); |
131 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function)); | 138 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function)); |
132 } else { | 139 } else { |
133 int arg_count = sizeof...(A); | 140 int arg_count = sizeof...(A); |
134 std::string source("(function " + function_name() + "("); | 141 std::string source("(function " + function_name() + "("); |
135 for (int i = 0; i < arg_count; i++) { | 142 for (int i = 0; i < arg_count; i++) { |
136 source += i == 0 ? "a" : ", a"; | 143 source += i == 0 ? "a" : ", a"; |
137 } | 144 } |
138 source += "){})"; | 145 source += "){})"; |
139 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 146 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
140 *v8::Handle<v8::Function>::Cast(CompileRun(source.c_str())))); | 147 *v8::Local<v8::Function>::Cast(CompileRun(source.c_str())))); |
141 function->ReplaceCode( | 148 function->ReplaceCode( |
142 *isolate_->builtins()->InterpreterEntryTrampoline()); | 149 *isolate_->builtins()->InterpreterEntryTrampoline()); |
143 } | 150 } |
144 | 151 |
145 if (!bytecode_.is_null()) { | 152 if (!bytecode_.is_null()) { |
146 function->shared()->set_function_data(*bytecode_.ToHandleChecked()); | 153 function->shared()->set_function_data(*bytecode_.ToHandleChecked()); |
147 } | 154 } |
148 if (!feedback_vector_.is_null()) { | 155 if (!feedback_vector_.is_null()) { |
149 function->shared()->set_feedback_vector( | 156 function->shared()->set_feedback_vector( |
150 *feedback_vector_.ToHandleChecked()); | 157 *feedback_vector_.ToHandleChecked()); |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 " }", | 2724 " }", |
2718 0}}; | 2725 0}}; |
2719 | 2726 |
2720 for (size_t i = 0; i < arraysize(for_in_samples); i++) { | 2727 for (size_t i = 0; i < arraysize(for_in_samples); i++) { |
2721 InterpreterTester tester(handles.main_isolate(), for_in_samples[i].first); | 2728 InterpreterTester tester(handles.main_isolate(), for_in_samples[i].first); |
2722 auto callable = tester.GetCallable<>(); | 2729 auto callable = tester.GetCallable<>(); |
2723 Handle<Object> return_val = callable().ToHandleChecked(); | 2730 Handle<Object> return_val = callable().ToHandleChecked(); |
2724 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), for_in_samples[i].second); | 2731 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), for_in_samples[i].second); |
2725 } | 2732 } |
2726 } | 2733 } |
OLD | NEW |