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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/execution.h" | 7 #include "src/execution.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 MaybeHandle<BytecodeArray> bytecode_; | 117 MaybeHandle<BytecodeArray> bytecode_; |
118 MaybeHandle<TypeFeedbackVector> feedback_vector_; | 118 MaybeHandle<TypeFeedbackVector> feedback_vector_; |
119 | 119 |
120 template <class... A> | 120 template <class... A> |
121 Handle<JSFunction> GetBytecodeFunction() { | 121 Handle<JSFunction> GetBytecodeFunction() { |
122 Handle<JSFunction> function; | 122 Handle<JSFunction> function; |
123 if (source_) { | 123 if (source_) { |
124 CompileRun(source_); | 124 CompileRun(source_); |
125 Local<Function> api_function = | 125 Local<Function> api_function = |
126 Local<Function>::Cast(CcTest::global()->Get(v8_str(kFunctionName))); | 126 Local<Function>::Cast(CcTest::global()->Get(v8_str(kFunctionName))); |
127 function = v8::Utils::OpenHandle(*api_function); | 127 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function)); |
128 } else { | 128 } else { |
129 int arg_count = sizeof...(A); | 129 int arg_count = sizeof...(A); |
130 std::string source("(function " + function_name() + "("); | 130 std::string source("(function " + function_name() + "("); |
131 for (int i = 0; i < arg_count; i++) { | 131 for (int i = 0; i < arg_count; i++) { |
132 source += i == 0 ? "a" : ", a"; | 132 source += i == 0 ? "a" : ", a"; |
133 } | 133 } |
134 source += "){})"; | 134 source += "){})"; |
135 function = v8::Utils::OpenHandle( | 135 function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
136 *v8::Handle<v8::Function>::Cast(CompileRun(source.c_str()))); | 136 *v8::Handle<v8::Function>::Cast(CompileRun(source.c_str())))); |
137 function->ReplaceCode( | 137 function->ReplaceCode( |
138 *isolate_->builtins()->InterpreterEntryTrampoline()); | 138 *isolate_->builtins()->InterpreterEntryTrampoline()); |
139 } | 139 } |
140 | 140 |
141 if (!bytecode_.is_null()) { | 141 if (!bytecode_.is_null()) { |
142 function->shared()->set_function_data(*bytecode_.ToHandleChecked()); | 142 function->shared()->set_function_data(*bytecode_.ToHandleChecked()); |
143 } | 143 } |
144 if (!feedback_vector_.is_null()) { | 144 if (!feedback_vector_.is_null()) { |
145 function->shared()->set_feedback_vector( | 145 function->shared()->set_feedback_vector( |
146 *feedback_vector_.ToHandleChecked()); | 146 *feedback_vector_.ToHandleChecked()); |
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 }; | 2257 }; |
2258 | 2258 |
2259 InterpreterTester tester(handles.main_isolate(), create_args[i].first); | 2259 InterpreterTester tester(handles.main_isolate(), create_args[i].first); |
2260 auto callable = | 2260 auto callable = |
2261 tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); | 2261 tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); |
2262 Handle<Object> return_val = | 2262 Handle<Object> return_val = |
2263 callable(args[0], args[1], args[2]).ToHandleChecked(); | 2263 callable(args[0], args[1], args[2]).ToHandleChecked(); |
2264 CHECK(return_val->SameValue(*args[create_args[i].second])); | 2264 CHECK(return_val->SameValue(*args[create_args[i].second])); |
2265 } | 2265 } |
2266 } | 2266 } |
OLD | NEW |