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