Commit 63279611 authored by ishell's avatar ishell Committed by Commit bot

[interpreter] Avoid allocation of temporary array of Nodes when generating...

[interpreter] Avoid allocation of temporary array of Nodes when generating dispatch to bytecode handler.

BUG=

Review-Url: https://codereview.chromium.org/2576213007
Cr-Commit-Position: refs/heads/master@{#41759}
parent 686d8c86
......@@ -405,19 +405,6 @@ void CodeAssembler::GotoIfException(Node* node, Label* if_exception,
Bind(&success);
}
Node* CodeAssembler::CallN(CallDescriptor* descriptor, Node* code_target,
Node** args) {
CallPrologue();
Node* return_value = raw_assembler()->CallN(descriptor, code_target, args);
CallEpilogue();
return return_value;
}
Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target,
Node** args) {
return raw_assembler()->TailCallN(descriptor, code_target, args);
}
template <class... TArgs>
Node* CodeAssembler::CallRuntime(Runtime::FunctionId function, Node* context,
TArgs... args) {
......@@ -535,15 +522,22 @@ Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
REPEAT_1_TO_7(INSTANTIATE, Node*)
#undef INSTANTIATE
template <class... TArgs>
Node* CodeAssembler::TailCallBytecodeDispatch(
const CallInterfaceDescriptor& interface_descriptor,
Node* code_target_address, Node** args) {
CallDescriptor* descriptor = Linkage::GetBytecodeDispatchCallDescriptor(
isolate(), zone(), interface_descriptor,
interface_descriptor.GetStackParameterCount());
return raw_assembler()->TailCallN(descriptor, code_target_address, args);
const CallInterfaceDescriptor& descriptor, Node* target, TArgs... args) {
DCHECK_EQ(descriptor.GetParameterCount(), sizeof...(args));
CallDescriptor* desc = Linkage::GetBytecodeDispatchCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount());
Node* nodes[] = {target, args...};
return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes);
}
// Instantiate TailCallBytecodeDispatch() with 4 arguments.
template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallBytecodeDispatch(
const CallInterfaceDescriptor& descriptor, Node* target, Node*, Node*,
Node*, Node*);
Node* CodeAssembler::CallCFunction2(MachineType return_type,
MachineType arg0_type,
MachineType arg1_type, Node* function,
......
......@@ -337,8 +337,9 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, TArgs... args);
template <class... TArgs>
Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor,
Node* code_target_address, Node** args);
Node* target, TArgs... args);
template <class... TArgs>
Node* CallJS(Callable const& callable, Node* context, Node* function,
......@@ -372,9 +373,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
virtual void CallEpilogue();
private:
Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args);
Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args);
RawMachineAssembler* raw_assembler() const;
CodeAssemblerState* state_;
......
......@@ -206,19 +206,6 @@ Node* RawMachineAssembler::CallNWithFrameState(CallDescriptor* desc,
return AddNode(common()->Call(desc), input_count, buffer);
}
Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function,
Node** args) {
int param_count = static_cast<int>(desc->ParameterCount());
int input_count = param_count + 1;
Node** buffer = zone()->NewArray<Node*>(input_count);
int index = 0;
buffer[index++] = function;
for (int i = 0; i < param_count; i++) {
buffer[index++] = args[i];
}
return TailCallN(desc, input_count, buffer);
}
Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, int input_count,
Node* const* inputs) {
// +1 is for target.
......
......@@ -732,9 +732,6 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
Node* arg1, Node* arg2, Node* arg3, Node* arg4,
Node* arg5, Node* arg6, Node* arg7);
// Tail call the given call descriptor and the given arguments.
Node* TailCallN(CallDescriptor* call_descriptor, Node* function, Node** args);
// ===========================================================================
// The following utility methods deal with control flow, hence might switch
// the current basic block or create new basic blocks for labels.
......
......@@ -1009,9 +1009,9 @@ Node* InterpreterAssembler::DispatchToBytecodeHandler(Node* handler,
Node* InterpreterAssembler::DispatchToBytecodeHandlerEntry(
Node* handler_entry, Node* bytecode_offset) {
InterpreterDispatchDescriptor descriptor(isolate());
Node* args[] = {GetAccumulatorUnchecked(), bytecode_offset,
BytecodeArrayTaggedPointer(), DispatchTableRawPointer()};
return TailCallBytecodeDispatch(descriptor, handler_entry, args);
return TailCallBytecodeDispatch(
descriptor, handler_entry, GetAccumulatorUnchecked(), bytecode_offset,
BytecodeArrayTaggedPointer(), DispatchTableRawPointer());
}
void InterpreterAssembler::DispatchWide(OperandScale operand_scale) {
......
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