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

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
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 Label is_negative, round;
1744 if (src != dst) {
1745 movsd(dst, src);
1746 }
1747 Label below_half, below_equal_neg_half, done;
1748 movsd(tmp, Address::Absolute(reinterpret_cast<uword>(&kZeroFiveConst)));
1749 comisd(tmp, dst);
1750 // 0.5 > dst ?
Florian Schneider 2013/01/11 09:49:30 For consistency with the jump label I'd rewrite th
srdjan 2013/01/11 19:41:08 Done.
1751 j(ABOVE, &below_half, Assembler::kNearJump);
1752 // floor(val + 0.5).
1753 addsd(dst, tmp);
1754 roundsd(dst, dst, Assembler::kRoundDown);
1755 jmp(&done, Assembler::kNearJump);
1756 Bind(&below_half);
1757 // Return -0.0 for -0.5.
1758 movsd(tmp, Address::Absolute(reinterpret_cast<uword>(&kNegZeroFiveConst)));
1759 comisd(tmp, dst);
1760 // -0.5 >= dst.
Florian Schneider 2013/01/11 09:49:30 Also here: dst <= -0.5 ?
srdjan 2013/01/11 19:41:08 Done.
1761 j(ABOVE_EQUAL, &below_equal_neg_half, Assembler::kNearJump);
1762 roundsd(dst, dst, Assembler::kRoundToZero);
1763 jmp(&done, Assembler::kNearJump);
1764 Bind(&below_equal_neg_half);
1765 addsd(dst, tmp);
1766 roundsd(dst, dst, Assembler::kRoundUp);
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

Powered by Google App Engine
This is Rietveld 408576698