Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1423723002: Map v8::Function to JSReceiver + IsCallable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/cctest/test-alloc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/cctest/test-alloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698