regress-4121.js 1.21 KB
Newer Older
1 2 3 4
// Copyright 2015 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.

5
// Flags: --allow-natives-syntax --no-always-opt
6

7 8 9
function literals_sharing_test(warmup, optimize) {
  function closure() {
    // Ensure small array literals start in specific element kind mode.
10 11 12 13 14
    assertTrue(%HasSmiElements([]));
    assertTrue(%HasSmiElements([1]));
    assertTrue(%HasSmiElements([1,2]));
    assertTrue(%HasDoubleElements([1.1]));
    assertTrue(%HasDoubleElements([1.1,2]));
15 16 17 18

    var a = [1, 2, 3];
    if (warmup) {
      // Transition elements kind during warmup...
19
      assertTrue(%HasSmiElements(a));
20 21 22 23
      assertEquals(4, a.push(1.3));
    }
    // ... and ensure that the information about transitioning is
    // propagated to the next closure.
24
    assertTrue(%HasDoubleElements(a));
25 26 27
  };
  if (optimize) %OptimizeFunctionOnNextCall(closure);
  closure();
28 29 30
}


31
function test() {
32
  var warmup = true;
33 34 35
  for (var i = 0; i < 3; i++) {
    print("iter: " + i + ", warmup: "+ warmup);
    literals_sharing_test(warmup, false);
36
    warmup = false;
37 38 39 40
  }
  print("iter: " + i + ", opt: true");
  literals_sharing_test(warmup, true);
}
41

42
test();