Commit 41df164a authored by Feng Yu's avatar Feng Yu Committed by V8 LUCI CQ

[test] Migrate cctest/test-run-tail-calls to unittests/

Bug: v8:12781
Change-Id: Ib2d7fe959f06cb750ccf419796002efb7e569623
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3865062Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Feng Yu <f3n67u@gmail.com>
Cr-Commit-Position: refs/heads/main@{#82986}
parent 8c12c24d
......@@ -84,13 +84,13 @@ v8_source_set("cctest_sources") {
"../common/assembler-tester.h",
"../common/c-signature.h",
"../common/call-tester.h",
"../common/code-assembler-tester.h",
"../common/flag-utils.h",
"../common/node-observer-tester.h",
"../common/value-helper.cc",
"../common/value-helper.h",
"cctest-utils.h",
"collector.h",
"compiler/code-assembler-tester.h",
"compiler/codegen-tester.cc",
"compiler/codegen-tester.h",
"compiler/function-tester.cc",
......@@ -121,7 +121,6 @@ v8_source_set("cctest_sources") {
"compiler/test-run-load-store.cc",
"compiler/test-run-machops.cc",
"compiler/test-run-stackcheck.cc",
"compiler/test-run-tail-calls.cc",
"compiler/test-run-unwinding-info.cc",
"compiler/test-run-variables.cc",
"compiler/test-verify-type.cc",
......
......@@ -581,14 +581,12 @@
'test-multiple-return/*': [SKIP],
'test-run-bytecode-graph-builder/*': [SKIP],
'test-run-calls-to-external-references/*': [SKIP],
'test-run-deopt/*': [SKIP],
'test-run-intrinsics/*': [SKIP],
'test-run-load-store/*': [SKIP],
'test-run-machops/*': [SKIP],
'test-run-native-calls/*': [SKIP],
'test-run-stackcheck/*': [SKIP],
'test-run-tail-calls/*': [SKIP],
'test-run-unwinding-info/*': [SKIP],
'test-run-variables/*': [SKIP],
'test-serialize/*': [SKIP],
......
......@@ -10,8 +10,8 @@
#include "src/objects/heap-number-inl.h"
#include "src/objects/js-function.h"
#include "src/objects/objects-inl.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
......@@ -15,9 +15,9 @@
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/codegen-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/compiler/wasm-compiler.h"
......
......@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test/cctest/cctest.h"
#include "src/base/utils/random-number-generator.h"
#include "src/ic/accessor-assembler.h"
#include "src/ic/stub-cache.h"
#include "src/objects/objects-inl.h"
#include "src/objects/smi.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
......@@ -28,8 +28,8 @@
#include "src/objects/transitions-inl.h"
#include "src/strings/char-predicates.h"
#include "test/cctest/cctest-utils.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
......@@ -10,9 +10,9 @@
#include "src/objects/string-inl.h"
#include "src/objects/transitions-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/cctest/test-transitions.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
......@@ -6,10 +6,10 @@
#include "src/codegen/cpu-features.h"
#include "src/objects/objects-inl.h"
#include "src/objects/swiss-name-dictionary-inl.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/cctest/test-swiss-name-dictionary-infra.h"
#include "test/cctest/test-swiss-name-dictionary-shared-tests.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
......@@ -18,8 +18,8 @@
#include "src/objects/promise-inl.h"
#include "src/objects/torque-defined-classes-inl.h"
#include "src/strings/char-predicates.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
namespace v8 {
namespace internal {
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_
#define V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_
#ifndef V8_TEST_COMMON_CODE_ASSEMBLER_TESTER_H_
#define V8_TEST_COMMON_CODE_ASSEMBLER_TESTER_H_
#include "src/codegen/assembler.h"
#include "src/codegen/interface-descriptors.h"
......@@ -11,7 +11,6 @@
#include "src/compiler/raw-machine-assembler.h"
#include "src/execution/isolate.h"
#include "src/handles/handles.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
......@@ -75,7 +74,6 @@ class CodeAssemblerTester {
private:
Zone zone_;
HandleScope scope_;
LocalContext context_;
CodeAssemblerState state_;
};
......@@ -83,4 +81,4 @@ class CodeAssemblerTester {
} // namespace internal
} // namespace v8
#endif // V8_TEST_CCTEST_COMPILER_CODE_ASSEMBLER_TESTER_H_
#endif // V8_TEST_COMMON_CODE_ASSEMBLER_TESTER_H_
......@@ -229,6 +229,7 @@ v8_source_set("unittests_sources") {
"../common/assembler-tester.h",
"../common/c-signature.h",
"../common/call-tester.h",
"../common/code-assembler-tester.h",
"../common/node-observer-tester.h",
"../common/value-helper.cc",
"../common/value-helper.h",
......@@ -351,6 +352,7 @@ v8_source_set("unittests_sources") {
"compiler/run-jsexceptions-unittest.cc",
"compiler/run-jsobjects-unittest.cc",
"compiler/run-jsops-unittest.cc",
"compiler/run-tail-calls-unittest.cc",
"compiler/schedule-unittest.cc",
"compiler/scheduler-rpo-unittest.cc",
"compiler/scheduler-unittest.cc",
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -7,14 +7,13 @@
#include "src/codegen/code-stub-assembler.h"
#include "src/codegen/macro-assembler.h"
#include "src/objects/code-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/code-assembler-tester.h"
#include "test/cctest/compiler/function-tester.h"
#include "test/common/code-assembler-tester.h"
#include "test/unittests/compiler/function-tester.h"
#include "test/unittests/test-utils.h"
namespace v8 {
namespace internal {
namespace compiler {
namespace test_run_tail_calls {
#define __ assembler.
......@@ -108,62 +107,64 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone, int param_slots) {
CallDescriptor::kNoFlags); // flags
}
// Test a tail call from a caller with n parameters to a callee with m
// parameters. All parameters are pointer-sized.
void TestHelper(int n, int m) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
CanonicalHandleScope canonical(isolate);
Zone* zone = scope.main_zone();
CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone, n);
CallDescriptor* callee_descriptor =
CreateDescriptorForStackArguments(zone, m);
Handle<Code> setup =
BuildSetupFunction(isolate, caller_descriptor, callee_descriptor);
FunctionTester ft(setup, 0);
Handle<Object> result = ft.Call().ToHandleChecked();
int expected = 0;
for (int i = 0; i < m; ++i) expected += (i + 1) * i;
CHECK_EQ(expected, Handle<Smi>::cast(result)->value());
}
} // namespace
class RunTailCallsTest : public TestWithContextAndZone {
protected:
// Test a tail call from a caller with n parameters to a callee with m
// parameters. All parameters are pointer-sized.
void TestHelper(int n, int m) {
Isolate* isolate = i_isolate();
CanonicalHandleScope canonical(isolate);
CallDescriptor* caller_descriptor =
CreateDescriptorForStackArguments(zone(), n);
CallDescriptor* callee_descriptor =
CreateDescriptorForStackArguments(zone(), m);
Handle<Code> setup =
BuildSetupFunction(isolate, caller_descriptor, callee_descriptor);
FunctionTester ft(isolate, setup, 0);
Handle<Object> result = ft.Call().ToHandleChecked();
int expected = 0;
for (int i = 0; i < m; ++i) expected += (i + 1) * i;
CHECK_EQ(expected, Handle<Smi>::cast(result)->value());
}
};
#undef __
TEST(CallerOddCalleeEven) {
TEST_F(RunTailCallsTest, CallerOddCalleeEven) {
TestHelper(1, 0);
TestHelper(1, 2);
TestHelper(3, 2);
TestHelper(3, 4);
}
TEST(CallerOddCalleeOdd) {
TEST_F(RunTailCallsTest, CallerOddCalleeOdd) {
TestHelper(1, 1);
TestHelper(1, 3);
TestHelper(3, 1);
TestHelper(3, 3);
}
TEST(CallerEvenCalleeEven) {
TEST_F(RunTailCallsTest, CallerEvenCalleeEven) {
TestHelper(0, 0);
TestHelper(0, 2);
TestHelper(2, 0);
TestHelper(2, 2);
}
TEST(CallerEvenCalleeOdd) {
TEST_F(RunTailCallsTest, CallerEvenCalleeOdd) {
TestHelper(0, 1);
TestHelper(0, 3);
TestHelper(2, 1);
TestHelper(2, 3);
}
TEST(FuzzStackParamCount) {
TEST_F(RunTailCallsTest, FuzzStackParamCount) {
const int kNumTests = 20;
const int kMaxSlots = 30;
base::RandomNumberGenerator* const rng = CcTest::random_number_generator();
base::RandomNumberGenerator* const rng =
i_isolate()->random_number_generator();
for (int i = 0; i < kNumTests; ++i) {
int n = rng->NextInt(kMaxSlots);
int m = rng->NextInt(kMaxSlots);
......@@ -171,7 +172,6 @@ TEST(FuzzStackParamCount) {
}
}
} // namespace test_run_tail_calls
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -271,6 +271,7 @@
# Tests that generate code at runtime.
'CodeGenTest.*': [SKIP],
'CodePagesTest.*': [SKIP],
'MacroAssemblerX64Test.EmbeddedObj': [SKIP],
'RegExpTest.MacroAssemblernativeAtStart': [SKIP],
'RegExpTest.MacroAssemblerNativeBackReferenceLATIN1': [SKIP],
......@@ -291,12 +292,10 @@
'RunJSExceptionsTest.*': [SKIP],
'RunJSObjectsTest.*': [SKIP],
'RunJSOpsTest.*': [SKIP],
'RunTailCallsTest.*': [SKIP],
# Tests generated irregexp code.
'RegExpTestWithContext.RegExpInterruptReentrantExecution': [SKIP],
# Tests that generate code at runtime.
'CodePagesTest.*': [SKIP],
}], # lite_mode or variant == jitless
##############################################################################
......
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