Commit 58abe44b authored by Dmitrii Tsykunov's avatar Dmitrii Tsykunov Committed by V8 LUCI CQ

Fix test-assembler-ia32

When compiled with gn argument 'is_debug=false' these tests fail on
Windows due to the fact that they're compiled with '/guard:cf'.

This CL changes the use of FUNCTION_CAST to GeneratedCode::Call which
contains DISABLE_CFI_ICALL attribute. This is analogous to how
assembled functions are called in Assembler tests for other
architectures.

Change-Id: I330e29a508ad1421cb98dea3d9761f05272ab763
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3341511
Auto-Submit: Dmitrii Tsykunov <dtsykunov1@yandex-team.ru>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78386}
parent 54fd89d8
......@@ -38,13 +38,14 @@
#include "src/init/v8.h"
#include "src/utils/ostreams.h"
#include "test/cctest/cctest.h"
#include "test/common/assembler-tester.h"
namespace v8 {
namespace internal {
using F0 = int (*)();
using F1 = int (*)(int x);
using F2 = int (*)(int x, int y);
using F0 = int();
using F1 = int(int x);
using F2 = int(int x, int y);
#define __ assm.
......@@ -69,8 +70,8 @@ TEST(AssemblerIa320) {
StdoutStream os;
code->Print(os);
#endif
F2 f = FUNCTION_CAST<F2>(code->entry());
int res = f(3, 4);
auto f = GeneratedCode<F2>::FromCode(*code);
auto res = f.Call(3, 4);
::printf("f() = %d\n", res);
CHECK_EQ(7, res);
}
......@@ -107,8 +108,8 @@ TEST(AssemblerIa321) {
StdoutStream os;
code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = f(100);
auto f = GeneratedCode<F1>::FromCode(*code);
int res = f.Call(100);
::printf("f() = %d\n", res);
CHECK_EQ(5050, res);
}
......@@ -149,13 +150,13 @@ TEST(AssemblerIa322) {
StdoutStream os;
code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = f(10);
auto f = GeneratedCode<F1>::FromCode(*code);
int res = f.Call(10);
::printf("f() = %d\n", res);
CHECK_EQ(3628800, res);
}
using F3 = int (*)(float x);
using F3 = int(float x);
TEST(AssemblerIa323) {
CcTest::InitializeVM();
......@@ -178,13 +179,13 @@ TEST(AssemblerIa323) {
StdoutStream os;
code->Print(os);
#endif
F3 f = FUNCTION_CAST<F3>(code->entry());
int res = f(static_cast<float>(-3.1415));
auto f = GeneratedCode<F3>::FromCode(*code);
int res = f.Call(-3.1415f);
::printf("f() = %d\n", res);
CHECK_EQ(-3, res);
}
using F4 = int (*)(double x);
using F4 = int(double x);
TEST(AssemblerIa324) {
CcTest::InitializeVM();
......@@ -207,8 +208,8 @@ TEST(AssemblerIa324) {
StdoutStream os;
code->Print(os);
#endif
F4 f = FUNCTION_CAST<F4>(code->entry());
int res = f(2.718281828);
auto f = GeneratedCode<F4>::FromCode(*code);
int res = f.Call(2.718281828);
::printf("f() = %d\n", res);
CHECK_EQ(2, res);
}
......@@ -231,12 +232,12 @@ TEST(AssemblerIa325) {
assm.GetCode(isolate, &desc);
Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
F0 f = FUNCTION_CAST<F0>(code->entry());
int res = f();
auto f = GeneratedCode<F0>::FromCode(*code);
int res = f.Call();
CHECK_EQ(42, res);
}
using F5 = double (*)(double x, double y);
using F5 = double(double x, double y);
TEST(AssemblerIa326) {
CcTest::InitializeVM();
......@@ -268,13 +269,13 @@ TEST(AssemblerIa326) {
StdoutStream os;
code->Print(os);
#endif
F5 f = FUNCTION_CAST<F5>(code->entry());
double res = f(2.2, 1.1);
auto f = GeneratedCode<F5>::FromCode(*code);
double res = f.Call(2.2, 1.1);
::printf("f() = %f\n", res);
CHECK(2.29 < res && res < 2.31);
}
using F6 = double (*)(int x);
using F6 = double(int x);
TEST(AssemblerIa328) {
CcTest::InitializeVM();
......@@ -300,8 +301,8 @@ TEST(AssemblerIa328) {
StdoutStream os;
code->Print(os);
#endif
F6 f = FUNCTION_CAST<F6>(code->entry());
double res = f(12);
auto f = GeneratedCode<F6>::FromCode(*code);
double res = f.Call(12);
::printf("f() = %f\n", res);
CHECK(11.99 < res && res < 12.001);
......@@ -381,8 +382,8 @@ TEST(AssemblerMultiByteNop) {
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
CHECK(code->IsCode());
F0 f = FUNCTION_CAST<F0>(code->entry());
int res = f();
auto f = GeneratedCode<F0>::FromCode(*code);
int res = f.Call();
CHECK_EQ(42, res);
}
......@@ -431,8 +432,8 @@ void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) {
Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
F0 f = FUNCTION_CAST<F0>(code->entry());
int res = f();
auto f = GeneratedCode<F0>::FromCode(*code);
int res = f.Call();
args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res));
}
......@@ -500,14 +501,15 @@ TEST(AssemblerIa32Extractps) {
code->Print(os);
#endif
F4 f = FUNCTION_CAST<F4>(code->entry());
auto f = GeneratedCode<F4>::FromCode(*code);
uint64_t value1 = 0x1234'5678'8765'4321;
CHECK_EQ(0x12345678, f(base::uint64_to_double(value1)));
CHECK_EQ(0x12345678, f.Call(base::uint64_to_double(value1)));
uint64_t value2 = 0x8765'4321'1234'5678;
CHECK_EQ(static_cast<int>(0x87654321), f(base::uint64_to_double(value2)));
CHECK_EQ(static_cast<int>(0x87654321),
f.Call(base::uint64_to_double(value2)));
}
using F8 = int (*)(float x, float y);
using F8 = int(float x, float y);
TEST(AssemblerIa32SSE) {
CcTest::InitializeVM();
......@@ -539,8 +541,8 @@ TEST(AssemblerIa32SSE) {
code->Print(os);
#endif
F8 f = FUNCTION_CAST<F8>(code->entry());
CHECK_EQ(2, f(1.0, 2.0));
auto f = GeneratedCode<F8>::FromCode(*code);
CHECK_EQ(2, f.Call(1.0, 2.0));
}
TEST(AssemblerIa32SSE3) {
......@@ -572,11 +574,11 @@ TEST(AssemblerIa32SSE3) {
code->Print(os);
#endif
F8 f = FUNCTION_CAST<F8>(code->entry());
CHECK_EQ(4, f(1.0, 2.0));
auto f = GeneratedCode<F8>::FromCode(*code);
CHECK_EQ(4, f.Call(1.0, 2.0));
}
using F9 = int (*)(double x, double y, double z);
using F9 = int(double x, double y, double z);
TEST(AssemblerX64FMA_sd) {
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(FMA3)) return;
......@@ -800,11 +802,12 @@ TEST(AssemblerX64FMA_sd) {
code->Print(os);
#endif
F9 f = FUNCTION_CAST<F9>(code->entry());
CHECK_EQ(0, f(0.000092662107262076, -2.460774966188315, -1.0958787393627414));
auto f = GeneratedCode<F9>::FromCode(*code);
CHECK_EQ(
0, f.Call(0.000092662107262076, -2.460774966188315, -1.0958787393627414));
}
using F10 = int (*)(float x, float y, float z);
using F10 = int(float x, float y, float z);
TEST(AssemblerX64FMA_ss) {
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(FMA3)) return;
......@@ -1028,8 +1031,8 @@ TEST(AssemblerX64FMA_ss) {
code->Print(os);
#endif
F10 f = FUNCTION_CAST<F10>(code->entry());
CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
auto f = GeneratedCode<F10>::FromCode(*code);
CHECK_EQ(0, f.Call(9.26621069e-05f, -2.4607749f, -1.09587872f));
}
......@@ -1136,8 +1139,8 @@ TEST(AssemblerIa32BMI1) {
code->Print(os);
#endif
F0 f = FUNCTION_CAST<F0>(code->entry());
CHECK_EQ(0, f());
auto f = GeneratedCode<F0>::FromCode(*code);
CHECK_EQ(0, f.Call());
}
......@@ -1184,8 +1187,8 @@ TEST(AssemblerIa32LZCNT) {
code->Print(os);
#endif
F0 f = FUNCTION_CAST<F0>(code->entry());
CHECK_EQ(0, f());
auto f = GeneratedCode<F0>::FromCode(*code);
CHECK_EQ(0, f.Call());
}
......@@ -1232,8 +1235,8 @@ TEST(AssemblerIa32POPCNT) {
code->Print(os);
#endif
F0 f = FUNCTION_CAST<F0>(code->entry());
CHECK_EQ(0, f());
auto f = GeneratedCode<F0>::FromCode(*code);
CHECK_EQ(0, f.Call());
}
......@@ -1378,8 +1381,8 @@ TEST(AssemblerIa32BMI2) {
code->Print(os);
#endif
F0 f = FUNCTION_CAST<F0>(code->entry());
CHECK_EQ(0, f());
auto f = GeneratedCode<F0>::FromCode(*code);
CHECK_EQ(0, f.Call());
}
......@@ -1421,9 +1424,9 @@ TEST(AssemblerIa32JumpTables1) {
StdoutStream os;
code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
auto f = GeneratedCode<F1>::FromCode(*code);
for (int i = 0; i < kNumCases; ++i) {
int res = f(i);
int res = f.Call(i);
::printf("f(%d) = %d\n", i, res);
CHECK_EQ(values[i], res);
}
......@@ -1469,9 +1472,9 @@ TEST(AssemblerIa32JumpTables2) {
StdoutStream os;
code->Print(os);
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
auto f = GeneratedCode<F1>::FromCode(*code);
for (int i = 0; i < kNumCases; ++i) {
int res = f(i);
int res = f.Call(i);
::printf("f(%d) = %d\n", i, res);
CHECK_EQ(values[i], res);
}
......@@ -1514,8 +1517,8 @@ TEST(Regress621926) {
code->Print(os);
#endif
F0 f = FUNCTION_CAST<F0>(code->entry());
CHECK_EQ(1, f());
auto f = GeneratedCode<F0>::FromCode(*code);
CHECK_EQ(1, f.Call());
}
TEST(DeoptExitSizeIsFixed) {
......
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