Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: src/x87/codegen-x87.cc

Issue 1417553007: X87: Fix the sqrt precision issue. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/x87/code-generator-x87.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/x87/codegen-x87.h" 5 #include "src/x87/codegen-x87.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/heap/heap.h" 10 #include "src/heap/heap.h"
(...skipping 23 matching lines...) Expand all
34 #define __ masm. 34 #define __ masm.
35 35
36 36
37 UnaryMathFunction CreateExpFunction() { 37 UnaryMathFunction CreateExpFunction() {
38 // No SSE2 support 38 // No SSE2 support
39 return &std::exp; 39 return &std::exp;
40 } 40 }
41 41
42 42
43 UnaryMathFunction CreateSqrtFunction() { 43 UnaryMathFunction CreateSqrtFunction() {
44 // No SSE2 support 44 size_t actual_size;
45 return &std::sqrt; 45 // Allocate buffer in executable space.
46 byte* buffer =
47 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
48 if (buffer == NULL) return &std::sqrt;
49
50 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
51 // Load double input into registers.
52 __ fld_d(MemOperand(esp, 4));
53 __ X87SetFPUCW(0x027F);
54 __ fsqrt();
55 __ X87SetFPUCW(0x037F);
56 __ Ret();
57
58 CodeDesc desc;
59 masm.GetCode(&desc);
60 DCHECK(!RelocInfo::RequiresRelocation(desc));
61
62 Assembler::FlushICacheWithoutIsolate(buffer, actual_size);
63 base::OS::ProtectCode(buffer, actual_size);
64 return FUNCTION_CAST<UnaryMathFunction>(buffer);
46 } 65 }
47 66
48 67
49 // Helper functions for CreateMemMoveFunction. 68 // Helper functions for CreateMemMoveFunction.
50 #undef __ 69 #undef __
51 #define __ ACCESS_MASM(masm) 70 #define __ ACCESS_MASM(masm)
52 71
53 enum Direction { FORWARD, BACKWARD }; 72 enum Direction { FORWARD, BACKWARD };
54 enum Alignment { MOVE_ALIGNED, MOVE_UNALIGNED }; 73 enum Alignment { MOVE_ALIGNED, MOVE_UNALIGNED };
55 74
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 CodePatcher patcher(sequence, young_length); 642 CodePatcher patcher(sequence, young_length);
624 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); 643 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
625 } 644 }
626 } 645 }
627 646
628 647
629 } // namespace internal 648 } // namespace internal
630 } // namespace v8 649 } // namespace v8
631 650
632 #endif // V8_TARGET_ARCH_X87 651 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/compiler/x87/code-generator-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698