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

Side by Side Diff: src/compiler/interpreter-assembler.cc

Issue 1362383002: [Interpreter] Add CallRuntime support to the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm32 debug build check errors. Created 5 years, 2 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
« no previous file with comments | « src/compiler/interpreter-assembler.h ('k') | src/ia32/builtins-ia32.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/compiler/interpreter-assembler.h" 5 #include "src/compiler/interpreter-assembler.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 kMachAnyTagged, RegisterFileRawPointer(), 307 kMachAnyTagged, RegisterFileRawPointer(),
308 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); 308 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer));
309 Node* shared_info = 309 Node* shared_info =
310 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); 310 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset);
311 Node* vector = 311 Node* vector =
312 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); 312 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset);
313 return vector; 313 return vector;
314 } 314 }
315 315
316 316
317 Node* InterpreterAssembler::CallN(CallDescriptor* descriptor,
318 Node* code_target,
319 Node** args) {
320 Node* stack_pointer_before_call = nullptr;
321 if (FLAG_debug_code) {
322 stack_pointer_before_call = raw_assembler_->LoadStackPointer();
323 }
324 Node* return_val = raw_assembler_->CallN(descriptor, code_target, args);
325 if (FLAG_debug_code) {
326 Node* stack_pointer_after_call = raw_assembler_->LoadStackPointer();
327 AbortIfWordNotEqual(stack_pointer_before_call, stack_pointer_after_call,
328 kUnexpectedStackPointer);
329 }
330 return return_val;
331 }
332
333
317 Node* InterpreterAssembler::CallJS(Node* function, Node* first_arg, 334 Node* InterpreterAssembler::CallJS(Node* function, Node* first_arg,
318 Node* arg_count) { 335 Node* arg_count) {
319 Callable builtin = CodeFactory::PushArgsAndCall(isolate()); 336 Callable callable = CodeFactory::InterpreterPushArgsAndCall(isolate());
320 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( 337 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
321 isolate(), zone(), builtin.descriptor(), 0, CallDescriptor::kNoFlags); 338 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
322 339
323 Node* code_target = HeapConstant(builtin.code()); 340 Node* code_target = HeapConstant(callable.code());
324 341
325 Node** args = zone()->NewArray<Node*>(4); 342 Node** args = zone()->NewArray<Node*>(4);
326 args[0] = arg_count; 343 args[0] = arg_count;
327 args[1] = first_arg; 344 args[1] = first_arg;
328 args[2] = function; 345 args[2] = function;
329 args[3] = ContextTaggedPointer(); 346 args[3] = ContextTaggedPointer();
330 347
331 return raw_assembler_->CallN(descriptor, code_target, args); 348 return CallN(descriptor, code_target, args);
332 } 349 }
333 350
334 351
335 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 352 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
336 Node* target, Node** args) { 353 Node* target, Node** args) {
337 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 354 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
338 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags); 355 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags);
339 return raw_assembler_->CallN(call_descriptor, target, args); 356 return CallN(call_descriptor, target, args);
340 } 357 }
341 358
342 359
343 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 360 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
344 Node* target, Node* arg1, Node* arg2, 361 Node* target, Node* arg1, Node* arg2,
345 Node* arg3, Node* arg4) { 362 Node* arg3, Node* arg4) {
346 Node** args = zone()->NewArray<Node*>(5); 363 Node** args = zone()->NewArray<Node*>(5);
347 args[0] = arg1; 364 args[0] = arg1;
348 args[1] = arg2; 365 args[1] = arg2;
349 args[2] = arg3; 366 args[2] = arg3;
(...skipping 10 matching lines...) Expand all
360 args[0] = arg1; 377 args[0] = arg1;
361 args[1] = arg2; 378 args[1] = arg2;
362 args[2] = arg3; 379 args[2] = arg3;
363 args[3] = arg4; 380 args[3] = arg4;
364 args[4] = arg5; 381 args[4] = arg5;
365 args[5] = ContextTaggedPointer(); 382 args[5] = ContextTaggedPointer();
366 return CallIC(descriptor, target, args); 383 return CallIC(descriptor, target, args);
367 } 384 }
368 385
369 386
387 Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg,
388 Node* arg_count) {
389 Callable callable = CodeFactory::InterpreterCEntry(isolate());
390 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
391 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
392
393 Node* code_target = HeapConstant(callable.code());
394
395 // Get the function entry from the function id.
396 Node* function_table = raw_assembler_->ExternalConstant(
397 ExternalReference::runtime_function_table_address(isolate()));
398 Node* function_offset = raw_assembler_->Int32Mul(
399 function_id, Int32Constant(sizeof(Runtime::Function)));
400 Node* function = IntPtrAdd(function_table, function_offset);
401 Node* function_entry = raw_assembler_->Load(
402 kMachPtr, function, Int32Constant(offsetof(Runtime::Function, entry)));
403
404 Node** args = zone()->NewArray<Node*>(4);
405 args[0] = arg_count;
406 args[1] = first_arg;
407 args[2] = function_entry;
408 args[3] = ContextTaggedPointer();
409
410 return CallN(descriptor, code_target, args);
411 }
412
413
370 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, 414 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id,
371 Node* arg1) { 415 Node* arg1) {
372 return raw_assembler_->CallRuntime1(function_id, arg1, 416 return raw_assembler_->CallRuntime1(function_id, arg1,
373 ContextTaggedPointer()); 417 ContextTaggedPointer());
374 } 418 }
375 419
376 420
377 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, 421 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id,
378 Node* arg1, Node* arg2) { 422 Node* arg1, Node* arg2) {
379 return raw_assembler_->CallRuntime2(function_id, arg1, arg2, 423 return raw_assembler_->CallRuntime2(function_id, arg1, arg2,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 BytecodeArrayTaggedPointer(), 501 BytecodeArrayTaggedPointer(),
458 DispatchTableRawPointer(), 502 DispatchTableRawPointer(),
459 ContextTaggedPointer() }; 503 ContextTaggedPointer() };
460 Node* tail_call = 504 Node* tail_call =
461 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args); 505 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args);
462 // This should always be the end node. 506 // This should always be the end node.
463 AddEndInput(tail_call); 507 AddEndInput(tail_call);
464 } 508 }
465 509
466 510
511 void InterpreterAssembler::AbortIfWordNotEqual(
512 Node* lhs, Node* rhs, BailoutReason bailout_reason) {
513 RawMachineAssembler::Label match, no_match;
514 Node* condition = raw_assembler_->WordEqual(lhs, rhs);
515 raw_assembler_->Branch(condition, &match, &no_match);
516 raw_assembler_->Bind(&no_match);
517 Node* abort_id = SmiTag(Int32Constant(bailout_reason));
518 CallRuntime(Runtime::kAbort, abort_id);
519 Return();
520 raw_assembler_->Bind(&match);
521 }
522
523
467 void InterpreterAssembler::AddEndInput(Node* input) { 524 void InterpreterAssembler::AddEndInput(Node* input) {
468 DCHECK_NOT_NULL(input); 525 DCHECK_NOT_NULL(input);
469 end_nodes_.push_back(input); 526 end_nodes_.push_back(input);
470 } 527 }
471 528
472 529
473 void InterpreterAssembler::End() { 530 void InterpreterAssembler::End() {
474 DCHECK(!end_nodes_.empty()); 531 DCHECK(!end_nodes_.empty());
475 int end_count = static_cast<int>(end_nodes_.size()); 532 int end_count = static_cast<int>(end_nodes_.size());
476 Node* end = graph()->NewNode(raw_assembler_->common()->End(end_count), 533 Node* end = graph()->NewNode(raw_assembler_->common()->End(end_count),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return raw_assembler_->schedule(); 566 return raw_assembler_->schedule();
510 } 567 }
511 568
512 569
513 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } 570 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); }
514 571
515 572
516 } // namespace compiler 573 } // namespace compiler
517 } // namespace internal 574 } // namespace internal
518 } // namespace v8 575 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/interpreter-assembler.h ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698