summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/array-push-2.js
blob: cb18d71d636d51cda1701b680c8642dfec74d89c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2017 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 --opt

// Test elements transition from SMI to DOUBLE.
(function() {
  const a = [];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo(5, 6.6);
  assertEquals([1, 2, 3, 4, 5, 6.6], a);
})();
(function() {
  const a = [];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo(5.5, 6.6);
  assertEquals([1, 2, 3, 4, 5.5, 6.6], a);
})();

// Test elements transition from SMI to OBJECT.
(function() {
  const a = [];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo(5, '6');
  assertEquals([1, 2, 3, 4, 5, '6'], a);
})();
(function() {
  const a = [];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo('5', '6');
  assertEquals([1, 2, 3, 4, '5', '6'], a);
})();

// Test elements transition from DOUBLE to OBJECT.
(function() {
  const a = [0.5];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo(5, '6');
  assertEquals([0.5, 1, 2, 3, 4, 5, '6'], a);
})();
(function() {
  const a = [0.5];
  const foo = (x, y) => a.push(x, y);
  foo(1, 2);
  foo(3, 4);
  %OptimizeFunctionOnNextCall(foo);
  foo('5', '6');
  assertEquals([0.5, 1, 2, 3, 4, '5', '6'], a);
})();