| OLD | NEW | 
|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Flags: --harmony-sharedarraybuffer | 5 // Flags: --harmony-sharedarraybuffer | 
| 6 | 6 | 
| 7 function Module(stdlib, foreign, heap, offset) { | 7 function Module(stdlib, foreign, heap, offset) { | 
| 8   "use asm"; | 8   "use asm"; | 
| 9   var MEM8 = new stdlib.Int8Array(heap, offset); | 9   var MEM8 = new stdlib.Int8Array(heap, offset); | 
| 10   var MEM16 = new stdlib.Int16Array(heap, offset); | 10   var MEM16 = new stdlib.Int16Array(heap, offset); | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79 | 79 | 
| 80   var ta = new taConstr(sab, offset); | 80   var ta = new taConstr(sab, offset); | 
| 81   var name = Object.prototype.toString.call(ta); | 81   var name = Object.prototype.toString.call(ta); | 
| 82   assertEquals(0, ta[0]); | 82   assertEquals(0, ta[0]); | 
| 83   assertEquals(0, f(0, 0, 50), name); | 83   assertEquals(0, f(0, 0, 50), name); | 
| 84   assertEquals(50, ta[0]); | 84   assertEquals(50, ta[0]); | 
| 85   // Value is not equal to 0, so compareExchange won't store 100 | 85   // Value is not equal to 0, so compareExchange won't store 100 | 
| 86   assertEquals(50, f(0, 0, 100), name); | 86   assertEquals(50, f(0, 0, 100), name); | 
| 87   assertEquals(50, ta[0]); | 87   assertEquals(50, ta[0]); | 
| 88   // out of bounds | 88   // out of bounds | 
| 89   assertEquals(oobValue, f(-1, 0, 0), name); | 89   assertThrows(function() { f(-1, 0, 0); }); | 
| 90   assertEquals(oobValue, f(ta.length, 0, 0), name); | 90   assertThrows(function() { f(ta.length, 0, 0); }); | 
| 91 } | 91 } | 
| 92 | 92 | 
| 93 function testElement(m, offset) { | 93 function testElement(m, offset) { | 
| 94   testElementType(Int8Array, m.compareExchangei8, 0, offset); | 94   testElementType(Int8Array, m.compareExchangei8, 0, offset); | 
| 95   testElementType(Int16Array, m.compareExchangei16, 0, offset); | 95   testElementType(Int16Array, m.compareExchangei16, 0, offset); | 
| 96   testElementType(Int32Array, m.compareExchangei32, 0, offset); | 96   testElementType(Int32Array, m.compareExchangei32, 0, offset); | 
| 97   testElementType(Uint8Array, m.compareExchangeu8, 0, offset); | 97   testElementType(Uint8Array, m.compareExchangeu8, 0, offset); | 
| 98   testElementType(Uint16Array, m.compareExchangeu16, 0, offset); | 98   testElementType(Uint16Array, m.compareExchangeu16, 0, offset); | 
| 99   testElementType(Uint32Array, m.compareExchangeu32, 0, offset); | 99   testElementType(Uint32Array, m.compareExchangeu32, 0, offset); | 
| 100 } | 100 } | 
| 101 | 101 | 
| 102 var offset = 0; | 102 var offset = 0; | 
| 103 var sab = new SharedArrayBuffer(16); | 103 var sab = new SharedArrayBuffer(16); | 
| 104 var m1 = Module(this, {}, sab, offset); | 104 var m1 = Module(this, {}, sab, offset); | 
| 105 testElement(m1, offset); | 105 testElement(m1, offset); | 
| 106 | 106 | 
| 107 offset = 32; | 107 offset = 32; | 
| 108 sab = new SharedArrayBuffer(64); | 108 sab = new SharedArrayBuffer(64); | 
| 109 var m2 = Module(this, {}, sab, offset); | 109 var m2 = Module(this, {}, sab, offset); | 
| 110 testElement(m2, offset); | 110 testElement(m2, offset); | 
| OLD | NEW | 
|---|