1// Copyright 2013 the V8 project authors. All rights reserved.
2// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions
6// are met:
7// 1.  Redistributions of source code must retain the above copyright
8//     notice, this list of conditions and the following disclaimer.
9// 2.  Redistributions in binary form must reproduce the above copyright
10//     notice, this list of conditions and the following disclaimer in the
11//     documentation and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24description(
25"Tests that if you alias the arguments in a very small function, arguments simplification still works even if you OSR exit."
26);
27
28function foo() {
29    var args = arguments;
30    return args[0] + args[1] + args[2];
31}
32
33var result = "";
34for (var i = 0; i < 300; ++i) {
35    var a;
36    if (i < 200)
37        a = i;
38    else
39        a = "hello";
40    var b = i + 1;
41    var c = i + 3;
42    result += foo(a, b, c);
43}
44
45shouldBe("result", "\"47101316192225283134374043464952555861646770737679828588919497100103106109112115118121124127130133136139142145148151154157160163166169172175178181184187190193196199202205208211214217220223226229232235238241244247250253256259262265268271274277280283286289292295298301304307310313316319322325328331334337340343346349352355358361364367370373376379382385388391394397400403406409412415418421424427430433436439442445448451454457460463466469472475478481484487490493496499502505508511514517520523526529532535538541544547550553556559562565568571574577580583586589592595598601hello201203hello202204hello203205hello204206hello205207hello206208hello207209hello208210hello209211hello210212hello211213hello212214hello213215hello214216hello215217hello216218hello217219hello218220hello219221hello220222hello221223hello222224hello223225hello224226hello225227hello226228hello227229hello228230hello229231hello230232hello231233hello232234hello233235hello234236hello235237hello236238hello237239hello238240hello239241hello240242hello241243hello242244hello243245hello244246hello245247hello246248hello247249hello248250hello249251hello250252hello251253hello252254hello253255hello254256hello255257hello256258hello257259hello258260hello259261hello260262hello261263hello262264hello263265hello264266hello265267hello266268hello267269hello268270hello269271hello270272hello271273hello272274hello273275hello274276hello275277hello276278hello277279hello278280hello279281hello280282hello281283hello282284hello283285hello284286hello285287hello286288hello287289hello288290hello289291hello290292hello291293hello292294hello293295hello294296hello295297hello296298hello297299hello298300hello299301hello300302\"");
46