Commit 2e4666ab authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[compiler] Remove redundant is_tail_call param

For tail calls, we already set the flag kCallTail on CallBufferFlags,
the bool is_tail_cal always matches the flag (and there is only one call
site (L3037).

Drive-by clean up to get SaveFPRegsMode once, this is used when we need
to save and restore caller-saved registers.

Change-Id: Id175922c4cb5162d38b5ab61b84e151aaf2083e8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2945536Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75056}
parent e63a71ea
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/codegen/assembler-inl.h" #include "src/codegen/assembler-inl.h"
#include "src/codegen/interface-descriptors-inl.h" #include "src/codegen/interface-descriptors-inl.h"
#include "src/codegen/tick-counter.h" #include "src/codegen/tick-counter.h"
#include "src/common/globals.h"
#include "src/compiler/backend/instruction-selector-impl.h" #include "src/compiler/backend/instruction-selector-impl.h"
#include "src/compiler/compiler-source-position-table.h" #include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/js-heap-broker.h" #include "src/compiler/js-heap-broker.h"
...@@ -962,10 +963,10 @@ struct CallBuffer { ...@@ -962,10 +963,10 @@ struct CallBuffer {
// InstructionSelector::VisitCall platform independent instead. // InstructionSelector::VisitCall platform independent instead.
void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
CallBufferFlags flags, CallBufferFlags flags,
bool is_tail_call,
int stack_param_delta) { int stack_param_delta) {
OperandGenerator g(this); OperandGenerator g(this);
size_t ret_count = buffer->descriptor->ReturnCount(); size_t ret_count = buffer->descriptor->ReturnCount();
bool is_tail_call = (flags & kCallTail) != 0;
DCHECK_LE(call->op()->ValueOutputCount(), ret_count); DCHECK_LE(call->op()->ValueOutputCount(), ret_count);
DCHECK_EQ( DCHECK_EQ(
call->op()->ValueInputCount(), call->op()->ValueInputCount(),
...@@ -1135,20 +1136,19 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, ...@@ -1135,20 +1136,19 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
// as an InstructionOperand argument to the call. // as an InstructionOperand argument to the call.
auto iter(call->inputs().begin()); auto iter(call->inputs().begin());
size_t pushed_count = 0; size_t pushed_count = 0;
bool call_tail = (flags & kCallTail) != 0;
for (size_t index = 0; index < input_count; ++iter, ++index) { for (size_t index = 0; index < input_count; ++iter, ++index) {
DCHECK(iter != call->inputs().end()); DCHECK(iter != call->inputs().end());
DCHECK_NE(IrOpcode::kFrameState, (*iter)->op()->opcode()); DCHECK_NE(IrOpcode::kFrameState, (*iter)->op()->opcode());
if (index == 0) continue; // The first argument (callee) is already done. if (index == 0) continue; // The first argument (callee) is already done.
LinkageLocation location = buffer->descriptor->GetInputLocation(index); LinkageLocation location = buffer->descriptor->GetInputLocation(index);
if (call_tail) { if (is_tail_call) {
location = LinkageLocation::ConvertToTailCallerLocation( location = LinkageLocation::ConvertToTailCallerLocation(
location, stack_param_delta); location, stack_param_delta);
} }
InstructionOperand op = g.UseLocation(*iter, location); InstructionOperand op = g.UseLocation(*iter, location);
UnallocatedOperand unallocated = UnallocatedOperand::cast(op); UnallocatedOperand unallocated = UnallocatedOperand::cast(op);
if (unallocated.HasFixedSlotPolicy() && !call_tail) { if (unallocated.HasFixedSlotPolicy() && !is_tail_call) {
int stack_index = buffer->descriptor->GetStackIndexFromSlot( int stack_index = buffer->descriptor->GetStackIndexFromSlot(
unallocated.fixed_slot_index()); unallocated.fixed_slot_index());
// This can insert empty slots before stack_index and will insert enough // This can insert empty slots before stack_index and will insert enough
...@@ -1180,7 +1180,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, ...@@ -1180,7 +1180,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
} }
DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count - DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count -
frame_state_entries - 1); frame_state_entries - 1);
if (V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK && call_tail && if (V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK && is_tail_call &&
stack_param_delta != 0) { stack_param_delta != 0) {
// For tail calls that change the size of their parameter list and keep // For tail calls that change the size of their parameter list and keep
// their return address on the stack, move the return address to just above // their return address on the stack, move the return address to just above
...@@ -2932,11 +2932,11 @@ void InstructionSelector::UpdateMaxPushedArgumentCount(size_t count) { ...@@ -2932,11 +2932,11 @@ void InstructionSelector::UpdateMaxPushedArgumentCount(size_t count) {
void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
OperandGenerator g(this); OperandGenerator g(this);
auto call_descriptor = CallDescriptorOf(node->op()); auto call_descriptor = CallDescriptorOf(node->op());
SaveFPRegsMode mode = call_descriptor->NeedsCallerSavedFPRegisters()
? SaveFPRegsMode::kSave
: SaveFPRegsMode::kIgnore;
if (call_descriptor->NeedsCallerSavedRegisters()) { if (call_descriptor->NeedsCallerSavedRegisters()) {
SaveFPRegsMode mode = call_descriptor->NeedsCallerSavedFPRegisters()
? SaveFPRegsMode::kSave
: SaveFPRegsMode::kIgnore;
Emit(kArchSaveCallerRegisters | MiscField::encode(static_cast<int>(mode)), Emit(kArchSaveCallerRegisters | MiscField::encode(static_cast<int>(mode)),
g.NoOutput()); g.NoOutput());
} }
...@@ -2956,7 +2956,7 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { ...@@ -2956,7 +2956,7 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
// Improve constant pool and the heuristics in the register allocator // Improve constant pool and the heuristics in the register allocator
// for where to emit constants. // for where to emit constants.
CallBufferFlags call_buffer_flags(kCallCodeImmediate | kCallAddressImmediate); CallBufferFlags call_buffer_flags(kCallCodeImmediate | kCallAddressImmediate);
InitializeCallBuffer(node, &buffer, call_buffer_flags, false); InitializeCallBuffer(node, &buffer, call_buffer_flags);
EmitPrepareArguments(&buffer.pushed_nodes, call_descriptor, node); EmitPrepareArguments(&buffer.pushed_nodes, call_descriptor, node);
UpdateMaxPushedArgumentCount(buffer.pushed_nodes.size()); UpdateMaxPushedArgumentCount(buffer.pushed_nodes.size());
...@@ -3014,9 +3014,6 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { ...@@ -3014,9 +3014,6 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
EmitPrepareResults(&(buffer.output_nodes), call_descriptor, node); EmitPrepareResults(&(buffer.output_nodes), call_descriptor, node);
if (call_descriptor->NeedsCallerSavedRegisters()) { if (call_descriptor->NeedsCallerSavedRegisters()) {
SaveFPRegsMode mode = call_descriptor->NeedsCallerSavedFPRegisters()
? SaveFPRegsMode::kSave
: SaveFPRegsMode::kIgnore;
Emit( Emit(
kArchRestoreCallerRegisters | MiscField::encode(static_cast<int>(mode)), kArchRestoreCallerRegisters | MiscField::encode(static_cast<int>(mode)),
g.NoOutput()); g.NoOutput());
...@@ -3041,7 +3038,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -3041,7 +3038,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
if (callee->flags() & CallDescriptor::kFixedTargetRegister) { if (callee->flags() & CallDescriptor::kFixedTargetRegister) {
flags |= kCallFixedTargetRegister; flags |= kCallFixedTargetRegister;
} }
InitializeCallBuffer(node, &buffer, flags, true, stack_param_delta); InitializeCallBuffer(node, &buffer, flags, stack_param_delta);
UpdateMaxPushedArgumentCount(stack_param_delta); UpdateMaxPushedArgumentCount(stack_param_delta);
// Select the appropriate opcode based on the call type. // Select the appropriate opcode based on the call type.
......
...@@ -592,8 +592,7 @@ class V8_EXPORT_PRIVATE InstructionSelector final { ...@@ -592,8 +592,7 @@ class V8_EXPORT_PRIVATE InstructionSelector final {
// {call_code_immediate} to generate immediate operands to calls of code. // {call_code_immediate} to generate immediate operands to calls of code.
// {call_address_immediate} to generate immediate operands to address calls. // {call_address_immediate} to generate immediate operands to address calls.
void InitializeCallBuffer(Node* call, CallBuffer* buffer, void InitializeCallBuffer(Node* call, CallBuffer* buffer,
CallBufferFlags flags, bool is_tail_call, CallBufferFlags flags, int stack_slot_delta = 0);
int stack_slot_delta = 0);
bool IsTailCallAddressImmediate(); bool IsTailCallAddressImmediate();
void UpdateMaxPushedArgumentCount(size_t count); void UpdateMaxPushedArgumentCount(size_t count);
......
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