Commit d884663f authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[test] Switch cctest to be W^X compliant as well.

R=clemensh@chromium.org
BUG=v8:6792

Change-Id: Ia2567112ab86f42729337e539f9aaa1719d9a39f
Reviewed-on: https://chromium-review.googlesource.com/811305Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49929}
parent 37eb501b
......@@ -575,12 +575,19 @@ static inline uint8_t* AllocateAssemblerBuffer(
size_t alloc_size = RoundUp(requested, page_size);
void* result =
v8::base::OS::Allocate(nullptr, alloc_size, page_size,
v8::base::OS::MemoryPermission::kReadWriteExecute);
v8::base::OS::MemoryPermission::kReadWrite);
CHECK(result);
*allocated = alloc_size;
return static_cast<uint8_t*>(result);
}
static inline void MakeAssemblerBufferExecutable(uint8_t* buffer,
size_t allocated) {
bool result = v8::base::OS::SetPermissions(
buffer, allocated, v8::base::OS::MemoryPermission::kReadExecute);
CHECK(result);
}
static v8::debug::DebugDelegate dummy_delegate;
static inline void EnableDebugger(v8::Isolate* isolate) {
......
......@@ -199,6 +199,7 @@ static void InitializeVM() {
START_AFTER_RESET();
#define RUN() \
MakeAssemblerBufferExecutable(buf, allocated); \
Assembler::FlushICache(isolate, buf, masm.SizeOfGeneratedCode()); \
{ \
void (*test_function)(void); \
......
......@@ -82,6 +82,7 @@ TEST(AssemblerX64ReturnOperation) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(2, result);
......@@ -111,6 +112,7 @@ TEST(AssemblerX64StackOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(2, result);
......@@ -130,6 +132,7 @@ TEST(AssemblerX64ArithmeticOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(5, result);
......@@ -156,6 +159,7 @@ TEST(AssemblerX64CmpbOperation) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2002);
CHECK_EQ(1, result);
......@@ -193,6 +197,7 @@ TEST(AssemblerX64ImulOperation) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(0, result);
......@@ -362,6 +367,7 @@ TEST(AssemblerX64testbwqOperation) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(0, 0);
CHECK_EQ(1, result);
......@@ -382,6 +388,7 @@ TEST(AssemblerX64XchglOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
......@@ -404,6 +411,7 @@ TEST(AssemblerX64OrlOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
......@@ -425,6 +433,7 @@ TEST(AssemblerX64RollOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t src = V8_2PART_UINT64_C(0x10000000, C0000000);
uint64_t result = FUNCTION_CAST<F5>(buffer)(src);
......@@ -444,6 +453,7 @@ TEST(AssemblerX64SublOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
......@@ -471,6 +481,7 @@ TEST(AssemblerX64TestlOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
uint64_t right = V8_2PART_UINT64_C(0x30000000, 00000000);
......@@ -496,6 +507,7 @@ TEST(AssemblerX64TestwOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint16_t operand = 0x8000;
uint16_t result = FUNCTION_CAST<F>(buffer)(&operand);
......@@ -514,6 +526,7 @@ TEST(AssemblerX64XorlOperations) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
uint64_t right = V8_2PART_UINT64_C(0x30000000, 60000000);
......@@ -548,6 +561,7 @@ TEST(AssemblerX64MemoryOperands) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(3, result);
......@@ -574,6 +588,7 @@ TEST(AssemblerX64ControlFlow) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F2>(buffer)(3, 2);
CHECK_EQ(3, result);
......@@ -622,6 +637,7 @@ TEST(AssemblerX64LoopImmediates) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(1, result);
......@@ -2444,6 +2460,7 @@ TEST(AssemblerX64PslldWithXmm15) {
CodeDesc desc;
masm.GetCode(CcTest::i_isolate(), &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
uint64_t result = FUNCTION_CAST<F5>(buffer)(uint64_t{0x1122334455667788});
CHECK_EQ(uint64_t{0x22446688AACCEF10}, result);
}
......
......@@ -115,6 +115,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
Assembler::FlushICache(isolate, buffer, allocated);
return (reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer)));
......
......@@ -119,6 +119,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
Assembler::FlushICache(isolate, buffer, allocated);
return (reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer)));
......
......@@ -108,6 +108,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
return reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer));
}
......
......@@ -128,6 +128,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
Assembler::FlushICache(isolate, buffer, allocated);
return (reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer)));
......
......@@ -125,6 +125,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
Assembler::FlushICache(isolate, buffer, allocated);
return (reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer)));
......
......@@ -106,6 +106,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
CodeDesc desc;
masm.GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
return reinterpret_cast<ConvertDToIFunc>(
reinterpret_cast<intptr_t>(buffer));
}
......
......@@ -127,6 +127,7 @@ TEST(SmiMove) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -218,6 +219,7 @@ TEST(SmiCompare) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -317,6 +319,7 @@ TEST(Integer32ToSmi) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -391,6 +394,7 @@ TEST(SmiCheck) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -444,6 +448,7 @@ TEST(SmiIndex) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -794,6 +799,7 @@ TEST(OperandOffset) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -940,6 +946,7 @@ TEST(LoadAndStoreWithRepresentation) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......@@ -1092,6 +1099,7 @@ TEST(SIMDMacros) {
CodeDesc desc;
masm->GetCode(isolate, &desc);
MakeAssemblerBufferExecutable(buffer, allocated);
// Call the function from C++.
int result = FUNCTION_CAST<F0>(buffer)();
CHECK_EQ(0, result);
......
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