Commit 01408ea6 authored by ishell's avatar ishell Committed by Commit bot

[turbofan] Combine family of CallJS() methods into single implementation.

... by using variadic templates in CodeAssembler.

BUG=

Review-Url: https://codereview.chromium.org/2579163003
Cr-Commit-Position: refs/heads/master@{#41753}
parent 92b370ee
......@@ -485,11 +485,11 @@ Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor,
return CallStubN(descriptor, result_size, arraysize(nodes), nodes);
}
// Instantiate CallStubR() with up to 5 arguments.
// Instantiate CallStubR() with up to 6 arguments.
#define INSTANTIATE(...) \
template V8_EXPORT_PRIVATE Node* CodeAssembler::CallStubR( \
const CallInterfaceDescriptor& descriptor, size_t, Node*, __VA_ARGS__);
REPEAT_1_TO_6(INSTANTIATE, Node*)
REPEAT_1_TO_7(INSTANTIATE, Node*)
#undef INSTANTIATE
Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor,
......@@ -513,18 +513,6 @@ Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor,
return return_value;
}
Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor,
int js_parameter_count, Node* target,
Node** args, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor,
descriptor.GetStackParameterCount() + js_parameter_count,
CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context,
Node* arg1, size_t result_size) {
Node* target = HeapConstant(callable.code());
......@@ -680,72 +668,6 @@ Node* CodeAssembler::TailCallBytecodeDispatch(
return raw_assembler()->TailCallN(descriptor, code_target_address, args);
}
Node* CodeAssembler::CallJS(Callable const& callable, Node* context,
Node* function, Node* receiver,
size_t result_size) {
const int argc = 0;
Node* target = HeapConstant(callable.code());
Node** args = zone()->NewArray<Node*>(argc + 4);
args[0] = function;
args[1] = Int32Constant(argc);
args[2] = receiver;
args[3] = context;
return CallStubN(callable.descriptor(), argc + 1, target, args, result_size);
}
Node* CodeAssembler::CallJS(Callable const& callable, Node* context,
Node* function, Node* receiver, Node* arg1,
size_t result_size) {
const int argc = 1;
Node* target = HeapConstant(callable.code());
Node** args = zone()->NewArray<Node*>(argc + 4);
args[0] = function;
args[1] = Int32Constant(argc);
args[2] = receiver;
args[3] = arg1;
args[4] = context;
return CallStubN(callable.descriptor(), argc + 1, target, args, result_size);
}
Node* CodeAssembler::CallJS(Callable const& callable, Node* context,
Node* function, Node* receiver, Node* arg1,
Node* arg2, size_t result_size) {
const int argc = 2;
Node* target = HeapConstant(callable.code());
Node** args = zone()->NewArray<Node*>(argc + 4);
args[0] = function;
args[1] = Int32Constant(argc);
args[2] = receiver;
args[3] = arg1;
args[4] = arg2;
args[5] = context;
return CallStubN(callable.descriptor(), argc + 1, target, args, result_size);
}
Node* CodeAssembler::CallJS(Callable const& callable, Node* context,
Node* function, Node* receiver, Node* arg1,
Node* arg2, Node* arg3, size_t result_size) {
const int argc = 3;
Node* target = HeapConstant(callable.code());
Node** args = zone()->NewArray<Node*>(argc + 4);
args[0] = function;
args[1] = Int32Constant(argc);
args[2] = receiver;
args[3] = arg1;
args[4] = arg2;
args[5] = arg3;
args[6] = context;
return CallStubN(callable.descriptor(), argc + 1, target, args, result_size);
}
Node* CodeAssembler::CallCFunction2(MachineType return_type,
MachineType arg0_type,
MachineType arg1_type, Node* function,
......
......@@ -327,14 +327,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* CallStubN(const CallInterfaceDescriptor& descriptor, size_t result_size,
int input_count, Node* const* inputs);
Node* CallStubN(const CallInterfaceDescriptor& descriptor,
int js_parameter_count, Node* target, Node** args,
size_t result_size = 1);
Node* CallStubN(const CallInterfaceDescriptor& descriptor, Node* target,
Node** args, size_t result_size = 1) {
return CallStubN(descriptor, 0, target, args, result_size);
}
Node* TailCallStub(Callable const& callable, Node* context, Node* arg1,
size_t result_size = 1);
Node* TailCallStub(Callable const& callable, Node* context, Node* arg1,
......@@ -370,15 +362,13 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor,
Node* code_target_address, Node** args);
template <class... TArgs>
Node* CallJS(Callable const& callable, Node* context, Node* function,
Node* receiver, size_t result_size = 1);
Node* CallJS(Callable const& callable, Node* context, Node* function,
Node* receiver, Node* arg1, size_t result_size = 1);
Node* CallJS(Callable const& callable, Node* context, Node* function,
Node* receiver, Node* arg1, Node* arg2, size_t result_size = 1);
Node* CallJS(Callable const& callable, Node* context, Node* function,
Node* receiver, Node* arg1, Node* arg2, Node* arg3,
size_t result_size = 1);
Node* receiver, TArgs... args) {
int argc = static_cast<int>(sizeof...(args));
Node* arity = Int32Constant(argc);
return CallStub(callable, context, function, arity, receiver, args...);
}
// Call to a C function with two arguments.
Node* CallCFunction2(MachineType return_type, MachineType arg0_type,
......@@ -407,8 +397,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args);
Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args);
void InstallBreakOnNodeDecorator();
RawMachineAssembler* raw_assembler() const;
CodeAssemblerState* state_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment