Index: src/ia32/codegen-ia32.cc |
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc |
index 84a4d238bd427ac0d3e916fd849bab069207d407..0e4fe8c41ba40ba2c06ebee281763cbd12296579 100644 |
--- a/src/ia32/codegen-ia32.cc |
+++ b/src/ia32/codegen-ia32.cc |
@@ -60,9 +60,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) { |
@@ -97,7 +96,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); |
} |
@@ -106,7 +107,8 @@ UnaryMathFunction CreateExpFunction() { |
if (!CpuFeatures::IsSupported(SSE2)) return &exp; |
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(); |
@@ -135,7 +137,9 @@ UnaryMathFunction CreateExpFunction() { |
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); |
} |
@@ -143,9 +147,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 SSE2 is not available, we can use libc's implementation to ensure |
// consistency since code by fullcodegen's calls into runtime in that case. |
if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &sqrt; |
@@ -168,7 +171,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); |
} |
@@ -262,7 +267,8 @@ class LabelConverter { |
OS::MemMoveFunction CreateMemMoveFunction() { |
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 NULL; |
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
LabelConverter conv(buffer); |
@@ -639,7 +645,9 @@ OS::MemMoveFunction CreateMemMoveFunction() { |
masm.GetCode(&desc); |
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); |
// TODO(jkummerow): It would be nice to register this code creation event |
// with the PROFILE / GDBJIT system. |
return FUNCTION_CAST<OS::MemMoveFunction>(buffer); |