Commit c55c00d4 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[CSA] Fix CSA::PopAndReturn tests

These tests were incorrectly declaring the number of parameters the
generated function would take by omitting the receiver and
PopAndReturnVariable was accessing the wrong parameter.

Also updated a passed in parameter to not match the constant that was
being returned in case that led to the test passing accidentally.

Bug: v8:10933
Change-Id: Ia354e4e30b464a333039ab6bc54198acd16a4789
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2434334Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70157}
parent 4924d01f
...@@ -1938,7 +1938,9 @@ TEST(PopAndReturnConstant) { ...@@ -1938,7 +1938,9 @@ TEST(PopAndReturnConstant) {
const int kNumParams = 4; const int kNumParams = 4;
const int kNumProgrammaticParams = 2; const int kNumProgrammaticParams = 2;
CodeAssemblerTester asm_tester(isolate, kNumParams - kNumProgrammaticParams); CodeAssemblerTester asm_tester(
isolate,
kNumParams - kNumProgrammaticParams + 1); // Include receiver.
CodeStubAssembler m(asm_tester.state()); CodeStubAssembler m(asm_tester.state());
// Call a function that return |kNumProgramaticParams| parameters in addition // Call a function that return |kNumProgramaticParams| parameters in addition
...@@ -1951,7 +1953,7 @@ TEST(PopAndReturnConstant) { ...@@ -1951,7 +1953,7 @@ TEST(PopAndReturnConstant) {
Handle<Object> result; Handle<Object> result;
for (int test_count = 0; test_count < 100; ++test_count) { for (int test_count = 0; test_count < 100; ++test_count) {
result = ft.Call(isolate->factory()->undefined_value(), result = ft.Call(isolate->factory()->undefined_value(),
Handle<Smi>(Smi::FromInt(1234), isolate), Handle<Smi>(Smi::FromInt(5678), isolate),
isolate->factory()->undefined_value(), isolate->factory()->undefined_value(),
isolate->factory()->undefined_value()) isolate->factory()->undefined_value())
.ToHandleChecked(); .ToHandleChecked();
...@@ -1964,20 +1966,23 @@ TEST(PopAndReturnVariable) { ...@@ -1964,20 +1966,23 @@ TEST(PopAndReturnVariable) {
const int kNumParams = 4; const int kNumParams = 4;
const int kNumProgrammaticParams = 2; const int kNumProgrammaticParams = 2;
CodeAssemblerTester asm_tester(isolate, kNumParams - kNumProgrammaticParams); CodeAssemblerTester asm_tester(
isolate,
kNumParams - kNumProgrammaticParams + 1); // Include receiver.
CodeStubAssembler m(asm_tester.state()); CodeStubAssembler m(asm_tester.state());
// Call a function that return |kNumProgramaticParams| parameters in addition // Call a function that return |kNumProgramaticParams| parameters in addition
// to those specified by the static descriptor. |kNumProgramaticParams| is // to those specified by the static descriptor. |kNumProgramaticParams| is
// passed in as a parameter to the function so that it can't be recongized as // passed in as a parameter to the function so that it can't be recognized as
// a constant. // a constant.
m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234))); m.PopAndReturn(m.SmiUntag(m.CAST(m.Parameter(2))),
m.SmiConstant(Smi::FromInt(1234)));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result; Handle<Object> result;
for (int test_count = 0; test_count < 100; ++test_count) { for (int test_count = 0; test_count < 100; ++test_count) {
result = ft.Call(isolate->factory()->undefined_value(), result = ft.Call(isolate->factory()->undefined_value(),
Handle<Smi>(Smi::FromInt(1234), isolate), Handle<Smi>(Smi::FromInt(5678), isolate),
isolate->factory()->undefined_value(), isolate->factory()->undefined_value(),
Handle<Smi>(Smi::FromInt(kNumProgrammaticParams), isolate)) Handle<Smi>(Smi::FromInt(kNumProgrammaticParams), isolate))
.ToHandleChecked(); .ToHandleChecked();
......
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