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 overwrite the arguments register."
26);
27
28function foo() {
29    var args = arguments;
30    arguments = [1, 2, 3];
31    return args[0] + arguments[1] + args[2];
32}
33
34var result = "";
35for (var i = 0; i < 300; ++i) {
36    var a;
37    if (i < 200)
38        a = i;
39    else
40        a = "hello";
41    var b = i + 1;
42    var c = i + 3;
43    result += foo(a, b, c);
44}
45shouldBe("result", "\"579111315171921232527293133353739414345474951535557596163656769717375777981838587899193959799101103105107109111113115117119121123125127129131133135137139141143145147149151153155157159161163165167169171173175177179181183185187189191193195197199201203205207209211213215217219221223225227229231233235237239241243245247249251253255257259261263265267269271273275277279281283285287289291293295297299301303305307309311313315317319321323325327329331333335337339341343345347349351353355357359361363365367369371373375377379381383385387389391393395397399401403hello2203hello2204hello2205hello2206hello2207hello2208hello2209hello2210hello2211hello2212hello2213hello2214hello2215hello2216hello2217hello2218hello2219hello2220hello2221hello2222hello2223hello2224hello2225hello2226hello2227hello2228hello2229hello2230hello2231hello2232hello2233hello2234hello2235hello2236hello2237hello2238hello2239hello2240hello2241hello2242hello2243hello2244hello2245hello2246hello2247hello2248hello2249hello2250hello2251hello2252hello2253hello2254hello2255hello2256hello2257hello2258hello2259hello2260hello2261hello2262hello2263hello2264hello2265hello2266hello2267hello2268hello2269hello2270hello2271hello2272hello2273hello2274hello2275hello2276hello2277hello2278hello2279hello2280hello2281hello2282hello2283hello2284hello2285hello2286hello2287hello2288hello2289hello2290hello2291hello2292hello2293hello2294hello2295hello2296hello2297hello2298hello2299hello2300hello2301hello2302\"");
46