11510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
21510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
31510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org//
41510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// Redistribution and use in source and binary forms, with or without
51510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// modification, are permitted provided that the following conditions
61510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// are met:
71510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// 1.  Redistributions of source code must retain the above copyright
81510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org//     notice, this list of conditions and the following disclaimer.
91510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// 2.  Redistributions in binary form must reproduce the above copyright
101510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org//     notice, this list of conditions and the following disclaimer in the
111510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org//     documentation and/or other materials provided with the distribution.
121510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org//
131510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
141510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
151510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
161510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
171510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
181510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
191510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
201510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
211510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
221510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
231510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
241510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgdescription(
251510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org"Tests that if you alias the arguments in a very small function, arguments simplification still works even if you OSR exit."
261510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org);
271510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
281510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgfunction foo() {
291510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    var args = arguments;
301510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    return args[0] + args[1] + args[2];
311510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org}
321510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
331510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgvar result = "";
341510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgfor (var i = 0; i < 300; ++i) {
351510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    var a;
361510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    if (i < 200)
371510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org        a = i;
381510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    else
391510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org        a = "hello";
401510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    var b = i + 1;
411510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    var c = i + 3;
421510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org    result += foo(a, b, c);
431510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org}
441510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
451510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgshouldBe("result", "\"47101316192225283134374043464952555861646770737679828588919497100103106109112115118121124127130133136139142145148151154157160163166169172175178181184187190193196199202205208211214217220223226229232235238241244247250253256259262265268271274277280283286289292295298301304307310313316319322325328331334337340343346349352355358361364367370373376379382385388391394397400403406409412415418421424427430433436439442445448451454457460463466469472475478481484487490493496499502505508511514517520523526529532535538541544547550553556559562565568571574577580583586589592595598601hello201203hello202204hello203205hello204206hello205207hello206208hello207209hello208210hello209211hello210212hello211213hello212214hello213215hello214216hello215217hello216218hello217219hello218220hello219221hello220222hello221223hello222224hello223225hello224226hello225227hello226228hello227229hello228230hello229231hello230232hello231233hello232234hello233235hello234236hello235237hello236238hello237239hello238240hello239241hello240242hello241243hello242244hello243245hello244246hello245247hello246248hello247249hello248250hello249251hello250252hello251253hello252254hello253255hello254256hello255257hello256258hello257259hello258260hello259261hello260262hello261263hello262264hello263265hello264266hello265267hello266268hello267269hello268270hello269271hello270272hello271273hello272274hello273275hello274276hello275277hello276278hello277279hello278280hello279281hello280282hello281283hello282284hello283285hello284286hello285287hello286288hello287289hello288290hello289291hello290292hello291293hello292294hello293295hello294296hello295297hello296298hello297299hello298300hello299301hello300302\"");
46