Commit bd19ea4a authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Reland "[test] Add nan bit patterns to uint{32,64}_vector"

This is a reland of 6f93d59d.
One more test had to be disabled (tracked by bug 6954), and
two machops tests needed to be changed to use boxed floats
and doubles.

Original change's description:
> [test] Add nan bit patterns to uint{32,64}_vector
> 
> If you just cast those patterns to float or double and pass them
> around, the quiet/signaling NaN bit might change. We had several bugs
> around this, so add these patterns to the general input vectors.
> 
> This uncovers a bug in the wasm interpreter, which will be fixed in a
> separate CL.
> 
> R=ahaas@chromium.org
> 
> Bug: v8:6947, v8:6954
> Change-Id: I205b8ab784b087b1e4988190fa725df0b90e7ee0
> Reviewed-on: https://chromium-review.googlesource.com/725345
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#48731}

Bug: v8:6947, v8:6954
Change-Id: I9a38b5d9324131c3950c537910371a73c93d2c13
Reviewed-on: https://chromium-review.googlesource.com/728439Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48780}
parent 49369fa7
......@@ -43,6 +43,10 @@ class Float32 {
return std::isnan(get_scalar());
}
// Return a pointer to the field storing the bit pattern. Used in code
// generation tests to store generated values there directly.
uint32_t* get_bits_address() { return &bit_pattern_; }
static constexpr Float32 FromBits(uint32_t bits) { return Float32(bits); }
private:
......@@ -78,6 +82,11 @@ class Float64 {
// because this does not change the is_nan property.
return std::isnan(get_scalar());
}
// Return a pointer to the field storing the bit pattern. Used in code
// generation tests to store generated values there directly.
uint64_t* get_bits_address() { return &bit_pattern_; }
static constexpr Float64 FromBits(uint64_t bits) { return Float64(bits); }
private:
......
......@@ -9,6 +9,7 @@
#include "src/base/bits.h"
#include "src/base/ieee754.h"
#include "src/base/utils/random-number-generator.h"
#include "src/boxed-float.h"
#include "src/codegen.h"
#include "src/objects-inl.h"
#include "src/utils.h"
......@@ -6297,17 +6298,17 @@ TEST(RunCallCFunction9) {
TEST(RunBitcastInt64ToFloat64) {
int64_t input = 1;
double output = 0.0;
Float64 output;
RawMachineAssemblerTester<int32_t> m;
m.StoreToPointer(
&output, MachineRepresentation::kFloat64,
output.get_bits_address(), MachineRepresentation::kFloat64,
m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64())));
m.Return(m.Int32Constant(11));
FOR_INT64_INPUTS(i) {
input = *i;
CHECK_EQ(11, m.Call());
double expected = bit_cast<double>(input);
CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
Float64 expected = Float64::FromBits(input);
CHECK_EQ(expected.get_bits(), output.get_bits());
}
}
......@@ -6694,17 +6695,17 @@ TEST(RunRoundUint32ToFloat32) {
TEST(RunBitcastInt32ToFloat32) {
int32_t input = 1;
float output = 0.0;
Float32 output;
RawMachineAssemblerTester<int32_t> m;
m.StoreToPointer(
&output, MachineRepresentation::kFloat32,
output.get_bits_address(), MachineRepresentation::kFloat32,
m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32())));
m.Return(m.Int32Constant(11));
FOR_INT32_INPUTS(i) {
input = *i;
CHECK_EQ(11, m.Call());
float expected = bit_cast<float>(input);
CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
Float32 expected = Float32::FromBits(input);
CHECK_EQ(expected.get_bits(), output.get_bits());
}
}
......
......@@ -248,7 +248,10 @@ class ValueHelper {
0x761c4761, 0x80000000, 0x88888888, 0xa0000000, 0xdddddddd, 0xe0000000,
0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff,
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff};
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff,
// Bit pattern of a quiet NaN and signaling NaN, with or without
// additional payload.
0x7fc00000, 0x7f800000, 0x7fffffff, 0x7f876543};
static constexpr Vector<const uint32_t> uint32_vector() {
return ArrayVector(uint32_array);
......@@ -259,32 +262,30 @@ class ValueHelper {
}
static constexpr uint64_t uint64_array[] = {
0x00000000, 0x00000001, 0xffffffff,
0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
0x00000002, 0x00000003, 0x00000004,
0x00000005, 0x00000008, 0x00000009,
0x00000000, 0x00000001, 0xffffffff, 0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000008, 0x00000009,
0xffffffffffffffff, 0xfffffffffffffffe, 0xfffffffffffffffd,
0x0000000000000000, 0x0000000100000000, 0xffffffff00000000,
0x1b09788b00000000, 0x04c5fce800000000, 0xcc0de5bf00000000,
0x0000000200000000, 0x0000000300000000, 0x0000000400000000,
0x0000000500000000, 0x0000000800000000, 0x0000000900000000,
0x273a798e187937a3, 0xece3af835495a16b, 0x0b668ecc11223344,
0x0000009e, 0x00000043, 0x0000af73,
0x0000116b, 0x00658ecc, 0x002b3b4c,
0x88776655, 0x70000000, 0x07200000,
0x7fffffff, 0x56123761, 0x7fffff00,
0x273a798e187937a3, 0xece3af835495a16b, 0x0b668ecc11223344, 0x0000009e,
0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c, 0x88776655,
0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00,
0x761c4761eeeeeeee, 0x80000000eeeeeeee, 0x88888888dddddddd,
0xa0000000dddddddd, 0xddddddddaaaaaaaa, 0xe0000000aaaaaaaa,
0xeeeeeeeeeeeeeeee, 0xfffffffdeeeeeeee, 0xf0000000dddddddd,
0x007fffffdddddddd, 0x003fffffaaaaaaaa, 0x001fffffaaaaaaaa,
0x000fffff, 0x0007ffff, 0x0003ffff,
0x0001ffff, 0x0000ffff, 0x00007fff,
0x00003fff, 0x00001fff, 0x00000fff,
0x000007ff, 0x000003ff, 0x000001ff,
0x007fffffdddddddd, 0x003fffffaaaaaaaa, 0x001fffffaaaaaaaa, 0x000fffff,
0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff, 0x00003fff,
0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff,
0x00003fffffffffff, 0x00001fffffffffff, 0x00000fffffffffff,
0x000007ffffffffff, 0x000003ffffffffff, 0x000001ffffffffff,
0x8000008000000000, 0x8000008000000001, 0x8000000000000400,
0x8000000000000401, 0x0000000000000020};
0x8000000000000401, 0x0000000000000020,
// Bit pattern of a quiet NaN and signaling NaN, with or without
// additional payload.
0x7ff8000000000000, 0x7ff0000000000000, 0x7ff8123456789abc,
0x7ff7654321fedcba};
static constexpr Vector<const uint64_t> uint64_vector() {
return ArrayVector(uint64_array);
......
......@@ -1034,6 +1034,9 @@ WASM_EXEC_TEST(BrTable_loop_target) {
WASM_EXEC_TEST(F32ReinterpretI32) {
WasmRunner<int32_t> r(execution_mode);
// TODO(clemensh): Reenable this test after fixing crbug.com/v8/6954.
if (execution_mode == kExecuteInterpreted) return;
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
BUILD(r, WASM_I32_REINTERPRET_F32(
......@@ -1048,6 +1051,9 @@ WASM_EXEC_TEST(F32ReinterpretI32) {
WASM_EXEC_TEST(I32ReinterpretF32) {
WasmRunner<int32_t, int32_t> r(execution_mode);
// TODO(clemensh): Reenable this test after fixing crbug.com/v8/6954.
if (execution_mode == kExecuteInterpreted) return;
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment