1c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// Copyright 2010 the V8 project authors. All rights reserved.
2c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// Redistribution and use in source and binary forms, with or without
3c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// modification, are permitted provided that the following conditions are
4c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// met:
5c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//
6c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//     * Redistributions of source code must retain the above copyright
7c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       notice, this list of conditions and the following disclaimer.
8c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//     * Redistributions in binary form must reproduce the above
9c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       copyright notice, this list of conditions and the following
10c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       disclaimer in the documentation and/or other materials provided
11c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       with the distribution.
12c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//     * Neither the name of Google Inc. nor the names of its
13c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       contributors may be used to endorse or promote products derived
14c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//       from this software without specific prior written permission.
15c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org//
16c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org
28fb144a0716afe7ab8bf245f2391a9e53b3db3c89fschneider@chromium.org// Flags: --allow-natives-syntax
29fb144a0716afe7ab8bf245f2391a9e53b3db3c89fschneider@chromium.org
30c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.orgfunction runner(f, expected) {
31fb144a0716afe7ab8bf245f2391a9e53b3db3c89fschneider@chromium.org  assertEquals(expected, f.call(this));
32c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org}
33c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org
34c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.orgfunction test(n) {
35c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  function MyFunction() {
36c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org    var result = n * 2 + arguments.length;
37c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org    return result;
38c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  }
39fb144a0716afe7ab8bf245f2391a9e53b3db3c89fschneider@chromium.org  for (var i = 0; i < 5; ++i) MyFunction();
40fb144a0716afe7ab8bf245f2391a9e53b3db3c89fschneider@chromium.org  %OptimizeFunctionOnNextCall(MyFunction)
41c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  runner(MyFunction, n * 2);
42c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org}
43c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org
44c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.orgtest(1);
45c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.orgtest(42);
46c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.orgtest(239);
47