blob: e9f2a9aaf58aa4c59dd1ecba433de549a485f91a [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 f1(a, i) {
8 return a[i] + 0.5;
9}
10var arr = [,0.0,2.5];
11assertEquals(0.5, f1(arr, 1));
12assertEquals(0.5, f1(arr, 1));
13%OptimizeFunctionOnNextCall(f1);
14assertEquals(0.5, f1(arr, 1));
15
16// Trick crankshaft into accepting feedback with the array prototype
17// map even though a call on that map was never made. optopush should
18// refuse to inline the push call based on the danger that it's modifying
19// the array prototype.
20var push = Array.prototype.push;
21var array_prototype = Array.prototype;
22
23function optopush(a) {
24 push.call(a, 1);
25}
26
27function foo() {
28 optopush(array_prototype);
29}
30
31optopush([]);
32optopush([]);
33optopush([]);
34%OptimizeFunctionOnNextCall(foo);
35foo();
36assertEquals(1.5, f1(arr, 0));