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

Side by Side Diff: runtime/vm/assembler_ia32.cc

Issue 11573044: Inline Doubles truncate and round. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 802
803 void Assembler::pxor(XmmRegister dst, XmmRegister src) { 803 void Assembler::pxor(XmmRegister dst, XmmRegister src) {
804 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 804 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
805 EmitUint8(0x66); 805 EmitUint8(0x66);
806 EmitUint8(0x0F); 806 EmitUint8(0x0F);
807 EmitUint8(0xEF); 807 EmitUint8(0xEF);
808 EmitXmmRegisterOperand(dst, src); 808 EmitXmmRegisterOperand(dst, src);
809 } 809 }
810 810
811 811
812 void Assembler::roundsd(XmmRegister dst, XmmRegister src, RoundingMode mode) {
813 ASSERT(CPUFeatures::sse4_1_supported());
814 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
815 EmitUint8(0x66);
816 EmitUint8(0x0F);
817 EmitUint8(0x3A);
818 EmitUint8(0x0B);
819 EmitXmmRegisterOperand(dst, src);
820 // Mask precision exeption.
821 EmitUint8(static_cast<uint8_t>(mode) | 0x8);
822 }
823
824
812 void Assembler::fldl(const Address& src) { 825 void Assembler::fldl(const Address& src) {
813 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 826 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
814 EmitUint8(0xDD); 827 EmitUint8(0xDD);
815 EmitOperand(0, src); 828 EmitOperand(0, src);
816 } 829 }
817 830
818 831
819 void Assembler::fstpl(const Address& dst) { 832 void Assembler::fstpl(const Address& dst) {
820 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 833 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
821 EmitUint8(0xDD); 834 EmitUint8(0xDD);
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 void Assembler::DoubleAbs(XmmRegister reg) { 1729 void Assembler::DoubleAbs(XmmRegister reg) {
1717 static const struct ALIGN16 { 1730 static const struct ALIGN16 {
1718 uint64_t a; 1731 uint64_t a;
1719 uint64_t b; 1732 uint64_t b;
1720 } double_abs_constant = 1733 } double_abs_constant =
1721 {0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL}; 1734 {0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL};
1722 andpd(reg, Address::Absolute(reinterpret_cast<uword>(&double_abs_constant))); 1735 andpd(reg, Address::Absolute(reinterpret_cast<uword>(&double_abs_constant)));
1723 } 1736 }
1724 1737
1725 1738
1739 void Assembler::DoubleRound(XmmRegister dst, XmmRegister src, XmmRegister tmp) {
1740 ASSERT(tmp != src);
1741 static double kZeroFiveConst = 0.5;
1742 static double kNegZeroFiveConst = -0.5;
1743 static double kOneConst = 1.0;
1744 static double kNegOneConst = -1.0;
1745 Label is_negative, round;
1746 if (src != dst) {
1747 movsd(dst, src);
1748 }
1749 // Special handling: 0.5 -> 1.0, -0.5 -> -1.0;
1750 Label done, equal_point5, equal_neg_point5;
1751 movsd(tmp, Address::Absolute(reinterpret_cast<intptr_t>(&kZeroFiveConst)));
1752 comisd(tmp, dst);
1753 j(EQUAL, &equal_point5, Assembler::kNearJump);
1754 movsd(tmp, Address::Absolute(reinterpret_cast<intptr_t>(&kNegZeroFiveConst)));
1755 comisd(tmp, dst);
1756 j(EQUAL, &equal_neg_point5, Assembler::kNearJump);
1757
1758 roundsd(dst, dst, Assembler::kRoundToNearest);
1759 jmp(&done, Assembler::kNearJump);
1760
1761 Bind(&equal_point5);
1762 movsd(dst, Address::Absolute(reinterpret_cast<intptr_t>(&kOneConst)));
1763 jmp(&done);
1764
1765 Bind(&equal_neg_point5);
1766 movsd(dst, Address::Absolute(reinterpret_cast<intptr_t>(&kNegOneConst)));
1767 Bind(&done);
1768 }
1769
1770
1726 void Assembler::EnterFrame(intptr_t frame_size) { 1771 void Assembler::EnterFrame(intptr_t frame_size) {
1727 if (prologue_offset_ == -1) { 1772 if (prologue_offset_ == -1) {
1728 prologue_offset_ = CodeSize(); 1773 prologue_offset_ = CodeSize();
1729 } 1774 }
1730 pushl(EBP); 1775 pushl(EBP);
1731 movl(EBP, ESP); 1776 movl(EBP, ESP);
1732 if (frame_size != 0) { 1777 if (frame_size != 0) {
1733 Immediate frame_space(frame_size); 1778 Immediate frame_space(frame_size);
1734 subl(ESP, frame_space); 1779 subl(ESP, frame_space);
1735 } 1780 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 2097
2053 const char* Assembler::XmmRegisterName(XmmRegister reg) { 2098 const char* Assembler::XmmRegisterName(XmmRegister reg) {
2054 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 2099 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
2055 return xmm_reg_names[reg]; 2100 return xmm_reg_names[reg];
2056 } 2101 }
2057 2102
2058 2103
2059 } // namespace dart 2104 } // namespace dart
2060 2105
2061 #endif // defined TARGET_ARCH_IA32 2106 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698