Commit 55c12f40 authored by Feng Yu's avatar Feng Yu Committed by V8 LUCI CQ

[test] Migrate cctest/test-macro-assembler-x64 to unittests/

Bug: v8:12781
Change-Id: I57bda54ef37a9dfdb9f3f8ad7c9e16541b345509
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3827130
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82471}
parent f4588f07
...@@ -278,7 +278,6 @@ v8_source_set("cctest_sources") { ...@@ -278,7 +278,6 @@ v8_source_set("cctest_sources") {
sources += [ ### gcmole(arch:x64) ### sources += [ ### gcmole(arch:x64) ###
"test-assembler-x64.cc", "test-assembler-x64.cc",
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
"test-macro-assembler-x64.cc",
] ]
if (is_win) { if (is_win) {
sources += [ "test-stack-unwinding-win64.cc" ] sources += [ "test-stack-unwinding-win64.cc" ]
......
...@@ -599,7 +599,6 @@ ...@@ -599,7 +599,6 @@
'test-code-stub-assembler/*': [SKIP], 'test-code-stub-assembler/*': [SKIP],
'test-debug-helper/GetObjectProperties': [SKIP], 'test-debug-helper/GetObjectProperties': [SKIP],
'test-js-context-specialization/*': [SKIP], 'test-js-context-specialization/*': [SKIP],
'test-macro-assembler-x64/EmbeddedObj': [SKIP],
'test-multiple-return/*': [SKIP], 'test-multiple-return/*': [SKIP],
'test-run-bytecode-graph-builder/*': [SKIP], 'test-run-bytecode-graph-builder/*': [SKIP],
'test-run-calls-to-external-references/*': [SKIP], 'test-run-calls-to-external-references/*': [SKIP],
......
...@@ -599,6 +599,7 @@ v8_source_set("unittests_sources") { ...@@ -599,6 +599,7 @@ v8_source_set("unittests_sources") {
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ sources += [
"assembler/disasm-x64-unittest.cc", "assembler/disasm-x64-unittest.cc",
"assembler/macro-assembler-x64-unittest.cc",
"assembler/turbo-assembler-x64-unittest.cc", "assembler/turbo-assembler-x64-unittest.cc",
"compiler/x64/instruction-selector-x64-unittest.cc", "compiler/x64/instruction-selector-x64-unittest.cc",
] ]
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include "src/objects/objects-inl.h" #include "src/objects/objects-inl.h"
#include "src/objects/smi.h" #include "src/objects/smi.h"
#include "src/utils/ostreams.h" #include "src/utils/ostreams.h"
#include "test/cctest/cctest.h"
#include "test/common/assembler-tester.h" #include "test/common/assembler-tester.h"
#include "test/unittests/test-utils.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -51,6 +51,8 @@ namespace test_macro_assembler_x64 { ...@@ -51,6 +51,8 @@ namespace test_macro_assembler_x64 {
// This calling convention is used on Linux, with GCC, and on Mac OS, // This calling convention is used on Linux, with GCC, and on Mac OS,
// with GCC. A different convention is used on 64-bit windows. // with GCC. A different convention is used on 64-bit windows.
using MacroAssemblerX64Test = TestWithIsolate;
using F0 = int(); using F0 = int();
#define __ masm-> #define __ masm->
...@@ -71,13 +73,15 @@ static void ExitCode(MacroAssembler* masm) { ...@@ -71,13 +73,15 @@ static void ExitCode(MacroAssembler* masm) {
__ popq(kRootRegister); __ popq(kRootRegister);
} }
TEST(Smi) { TEST_F(MacroAssemblerX64Test, Smi) {
// clang-format off
// Check that C++ Smi operations work as expected. // Check that C++ Smi operations work as expected.
int64_t test_numbers[] = { int64_t test_numbers[] = {
0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257,
Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1,
Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1
}; };
// clang-format on
int test_number_count = 15; int test_number_count = 15;
for (int i = 0; i < test_number_count; i++) { for (int i = 0; i < test_number_count; i++) {
int64_t number = test_numbers[i]; int64_t number = test_numbers[i];
...@@ -104,10 +108,9 @@ static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi value) { ...@@ -104,10 +108,9 @@ static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi value) {
__ j(not_equal, exit); __ j(not_equal, exit);
} }
// Test that we can move a Smi value literally into a register. // Test that we can move a Smi value literally into a register.
TEST(SmiMove) { TEST_F(MacroAssemblerX64Test, SmiMove) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -145,12 +148,11 @@ TEST(SmiMove) { ...@@ -145,12 +148,11 @@ TEST(SmiMove) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) {
__ Move(rcx, Smi::FromInt(x)); __ Move(rcx, Smi::FromInt(x));
__ movq(r8, rcx); __ movq(r8, rcx);
...@@ -195,10 +197,9 @@ void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { ...@@ -195,10 +197,9 @@ void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) {
} }
} }
// Test that we can compare smis for equality (and more). // Test that we can compare smis for equality (and more).
TEST(SmiCompare) { TEST_F(MacroAssemblerX64Test, SmiCompare) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(2 * Assembler::kDefaultBufferSize); auto buffer = AllocateAssemblerBuffer(2 * Assembler::kDefaultBufferSize);
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -237,13 +238,13 @@ TEST(SmiCompare) { ...@@ -237,13 +238,13 @@ TEST(SmiCompare) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
TEST(SmiTag) { TEST_F(MacroAssemblerX64Test, SmiTag) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -325,7 +326,6 @@ TEST(SmiTag) { ...@@ -325,7 +326,6 @@ TEST(SmiTag) {
__ cmp_tagged(r8, rdx); __ cmp_tagged(r8, rdx);
__ j(not_equal, &exit); __ j(not_equal, &exit);
__ xorq(rax, rax); // Success. __ xorq(rax, rax); // Success.
__ bind(&exit); __ bind(&exit);
ExitCode(masm); ExitCode(masm);
...@@ -335,13 +335,13 @@ TEST(SmiTag) { ...@@ -335,13 +335,13 @@ TEST(SmiTag) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
TEST(SmiCheck) { TEST_F(MacroAssemblerX64Test, SmiCheck) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -410,7 +410,7 @@ TEST(SmiCheck) { ...@@ -410,7 +410,7 @@ TEST(SmiCheck) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
...@@ -438,11 +438,11 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { ...@@ -438,11 +438,11 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) {
} }
} }
TEST(EmbeddedObj) { TEST_F(MacroAssemblerX64Test, EmbeddedObj) {
#ifdef V8_COMPRESS_POINTERS #ifdef V8_COMPRESS_POINTERS
FLAG_compact_on_every_full_gc = true; FLAG_compact_on_every_full_gc = true;
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -473,9 +473,9 @@ TEST(EmbeddedObj) { ...@@ -473,9 +473,9 @@ TEST(EmbeddedObj) {
CHECK_EQ(old_array->ptr(), result.ptr()); CHECK_EQ(old_array->ptr(), result.ptr());
// Collect garbage to ensure reloc info can be walked by the heap. // Collect garbage to ensure reloc info can be walked by the heap.
CcTest::CollectAllGarbage(); CollectAllGarbage();
CcTest::CollectAllGarbage(); CollectAllGarbage();
CcTest::CollectAllGarbage(); CollectAllGarbage();
PtrComprCageBase cage_base(isolate); PtrComprCageBase cage_base(isolate);
...@@ -493,8 +493,8 @@ TEST(EmbeddedObj) { ...@@ -493,8 +493,8 @@ TEST(EmbeddedObj) {
#endif // V8_COMPRESS_POINTERS #endif // V8_COMPRESS_POINTERS
} }
TEST(SmiIndex) { TEST_F(MacroAssemblerX64Test, SmiIndex) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -519,16 +519,18 @@ TEST(SmiIndex) { ...@@ -519,16 +519,18 @@ TEST(SmiIndex) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
TEST(OperandOffset) { TEST_F(MacroAssemblerX64Test, OperandOffset) {
uint32_t data[256]; uint32_t data[256];
for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; } for (uint32_t i = 0; i < 256; i++) {
data[i] = i * 0x01010101;
}
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -618,7 +620,6 @@ TEST(OperandOffset) { ...@@ -618,7 +620,6 @@ TEST(OperandOffset) {
__ j(not_equal, &exit); __ j(not_equal, &exit);
__ incq(rax); __ incq(rax);
Operand bp0 = Operand(rbp, 0); Operand bp0 = Operand(rbp, 0);
// Test 9. // Test 9.
...@@ -783,7 +784,6 @@ TEST(OperandOffset) { ...@@ -783,7 +784,6 @@ TEST(OperandOffset) {
__ j(not_equal, &exit); __ j(not_equal, &exit);
__ incq(rax); __ incq(rax);
Operand r864 = Operand(r8, 64 * kIntSize); Operand r864 = Operand(r8, 64 * kIntSize);
// Test 36. // Test 36.
...@@ -868,12 +868,11 @@ TEST(OperandOffset) { ...@@ -868,12 +868,11 @@ TEST(OperandOffset) {
ExitCode(masm); ExitCode(masm);
__ ret(0); __ ret(0);
CodeDesc desc; CodeDesc desc;
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
...@@ -1000,8 +999,8 @@ void TestFloat64x2Neg(MacroAssembler* masm, Label* exit, double x, double y) { ...@@ -1000,8 +999,8 @@ void TestFloat64x2Neg(MacroAssembler* masm, Label* exit, double x, double y) {
__ addq(rsp, Immediate(kSimd128Size)); __ addq(rsp, Immediate(kSimd128Size));
} }
TEST(SIMDMacros) { TEST_F(MacroAssemblerX64Test, SIMDMacros) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler assembler(isolate, v8::internal::CodeObjectRequired::kYes,
...@@ -1026,12 +1025,12 @@ TEST(SIMDMacros) { ...@@ -1026,12 +1025,12 @@ TEST(SIMDMacros) {
masm->GetCode(isolate, &desc); masm->GetCode(isolate, &desc);
buffer->MakeExecutable(); buffer->MakeExecutable();
// Call the function from C++. // Call the function from C++.
auto f = GeneratedCode<F0>::FromBuffer(CcTest::i_isolate(), buffer->start()); auto f = GeneratedCode<F0>::FromBuffer(i_isolate(), buffer->start());
int result = f.Call(); int result = f.Call();
CHECK_EQ(0, result); CHECK_EQ(0, result);
} }
TEST(AreAliased) { TEST_F(MacroAssemblerX64Test, AreAliased) {
DCHECK(!AreAliased(rax)); DCHECK(!AreAliased(rax));
DCHECK(!AreAliased(rax, no_reg)); DCHECK(!AreAliased(rax, no_reg));
DCHECK(!AreAliased(no_reg, rax, no_reg)); DCHECK(!AreAliased(no_reg, rax, no_reg));
...@@ -1047,8 +1046,8 @@ TEST(AreAliased) { ...@@ -1047,8 +1046,8 @@ TEST(AreAliased) {
DCHECK(AreAliased(rax, no_reg, rbx, no_reg, rcx, no_reg, rdx, rax, no_reg)); DCHECK(AreAliased(rax, no_reg, rbx, no_reg, rcx, no_reg, rdx, rax, no_reg));
} }
TEST(DeoptExitSizeIsFixed) { TEST_F(MacroAssemblerX64Test, DeoptExitSizeIsFixed) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = i_isolate();
HandleScope handles(isolate); HandleScope handles(isolate);
auto buffer = AllocateAssemblerBuffer(); auto buffer = AllocateAssemblerBuffer();
MacroAssembler masm(isolate, v8::internal::CodeObjectRequired::kYes, MacroAssembler masm(isolate, v8::internal::CodeObjectRequired::kYes,
......
...@@ -241,6 +241,7 @@ ...@@ -241,6 +241,7 @@
['lite_mode or variant == jitless', { ['lite_mode or variant == jitless', {
# Tests that generate code at runtime. # Tests that generate code at runtime.
'MacroAssemblerX64Test.EmbeddedObj': [SKIP],
'RegExpTest.MacroAssemblernativeAtStart': [SKIP], 'RegExpTest.MacroAssemblernativeAtStart': [SKIP],
'RegExpTest.MacroAssemblerNativeBackReferenceLATIN1': [SKIP], 'RegExpTest.MacroAssemblerNativeBackReferenceLATIN1': [SKIP],
'RegExpTest.MacroAssemblerNativeBackReferenceUC16': [SKIP], 'RegExpTest.MacroAssemblerNativeBackReferenceUC16': [SKIP],
......
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