119aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// Copyright 2013 the V8 project authors. All rights reserved. 219aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// Redistribution and use in source and binary forms, with or without 319aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// modification, are permitted provided that the following conditions are 419aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// met: 519aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// 619aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// * Redistributions of source code must retain the above copyright 719aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// notice, this list of conditions and the following disclaimer. 819aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// * Redistributions in binary form must reproduce the above 919aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// copyright notice, this list of conditions and the following 1019aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// disclaimer in the documentation and/or other materials provided 1119aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// with the distribution. 1219aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// * Neither the name of Google Inc. nor the names of its 1319aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// contributors may be used to endorse or promote products derived 1419aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// from this software without specific prior written permission. 1519aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// 1619aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1719aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1819aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1919aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2019aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2119aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2219aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2319aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2419aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2519aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2619aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2719aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org 2819aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org// Flags: --allow-natives-syntax 2919aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org 3019aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.orgfunction bar(a, b) { with(a) {return a + b;} } 3119aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org 3219aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.orgvar obj = { 3319aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org functions: [bar, bar, bar, bar], 3419aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org receivers: [bar, bar, undefined, null], 3519aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org foo: function () { 3619aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org for (var a = this.functions, e = this.receivers, c = a.length, 3719aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org d = 0; d < c ; d++) { 3819aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org a[d].apply(e[d], arguments) 3919aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org } 4019aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org } 4119aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org} 4219aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org 4319aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.orgobj.foo(1, 2, 3, 4); 4419aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.orgobj.foo(1, 2, 3, 4); 4519aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.org%OptimizeFunctionOnNextCall(obj.foo); 4619aca23f3409e50f53ad9746c3754bbf10f3d05eulan@chromium.orgobj.foo(1, 2, 3, 4); 47