143c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
243c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// Redistribution and use in source and binary forms, with or without
343c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// modification, are permitted provided that the following conditions are
443c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// met:
543c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//
643c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//     * Redistributions of source code must retain the above copyright
743c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       notice, this list of conditions and the following disclaimer.
843c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//     * Redistributions in binary form must reproduce the above
943c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       copyright notice, this list of conditions and the following
1043c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       disclaimer in the documentation and/or other materials provided
1143c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       with the distribution.
1243c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//     * Neither the name of Google Inc. nor the names of its
1343c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       contributors may be used to endorse or promote products derived
1443c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//       from this software without specific prior written permission.
1543c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org//
1643c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1743c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1843c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1943c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2043c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2143c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2243c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2343c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2443c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2543c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2643c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2743c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org
2843c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// CallIC accumulates feedback that string index is out of bounds, then
2943c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// misses
3043c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgfunction foo(index) {
3143c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org  return text.charAt(index);
3243c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org}
3343c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org
3443c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgvar text = "hi there";
3543c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgfoo(0);
3643c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgfoo(0);
3743c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgfoo(100);     // Accumulate feedback that index is out of bounds.
3843c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgtext = false;
3943c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org
4043c51e51fafad9405752a3d7e953367531469575machenbach@chromium.org// This line ASSERTS in debug without fix.
4143c51e51fafad9405752a3d7e953367531469575machenbach@chromium.orgassertThrows(function () { foo(); }, TypeError);
42