Commit ebcc39d5 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[tests] Fix parameter indices in test-code-stub-assembler

The cctests were wrong, since they access the first parameter using `Parameter(0)`. They should instead use `Parameter(1)`, since the index 0 is the receiver, and the receiver is set to be always the undefined object in `FunctionTester::Call`.

The reason it used to work is that the tests would set up an access to the stack with the wrong number of parameters, accessing only a stack suffix.

Change-Id: I02b7ee97c8759c7aecda0338863b7727762df1ba
Bug: v8:10201
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2299364
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68876}
parent cd718536
......@@ -147,11 +147,12 @@ Handle<JSFunction> CreateSumAllArgumentsFunction(FunctionTester* ft) {
TEST(SimpleCallJSFunction0Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 1;
CodeAssemblerTester asm_tester(isolate, kNumParams);
const int kContextOffset = kNumParams + 3;
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
CodeAssembler m(asm_tester.state());
{
Node* function = m.Parameter(0);
Node* context = m.Parameter(kNumParams + 2);
Node* function = m.Parameter(1);
Node* context = m.Parameter(kContextOffset);
Node* receiver = SmiTag(&m, m.Int32Constant(42));
......@@ -168,12 +169,13 @@ TEST(SimpleCallJSFunction0Arg) {
TEST(SimpleCallJSFunction1Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 2;
CodeAssemblerTester asm_tester(isolate, kNumParams);
const int kNumParams = 1;
const int kContextOffset = kNumParams + 3;
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
CodeAssembler m(asm_tester.state());
{
Node* function = m.Parameter(0);
Node* context = m.Parameter(1);
Node* function = m.Parameter(1);
Node* context = m.Parameter(kContextOffset);
Node* receiver = SmiTag(&m, m.Int32Constant(42));
Node* a = SmiTag(&m, m.Int32Constant(13));
......@@ -192,11 +194,12 @@ TEST(SimpleCallJSFunction1Arg) {
TEST(SimpleCallJSFunction2Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 2;
CodeAssemblerTester asm_tester(isolate, kNumParams);
const int kContextOffset = kNumParams + 3;
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
CodeAssembler m(asm_tester.state());
{
Node* function = m.Parameter(0);
Node* context = m.Parameter(1);
Node* function = m.Parameter(1);
Node* context = m.Parameter(kContextOffset);
Node* receiver = SmiTag(&m, m.Int32Constant(42));
Node* a = SmiTag(&m, m.Int32Constant(13));
......
......@@ -24,12 +24,12 @@ namespace {
void TestStubCacheOffsetCalculation(StubCache::Table table) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 2;
CodeAssemblerTester data(isolate, kNumParams);
CodeAssemblerTester data(isolate, kNumParams + 1); // Include receiver.
AccessorAssembler m(data.state());
{
TNode<Name> name = m.CAST(m.Parameter(0));
TNode<Map> map = m.CAST(m.Parameter(1));
TNode<Name> name = m.CAST(m.Parameter(1));
TNode<Map> map = m.CAST(m.Parameter(2));
TNode<IntPtrT> primary_offset =
m.StubCachePrimaryOffsetForTesting(name, map);
Node* result;
......@@ -121,17 +121,17 @@ TEST(TryProbeStubCache) {
using Label = CodeStubAssembler::Label;
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 3;
CodeAssemblerTester data(isolate, kNumParams);
CodeAssemblerTester data(isolate, kNumParams + 1); // Include receiver.
AccessorAssembler m(data.state());
StubCache stub_cache(isolate);
stub_cache.Clear();
{
TNode<Object> receiver = m.CAST(m.Parameter(0));
TNode<Name> name = m.CAST(m.Parameter(1));
TNode<Object> receiver = m.CAST(m.Parameter(1));
TNode<Name> name = m.CAST(m.Parameter(2));
TNode<MaybeObject> expected_handler =
m.UncheckedCast<MaybeObject>(m.Parameter(2));
m.UncheckedCast<MaybeObject>(m.Parameter(3));
Label passed(&m), failed(&m);
......
This diff is collapsed.
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