1830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org// Copyright 2012 the V8 project authors. All rights reserved.
2394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// Redistribution and use in source and binary forms, with or without
3394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// modification, are permitted provided that the following conditions are
4394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// met:
5394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//
6394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//     * Redistributions of source code must retain the above copyright
7394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       notice, this list of conditions and the following disclaimer.
8394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//     * Redistributions in binary form must reproduce the above
9394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       copyright notice, this list of conditions and the following
10394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       disclaimer in the documentation and/or other materials provided
11394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       with the distribution.
12394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//     * Neither the name of Google Inc. nor the names of its
13394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       contributors may be used to endorse or promote products derived
14394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//       from this software without specific prior written permission.
15394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com//
16394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
28471f2f1d24adb4bad1edc3bf0ee35092486de187mstarzinger@chromium.org// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
29471f2f1d24adb4bad1edc3bf0ee35092486de187mstarzinger@chromium.org
30394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// Test element kind of objects.
31394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// Since --smi-only-arrays affects builtins, its default setting at compile
32394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// time sticks if built with snapshot.  If --smi-only-arrays is deactivated
33394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// by default, only a no-snapshot build actually has smi-only arrays enabled
34394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// in this test case.  Depending on whether smi-only arrays are actually
35394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// enabled, this test takes the appropriate code path to check smi-only arrays.
36394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
37830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.orgsupport_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]);
3864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
3964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.orgif (support_smi_only_arrays) {
4064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  print("Tests include smi-only arrays.");
4164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org} else {
4264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  print("Tests do NOT include smi-only arrays.");
4364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org}
44394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
45394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com// IC and Crankshaft support for smi-only elements in dynamic array literals.
46394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.comfunction get(foo) { return foo; }  // Used to generate dynamic values.
47394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
48394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.comfunction array_literal_test() {
49394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var a0 = [1, 2, 3];
50830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastSmiElements(a0));
51394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var a1 = [get(1), get(2), get(3)];
52830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastSmiElements(a1));
53394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
54394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var b0 = [1, 2, get("three")];
55830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastObjectElements(b0));
56394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var b1 = [get(1), get(2), get("three")];
57830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastObjectElements(b1));
58394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
59394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var c0 = [1, 2, get(3.5)];
60394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertTrue(%HasFastDoubleElements(c0));
61394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(3.5, c0[2]);
62394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, c0[1]);
63394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, c0[0]);
64394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
65394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var c1 = [1, 2, 3.5];
66394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertTrue(%HasFastDoubleElements(c1));
67394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(3.5, c1[2]);
68394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, c1[1]);
69394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, c1[0]);
70394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
71394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var c2 = [get(1), get(2), get(3.5)];
72394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertTrue(%HasFastDoubleElements(c2));
73394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(3.5, c2[2]);
74394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, c2[1]);
75394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, c2[0]);
76394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
77394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var object = new Object();
78394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var d0 = [1, 2, object];
79830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastObjectElements(d0));
80394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(object, d0[2]);
81394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, d0[1]);
82394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, d0[0]);
83394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
84394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var e0 = [1, 2, 3.5];
85394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertTrue(%HasFastDoubleElements(e0));
86394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(3.5, e0[2]);
87394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, e0[1]);
88394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, e0[0]);
89394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
90394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  var f0 = [1, 2, [1, 2]];
91830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org  assertTrue(%HasFastObjectElements(f0));
92394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals([1,2], f0[2]);
93394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(2, f0[1]);
94394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  assertEquals(1, f0[0]);
95394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com}
96394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
97394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.comif (support_smi_only_arrays) {
98394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  for (var i = 0; i < 3; i++) {
99394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    array_literal_test();
100394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  }
101394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  %OptimizeFunctionOnNextCall(array_literal_test);
102394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  array_literal_test();
103394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
104394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  function test_large_literal() {
105394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
106394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    function d() {
107394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com      gc();
108394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com      return 2.5;
109394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    }
110394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
111394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    function o() {
112394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com      gc();
113394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com      return new Object();
114394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    }
115394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
116394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    large =
117394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com        [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ];
118394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    assertFalse(%HasDictionaryElements(large));
119830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org    assertFalse(%HasFastSmiElements(large));
120394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    assertFalse(%HasFastDoubleElements(large));
121830d30c478be03b0ac560f4002833ab141e41effsvenpanne@chromium.org    assertTrue(%HasFastObjectElements(large));
122394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    assertEquals(large,
123394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                 [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
124394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                  new Object(), new Object(), new Object(), new Object()]);
125394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  }
126394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
127394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  for (var i = 0; i < 3; i++) {
128394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    test_large_literal();
129394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  }
130394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  %OptimizeFunctionOnNextCall(test_large_literal);
131394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  test_large_literal();
13264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
13364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  function deopt_array(use_literal) {
13464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org    if (use_literal) {
13564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org      return [.5, 3, 4];
13664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org    }  else {
13764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org      return new Array();
13864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org    }
13964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  }
14064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
14164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array(false);
14264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array(false);
14364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array(false);
14464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  %OptimizeFunctionOnNextCall(deopt_array);
14564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  var array = deopt_array(false);
146ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertOptimized(deopt_array);
14764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array(true);
148ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertOptimized(deopt_array);
14964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array(false);
150ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertOptimized(deopt_array);
15164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
15264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  // Check that unexpected changes in the objects stored into the boilerplate
15364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  // also force a deopt.
15464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  function deopt_array_literal_all_smis(a) {
15564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org    return [0, 1, a];
15664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  }
15764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
15864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_smis(2);
15964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_smis(3);
16064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_smis(4);
16164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_smis(4);
16264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0, array[0]);
16364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
16464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(4, array[2]);
16564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis);
16664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_smis(5);
16764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_smis(6);
168ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertOptimized(deopt_array_literal_all_smis);
16964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0, array[0]);
17064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
17164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(6, array[2]);
17264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
17364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_smis(.5);
174ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertUnoptimized(deopt_array_literal_all_smis);
17564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0, array[0]);
17664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
17764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(.5, array[2]);
17864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
17964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  function deopt_array_literal_all_doubles(a) {
18064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org    return [0.5, 1, a];
18164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  }
18264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
18364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_doubles(.5);
18464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_doubles(.5);
18564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  deopt_array_literal_all_doubles(.5);
18664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_doubles(0.5);
18764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0.5, array[0]);
18864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
18964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0.5, array[2]);
19064e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles);
19164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_doubles(5);
19264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_doubles(6);
193ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertOptimized(deopt_array_literal_all_doubles);
19464e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0.5, array[0]);
19564e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
19664e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(6, array[2]);
19764e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org
19864e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  var foo = new Object();
19964e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  array = deopt_array_literal_all_doubles(foo);
200ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  assertUnoptimized(deopt_array_literal_all_doubles);
20164e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(0.5, array[0]);
20264e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(1, array[1]);
20364e3a4be4a99f31920128de34573c8ac9038de42ricow@chromium.org  assertEquals(foo, array[2]);
204394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com}
2057ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org
2067ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org(function literals_after_osr() {
2077ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org  var color = [0];
208935781b3604caa053bf75ce6b1079d79a225e63fdanno@chromium.org  // Trigger OSR, if optimization is not disabled.
209935781b3604caa053bf75ce6b1079d79a225e63fdanno@chromium.org  if (%GetOptimizationStatus(literals_after_osr) != 4) {
210935781b3604caa053bf75ce6b1079d79a225e63fdanno@chromium.org    while (%GetOptimizationCount(literals_after_osr) == 0) {}
211935781b3604caa053bf75ce6b1079d79a225e63fdanno@chromium.org  }
2127ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org  return [color[0]];
2137ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org})();
214