1906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
2906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// Redistribution and use in source and binary forms, with or without
3906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// modification, are permitted provided that the following conditions are
4906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// met:
5906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//
6906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//     * Redistributions of source code must retain the above copyright
7906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       notice, this list of conditions and the following disclaimer.
8906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//     * Redistributions in binary form must reproduce the above
9906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       copyright notice, this list of conditions and the following
10906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       disclaimer in the documentation and/or other materials provided
11906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       with the distribution.
12906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//     * Neither the name of Google Inc. nor the names of its
13906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       contributors may be used to endorse or promote products derived
14906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//       from this software without specific prior written permission.
15906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org//
16906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org
28906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org// Flags: --allow-natives-syntax
29906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org
30906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgfunction f1(a, i) {
31906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org  return a[i] + 0.5;
32906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org}
33906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgvar arr = [0.0,,2.5];
34906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgassertEquals(0.5, f1(arr, 0));
35906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgassertEquals(0.5, f1(arr, 0));
36906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgArray.prototype.__proto__[1] = 1.5;
37906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgassertEquals(2, f1(arr, 1));
38906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.org%OptimizeFunctionOnNextCall(f1);
39906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgassertEquals(2, f1(arr, 1));
40906e2fb760f52fe6e75b744b1ea42576ea5b2c29ulan@chromium.orgassertEquals(0.5, f1(arr, 0));
41