Commit 7fc10cb9 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[CSA] Fix CSArguments::PopAndReturn for SMIs

Assembler::PopAndReturn expects an Integral type so convert argc from a
SMI if necessary.

On 64-bit architectures, convert 64-bit immediate pop values into
32-bit values. This is safe since the conversion checks that nothing
was truncated.

Also change CodeStubArguments unit tests to use PopAndReturn rather
than Return.

Change-Id: I91b47d2e81dc0504d185ad59752d638b1c3135a7
Reviewed-on: https://chromium-review.googlesource.com/867052Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50645}
parent cb903d80
......@@ -10468,7 +10468,9 @@ void CodeStubArguments::PopAndReturn(Node* value) {
} else {
pop_count = argc_;
}
assembler_->PopAndReturn(pop_count, value);
assembler_->PopAndReturn(assembler_->ParameterToWord(pop_count, argc_mode_),
value);
}
Node* CodeStubAssembler::IsFastElementsKind(Node* elements_kind) {
......
......@@ -2465,7 +2465,6 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
}
if (pop->IsImmediate()) {
DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
pop_count += g.ToConstant(pop).ToInt32();
__ DropArguments(pop_count);
} else {
......
......@@ -3662,7 +3662,6 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
}
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop->IsImmediate()) {
DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
pop_count += g.ToConstant(pop).ToInt32();
} else {
Register pop_reg = g.ToRegister(pop);
......
......@@ -3080,7 +3080,6 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
}
if (pop->IsImmediate()) {
DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
pop_size += g.ToConstant(pop).ToInt32() * kPointerSize;
CHECK_LT(pop_size, static_cast<size_t>(std::numeric_limits<int>::max()));
__ Ret(static_cast<int>(pop_size), rcx);
......
......@@ -1706,7 +1706,7 @@ TEST(Arguments) {
CSA_ASSERT(
&m, m.WordEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14))));
m.Return(arguments.GetReceiver());
arguments.PopAndReturn(arguments.GetReceiver());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
......@@ -1740,7 +1740,7 @@ TEST(ArgumentsWithSmiConstantIndices) {
CodeStubAssembler::SMI_PARAMETERS),
m.SmiConstant(Smi::FromInt(14))));
m.Return(arguments.GetReceiver());
arguments.PopAndReturn(arguments.GetReceiver());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
......@@ -1793,7 +1793,7 @@ TEST(ArgumentsWithSmiIndices) {
CodeStubAssembler::SMI_PARAMETERS),
m.SmiConstant(Smi::FromInt(14))));
m.Return(arguments.GetReceiver());
arguments.PopAndReturn(arguments.GetReceiver());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
......@@ -1821,7 +1821,7 @@ TEST(ArgumentsForEach) {
arguments.ForEach(
list, [&m, &sum](Node* arg) { sum.Bind(m.SmiAdd(sum.value(), arg)); });
m.Return(sum.value());
arguments.PopAndReturn(sum.value());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
......
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