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

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
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_ia32_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_ia32.cc
===================================================================
--- runtime/vm/assembler_ia32.cc (revision 16975)
+++ 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;
+ static double kOneConst = 1.0;
+ static double kNegOneConst = -1.0;
+ Label is_negative, round;
+ if (src != dst) {
+ movsd(dst, src);
+ }
+ // Special handling: 0.5 -> 1.0, -0.5 -> -1.0;
+ Label done, equal_point5, equal_neg_point5;
+ movsd(tmp, Address::Absolute(reinterpret_cast<intptr_t>(&kZeroFiveConst)));
+ comisd(tmp, dst);
+ j(EQUAL, &equal_point5, Assembler::kNearJump);
+ movsd(tmp, Address::Absolute(reinterpret_cast<intptr_t>(&kNegZeroFiveConst)));
+ comisd(tmp, dst);
+ j(EQUAL, &equal_neg_point5, Assembler::kNearJump);
+
+ roundsd(dst, dst, Assembler::kRoundToNearest);
+ jmp(&done, Assembler::kNearJump);
+
+ Bind(&equal_point5);
+ movsd(dst, Address::Absolute(reinterpret_cast<intptr_t>(&kOneConst)));
+ jmp(&done);
+
+ Bind(&equal_neg_point5);
+ movsd(dst, Address::Absolute(reinterpret_cast<intptr_t>(&kNegOneConst)));
+ Bind(&done);
+}
+
+
void Assembler::EnterFrame(intptr_t frame_size) {
if (prologue_offset_ == -1) {
prologue_offset_ = CodeSize();
« 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