nodejs/deps/v8/test/mjsunit/regress/regress-crbug-1335445.js
Michaël Zasso 6bd756d7c6
deps: update V8 to 10.7.193.13
PR-URL: https://github.com/nodejs/node/pull/44741
Fixes: https://github.com/nodejs/node/issues/44650
Fixes: https://github.com/nodejs/node/issues/37472
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-11 07:24:33 +02:00

38 lines
1.1 KiB
JavaScript

// Copyright 2022 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.
// This test checks that indexOf correctly sees that -0.0 == 0 when using its
// SIMD fast path on unaligned FixedDoubleArrays. The issue with testing that is
// that when creating an array from JavaScript, it's not possible to ensure that
// it will be unaligned. Thus, we wrapped the test in a loop, which additionally
// allocates some objects (or variable size), so that the array is eventually
// not aligned. In practice, this looks fairly reliable: about half the arrays
// are aligned on 8 bytes, and half are not.
// We store all the objects we create in this array, so that escape analysis
// doesn't get rid of allocations.
let objects = [];
for (let i = 0; i < 100; i++) {
for (let x = 0; x < i; x++) {
if (i % 2 == 0) {
objects.push({ i: 35 });
} else {
objects.push({ i: 35, "a":42 });
}
}
let arr = Array();
objects.push(arr);
for (let i = 0; i < 100; i++) {
arr[i] = 1.5;
}
arr[20] = -0.0;
arr[23] = 0;
assertEquals(20, arr.indexOf(0));
}