Commit f8502357 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[mjsunit] Speed up test by using const

Bug: v8:7783
Change-Id: I0399d20c990e40b1a6dad8a7c12eb6fbce022d12
Reviewed-on: https://chromium-review.googlesource.com/1101028Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53739}
parent 95bc6c7b
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
%NeverOptimizeFunction(test);
function test() {
var iteration_count = 1;
const iteration_count = 1;
function transition1(a, i, v) {
a[i] = v;
......@@ -40,14 +17,14 @@ function test() {
// Test PACKED SMI -> PACKED DOUBLE
//
var a1 = [0, 1, 2, 3, 4];
const a1 = [0, 1, 2, 3, 4];
transition1(a1, 0, 2.5);
var a2 = [0, 1, 2, 3, 4];
const a2 = [0, 1, 2, 3, 4];
transition1(a2, 0, 2.5);
assertFalse(%HasHoleyElements(a2));
%OptimizeFunctionOnNextCall(transition1);
var a3 = [0, 1, 2, 3, 4];
const a3 = [0, 1, 2, 3, 4];
assertTrue(%HasSmiElements(a3));
transition1(a3, 0, 2.5);
assertFalse(%HasHoleyElements(a3));
......@@ -55,7 +32,7 @@ function test() {
assertEquals(2.5, a3[0]);
// Test handling of hole.
var a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
a4.length = 7;
assertTrue(%HasSmiElements(a4));
transition1(a4, 0, 2.5);
......@@ -65,7 +42,7 @@ function test() {
// Large array should deopt to runtimea
for (j = 0; j < iteration_count; ++j) {
a5 = new Array();
const a5 = new Array();
for (i = 0; i < 0x40000; ++i) {
a5[i] = 0;
}
......@@ -82,14 +59,14 @@ function test() {
a[i] = v;
}
var b1 = [0, 1, 2, , 4];
const b1 = [0, 1, 2, , 4];
transition2(b1, 0, 2.5);
var b2 = [0, 1, 2, , 4];
const b2 = [0, 1, 2, , 4];
transition2(b2, 0, 2.5);
assertTrue(%HasHoleyElements(b2));
%OptimizeFunctionOnNextCall(transition2);
var b3 = [0, 1, 2, , 4];
const b3 = [0, 1, 2, , 4];
assertTrue(%HasSmiElements(b3));
assertTrue(%HasHoleyElements(b3));
transition2(b3, 0, 2.5);
......@@ -99,7 +76,7 @@ function test() {
// Large array should deopt to runtime
for (j = 0; j < iteration_count; ++j) {
b4 = [0, ,0];
const b4 = [0, ,0];
for (i = 3; i < 0x40000; ++i) {
b4[i] = 0;
}
......@@ -116,15 +93,15 @@ function test() {
a[i] = v;
}
var c1 = [0, 1, 2, 3.5, 4];
const c1 = [0, 1, 2, 3.5, 4];
transition3(c1, 0, new Object());
var c2 = [0, 1, 2, 3.5, 4];
const c2 = [0, 1, 2, 3.5, 4];
transition3(c2, 0, new Object());
assertTrue(%HasObjectElements(c2));
assertTrue(!%HasHoleyElements(c2));
%OptimizeFunctionOnNextCall(transition3);
var c3 = [0, 1, 2, 3.5, 4];
const c3 = [0, 1, 2, 3.5, 4];
assertTrue(%HasDoubleElements(c3));
assertTrue(!%HasHoleyElements(c3));
transition3(c3, 0, new Array());
......@@ -136,7 +113,7 @@ function test() {
// Large array under the deopt threshold should be able to trigger GC without
// causing crashes.
for (j = 0; j < iteration_count; ++j) {
c4 = [0, 2.5, 0];
const c4 = [0, 2.5, 0];
for (i = 3; i < 0xa000; ++i) {
c4[i] = 0;
}
......@@ -150,7 +127,7 @@ function test() {
// Large array should deopt to runtime
for (j = 0; j < iteration_count; ++j) {
c5 = [0, 2.5, 0];
const c5 = [0, 2.5, 0];
for (i = 3; i < 0x40000; ++i) {
c5[i] = 0;
}
......@@ -170,15 +147,15 @@ function test() {
a[i] = v;
}
var d1 = [0, 1, , 3.5, 4];
const d1 = [0, 1, , 3.5, 4];
transition4(d1, 0, new Object());
var d2 = [0, 1, , 3.5, 4];
const d2 = [0, 1, , 3.5, 4];
transition4(d2, 0, new Object());
assertTrue(%HasObjectElements(d2));
assertTrue(%HasHoleyElements(d2));
%OptimizeFunctionOnNextCall(transition4);
var d3 = [0, 1, , 3.5, 4];
const d3 = [0, 1, , 3.5, 4];
assertTrue(%HasDoubleElements(d3));
assertTrue(%HasHoleyElements(d3));
transition4(d3, 0, new Array());
......@@ -190,7 +167,7 @@ function test() {
// Large array under the deopt threshold should be able to trigger GC without
// causing crashes.
for (j = 0; j < iteration_count; ++j) {
d4 = [, 2.5, ,];
const d4 = [, 2.5, ,];
for (i = 3; i < 0xa000; ++i) {
d4[i] = 0;
}
......@@ -205,7 +182,7 @@ function test() {
// Large array should deopt to runtime
for (j = 0; j < iteration_count; ++j) {
d5 = [, 2.5, ,];
const d5 = [, 2.5, ,];
for (i = 3; i < 0x40000; ++i) {
d5[i] = 0;
}
......
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