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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assembler_ia32.cc
===================================================================
--- runtime/vm/assembler_ia32.cc (revision 16928)
+++ runtime/vm/assembler_ia32.cc (working copy)
@@ -809,6 +809,19 @@
}
+void Assembler::roundsd(XmmRegister dst, XmmRegister src, RoundingMode mode) {
+ ASSERT(CPUFeatures::sse4_1_supported());
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x3A);
+ EmitUint8(0x0B);
+ EmitXmmRegisterOperand(dst, src);
+ // Mask precision exeption.
+ EmitUint8(static_cast<uint8_t>(mode) | 0x8);
+}
+
+
void Assembler::fldl(const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xDD);
@@ -1723,6 +1736,38 @@
}
+void Assembler::DoubleRound(XmmRegister dst, XmmRegister src, XmmRegister tmp) {
+ ASSERT(tmp != src);
+ static double kZeroFiveConst = 0.5;
+ static double kNegZeroFiveConst = -0.5;
+ Label is_negative, round;
+ if (src != dst) {
+ movsd(dst, src);
+ }
+ Label below_half, below_equal_neg_half, done;
+ movsd(tmp, Address::Absolute(reinterpret_cast<uword>(&kZeroFiveConst)));
+ comisd(tmp, dst);
+ // 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.
+ j(ABOVE, &below_half, Assembler::kNearJump);
+ // floor(val + 0.5).
+ addsd(dst, tmp);
+ roundsd(dst, dst, Assembler::kRoundDown);
+ jmp(&done, Assembler::kNearJump);
+ Bind(&below_half);
+ // Return -0.0 for -0.5.
+ movsd(tmp, Address::Absolute(reinterpret_cast<uword>(&kNegZeroFiveConst)));
+ comisd(tmp, dst);
+ // -0.5 >= dst.
Florian Schneider 2013/01/11 09:49:30 Also here: dst <= -0.5 ?
srdjan 2013/01/11 19:41:08 Done.
+ j(ABOVE_EQUAL, &below_equal_neg_half, Assembler::kNearJump);
+ roundsd(dst, dst, Assembler::kRoundToZero);
+ jmp(&done, Assembler::kNearJump);
+ Bind(&below_equal_neg_half);
+ addsd(dst, tmp);
+ roundsd(dst, dst, Assembler::kRoundUp);
+ Bind(&done);
+}
+
+
void Assembler::EnterFrame(intptr_t frame_size) {
if (prologue_offset_ == -1) {
prologue_offset_ = CodeSize();

Powered by Google App Engine
This is Rietveld 408576698