Chromium Code Reviews| Index: src/ia32/codegen-ia32.cc |
| diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc |
| index de6901f9cdbe34d84066b317fd5fb9af5950da80..f717f059bbc10dc36a3fa88f03cf52a2105f2f1f 100644 |
| --- a/src/ia32/codegen-ia32.cc |
| +++ b/src/ia32/codegen-ia32.cc |
| @@ -57,8 +57,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, |
| @@ -99,7 +98,44 @@ 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
Using !CpuFeatures::IsSupported(SSE2) here would g
|
| + MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
| + // esp[1 * kPointerSize]: raw double input |
| + // esp[0 * kPointerSize]: return address |
| + // Move double input into registers. |
| + |
| + // Crankshaft cannot be enabled without SSE2. |
| + ASSERT(CpuFeatures::IsSupported(SSE2)); |
| + { |
| + CpuFeatures::Scope use_sse2(SSE2); |
| + __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); |
| + __ sqrtsd(xmm0, xmm0); |
| + __ movdbl(Operand(esp, 1 * kPointerSize), xmm0); |
| + // Load result into floating point register as return value. |
| + __ fld_d(Operand(esp, 1 * kPointerSize)); |
| + __ 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); |
| } |