v8/test/mjsunit/regress/regress-crbug-898974.js
Michael Starzinger 545fa6e51a [asm.js] Fix storing float32 value into float64 heap view.
The valid store types of a {Float64Array} heap view are specified to be
"float?" and "double?". We correctly accepted both types but forgot to
emit the appropriate conversion in the "float?" case. This just adds the
missing conversion expression.

R=clemensh@chromium.org
TEST=mjsunit/regress/regress-crbug-898974
BUG=chromium:898974,v8:8347

Change-Id: I306b10e2088185b1522da29b1a113908ef9925f2
Reviewed-on: https://chromium-review.googlesource.com/c/1301499
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57025}
2018-10-26 11:33:23 +00:00

35 lines
1.0 KiB
JavaScript

// Copyright 2018 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.
// Flags: --allow-natives-syntax
function Module(global, env, buffer) {
"use asm";
var HEAPF64 = new global.Float64Array(buffer);
var HEAPF32 = new global.Float32Array(buffer);
var Math_fround = global.Math.fround;
function main_d_f() {
HEAPF64[0] = Math_fround(+HEAPF64[0]);
}
function main_d_fq() {
HEAPF64[1] = HEAPF32[4096];
}
function main_f_dq() {
HEAPF32[4] = HEAPF64[4096];
}
return {main_d_f: main_d_f, main_d_fq: main_d_fq, main_f_dq: main_f_dq};
};
let buffer = new ArrayBuffer(4096);
let module = Module(this, undefined, buffer);
let view64 = new Float64Array(buffer);
let view32 = new Float32Array(buffer);
assertEquals(view64[0] = 2.3, view64[0]);
module.main_d_f();
module.main_d_fq();
module.main_f_dq();
assertTrue(%IsAsmWasmCode(Module));
assertEquals(Math.fround(2.3), view64[0]);
assertTrue(isNaN(view64[1]));
assertTrue(isNaN(view32[4]));