Reviewers: Vyacheslav Egorov,

Description:
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/

Please review this at https://chromiumcodereview.appspot.com/10068006/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/assembler.h
  M     src/mips/assembler-mips.h
  M     src/mips/assembler-mips.cc
  M     src/serialize.cc


Index: src/assembler.h
===================================================================
--- src/assembler.h     (revision 11280)
+++ src/assembler.h     (working copy)
@@ -62,6 +62,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_;
   int jit_cookie_;
Index: src/mips/assembler-mips.cc
===================================================================
--- src/mips/assembler-mips.cc  (revision 11280)
+++ src/mips/assembler-mips.cc  (working copy)
@@ -2137,6 +2137,21 @@
 }


+#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.
+  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
 // of which load 16 bits of the 32-bit address to a register.
 // Patching the address must replace both instr, and flush the i-cache.
Index: src/mips/assembler-mips.h
===================================================================
--- src/mips/assembler-mips.h   (revision 11280)
+++ src/mips/assembler-mips.h   (working copy)
@@ -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.
Index: src/serialize.cc
===================================================================
--- src/serialize.cc    (revision 11280)
+++ src/serialize.cc    (working copy)
@@ -1444,6 +1444,8 @@
     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