1b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Copyright 2013 the V8 project authors. All rights reserved. 281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// Redistribution and use in source and binary forms, with or without 381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// modification, are permitted provided that the following conditions are 481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// met: 581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// 681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// * Redistributions of source code must retain the above copyright 781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// notice, this list of conditions and the following disclaimer. 881362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// * Redistributions in binary form must reproduce the above 981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// copyright notice, this list of conditions and the following 1081362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// disclaimer in the documentation and/or other materials provided 1181362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// with the distribution. 1281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// * Neither the name of Google Inc. nor the names of its 1381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// contributors may be used to endorse or promote products derived 1481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// from this software without specific prior written permission. 1581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// 1681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1881362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2081362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2181362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen 28b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Flags: --allow-natives-syntax 2981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen 30b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochfunction TestNonSmiArrayLength() { 31b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch function f(a) { 32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return a.length+1; 33b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch } 3481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen 35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch var a = []; 36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch a.length = 0xFFFF; 37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch assertSame(0x10000, f(a)); 38b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch assertSame(0x10000, f(a)); 3981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen 40b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch %OptimizeFunctionOnNextCall(f); 41b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch a.length = 0xFFFFFFFF; 42b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch assertSame(0x100000000, f(a)); 4381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen} 44b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 45b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochTestNonSmiArrayLength(); 46