Commit fb7ee44c authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm][asm.js] Fix errata 5.4, allow fround on int literal.s

asm.js errata on section 5.4 allows fround of numeric literals
without '.'.

BUG=v8:4203
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2552243002
Cr-Commit-Position: refs/heads/master@{#41510}
parent df2fc5ef
...@@ -2814,14 +2814,12 @@ AsmType* AsmTyper::VariableTypeAnnotations( ...@@ -2814,14 +2814,12 @@ AsmType* AsmTyper::VariableTypeAnnotations(
"to fround."); "to fround.");
} }
// Float constants must contain dots in local, but not in globals. // ERRATA: 5.4
if (mutability_type == VariableInfo::kLocal) { // According to the spec: float constants must contain dots in local,
if (!src_expr->raw_value()->ContainsDot()) { // but not in globals.
FAIL(initializer, // However, the errata doc (and actual programs), use integer values
"Invalid float type annotation - expected literal argument to be a " // with fround(..).
"floating point literal."); // Skipping the check that would go here to enforce this.
}
}
return AsmType::Float(); return AsmType::Float();
} }
......
...@@ -1649,6 +1649,19 @@ function TestDotfulFloat(stdlib) { ...@@ -1649,6 +1649,19 @@ function TestDotfulFloat(stdlib) {
assertWasm(55, TestDotfulFloat); assertWasm(55, TestDotfulFloat);
function TestDotfulLocalFloat(stdlib) {
"use asm";
var fround = stdlib.Math.fround;
function caller() {
var foo = fround(55.0);
return +foo;
}
return {caller: caller};
}
assertWasm(55, TestDotfulLocalFloat);
function TestDotlessFloat(stdlib) { function TestDotlessFloat(stdlib) {
"use asm"; "use asm";
var fround = stdlib.Math.fround; var fround = stdlib.Math.fround;
...@@ -1662,6 +1675,19 @@ function TestDotlessFloat(stdlib) { ...@@ -1662,6 +1675,19 @@ function TestDotlessFloat(stdlib) {
assertWasm(55, TestDotlessFloat); assertWasm(55, TestDotlessFloat);
function TestDotlessLocalFloat(stdlib) {
"use asm";
var fround = stdlib.Math.fround;
function caller() {
var foo = fround(55);
return +foo;
}
return {caller: caller};
}
assertWasm(55, TestDotlessLocalFloat);
function TestFloatGlobals(stdlib) { function TestFloatGlobals(stdlib) {
"use asm"; "use asm";
var fround = stdlib.Math.fround; var fround = stdlib.Math.fround;
......
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