Commit 1e696896 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[codegen] Removed ParameterCount class

It was used only with Register inputs, so we can replace its uses with
the Registers themselves.

Change-Id: I1ea3ed88ee41177b696a7281cdf3b90fefdc5870
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1886916Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64639}
parent 0f872428
...@@ -1494,35 +1494,23 @@ void TurboAssembler::MovFromFloatParameter(DwVfpRegister dst) { ...@@ -1494,35 +1494,23 @@ void TurboAssembler::MovFromFloatParameter(DwVfpRegister dst) {
MovFromFloatResult(dst); MovFromFloatResult(dst);
} }
void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, void TurboAssembler::PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register caller_args_count,
Register scratch0, Register scratch1) { Register scratch0, Register scratch1) {
#if DEBUG DCHECK(!AreAliased(callee_args_count, caller_args_count, scratch0, scratch1));
if (callee_args_count.is_reg()) {
DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0,
scratch1));
} else {
DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1));
}
#endif
// Calculate the end of destination area where we will put the arguments // Calculate the end of destination area where we will put the arguments
// after we drop current frame. We add kPointerSize to count the receiver // after we drop current frame. We add kPointerSize to count the receiver
// argument which is not included into formal parameters count. // argument which is not included into formal parameters count.
Register dst_reg = scratch0; Register dst_reg = scratch0;
add(dst_reg, fp, Operand(caller_args_count_reg, LSL, kPointerSizeLog2)); add(dst_reg, fp, Operand(caller_args_count, LSL, kPointerSizeLog2));
add(dst_reg, dst_reg, add(dst_reg, dst_reg,
Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize));
Register src_reg = caller_args_count_reg; Register src_reg = caller_args_count;
// Calculate the end of source area. +kPointerSize is for the receiver. // Calculate the end of source area. +kPointerSize is for the receiver.
if (callee_args_count.is_reg()) { add(src_reg, sp, Operand(callee_args_count, LSL, kPointerSizeLog2));
add(src_reg, sp, Operand(callee_args_count.reg(), LSL, kPointerSizeLog2)); add(src_reg, src_reg, Operand(kPointerSize));
add(src_reg, src_reg, Operand(kPointerSize));
} else {
add(src_reg, sp,
Operand((callee_args_count.immediate() + 1) * kPointerSize));
}
if (FLAG_debug_code) { if (FLAG_debug_code) {
cmp(src_reg, dst_reg); cmp(src_reg, dst_reg);
......
...@@ -223,11 +223,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -223,11 +223,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Removes current frame and its arguments from the stack preserving // Removes current frame and its arguments from the stack preserving
// the arguments and a return address pushed to the stack for the next call. // the arguments and a return address pushed to the stack for the next call.
// Both |callee_args_count| and |caller_args_count_reg| do not include // Both |callee_args_count| and |caller_args_count| do not include
// receiver. |callee_args_count| is not modified, |caller_args_count_reg| // receiver. |callee_args_count| is not modified. |caller_args_count|
// is trashed. // is trashed.
void PrepareForTailCall(const ParameterCount& callee_args_count, void PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register scratch0, Register caller_args_count, Register scratch0,
Register scratch1); Register scratch1);
// There are two ways of passing double arguments on ARM, depending on // There are two ways of passing double arguments on ARM, depending on
......
...@@ -2074,23 +2074,16 @@ void TurboAssembler::CallForDeoptimization(Address target, int deopt_id) { ...@@ -2074,23 +2074,16 @@ void TurboAssembler::CallForDeoptimization(Address target, int deopt_id) {
DCHECK_EQ(SizeOfCodeGeneratedSince(&start), Deoptimizer::kDeoptExitSize); DCHECK_EQ(SizeOfCodeGeneratedSince(&start), Deoptimizer::kDeoptExitSize);
} }
void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, void TurboAssembler::PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register caller_args_count,
Register scratch0, Register scratch1) { Register scratch0, Register scratch1) {
#if DEBUG DCHECK(!AreAliased(callee_args_count, caller_args_count, scratch0, scratch1));
if (callee_args_count.is_reg()) {
DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0,
scratch1));
} else {
DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1));
}
#endif
// Calculate the end of destination area where we will put the arguments // Calculate the end of destination area where we will put the arguments
// after we drop current frame. We add kSystemPointerSize to count the // after we drop current frame. We add kSystemPointerSize to count the
// receiver argument which is not included into formal parameters count. // receiver argument which is not included into formal parameters count.
Register dst_reg = scratch0; Register dst_reg = scratch0;
Add(dst_reg, fp, Operand(caller_args_count_reg, LSL, kSystemPointerSizeLog2)); Add(dst_reg, fp, Operand(caller_args_count, LSL, kSystemPointerSizeLog2));
Add(dst_reg, dst_reg, Add(dst_reg, dst_reg,
StandardFrameConstants::kCallerSPOffset + kSystemPointerSize); StandardFrameConstants::kCallerSPOffset + kSystemPointerSize);
// Round dst_reg up to a multiple of 16 bytes, so that we overwrite any // Round dst_reg up to a multiple of 16 bytes, so that we overwrite any
...@@ -2098,15 +2091,10 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, ...@@ -2098,15 +2091,10 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count,
Add(dst_reg, dst_reg, 15); Add(dst_reg, dst_reg, 15);
Bic(dst_reg, dst_reg, 15); Bic(dst_reg, dst_reg, 15);
Register src_reg = caller_args_count_reg; Register src_reg = caller_args_count;
// Calculate the end of source area. +kSystemPointerSize is for the receiver. // Calculate the end of source area. +kSystemPointerSize is for the receiver.
if (callee_args_count.is_reg()) { Add(src_reg, sp, Operand(callee_args_count, LSL, kSystemPointerSizeLog2));
Add(src_reg, sp, Add(src_reg, src_reg, kSystemPointerSize);
Operand(callee_args_count.reg(), LSL, kSystemPointerSizeLog2));
Add(src_reg, src_reg, kSystemPointerSize);
} else {
Add(src_reg, sp, (callee_args_count.immediate() + 1) * kSystemPointerSize);
}
// Round src_reg up to a multiple of 16 bytes, so we include any potential // Round src_reg up to a multiple of 16 bytes, so we include any potential
// padding in the copy. // padding in the copy.
......
...@@ -566,11 +566,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -566,11 +566,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Removes current frame and its arguments from the stack preserving // Removes current frame and its arguments from the stack preserving
// the arguments and a return address pushed to the stack for the next call. // the arguments and a return address pushed to the stack for the next call.
// Both |callee_args_count| and |caller_args_count_reg| do not include // Both |callee_args_count| and |caller_args_count| do not include
// receiver. |callee_args_count| is not modified, |caller_args_count_reg| // receiver. |callee_args_count| is not modified. |caller_args_count| is
// is trashed. // trashed.
void PrepareForTailCall(const ParameterCount& callee_args_count, void PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register scratch0, Register caller_args_count, Register scratch0,
Register scratch1); Register scratch1);
inline void SmiUntag(Register dst, Register src); inline void SmiUntag(Register dst, Register src);
......
...@@ -1028,36 +1028,18 @@ void MacroAssembler::JumpToInstructionStream(Address entry) { ...@@ -1028,36 +1028,18 @@ void MacroAssembler::JumpToInstructionStream(Address entry) {
} }
void TurboAssembler::PrepareForTailCall( void TurboAssembler::PrepareForTailCall(
const ParameterCount& callee_args_count, Register caller_args_count_reg, Register callee_args_count, Register caller_args_count, Register scratch0,
Register scratch0, Register scratch1, Register scratch1, int number_of_temp_values_after_return_address) {
int number_of_temp_values_after_return_address) { DCHECK(!AreAliased(callee_args_count, caller_args_count, scratch0, scratch1));
#if DEBUG
if (callee_args_count.is_reg()) {
DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0,
scratch1));
} else {
DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1));
}
#endif
// Calculate the destination address where we will put the return address // Calculate the destination address where we will put the return address
// after we drop current frame. // after we drop current frame.
Register new_sp_reg = scratch0; Register new_sp_reg = scratch0;
if (callee_args_count.is_reg()) { sub(caller_args_count, callee_args_count);
sub(caller_args_count_reg, callee_args_count.reg()); lea(new_sp_reg, Operand(ebp, caller_args_count, times_system_pointer_size,
lea(new_sp_reg, StandardFrameConstants::kCallerPCOffset -
Operand(ebp, caller_args_count_reg, times_system_pointer_size, number_of_temp_values_after_return_address *
StandardFrameConstants::kCallerPCOffset - kSystemPointerSize));
number_of_temp_values_after_return_address *
kSystemPointerSize));
} else {
lea(new_sp_reg,
Operand(ebp, caller_args_count_reg, times_system_pointer_size,
StandardFrameConstants::kCallerPCOffset -
(callee_args_count.immediate() +
number_of_temp_values_after_return_address) *
kSystemPointerSize));
}
if (FLAG_debug_code) { if (FLAG_debug_code) {
cmp(esp, new_sp_reg); cmp(esp, new_sp_reg);
...@@ -1078,15 +1060,9 @@ void TurboAssembler::PrepareForTailCall( ...@@ -1078,15 +1060,9 @@ void TurboAssembler::PrepareForTailCall(
mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
// +2 here is to copy both receiver and return address. // +2 here is to copy both receiver and return address.
Register count_reg = caller_args_count_reg; Register count_reg = caller_args_count;
if (callee_args_count.is_reg()) { lea(count_reg, Operand(callee_args_count,
lea(count_reg, Operand(callee_args_count.reg(), 2 + number_of_temp_values_after_return_address));
2 + number_of_temp_values_after_return_address));
} else {
mov(count_reg, Immediate(callee_args_count.immediate() + 2 +
number_of_temp_values_after_return_address));
// TODO(ishell): Unroll copying loop for small immediate values.
}
// Now copy callee arguments to the caller frame going backwards to avoid // Now copy callee arguments to the caller frame going backwards to avoid
// callee arguments corruption (source and destination areas could overlap). // callee arguments corruption (source and destination areas could overlap).
......
...@@ -140,14 +140,14 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -140,14 +140,14 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Removes current frame and its arguments from the stack preserving the // Removes current frame and its arguments from the stack preserving the
// arguments and a return address pushed to the stack for the next call. Both // arguments and a return address pushed to the stack for the next call. Both
// |callee_args_count| and |caller_args_count_reg| do not include receiver. // |callee_args_count| and |caller_args_count| do not include receiver.
// |callee_args_count| is not modified, |caller_args_count_reg| is trashed. // |callee_args_count| is not modified. |caller_args_count| is trashed.
// |number_of_temp_values_after_return_address| specifies the number of words // |number_of_temp_values_after_return_address| specifies the number of words
// pushed to the stack after the return address. This is to allow "allocation" // pushed to the stack after the return address. This is to allow "allocation"
// of scratch registers that this function requires by saving their values on // of scratch registers that this function requires by saving their values on
// the stack. // the stack.
void PrepareForTailCall(const ParameterCount& callee_args_count, void PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register scratch0, Register caller_args_count, Register scratch0,
Register scratch1, Register scratch1,
int number_of_temp_values_after_return_address); int number_of_temp_values_after_return_address);
......
...@@ -186,34 +186,6 @@ class NoRootArrayScope { ...@@ -186,34 +186,6 @@ class NoRootArrayScope {
bool old_value_; bool old_value_;
}; };
// Wrapper class for passing expected and actual parameter counts as
// either registers or immediate values. Used to make sure that the
// caller provides exactly the expected number of parameters to the
// callee.
class ParameterCount {
public:
explicit ParameterCount(Register reg) : reg_(reg), immediate_(0) {}
explicit ParameterCount(uint16_t imm) : reg_(no_reg), immediate_(imm) {}
bool is_reg() const { return reg_.is_valid(); }
bool is_immediate() const { return !is_reg(); }
Register reg() const {
DCHECK(is_reg());
return reg_;
}
uint16_t immediate() const {
DCHECK(is_immediate());
return immediate_;
}
private:
const Register reg_;
const uint16_t immediate_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount);
};
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -58,19 +58,6 @@ Operand StackArgumentsAccessor::GetArgumentOperand(int index) { ...@@ -58,19 +58,6 @@ Operand StackArgumentsAccessor::GetArgumentOperand(int index) {
} }
} }
StackArgumentsAccessor::StackArgumentsAccessor(
Register base_reg, const ParameterCount& parameter_count,
StackArgumentsAccessorReceiverMode receiver_mode,
int extra_displacement_to_last_argument)
: base_reg_(base_reg),
argument_count_reg_(parameter_count.is_reg() ? parameter_count.reg()
: no_reg),
argument_count_immediate_(
parameter_count.is_immediate() ? parameter_count.immediate() : 0),
receiver_mode_(receiver_mode),
extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) {}
void MacroAssembler::Load(Register destination, ExternalReference source) { void MacroAssembler::Load(Register destination, ExternalReference source) {
if (root_array_available_ && options().enable_root_array_delta_access) { if (root_array_available_ && options().enable_root_array_delta_access) {
intptr_t delta = RootRegisterOffsetForExternalReference(isolate(), source); intptr_t delta = RootRegisterOffsetForExternalReference(isolate(), source);
...@@ -2282,32 +2269,17 @@ void MacroAssembler::MaybeDropFrames() { ...@@ -2282,32 +2269,17 @@ void MacroAssembler::MaybeDropFrames() {
bind(&dont_drop); bind(&dont_drop);
} }
void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, void TurboAssembler::PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register caller_args_count,
Register scratch0, Register scratch1) { Register scratch0, Register scratch1) {
#if DEBUG DCHECK(!AreAliased(callee_args_count, caller_args_count, scratch0, scratch1));
if (callee_args_count.is_reg()) {
DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0,
scratch1));
} else {
DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1));
}
#endif
// Calculate the destination address where we will put the return address // Calculate the destination address where we will put the return address
// after we drop current frame. // after we drop current frame.
Register new_sp_reg = scratch0; Register new_sp_reg = scratch0;
if (callee_args_count.is_reg()) { subq(caller_args_count, callee_args_count);
subq(caller_args_count_reg, callee_args_count.reg()); leaq(new_sp_reg, Operand(rbp, caller_args_count, times_system_pointer_size,
leaq(new_sp_reg, StandardFrameConstants::kCallerPCOffset));
Operand(rbp, caller_args_count_reg, times_system_pointer_size,
StandardFrameConstants::kCallerPCOffset));
} else {
leaq(new_sp_reg,
Operand(rbp, caller_args_count_reg, times_system_pointer_size,
StandardFrameConstants::kCallerPCOffset -
callee_args_count.immediate() * kSystemPointerSize));
}
if (FLAG_debug_code) { if (FLAG_debug_code) {
cmpq(rsp, new_sp_reg); cmpq(rsp, new_sp_reg);
...@@ -2326,13 +2298,8 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, ...@@ -2326,13 +2298,8 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count,
movq(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); movq(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
// +2 here is to copy both receiver and return address. // +2 here is to copy both receiver and return address.
Register count_reg = caller_args_count_reg; Register count_reg = caller_args_count;
if (callee_args_count.is_reg()) { leaq(count_reg, Operand(callee_args_count, 2));
leaq(count_reg, Operand(callee_args_count.reg(), 2));
} else {
movq(count_reg, Immediate(callee_args_count.immediate() + 2));
// TODO(ishell): Unroll copying loop for small immediate values.
}
// Now copy callee arguments to the caller frame going backwards to avoid // Now copy callee arguments to the caller frame going backwards to avoid
// callee arguments corruption (source and destination areas could overlap). // callee arguments corruption (source and destination areas could overlap).
......
...@@ -51,12 +51,6 @@ class StackArgumentsAccessor { ...@@ -51,12 +51,6 @@ class StackArgumentsAccessor {
extra_displacement_to_last_argument_( extra_displacement_to_last_argument_(
extra_displacement_to_last_argument) {} extra_displacement_to_last_argument) {}
StackArgumentsAccessor(Register base_reg,
const ParameterCount& parameter_count,
StackArgumentsAccessorReceiverMode receiver_mode =
ARGUMENTS_CONTAIN_RECEIVER,
int extra_displacement_to_last_argument = 0);
Operand GetArgumentOperand(int index); Operand GetArgumentOperand(int index);
Operand GetReceiverOperand() { Operand GetReceiverOperand() {
DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER); DCHECK(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER);
...@@ -485,10 +479,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -485,10 +479,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Removes current frame and its arguments from the stack preserving the // Removes current frame and its arguments from the stack preserving the
// arguments and a return address pushed to the stack for the next call. Both // arguments and a return address pushed to the stack for the next call. Both
// |callee_args_count| and |caller_args_count_reg| do not include receiver. // |callee_args_count| and |caller_args_count| do not include receiver.
// |callee_args_count| is not modified, |caller_args_count_reg| is trashed. // |callee_args_count| is not modified. |caller_args_count| is trashed.
void PrepareForTailCall(const ParameterCount& callee_args_count, void PrepareForTailCall(Register callee_args_count,
Register caller_args_count_reg, Register scratch0, Register caller_args_count, Register scratch0,
Register scratch1); Register scratch1);
// Call a runtime routine. This expects {centry} to contain a fitting CEntry // Call a runtime routine. This expects {centry} to contain a fitting CEntry
......
...@@ -628,7 +628,6 @@ class FullObjectSlot; ...@@ -628,7 +628,6 @@ class FullObjectSlot;
class FullMaybeObjectSlot; class FullMaybeObjectSlot;
class FullHeapObjectSlot; class FullHeapObjectSlot;
class OldSpace; class OldSpace;
class ParameterCount;
class ReadOnlySpace; class ReadOnlySpace;
class RelocInfo; class RelocInfo;
class Scope; class Scope;
......
...@@ -535,9 +535,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ...@@ -535,9 +535,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ SmiUntag(caller_args_count_reg); __ SmiUntag(caller_args_count_reg);
ParameterCount callee_args_count(args_reg); __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3);
__ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
scratch3);
__ bind(&done); __ bind(&done);
} }
......
...@@ -529,9 +529,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ...@@ -529,9 +529,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ SmiUntag(caller_args_count_reg); __ SmiUntag(caller_args_count_reg);
ParameterCount callee_args_count(args_reg); __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3);
__ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
scratch3);
__ bind(&done); __ bind(&done);
} }
......
...@@ -533,9 +533,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ...@@ -533,9 +533,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ SmiUntag(caller_args_count_reg); __ SmiUntag(caller_args_count_reg);
ParameterCount callee_args_count(args_reg); __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3,
__ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, scratch_count);
scratch3, scratch_count);
__ pop(scratch3); __ pop(scratch3);
__ pop(scratch2); __ pop(scratch2);
__ pop(scratch1); __ pop(scratch1);
......
...@@ -632,9 +632,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ...@@ -632,9 +632,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
__ SmiUntag(caller_args_count_reg, __ SmiUntag(caller_args_count_reg,
Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset)); Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset));
ParameterCount callee_args_count(args_reg); __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3);
__ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2,
scratch3);
__ bind(&done); __ bind(&done);
} }
......
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