blob: 68e1b6308821751ca7e62d4cdb73f63bad497051 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7function boom(a1, a2) {
8 // Do something with a2 that needs a map check (for DOUBLE_ELEMENTS).
9 var s = a2[0];
10 // Emit a load that transitions a1 to FAST_ELEMENTS.
11 var t = a1[0];
12 // Emit a store to a2 that assumes DOUBLE_ELEMENTS.
13 // The map check is considered redundant and will be eliminated.
14 a2[0] = 0.3;
15}
16
17// Prepare type feedback for the "t = a1[0]" load: fast elements.
18var fast_elem = new Array(1);
19fast_elem[0] = "tagged";
20boom(fast_elem, [1]);
21
22// Prepare type feedback for the "a2[0] = 0.3" store: double elements.
23var double_elem = new Array(1);
24double_elem[0] = 0.1;
25boom(double_elem, double_elem);
26
27// Reset |double_elem| and go have a party.
28double_elem = new Array(10);
29double_elem[0] = 0.1;
30
31%OptimizeFunctionOnNextCall(boom);
32boom(double_elem, double_elem);
33
34assertEquals(0.3, double_elem[0]);
35assertEquals(undefined, double_elem[1]);