149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Copyright 2011 the V8 project authors. All rights reserved.
249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Redistribution and use in source and binary forms, with or without
349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// modification, are permitted provided that the following conditions are
449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// met:
549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//
649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Redistributions of source code must retain the above copyright
749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       notice, this list of conditions and the following disclaimer.
849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Redistributions in binary form must reproduce the above
949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       copyright notice, this list of conditions and the following
1049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       disclaimer in the documentation and/or other materials provided
1149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       with the distribution.
1249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//     * Neither the name of Google Inc. nor the names of its
1349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       contributors may be used to endorse or promote products derived
1449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//       from this software without specific prior written permission.
1549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org//
1649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
2849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Test keyed calls with different key types.
2949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgfunction F() {}
3049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgvar a = new F();
3149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgfunction f(i) { return a[i](); }
3249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
3349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orga.first = function() { return 11; }
3449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orga[0] = function() { return 22; }
3549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgvar obj = {};
3649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orga[obj] = function() { return 33; }
3749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
3849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Make object slow-case.
3949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orga.foo = 0;
4049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgdelete a.foo;
4149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Do multiple calls for IC transitions.
4249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgvar b = "first";
4349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgf(b);
4449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgf(b);
4549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org
4649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgassertEquals(11, f(b));
4749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgassertEquals(22, f(0));
4849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.orgassertEquals(33, f(obj));
49