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