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/compiler/code-assembler.h" | 5 #include "src/compiler/code-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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 const Operator* op = raw_assembler()->common()->IfException(); | 398 const Operator* op = raw_assembler()->common()->IfException(); |
399 Node* exception_value = raw_assembler()->AddNode(op, node, node); | 399 Node* exception_value = raw_assembler()->AddNode(op, node, node); |
400 if (exception_var != nullptr) { | 400 if (exception_var != nullptr) { |
401 exception_var->Bind(exception_value); | 401 exception_var->Bind(exception_value); |
402 } | 402 } |
403 Goto(if_exception); | 403 Goto(if_exception); |
404 | 404 |
405 Bind(&success); | 405 Bind(&success); |
406 } | 406 } |
407 | 407 |
408 Node* CodeAssembler::CallN(CallDescriptor* descriptor, Node* code_target, | |
409 Node** args) { | |
410 CallPrologue(); | |
411 Node* return_value = raw_assembler()->CallN(descriptor, code_target, args); | |
412 CallEpilogue(); | |
413 return return_value; | |
414 } | |
415 | |
416 Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target, | |
417 Node** args) { | |
418 return raw_assembler()->TailCallN(descriptor, code_target, args); | |
419 } | |
420 | |
421 template <class... TArgs> | 408 template <class... TArgs> |
422 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function, Node* context, | 409 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function, Node* context, |
423 TArgs... args) { | 410 TArgs... args) { |
424 int argc = static_cast<int>(sizeof...(args)); | 411 int argc = static_cast<int>(sizeof...(args)); |
425 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | 412 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
426 zone(), function, argc, Operator::kNoProperties, | 413 zone(), function, argc, Operator::kNoProperties, |
427 CallDescriptor::kNoFlags); | 414 CallDescriptor::kNoFlags); |
428 int return_count = static_cast<int>(desc->ReturnCount()); | 415 int return_count = static_cast<int>(desc->ReturnCount()); |
429 | 416 |
430 Node* centry = | 417 Node* centry = |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); | 515 return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); |
529 } | 516 } |
530 | 517 |
531 // Instantiate TailCallStub() with up to 6 arguments. | 518 // Instantiate TailCallStub() with up to 6 arguments. |
532 #define INSTANTIATE(...) \ | 519 #define INSTANTIATE(...) \ |
533 template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallStub( \ | 520 template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallStub( \ |
534 const CallInterfaceDescriptor& descriptor, Node*, __VA_ARGS__); | 521 const CallInterfaceDescriptor& descriptor, Node*, __VA_ARGS__); |
535 REPEAT_1_TO_7(INSTANTIATE, Node*) | 522 REPEAT_1_TO_7(INSTANTIATE, Node*) |
536 #undef INSTANTIATE | 523 #undef INSTANTIATE |
537 | 524 |
| 525 template <class... TArgs> |
538 Node* CodeAssembler::TailCallBytecodeDispatch( | 526 Node* CodeAssembler::TailCallBytecodeDispatch( |
539 const CallInterfaceDescriptor& interface_descriptor, | 527 const CallInterfaceDescriptor& descriptor, Node* target, TArgs... args) { |
540 Node* code_target_address, Node** args) { | 528 DCHECK_EQ(descriptor.GetParameterCount(), sizeof...(args)); |
541 CallDescriptor* descriptor = Linkage::GetBytecodeDispatchCallDescriptor( | 529 CallDescriptor* desc = Linkage::GetBytecodeDispatchCallDescriptor( |
542 isolate(), zone(), interface_descriptor, | 530 isolate(), zone(), descriptor, descriptor.GetStackParameterCount()); |
543 interface_descriptor.GetStackParameterCount()); | 531 |
544 return raw_assembler()->TailCallN(descriptor, code_target_address, args); | 532 Node* nodes[] = {target, args...}; |
| 533 return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); |
545 } | 534 } |
546 | 535 |
| 536 // Instantiate TailCallBytecodeDispatch() with 4 arguments. |
| 537 template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallBytecodeDispatch( |
| 538 const CallInterfaceDescriptor& descriptor, Node* target, Node*, Node*, |
| 539 Node*, Node*); |
| 540 |
547 Node* CodeAssembler::CallCFunction2(MachineType return_type, | 541 Node* CodeAssembler::CallCFunction2(MachineType return_type, |
548 MachineType arg0_type, | 542 MachineType arg0_type, |
549 MachineType arg1_type, Node* function, | 543 MachineType arg1_type, Node* function, |
550 Node* arg0, Node* arg1) { | 544 Node* arg0, Node* arg1) { |
551 return raw_assembler()->CallCFunction2(return_type, arg0_type, arg1_type, | 545 return raw_assembler()->CallCFunction2(return_type, arg0_type, arg1_type, |
552 function, arg0, arg1); | 546 function, arg0, arg1); |
553 } | 547 } |
554 | 548 |
555 void CodeAssembler::Goto(Label* label) { | 549 void CodeAssembler::Goto(Label* label) { |
556 label->MergeVariables(); | 550 label->MergeVariables(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 } | 744 } |
751 } | 745 } |
752 } | 746 } |
753 | 747 |
754 bound_ = true; | 748 bound_ = true; |
755 } | 749 } |
756 | 750 |
757 } // namespace compiler | 751 } // namespace compiler |
758 } // namespace internal | 752 } // namespace internal |
759 } // namespace v8 | 753 } // namespace v8 |
OLD | NEW |