Index: src/x64/codegen-x64.cc |
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc |
index 24773c2595d1303aac57cacd10cad243a868e9e0..9d4421eaf31cf791137dee0639460cb9b29ced0b 100644 |
--- a/src/x64/codegen-x64.cc |
+++ b/src/x64/codegen-x64.cc |
@@ -58,9 +58,8 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { |
UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { |
size_t actual_size; |
// Allocate buffer in executable space. |
- byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
- &actual_size, |
- true)); |
+ byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion( |
+ 1 * KB, &actual_size, VirtualMemory::EXECUTABLE)); |
if (buffer == NULL) { |
// Fallback to library function if function cannot be created. |
switch (type) { |
@@ -94,7 +93,9 @@ UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { |
ASSERT(!RelocInfo::RequiresRelocation(desc)); |
CPU::FlushICache(buffer, actual_size); |
- OS::ProtectCode(buffer, actual_size); |
+ bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size); |
+ ASSERT(result); |
+ USE(result); |
return FUNCTION_CAST<UnaryMathFunction>(buffer); |
} |
@@ -102,7 +103,8 @@ UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { |
UnaryMathFunction CreateExpFunction() { |
if (!FLAG_fast_math) return &exp; |
size_t actual_size; |
- byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); |
+ byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion( |
+ 1 * KB, &actual_size, VirtualMemory::EXECUTABLE)); |
if (buffer == NULL) return &exp; |
ExternalReference::InitializeMathExpData(); |
@@ -125,7 +127,9 @@ UnaryMathFunction CreateExpFunction() { |
ASSERT(!RelocInfo::RequiresRelocation(desc)); |
CPU::FlushICache(buffer, actual_size); |
- OS::ProtectCode(buffer, actual_size); |
+ bool ok = VirtualMemory::WriteProtectRegion(buffer, actual_size); |
+ ASSERT(ok); |
+ USE(ok); |
return FUNCTION_CAST<UnaryMathFunction>(buffer); |
} |
@@ -133,9 +137,8 @@ UnaryMathFunction CreateExpFunction() { |
UnaryMathFunction CreateSqrtFunction() { |
size_t actual_size; |
// Allocate buffer in executable space. |
- byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
- &actual_size, |
- true)); |
+ byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion( |
+ 1 * KB, &actual_size, VirtualMemory::EXECUTABLE)); |
if (buffer == NULL) return &sqrt; |
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
@@ -149,7 +152,9 @@ UnaryMathFunction CreateSqrtFunction() { |
ASSERT(!RelocInfo::RequiresRelocation(desc)); |
CPU::FlushICache(buffer, actual_size); |
- OS::ProtectCode(buffer, actual_size); |
+ bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size); |
+ ASSERT(result); |
+ USE(result); |
return FUNCTION_CAST<UnaryMathFunction>(buffer); |
} |
@@ -237,7 +242,9 @@ ModuloFunction CreateModuloFunction() { |
CodeDesc desc; |
masm.GetCode(&desc); |
- OS::ProtectCode(buffer, actual_size); |
+ bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size); |
+ ASSERT(result); |
+ USE(result); |
// Call the function from C++ through this pointer. |
return FUNCTION_CAST<ModuloFunction>(buffer); |
} |