test262/implementation-contributed/javascriptcore/stress/get-array-length-on-undecided.js
test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

77 lines
1.7 KiB
JavaScript

function forceTransition() {
// We want to test the StructureCheck in testSparseArray(), not this watchpoint.
// We start with the transition so that it's nothing new.
let array = new Array();
array[100001] = "WebKit!";
}
forceTransition();
function opaqueGetArrayLength(array)
{
return array.length;
}
noInline(opaqueGetArrayLength);
function testEmptyArray()
{
let array = [];
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 0) {
throw "Failed testEmptyArray";
}
}
array = new Array();
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 0) {
throw "Failed testEmptyArray";
}
}
}
testEmptyArray();
function testUnitializedArray()
{
let array = new Array(32);
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 32) {
throw "Failed testUnitializedArray";
}
}
array = new Array();
array.length = 64
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 64) {
throw "Failed testUnitializedArray";
}
}
}
testUnitializedArray();
function testOversizedArray()
{
let array = new Array(100001);
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 100001) {
throw "Failed testOversizedArray";
}
}
}
testOversizedArray();
// This should OSR Exit and fallback to GetById to get the length.
function testSparseArray()
{
let array = new Array();
array[100001] = "WebKit!";
for (let i = 0; i < 1e6; ++i) {
if (opaqueGetArrayLength(array) !== 100002) {
throw "Failed testOversizedArray";
}
}
}
testSparseArray();