Index: src/x64/codegen-x64.cc |
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc |
index 902f7e93a31536c04938ef2fcfdea749cb67f6d4..4b9217cec7f0026ae7fbeb00b0e5101a86e570ae 100644 |
--- a/src/x64/codegen-x64.cc |
+++ b/src/x64/codegen-x64.cc |
@@ -55,8 +55,7 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { |
#define __ masm. |
-TranscendentalFunction CreateTranscendentalFunction( |
- TranscendentalCache::Type type) { |
+UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { |
size_t actual_size; |
// Allocate buffer in executable space. |
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
@@ -96,7 +95,34 @@ TranscendentalFunction CreateTranscendentalFunction( |
CPU::FlushICache(buffer, actual_size); |
OS::ProtectCode(buffer, actual_size); |
- return FUNCTION_CAST<TranscendentalFunction>(buffer); |
+ return FUNCTION_CAST<UnaryMathFunction>(buffer); |
+} |
+ |
+ |
+UnaryMathFunction CreateSqrtFunction() { |
+ size_t actual_size; |
+ // Allocate buffer in executable space. |
+ byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
+ &actual_size, |
+ true)); |
+ |
+ // If crankshaft is disabled, we can use libc's implementation to ensure |
+ // consistency since fullcodegen's implementation always calls into runtime. |
+ if (buffer == NULL || !V8::UseCrankshaft()) return &sqrt; |
Sven Panne
2012/03/12 13:23:46
To guarantee consistency between runs with and wit
|
+ |
+ MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
+ // xmm0: raw double input. |
+ // Move double input into registers. |
+ __ sqrtsd(xmm0, xmm0); |
+ __ Ret(); |
+ |
+ CodeDesc desc; |
+ masm.GetCode(&desc); |
+ ASSERT(desc.reloc_size == 0); |
+ |
+ CPU::FlushICache(buffer, actual_size); |
+ OS::ProtectCode(buffer, actual_size); |
+ return FUNCTION_CAST<UnaryMathFunction>(buffer); |
} |