зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1253884 - Baldr: fix parsing of (f32.const -0) (r=sunfish)
MozReview-Commit-ID: DEDehyShLqw
This commit is contained in:
Родитель
22efc12d22
Коммит
03b7302b4c
|
@ -784,6 +784,7 @@ class WasmToken
|
||||||
UnsignedInteger,
|
UnsignedInteger,
|
||||||
SignedInteger,
|
SignedInteger,
|
||||||
Memory,
|
Memory,
|
||||||
|
NegativeZero,
|
||||||
Load,
|
Load,
|
||||||
Local,
|
Local,
|
||||||
Loop,
|
Loop,
|
||||||
|
@ -1271,6 +1272,8 @@ WasmTokenStream::literal(const char16_t* begin)
|
||||||
|
|
||||||
if (*begin == '-') {
|
if (*begin == '-') {
|
||||||
uint64_t value = u.value();
|
uint64_t value = u.value();
|
||||||
|
if (value == 0)
|
||||||
|
return WasmToken(WasmToken::NegativeZero, begin, cur_);
|
||||||
if (value > uint64_t(INT64_MIN))
|
if (value > uint64_t(INT64_MIN))
|
||||||
return LexHexFloatLiteral(begin, end_, &cur_);
|
return LexHexFloatLiteral(begin, end_, &cur_);
|
||||||
|
|
||||||
|
@ -1295,6 +1298,8 @@ WasmTokenStream::literal(const char16_t* begin)
|
||||||
|
|
||||||
if (*begin == '-') {
|
if (*begin == '-') {
|
||||||
uint64_t value = u.value();
|
uint64_t value = u.value();
|
||||||
|
if (value == 0)
|
||||||
|
return WasmToken(WasmToken::NegativeZero, begin, cur_);
|
||||||
if (value > uint64_t(INT64_MIN))
|
if (value > uint64_t(INT64_MIN))
|
||||||
return LexDecFloatLiteral(begin, end_, &cur_);
|
return LexDecFloatLiteral(begin, end_, &cur_);
|
||||||
|
|
||||||
|
@ -2270,6 +2275,9 @@ ParseFloatLiteral(WasmParseContext& c, WasmToken token, Float* result)
|
||||||
case WasmToken::SignedInteger:
|
case WasmToken::SignedInteger:
|
||||||
*result = token.sint();
|
*result = token.sint();
|
||||||
return true;
|
return true;
|
||||||
|
case WasmToken::NegativeZero:
|
||||||
|
*result = -0.0;
|
||||||
|
return true;
|
||||||
case WasmToken::Float:
|
case WasmToken::Float:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2345,6 +2353,8 @@ ParseConst(WasmParseContext& c, WasmToken constToken)
|
||||||
break;
|
break;
|
||||||
return new(c.lifo) WasmAstConst(Val(uint32_t(sint.value())));
|
return new(c.lifo) WasmAstConst(Val(uint32_t(sint.value())));
|
||||||
}
|
}
|
||||||
|
case WasmToken::NegativeZero:
|
||||||
|
return new(c.lifo) WasmAstConst(Val(uint32_t(0)));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2358,6 +2368,8 @@ ParseConst(WasmParseContext& c, WasmToken constToken)
|
||||||
return new(c.lifo) WasmAstConst(Val(val.uint()));
|
return new(c.lifo) WasmAstConst(Val(val.uint()));
|
||||||
case WasmToken::SignedInteger:
|
case WasmToken::SignedInteger:
|
||||||
return new(c.lifo) WasmAstConst(Val(uint64_t(val.sint())));
|
return new(c.lifo) WasmAstConst(Val(uint64_t(val.sint())));
|
||||||
|
case WasmToken::NegativeZero:
|
||||||
|
return new(c.lifo) WasmAstConst(Val(uint32_t(0)));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,11 @@ testConst('i32', '0xffffffff', -1);
|
||||||
//testConst('i64', '0xffffffffffffffff', -1); // TODO: NYI
|
//testConst('i64', '0xffffffffffffffff', -1); // TODO: NYI
|
||||||
|
|
||||||
testConst('f32', '0.0', 0.0);
|
testConst('f32', '0.0', 0.0);
|
||||||
|
testConst('f32', '-0', -0.0);
|
||||||
testConst('f32', '-0.0', -0.0);
|
testConst('f32', '-0.0', -0.0);
|
||||||
testConst('f32', '0x0.0', 0.0);
|
testConst('f32', '0x0.0', 0.0);
|
||||||
testConst('f32', '-0x0.0', -0.0);
|
testConst('f32', '-0x0.0', -0.0);
|
||||||
|
testConst('f32', '-0x0', -0.0);
|
||||||
testConst('f32', '0x0.0p0', 0.0);
|
testConst('f32', '0x0.0p0', 0.0);
|
||||||
testConst('f32', '-0x0.0p0', -0.0);
|
testConst('f32', '-0x0.0p0', -0.0);
|
||||||
testConst('f32', 'infinity', Infinity);
|
testConst('f32', 'infinity', Infinity);
|
||||||
|
@ -126,8 +128,10 @@ testConst('f32', '0', 0);
|
||||||
|
|
||||||
testConst('f64', '0.0', 0.0);
|
testConst('f64', '0.0', 0.0);
|
||||||
testConst('f64', '-0.0', -0.0);
|
testConst('f64', '-0.0', -0.0);
|
||||||
|
testConst('f64', '-0', -0.0);
|
||||||
testConst('f64', '0x0.0', 0.0);
|
testConst('f64', '0x0.0', 0.0);
|
||||||
testConst('f64', '-0x0.0', -0.0);
|
testConst('f64', '-0x0.0', -0.0);
|
||||||
|
testConst('f64', '-0x0', -0.0);
|
||||||
testConst('f64', '0x0.0p0', 0.0);
|
testConst('f64', '0x0.0p0', 0.0);
|
||||||
testConst('f64', '-0x0.0p0', -0.0);
|
testConst('f64', '-0x0.0p0', -0.0);
|
||||||
testConst('f64', 'infinity', Infinity);
|
testConst('f64', 'infinity', Infinity);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче