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