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