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

Side by Side Diff: src/interpreter/interpreter-intrinsics.cc

Issue 2051573002: [Interpreter] Add intrinsics called as stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix leak Created 4 years, 6 months 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
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/interpreter/interpreter-intrinsics.h" 5 #include "src/interpreter/interpreter-intrinsics.h"
6 6
7 #include "src/code-factory.h"
8
7 namespace v8 { 9 namespace v8 {
8 namespace internal { 10 namespace internal {
9 namespace interpreter { 11 namespace interpreter {
10 12
11 using compiler::Node; 13 using compiler::Node;
12 14
13 #define __ assembler_-> 15 #define __ assembler_->
14 16
15 IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler) 17 IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler)
16 : assembler_(assembler) {} 18 : isolate_(assembler->isolate()),
19 zone_(assembler->zone()),
20 assembler_(assembler) {}
17 21
18 // static 22 // static
19 bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) { 23 bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) {
20 switch (function_id) { 24 switch (function_id) {
21 #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name: 25 #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name:
22 INTRINSICS_LIST(SUPPORTED) 26 INTRINSICS_LIST(SUPPORTED)
23 return true; 27 return true;
24 #undef SUPPORTED 28 #undef SUPPORTED
25 default: 29 default:
26 return false; 30 return false;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 __ Bind(&if_not_smi); 224 __ Bind(&if_not_smi);
221 { 225 {
222 return_value.Bind(__ BooleanConstant(false)); 226 return_value.Bind(__ BooleanConstant(false));
223 __ Goto(&end); 227 __ Goto(&end);
224 } 228 }
225 229
226 __ Bind(&end); 230 __ Bind(&end);
227 return return_value.value(); 231 return return_value.value();
228 } 232 }
229 233
234 Node* IntrinsicsHelper::IntrinsicAsStubCall(Node* args_reg, Node* context,
235 Callable const& callable) {
236 int param_count = callable.descriptor().GetParameterCount();
237 Node** args = zone()->NewArray<Node*>(param_count + 1); // 1 for context
238 for (int i = 0; i < param_count; i++) {
239 args[i] = __ LoadRegister(args_reg);
240 args_reg = __ NextRegister(args_reg);
241 }
242 args[param_count] = context;
243
244 return __ CallStubN(callable, args);
245 }
246
247 Node* IntrinsicsHelper::HasProperty(Node* input, Node* arg_count,
248 Node* context) {
249 return IntrinsicAsStubCall(input, context,
250 CodeFactory::HasProperty(isolate()));
251 }
252
253 Node* IntrinsicsHelper::MathPow(Node* input, Node* arg_count, Node* context) {
254 return IntrinsicAsStubCall(input, context, CodeFactory::MathPow(isolate()));
255 }
256
257 Node* IntrinsicsHelper::NewObject(Node* input, Node* arg_count, Node* context) {
258 return IntrinsicAsStubCall(input, context,
259 CodeFactory::FastNewObject(isolate()));
260 }
261
262 Node* IntrinsicsHelper::NumberToString(Node* input, Node* arg_count,
263 Node* context) {
264 return IntrinsicAsStubCall(input, context,
265 CodeFactory::NumberToString(isolate()));
266 }
267
268 Node* IntrinsicsHelper::RegExpConstructResult(Node* input, Node* arg_count,
269 Node* context) {
270 return IntrinsicAsStubCall(input, context,
271 CodeFactory::RegExpConstructResult(isolate()));
272 }
273
274 Node* IntrinsicsHelper::RegExpExec(Node* input, Node* arg_count,
275 Node* context) {
276 return IntrinsicAsStubCall(input, context,
277 CodeFactory::RegExpExec(isolate()));
278 }
279
280 Node* IntrinsicsHelper::SubString(Node* input, Node* arg_count, Node* context) {
281 return IntrinsicAsStubCall(input, context, CodeFactory::SubString(isolate()));
282 }
283
284 Node* IntrinsicsHelper::ToString(Node* input, Node* arg_count, Node* context) {
285 return IntrinsicAsStubCall(input, context, CodeFactory::ToString(isolate()));
286 }
287
288 Node* IntrinsicsHelper::ToName(Node* input, Node* arg_count, Node* context) {
289 return IntrinsicAsStubCall(input, context, CodeFactory::ToName(isolate()));
290 }
291
292 Node* IntrinsicsHelper::ToLength(Node* input, Node* arg_count, Node* context) {
293 return IntrinsicAsStubCall(input, context, CodeFactory::ToLength(isolate()));
294 }
295
296 Node* IntrinsicsHelper::ToInteger(Node* input, Node* arg_count, Node* context) {
297 return IntrinsicAsStubCall(input, context, CodeFactory::ToInteger(isolate()));
298 }
299
300 Node* IntrinsicsHelper::ToNumber(Node* input, Node* arg_count, Node* context) {
301 return IntrinsicAsStubCall(input, context, CodeFactory::ToNumber(isolate()));
302 }
303
304 Node* IntrinsicsHelper::ToObject(Node* input, Node* arg_count, Node* context) {
305 return IntrinsicAsStubCall(input, context, CodeFactory::ToObject(isolate()));
306 }
307
230 Node* IntrinsicsHelper::Call(Node* args_reg, Node* arg_count, Node* context) { 308 Node* IntrinsicsHelper::Call(Node* args_reg, Node* arg_count, Node* context) {
231 // First argument register contains the function target. 309 // First argument register contains the function target.
232 Node* function = __ LoadRegister(args_reg); 310 Node* function = __ LoadRegister(args_reg);
233 311
234 // Receiver is the second runtime call argument. 312 // Receiver is the second runtime call argument.
235 Node* receiver_reg = __ NextRegister(args_reg); 313 Node* receiver_reg = __ NextRegister(args_reg);
236 Node* receiver_arg = __ RegisterLocation(receiver_reg); 314 Node* receiver_arg = __ RegisterLocation(receiver_reg);
237 315
238 // Subtract function and receiver from arg count. 316 // Subtract function and receiver from arg count.
239 Node* function_and_receiver_count = __ Int32Constant(2); 317 Node* function_and_receiver_count = __ Int32Constant(2);
(...skipping 18 matching lines...) Expand all
258 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); 336 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected));
259 __ GotoIf(comparison, &match); 337 __ GotoIf(comparison, &match);
260 __ Abort(kWrongArgumentCountForInvokeIntrinsic); 338 __ Abort(kWrongArgumentCountForInvokeIntrinsic);
261 __ Goto(&match); 339 __ Goto(&match);
262 __ Bind(&match); 340 __ Bind(&match);
263 } 341 }
264 342
265 } // namespace interpreter 343 } // namespace interpreter
266 } // namespace internal 344 } // namespace internal
267 } // namespace v8 345 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-intrinsics.h ('k') | test/cctest/interpreter/test-interpreter-intrinsics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698