summaryrefslogtreecommitdiff
path: root/deps/v8/src/x87/codegen-x87.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/x87/codegen-x87.cc')
-rw-r--r--deps/v8/src/x87/codegen-x87.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/deps/v8/src/x87/codegen-x87.cc b/deps/v8/src/x87/codegen-x87.cc
index 5df3f1f026..7f99fe332b 100644
--- a/deps/v8/src/x87/codegen-x87.cc
+++ b/deps/v8/src/x87/codegen-x87.cc
@@ -41,8 +41,27 @@ UnaryMathFunction CreateExpFunction() {
UnaryMathFunction CreateSqrtFunction() {
- // No SSE2 support
- return &std::sqrt;
+ size_t actual_size;
+ // Allocate buffer in executable space.
+ byte* buffer =
+ static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
+ if (buffer == NULL) return &std::sqrt;
+
+ MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
+ // Load double input into registers.
+ __ fld_d(MemOperand(esp, 4));
+ __ X87SetFPUCW(0x027F);
+ __ fsqrt();
+ __ X87SetFPUCW(0x037F);
+ __ Ret();
+
+ CodeDesc desc;
+ masm.GetCode(&desc);
+ DCHECK(!RelocInfo::RequiresRelocation(desc));
+
+ Assembler::FlushICacheWithoutIsolate(buffer, actual_size);
+ base::OS::ProtectCode(buffer, actual_size);
+ return FUNCTION_CAST<UnaryMathFunction>(buffer);
}