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() { |
| 8 function foo(a, v) { |
| 9 a[0] = v & 0xff; |
| 10 } |
| 11 |
| 12 var a = new Uint8ClampedArray(4); |
| 13 foo(a, 1); |
| 14 foo(a, 2); |
| 15 %OptimizeFunctionOnNextCall(foo); |
| 16 foo(a, 256); |
| 17 assertOptimized(foo); |
| 18 assertEquals(0, a[0]); |
| 19 })(); |
| 20 |
| 21 (function() { |
| 22 function foo(a, v) { |
| 23 a[0] = v >>> 0; |
| 24 } |
| 25 |
| 26 var a = new Uint8ClampedArray(4); |
| 27 foo(a, 1); |
| 28 foo(a, 2); |
| 29 %OptimizeFunctionOnNextCall(foo); |
| 30 foo(a, 256); |
| 31 assertOptimized(foo); |
| 32 assertEquals(255, a[0]); |
| 33 })(); |
| 34 |
| 35 (function() { |
| 36 function foo(a, v) { |
| 37 a[0] = v | 0; |
| 38 } |
| 39 |
| 40 var a = new Uint8ClampedArray(4); |
| 41 foo(a, 1); |
| 42 foo(a, 2); |
| 43 %OptimizeFunctionOnNextCall(foo); |
| 44 foo(a, 256); |
| 45 assertOptimized(foo); |
| 46 assertEquals(255, a[0]); |
| 47 foo(a, -1); |
| 48 assertOptimized(foo); |
| 49 assertEquals(0, a[0]); |
| 50 })(); |
| 51 |
| 52 (function() { |
| 53 function foo(a, v) { |
| 54 a[0] = v; |
| 55 } |
| 56 |
| 57 var a = new Uint8ClampedArray(4); |
| 58 foo(a, 1); |
| 59 foo(a, 2); |
| 60 %OptimizeFunctionOnNextCall(foo); |
| 61 foo(a, Infinity); |
| 62 assertOptimized(foo); |
| 63 assertEquals(255, a[0]); |
| 64 foo(a, -Infinity); |
| 65 assertOptimized(foo); |
| 66 assertEquals(0, a[0]); |
| 67 foo(a, 0.5); |
| 68 assertOptimized(foo); |
| 69 assertEquals(0, a[0]); |
| 70 foo(a, 1.5); |
| 71 assertOptimized(foo); |
| 72 assertEquals(2, a[0]); |
| 73 })(); |
OLD | NEW |