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

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

Issue 1568493002: [Interpreter] Add support for calling runtime functions which return a pair. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 143
144 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { 144 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) {
145 return raw_assembler_->Store( 145 return raw_assembler_->Store(
146 MachineRepresentation::kTagged, RegisterFileRawPointer(), 146 MachineRepresentation::kTagged, RegisterFileRawPointer(),
147 RegisterFrameOffset(reg_index), value, kNoWriteBarrier); 147 RegisterFrameOffset(reg_index), value, kNoWriteBarrier);
148 } 148 }
149 149
150 150
151 Node* InterpreterAssembler::NextRegister(Node* reg_index) {
152 // Register indexes are negative, so the next index is minus one.
153 return IntPtrAdd(reg_index, Int32Constant(-1));
154 }
155
156
151 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { 157 Node* InterpreterAssembler::BytecodeOperand(int operand_index) {
152 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); 158 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_));
153 DCHECK_EQ(interpreter::OperandSize::kByte, 159 DCHECK_EQ(interpreter::OperandSize::kByte,
154 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); 160 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index));
155 return raw_assembler_->Load( 161 return raw_assembler_->Load(
156 MachineType::Uint8(), BytecodeArrayTaggedPointer(), 162 MachineType::Uint8(), BytecodeArrayTaggedPointer(),
157 IntPtrAdd(BytecodeOffset(), 163 IntPtrAdd(BytecodeOffset(),
158 Int32Constant(interpreter::Bytecodes::GetOperandOffset( 164 Int32Constant(interpreter::Bytecodes::GetOperandOffset(
159 bytecode_, operand_index)))); 165 bytecode_, operand_index))));
160 } 166 }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 args[0] = arg1; 553 args[0] = arg1;
548 args[1] = arg2; 554 args[1] = arg2;
549 args[2] = arg3; 555 args[2] = arg3;
550 args[3] = arg4; 556 args[3] = arg4;
551 args[4] = arg5; 557 args[4] = arg5;
552 args[5] = GetContext(); 558 args[5] = GetContext();
553 return CallIC(descriptor, target, args); 559 return CallIC(descriptor, target, args);
554 } 560 }
555 561
556 562
557 Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg, 563 Node* InterpreterAssembler::CallRuntime(CallDescriptor* descriptor,
564 Handle<Code> call_stub,
565 Node* function_id, Node* first_arg,
558 Node* arg_count) { 566 Node* arg_count) {
559 Callable callable = CodeFactory::InterpreterCEntry(isolate()); 567 Node* code_target = HeapConstant(call_stub);
560 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
561 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
562
563 Node* code_target = HeapConstant(callable.code());
564 568
565 // Get the function entry from the function id. 569 // Get the function entry from the function id.
566 Node* function_table = raw_assembler_->ExternalConstant( 570 Node* function_table = raw_assembler_->ExternalConstant(
567 ExternalReference::runtime_function_table_address(isolate())); 571 ExternalReference::runtime_function_table_address(isolate()));
568 Node* function_offset = raw_assembler_->Int32Mul( 572 Node* function_offset = raw_assembler_->Int32Mul(
569 function_id, Int32Constant(sizeof(Runtime::Function))); 573 function_id, Int32Constant(sizeof(Runtime::Function)));
570 Node* function = IntPtrAdd(function_table, function_offset); 574 Node* function = IntPtrAdd(function_table, function_offset);
571 Node* function_entry = 575 Node* function_entry =
572 raw_assembler_->Load(MachineType::Pointer(), function, 576 raw_assembler_->Load(MachineType::Pointer(), function,
573 Int32Constant(offsetof(Runtime::Function, entry))); 577 Int32Constant(offsetof(Runtime::Function, entry)));
574 578
575 Node** args = zone()->NewArray<Node*>(4); 579 Node** args = zone()->NewArray<Node*>(4);
576 args[0] = arg_count; 580 args[0] = arg_count;
577 args[1] = first_arg; 581 args[1] = first_arg;
578 args[2] = function_entry; 582 args[2] = function_entry;
579 args[3] = GetContext(); 583 args[3] = GetContext();
580 584
581 return CallN(descriptor, code_target, args); 585 return CallN(descriptor, code_target, args);
582 } 586 }
583 587
584 588
589 Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg,
590 Node* arg_count) {
591 Callable callable = CodeFactory::InterpreterCEntry(isolate());
592 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
593 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
594
595 return CallRuntime(descriptor, callable.code(), function_id, first_arg,
596 arg_count);
597 }
598
599
600 Node* InterpreterAssembler::CallRuntimePair(Node* function_id, Node* first_arg,
601 Node* arg_count) {
602 Callable callable = CodeFactory::InterpreterCEntryPair(isolate());
603 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
604 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags,
605 Operator::kNoProperties, MachineType::AnyTagged(), 2);
606
607 return CallRuntime(descriptor, callable.code(), function_id, first_arg,
608 arg_count);
609 }
610
611
585 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, 612 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id,
586 Node* arg1) { 613 Node* arg1) {
587 CallPrologue(); 614 CallPrologue();
588 Node* return_val = 615 Node* return_val =
589 raw_assembler_->CallRuntime1(function_id, arg1, GetContext()); 616 raw_assembler_->CallRuntime1(function_id, arg1, GetContext());
590 CallEpilogue(); 617 CallEpilogue();
591 return return_val; 618 return return_val;
592 } 619 }
593 620
594 621
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return raw_assembler_->call_descriptor(); 762 return raw_assembler_->call_descriptor();
736 } 763 }
737 764
738 765
739 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } 766 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); }
740 767
741 768
742 } // namespace compiler 769 } // namespace compiler
743 } // namespace internal 770 } // namespace internal
744 } // namespace v8 771 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698