OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 TestConstructor(c) { |
| 8 var a = new c(-0); |
| 9 assertSame(Infinity, 1 / a.length); |
| 10 assertSame(Infinity, 1 / a.byteLength); |
| 11 |
| 12 var ab = new ArrayBuffer(-0); |
| 13 assertSame(Infinity, 1 / ab.byteLength); |
| 14 |
| 15 var a1 = new c(ab, -0, -0); |
| 16 assertSame(Infinity, 1 / a1.length); |
| 17 assertSame(Infinity, 1 / a1.byteLength); |
| 18 assertSame(Infinity, 1 / a1.byteOffset); |
| 19 } |
| 20 |
| 21 var constructors = |
| 22 [ Uint8Array, Int8Array, Uint8ClampedArray, |
| 23 Uint16Array, Int16Array, |
| 24 Uint32Array, Int32Array, |
| 25 Float32Array, Float64Array ]; |
| 26 for (var i = 0; i < constructors.length; i++) { |
| 27 TestConstructor(constructors[i]); |
| 28 } |
| 29 |
| 30 |
| 31 function TestOptimizedCode() { |
| 32 var a = new Uint8Array(-0); |
| 33 assertSame(Infinity, 1 / a.length); |
| 34 assertSame(Infinity, 1 / a.byteLength); |
| 35 |
| 36 var ab = new ArrayBuffer(-0); |
| 37 assertSame(Infinity, 1 / ab.byteLength); |
| 38 |
| 39 var a1 = new Uint8Array(ab, -0, -0); |
| 40 assertSame(Infinity, 1 / a1.length); |
| 41 assertSame(Infinity, 1 / a1.byteLength); |
| 42 assertSame(Infinity, 1 / a1.byteOffset); |
| 43 } |
| 44 |
| 45 %OptimizeFunctionOnNextCall(Uint8Array); |
| 46 for (var i = 0; i < 1000; i++) { |
| 47 TestOptimizedCode(); |
| 48 } |
OLD | NEW |