OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 var stdlib = this; |
| 6 var buffer = new ArrayBuffer(64 * 1024); |
| 7 var foreign = {} |
| 8 |
| 9 |
| 10 var sext8 = (function Module(stdlib, foreign, heap) { |
| 11 "use asm"; |
| 12 function sext8(i) { |
| 13 i = i|0; |
| 14 i = i << 24 >> 24; |
| 15 return i|0; |
| 16 } |
| 17 return { sext8: sext8 }; |
| 18 })(stdlib, foreign, buffer).sext8; |
| 19 |
| 20 assertEquals(-128, sext8(128)); |
| 21 assertEquals(-1, sext8(-1)); |
| 22 assertEquals(-1, sext8(255)); |
| 23 assertEquals(0, sext8(0)); |
| 24 assertEquals(0, sext8(256)); |
| 25 assertEquals(42, sext8(42)); |
| 26 assertEquals(127, sext8(127)); |
| 27 |
| 28 |
| 29 var sext16 = (function Module(stdlib, foreign, heap) { |
| 30 "use asm"; |
| 31 function sext16(i) { |
| 32 i = i|0; |
| 33 i = i << 16 >> 16; |
| 34 return i|0; |
| 35 } |
| 36 return { sext16: sext16 }; |
| 37 })(stdlib, foreign, buffer).sext16; |
| 38 |
| 39 assertEquals(-32768, sext16(32768)); |
| 40 assertEquals(-1, sext16(-1)); |
| 41 assertEquals(-1, sext16(65535)); |
| 42 assertEquals(0, sext16(0)); |
| 43 assertEquals(0, sext16(65536)); |
| 44 assertEquals(128, sext16(128)); |
| 45 assertEquals(32767, sext16(32767)); |
OLD | NEW |