Index: src/serialize.cc |
diff --git a/src/serialize.cc b/src/serialize.cc |
index 01d5f1c7bcb034efd6a4f95c1094a4502a0001ed..0cc12528cd2dbecadc163f9a1d61a07b65089e8f 100644 |
--- a/src/serialize.cc |
+++ b/src/serialize.cc |
@@ -1444,6 +1444,21 @@ void Serializer::ObjectSerializer::Serialize() { |
sink_->PutSection(space, "NewPageSpace"); |
} |
+#ifdef V8_TARGET_ARCH_MIPS |
+#define MIPS_QNAN_HI 0x7ff7ffff |
+#define MIPS_QNAN_LO 0xffffffff |
+ // 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. |
+ if (object_->IsNaN()) { |
+ uint64_t mips_qnan_bits = |
+ (static_cast<uint64_t>(MIPS_QNAN_HI) << 32) | MIPS_QNAN_LO; |
+ Address value_ptr = (reinterpret_cast<byte*>(object_) + |
+ HeapNumber::kValueOffset - kHeapObjectTag); |
+ memcpy(value_ptr, &mips_qnan_bits, sizeof(mips_qnan_bits)); |
+ } |
+#endif // V8_TARGET_ARCH_MIPS |
+ |
// Serialize the map (first word of the object). |
serializer_->SerializeObject(object_->map(), kPlain, kStartOfObject); |