blob: 54b283efc43a11cf847185595cd250697d0fd082 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// Copyright 2016 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 foo() {
8 return function(c) {
9 var double_var = [3.0, 3.5][0];
10 var literal = c ? [1, double_var] : [double_var, 3.5];
11 return literal[0];
12 };
13}
14
15var f1 = foo();
16var f2 = foo();
17
18// Both closures point to full code.
19f1(false);
20f2(false);
21
22// Optimize f1, but don't initialize the [1, double_var] literal.
23%OptimizeFunctionOnNextCall(f1);
24f1(false);
25
26// Initialize the [1, double_var] literal, and transition the boilerplate to
27// double.
28f2(true);
29
30// Trick crankshaft into writing double_var at the wrong position.
31var l = f1(true);
32assertEquals(1, l);