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

Unified Diff: src/compiler/bytecode-graph-builder.cc

Issue 2684993002: [interpreter] Create custom call opcodes for specific argument counts (Closed)
Patch Set: Latest Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/bytecode-graph-builder.cc
diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc
index c22cd52a17432cf4f41f4d62eb7285f298f69818..bf46684d6d7e89f5c46242ca7e05a88cc42a5b2b 100644
--- a/src/compiler/bytecode-graph-builder.cc
+++ b/src/compiler/bytecode-graph-builder.cc
@@ -1279,10 +1279,8 @@ void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
literal, Environment::kAttachFrameState);
}
-Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
- Node* callee,
- interpreter::Register receiver,
- size_t arity) {
+Node* const* BytecodeGraphBuilder::GetCallArgumentsFromRegister(
+ Node* callee, interpreter::Register receiver, size_t arity) {
Node** all = local_zone()->NewArray<Node*>(static_cast<int>(arity));
all[0] = callee;
all[1] = environment()->LookupRegister(receiver);
@@ -1291,36 +1289,134 @@ Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
all[i] = environment()->LookupRegister(
interpreter::Register(receiver_index + i - 1));
}
- Node* value = MakeNode(call_op, static_cast<int>(arity), all, false);
- return value;
+ return all;
+}
+
+Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
+ Node* const* args,
+ size_t arg_count) {
+ return MakeNode(call_op, static_cast<int>(arg_count), args, false);
+}
+
+Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op,
+ Node* callee,
+ interpreter::Register receiver,
+ size_t arg_count) {
+ return ProcessCallArguments(
+ call_op, GetCallArgumentsFromRegister(callee, receiver, arg_count),
+ arg_count);
}
void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode,
- ConvertReceiverMode receiver_hint) {
+ ConvertReceiverMode receiver_hint,
+ Node* const* args, size_t arg_count,
+ int slot_id) {
PrepareEagerCheckpoint();
- Node* callee =
- environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
- interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1);
- size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);
-
// Slot index of 0 is used indicate no feedback slot is available. Assert
// the assumption that slot index 0 is never a valid feedback slot.
STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0);
- int const slot_id = bytecode_iterator().GetIndexOperand(3);
VectorSlotPair feedback = CreateVectorSlotPair(slot_id);
float const frequency = ComputeCallFrequency(slot_id);
- const Operator* call = javascript()->Call(arg_count + 1, frequency, feedback,
+ const Operator* call = javascript()->Call(arg_count, frequency, feedback,
receiver_hint, tail_call_mode);
- Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1);
+ Node* value = ProcessCallArguments(call, args, arg_count);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
+void BytecodeGraphBuilder::BuildCall(TailCallMode tail_call_mode,
rmcilroy 2017/02/17 11:37:19 nit - BuildCallN or something to specify this is f
danno 2017/02/17 17:18:43 Done.
+ ConvertReceiverMode receiver_hint) {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1);
+ size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);
+ int const slot_id = bytecode_iterator().GetIndexOperand(3);
+ BuildCall(tail_call_mode, receiver_hint,
+ GetCallArgumentsFromRegister(callee, receiver, arg_count + 1),
+ arg_count + 1, slot_id);
+}
+
void BytecodeGraphBuilder::VisitCall() {
BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny);
}
+void BytecodeGraphBuilder::VisitCall0() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ int const slot_id = bytecode_iterator().GetIndexOperand(2);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny,
+ {callee, receiver}, slot_id);
+}
+
+void BytecodeGraphBuilder::VisitCall1() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ Node* arg0 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(2));
+ int const slot_id = bytecode_iterator().GetIndexOperand(3);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny,
+ {callee, receiver, arg0}, slot_id);
+}
+
+void BytecodeGraphBuilder::VisitCall2() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ Node* arg0 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(2));
+ Node* arg1 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(3));
+ int const slot_id = bytecode_iterator().GetIndexOperand(4);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kAny,
+ {callee, receiver, arg0, arg1}, slot_id);
+}
+
+void BytecodeGraphBuilder::VisitCallProperty() {
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined);
+}
+
+void BytecodeGraphBuilder::VisitCallProperty0() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ int const slot_id = bytecode_iterator().GetIndexOperand(2);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined,
+ {callee, receiver}, slot_id);
+}
+
+void BytecodeGraphBuilder::VisitCallProperty1() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ Node* arg0 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(2));
+ int const slot_id = bytecode_iterator().GetIndexOperand(3);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined,
+ {callee, receiver, arg0}, slot_id);
+}
+
+void BytecodeGraphBuilder::VisitCallProperty2() {
+ Node* callee =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ Node* receiver =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1));
+ Node* arg0 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(2));
+ Node* arg1 =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(3));
+ int const slot_id = bytecode_iterator().GetIndexOperand(4);
+ BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined,
+ {callee, receiver, arg0, arg1}, slot_id);
+}
+
void BytecodeGraphBuilder::VisitCallWithSpread() {
PrepareEagerCheckpoint();
Node* callee =
@@ -1334,10 +1430,6 @@ void BytecodeGraphBuilder::VisitCallWithSpread() {
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
-void BytecodeGraphBuilder::VisitCallProperty() {
- BuildCall(TailCallMode::kDisallow, ConvertReceiverMode::kNotNullOrUndefined);
-}
-
void BytecodeGraphBuilder::VisitTailCall() {
TailCallMode tail_call_mode =
bytecode_array_->GetIsolate()->is_tail_call_elimination_enabled()
@@ -2233,7 +2325,8 @@ void BytecodeGraphBuilder::EnterAndExitExceptionHandlers(int current_offset) {
}
Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count,
- Node** value_inputs, bool incomplete) {
+ Node* const* value_inputs,
+ bool incomplete) {
DCHECK_EQ(op->ValueInputCount(), value_input_count);
bool has_context = OperatorProperties::HasContextInput(op);

Powered by Google App Engine
This is Rietveld 408576698