Reviewers: Benedikt Meurer, danno, Jakob, paul.l..., akos.palfi.imgtec, balazs.kilvady,

Description:
Make SNaN verification universal for all arches.

The mips HW prior to revision 5 has opposite encoding for NaNs.

TEST=mjsunit/regress/*, regress-1167, regress-undefined-nan2
BUG=

Please review this at https://codereview.chromium.org/912833003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+7, -3 lines):
  M src/objects-debug.cc
  M src/objects-inl.h


Index: src/objects-debug.cc
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 4e7cf8f1dfb20faf28f30c3d9e861cf57fe773ba..059406e3dc21193be8ae9d5ba7be6d75d9ab5564 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -390,8 +390,12 @@ void FixedDoubleArray::FixedDoubleArrayVerify() {
   for (int i = 0; i < length(); i++) {
     if (!is_the_hole(i)) {
       uint64_t value = get_representation(i);
-      CHECK((value & V8_UINT64_C(0x7FF8000000000000)) !=
-                V8_UINT64_C(0x7FF0000000000000) ||
+      uint64_t unexpected =
+          bit_cast<uint64_t>(std::numeric_limits<double>::quiet_NaN()) &
+          V8_UINT64_C(0x7FF8000000000000);
+      // Create implementation specific sNaN by inverting relevant bit.
+      unexpected ^= V8_UINT64_C(0x0008000000000000);
+      CHECK((value & V8_UINT64_C(0x7FF8000000000000)) != unexpected ||
             (value & V8_UINT64_C(0x0007FFFFFFFFFFFF)) == V8_UINT64_C(0));
     }
   }
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 31439039de15f1506e13b117c2a56dd0b6109ac4..440b6934f3d43d10e201a5df97d3d626a7da3ae4 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2335,7 +2335,7 @@ void FixedDoubleArray::set(int index, double value) {
          map() != GetHeap()->fixed_array_map());
   int offset = kHeaderSize + index * kDoubleSize;
   if (std::isnan(value)) {
-    WRITE_UINT64_FIELD(this, offset, V8_UINT64_C(0xFFFFFFFFFFFFFFFF));
+ WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN());
   } else {
     WRITE_DOUBLE_FIELD(this, offset, value);
   }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to