Revision: 11283
Author:   [email protected]
Date:     Thu Apr 12 02:23:26 2012
Log:      MIPS: NaNs in the snapshot should be quiet according
to the MIPS FPU even when cross-building the snapshot.
This is based on code from Daniel Kalmar from
http://codereview.chromium.org/9910029/
Review URL: https://chromiumcodereview.appspot.com/10068006
http://code.google.com/p/v8/source/detail?r=11283

Modified:
 /branches/bleeding_edge/src/assembler.h
 /branches/bleeding_edge/src/mips/assembler-mips.cc
 /branches/bleeding_edge/src/mips/assembler-mips.h
 /branches/bleeding_edge/src/serialize.cc

=======================================
--- /branches/bleeding_edge/src/assembler.h     Thu Apr  5 07:10:39 2012
+++ /branches/bleeding_edge/src/assembler.h     Thu Apr 12 02:23:26 2012
@@ -61,6 +61,10 @@

   Isolate* isolate() const { return isolate_; }
   int jit_cookie() { return jit_cookie_; }
+
+  // Overwrite a host NaN with a quiet target NaN.  Used by mksnapshot for
+  // cross-snapshotting.
+  static void QuietNaN(HeapObject* nan) { }

  private:
   Isolate* isolate_;
=======================================
--- /branches/bleeding_edge/src/mips/assembler-mips.cc Thu Apr 5 08:18:22 2012 +++ /branches/bleeding_edge/src/mips/assembler-mips.cc Thu Apr 12 02:23:26 2012
@@ -2135,6 +2135,22 @@
   UNREACHABLE();
   return (Address)0x0;
 }
+
+
+#define MIPS_QNAN_HI 0x7ff7ffff
+#define MIPS_QNAN_LO 0xffffffff
+
+
+void Assembler::QuietNaN(HeapObject* object) {
+  // Mips has a different encoding of qNaN than ia32, so any heap NaN built
+ // with simulator must be re-encoded for the snapshot. Performance hit not + // critical at mksnapshot/build time. We can't use set_value because that
+  // will put the NaN in an fp register, which changes the bits.
+  uint64_t mips_qnan_bits =
+      (static_cast<uint64_t>(MIPS_QNAN_HI) << 32) | MIPS_QNAN_LO;
+  Address value_ptr = object->address() + HeapNumber::kValueOffset;
+  memcpy(value_ptr, &mips_qnan_bits, sizeof(mips_qnan_bits));
+}


 // On Mips, a target address is stored in a lui/ori instruction pair, each
=======================================
--- /branches/bleeding_edge/src/mips/assembler-mips.h Thu Apr 5 08:18:22 2012 +++ /branches/bleeding_edge/src/mips/assembler-mips.h Thu Apr 12 02:23:26 2012
@@ -570,6 +570,8 @@

   static void JumpLabelToJumpRegister(Address pc);

+  static void QuietNaN(HeapObject* nan);
+
// This sets the branch destination (which gets loaded at the call address).
   // This is for calls and branches within generated code.  The serializer
   // has already deserialized the lui/ori instructions etc.
=======================================
--- /branches/bleeding_edge/src/serialize.cc    Wed Mar 21 07:29:14 2012
+++ /branches/bleeding_edge/src/serialize.cc    Thu Apr 12 02:23:26 2012
@@ -1443,6 +1443,8 @@
     sink_->Put(kNewPage, "NewPage");
     sink_->PutSection(space, "NewPageSpace");
   }
+
+  if (object_->IsNaN()) Assembler::QuietNaN(object_);

   // Serialize the map (first word of the object).
   serializer_->SerializeObject(object_->map(), kPlain, kStartOfObject);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to