diff options
author | Ben Smith <binjimin@gmail.com> | 2017-03-24 14:44:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 14:44:37 -0700 |
commit | aad6e98314bc4225dca7e12aa9795cb0ad87f21e (patch) | |
tree | f1b7ad8914a19a169e9e256f0a1dd211616df3c8 /src/binary-writer-spec.cc | |
parent | 41d597d678b6443d9e8a692316271ceafd8bcc2d (diff) | |
download | wabt-aad6e98314bc4225dca7e12aa9795cb0ad87f21e.tar.gz wabt-aad6e98314bc4225dca7e12aa9795cb0ad87f21e.tar.bz2 wabt-aad6e98314bc4225dca7e12aa9795cb0ad87f21e.zip |
Support arithmetic/canonical NaN; update testsuite (#368)
Positive NaN (+nan) is defined as being a NaN value where the sign bit
is clear, the exponent is all ones, and the tag has only the "quiet" bit
set. The quiet bit is the most-significant bit of the tag. For example,
for a 32-bit float, +nan is 0x7cf00000.
"Canonical NaN" is either +nan or -nan, where -nan is +nan with the sign
bit set.
"Arithmetic NaN" is defined as any other quiet NaN (i.e. the quiet bit
must be set, but any other bit can be either 0 or 1.)
This change doesn't update the interpreter because it is only a
loosening of the previous NaN behavior.
Diffstat (limited to 'src/binary-writer-spec.cc')
-rw-r--r-- | src/binary-writer-spec.cc | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/binary-writer-spec.cc b/src/binary-writer-spec.cc index dac091a3..d87fe820 100644 --- a/src/binary-writer-spec.cc +++ b/src/binary-writer-spec.cc @@ -137,11 +137,20 @@ static void write_escaped_string_slice(Context* ctx, StringSlice ss) { static void write_command_type(Context* ctx, const Command& command) { static const char* s_command_names[] = { - "module", "action", "register", "assert_malformed", "assert_invalid", + "module", + "action", + "register", + "assert_malformed", + "assert_invalid", nullptr, /* ASSERT_INVALID_NON_BINARY, this command will never be written */ - "assert_unlinkable", "assert_uninstantiable", "assert_return", - "assert_return_nan", "assert_trap", "assert_exhaustion", + "assert_unlinkable", + "assert_uninstantiable", + "assert_return", + "assert_return_canonical_nan", + "assert_return_arithmetic_nan", + "assert_trap", + "assert_exhaustion", }; WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_command_names) == kCommandTypeCount); @@ -425,14 +434,24 @@ static void write_commands(Context* ctx, Script* script) { write_const_vector(ctx, *command.assert_return.expected); break; - case CommandType::AssertReturnNan: - write_location(ctx, &command.assert_return_nan.action->loc); + case CommandType::AssertReturnCanonicalNan: + write_location(ctx, &command.assert_return_canonical_nan.action->loc); write_separator(ctx); - write_action(ctx, command.assert_return_nan.action); + write_action(ctx, command.assert_return_canonical_nan.action); write_separator(ctx); write_key(ctx, "expected"); write_action_result_type(ctx, script, - command.assert_return_nan.action); + command.assert_return_canonical_nan.action); + break; + + case CommandType::AssertReturnArithmeticNan: + write_location(ctx, &command.assert_return_arithmetic_nan.action->loc); + write_separator(ctx); + write_action(ctx, command.assert_return_arithmetic_nan.action); + write_separator(ctx); + write_key(ctx, "expected"); + write_action_result_type(ctx, script, + command.assert_return_arithmetic_nan.action); break; case CommandType::AssertTrap: |