OLD | NEW |
(Empty) | |
| 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 // Flags: --allow-natives-syntax |
| 6 |
| 7 var g_eval = eval; |
| 8 function emit_f(size) { |
| 9 var body = "function f(x) {" + |
| 10 " if (x < 0) return x;" + |
| 11 " var a = [1];" + |
| 12 " if (x > 0) return ["; |
| 13 for (var i = 0; i < size; i++) { |
| 14 body += "0.1, "; |
| 15 } |
| 16 body += " ];" + |
| 17 " return a;" + |
| 18 "}"; |
| 19 g_eval(body); |
| 20 } |
| 21 |
| 22 // Length must be big enough to make the backing store's size not fit into |
| 23 // a single instruction's immediate field (2^12). |
| 24 var kLength = 701; |
| 25 emit_f(kLength); |
| 26 f(1); |
| 27 f(1); |
| 28 %OptimizeFunctionOnNextCall(f); |
| 29 var a = f(1); |
| 30 |
| 31 // Allocating something else should not disturb |a|. |
| 32 var b = new Object(); |
| 33 for (var i = 0; i < kLength; i++) { |
| 34 assertEquals(0.1, a[i]); |
| 35 } |
| 36 |
| 37 // Allocating more should not crash. |
| 38 for (var i = 0; i < 300; i++) { |
| 39 f(1); |
| 40 } |
OLD | NEW |