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(
"to fround.");
}
// Float constants must contain dots in local, but not in globals.
if (mutability_type == VariableInfo::kLocal) {
if (!src_expr->raw_value()->ContainsDot()) {
FAIL(initializer,
"Invalid float type annotation - expected literal argument to be a "
"floating point literal.");
}
}
// ERRATA: 5.4
// According to the spec: float constants must contain dots in local,
// but not in globals.
// However, the errata doc (and actual programs), use integer values
// with fround(..).
// Skipping the check that would go here to enforce this.
return AsmType::Float();
}
......
......@@ -1649,6 +1649,19 @@ function TestDotfulFloat(stdlib) {
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) {
"use asm";
var fround = stdlib.Math.fround;
......@@ -1662,6 +1675,19 @@ function TestDotlessFloat(stdlib) {
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) {
"use asm";
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