diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-08 15:36:35 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-08 15:36:35 -0800 |
commit | 78a8208beb12e3a1640670dc9a8fc4ecbb4b6085 (patch) | |
tree | 92f41e100b6cadea544e02474296a481b83592c4 | |
parent | ca0dc47b386a74e0493be77cfcbdcd7cd2fff61f (diff) | |
download | binaryen-78a8208beb12e3a1640670dc9a8fc4ecbb4b6085.tar.gz binaryen-78a8208beb12e3a1640670dc9a8fc4ecbb4b6085.tar.bz2 binaryen-78a8208beb12e3a1640670dc9a8fc4ecbb4b6085.zip |
nan fixes
-rwxr-xr-x | check.py | 2 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 1 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 23 |
3 files changed, 18 insertions, 8 deletions
@@ -80,7 +80,7 @@ for t in tests: print '\n[ checking wasm-shell spec testcases... ]\n' if len(requested) == 0: - BLACKLIST = ['float_literals.wast', 'float_misc.wast'] + BLACKLIST = ['float_misc.wast'] spec_tests = [os.path.join('spec', t) for t in sorted(os.listdir(os.path.join('test', 'spec'))) if t not in BLACKLIST] else: spec_tests = requested[:] diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 353352d8e..a3fe78666 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -611,7 +611,6 @@ private: } } case ReinterpretFloat: { - if (value.type == f64 && isnan(value.getf64())) return Literal((int64_t)0x7ff8000000000000); // canonicalized return curr->type == i32 ? Literal(value.reinterpreti32()) : Literal(value.reinterpreti64()); } case ConvertUInt32: return curr->type == f32 ? Literal(float(uint32_t(value.geti32()))) : Literal(double(uint32_t(value.geti32()))); diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 4f1cd09c7..672880fe0 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -709,16 +709,21 @@ private: bool negative = str[0] == '-'; const char *positive = negative ? str + 1 : str; if (positive[0] == '+') positive++; - if (positive[0] == 'n' && positive[1] == 'a' && positive[2] == 'n' && positive[3] == ':') { - assert(positive[4] == '0' && positive[5] == 'x'); + if (positive[0] == 'n' && positive[1] == 'a' && positive[2] == 'n') { + const char * modifier = positive[3] == ':' ? positive + 4 : nullptr; + assert(modifier ? positive[4] == '0' && positive[5] == 'x' : 1); switch (type) { case f32: { union { uint32_t pattern; float f; } u; - std::istringstream istr(positive+4); - istr >> std::hex >> u.pattern; + if (modifier) { + std::istringstream istr(modifier); + istr >> std::hex >> u.pattern; + } else { + u.pattern = 0x7fc00000; + } u.pattern |= 0x7f800000; if (negative) u.pattern |= 0x80000000; if (!isnan(u.f)) u.pattern |= 1; @@ -731,8 +736,12 @@ private: uint64_t pattern; double d; } u; - std::istringstream istr(positive+4); - istr >> std::hex >> u.pattern; + if (modifier) { + std::istringstream istr(modifier); + istr >> std::hex >> u.pattern; + } else { + u.pattern = 0x7ff8000000000000; + } u.pattern |= 0x7ff0000000000000LL; if (negative) u.pattern |= 0x8000000000000000LL; if (!isnan(u.d)) u.pattern |= 1; @@ -791,11 +800,13 @@ private: case f32: { char *end; ret->value.f32 = strtof(str, &end); + assert(!isnan(ret->value.f32)); break; } case f64: { char *end; ret->value.f64 = strtod(str, &end); + assert(!isnan(ret->value.f64)); break; } default: onError(); |