v8/test/mjsunit/asm/b5528-comma.js
jpp 07ac97835d [V8][asm.js] Fixes a bug in comma-expression validation.
Comma expressions need to special-handle function calls. When validating
the rhs of a Comma, the validatior needs to ensure that it returns
AsmType::Float() if the function being called is fround().

BUG= https://bugs.chromium.org/p/v8/issues/detail?id=5528

Review-Url: https://chromiumcodereview.appspot.com/2426473007
Cr-Commit-Position: refs/heads/master@{#40408}
2016-10-18 19:05:42 +00:00

32 lines
1.1 KiB
JavaScript

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function Module(stdlib, env, heap) {
"use asm";
var a = new stdlib.Int32Array(heap);
var b = new stdlib.Float32Array(heap);
var fround = stdlib.Math.fround;
var value = env.value|0;
function foo() {
var x = fround(0.0);
x = (a[0]=value|0,fround(b[0]));
return fround(x);
}
return { foo: foo };
}
var buffer = new ArrayBuffer(32);
assertEquals(0.0, Module(this, {value: 0x00000000}, buffer).foo());
assertEquals(-0.0, Module(this, {value: 0x80000000}, buffer).foo());
assertEquals(5.0, Module(this, {value: 0x40a00000}, buffer).foo());
assertEquals(-5.0, Module(this, {value: 0xc0a00000}, buffer).foo());
assertEquals(129.375, Module(this, {value: 0x43016000}, buffer).foo());
assertEquals(-129.375, Module(this, {value: 0xc3016000}, buffer).foo());
assertEquals(Infinity, Module(this, {value: 0x7f800000}, buffer).foo());
assertEquals(-Infinity, Module(this, {value: 0xff800000}, buffer).foo());
assertEquals(NaN, Module(this, {value: 0x7fffffff}, buffer).foo());