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 function c4(w, h) { |
| 8 var size = w * h; |
| 9 if (size < 0) size = 0; |
| 10 return new Uint32Array(size); |
| 11 } |
| 12 |
| 13 for (var i = 0; i < 3; i++) { |
| 14 // Computing -0 as the result makes the "size = w * h" multiplication IC |
| 15 // go into double mode. |
| 16 c4(0, -1); |
| 17 } |
| 18 // Optimize Uint32ConstructFromLength. |
| 19 for (var i = 0; i < 1000; i++) c4(2, 2); |
| 20 |
| 21 // This array will have a HeapNumber as its length: |
| 22 var bomb = c4(2, 2); |
| 23 |
| 24 function reader(o, i) { |
| 25 // Dummy try-catch, so that TurboFan is used to optimize this. |
| 26 try {} catch(e) {} |
| 27 return o[i]; |
| 28 } |
| 29 // Optimize reader! |
| 30 for (var i = 0; i < 3; i++) reader(bomb, 0); |
| 31 %OptimizeFunctionOnNextCall(reader); |
| 32 reader(bomb, 0); |
| 33 |
| 34 for (var i = bomb.length; i < 100; i++) { |
| 35 assertEquals(undefined, reader(bomb, i)); |
| 36 } |
OLD | NEW |