Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 1 | // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | "use strict"; |
| 6 | |
| 7 | function f(a, b, c) { return arguments } |
| 8 | function g(...args) { return args } |
| 9 | |
| 10 | // On 64-bit machine this produces a 768K array which is sufficiently small to |
| 11 | // not cause a stack overflow, but big enough to move the allocated arguments |
| 12 | // object into large object space (kMaxRegularHeapObjectSize == 600K). |
| 13 | var length = Math.pow(2, 15) * 3; |
| 14 | var args = new Array(length); |
| 15 | assertEquals(length, f.apply(null, args).length); |
| 16 | assertEquals(length, g.apply(null, args).length); |
| 17 | |
| 18 | // On 32-bit machines this produces an equally sized array, however it might in |
| 19 | // turn trigger a stack overflow on 64-bit machines, which we need to catch. |
| 20 | var length = Math.pow(2, 16) * 3; |
| 21 | var args = new Array(length); |
| 22 | try { f.apply(null, args) } catch(e) {} |
| 23 | try { g.apply(null, args) } catch(e) {} |