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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 function testElementType(taConstr, f, offset) { | 74 function testElementType(taConstr, f, offset) { |
75 clearArray(); | 75 clearArray(); |
76 | 76 |
77 var ta = new taConstr(sab, offset); | 77 var ta = new taConstr(sab, offset); |
78 var name = Object.prototype.toString.call(ta); | 78 var name = Object.prototype.toString.call(ta); |
79 assertEquals(0, f(0, 0xf), name); | 79 assertEquals(0, f(0, 0xf), name); |
80 assertEquals(0xf, ta[0]); | 80 assertEquals(0xf, ta[0]); |
81 assertEquals(0xf, f(0, 0x11), name); | 81 assertEquals(0xf, f(0, 0x11), name); |
82 assertEquals(0x1f, ta[0]); | 82 assertEquals(0x1f, ta[0]); |
83 // out of bounds | 83 // out of bounds |
84 assertEquals(0, f(-1, 0), name); | 84 assertThrows(function() { f(-1, 0); }); |
85 assertEquals(0, f(ta.length, 0), name); | 85 assertThrows(function() { f(ta.length, 0); }); |
86 } | 86 } |
87 | 87 |
88 function testElement(m, offset) { | 88 function testElement(m, offset) { |
89 testElementType(Int8Array, m.ori8, offset); | 89 testElementType(Int8Array, m.ori8, offset); |
90 testElementType(Int16Array, m.ori16, offset); | 90 testElementType(Int16Array, m.ori16, offset); |
91 testElementType(Int32Array, m.ori32, offset); | 91 testElementType(Int32Array, m.ori32, offset); |
92 testElementType(Uint8Array, m.oru8, offset); | 92 testElementType(Uint8Array, m.oru8, offset); |
93 testElementType(Uint16Array, m.oru16, offset); | 93 testElementType(Uint16Array, m.oru16, offset); |
94 testElementType(Uint32Array, m.oru32, offset); | 94 testElementType(Uint32Array, m.oru32, offset); |
95 } | 95 } |
96 | 96 |
97 var offset = 0; | 97 var offset = 0; |
98 var sab = new SharedArrayBuffer(16); | 98 var sab = new SharedArrayBuffer(16); |
99 var m1 = Module(this, {}, sab, offset); | 99 var m1 = Module(this, {}, sab, offset); |
100 testElement(m1, offset); | 100 testElement(m1, offset); |
101 | 101 |
102 offset = 32; | 102 offset = 32; |
103 sab = new SharedArrayBuffer(64); | 103 sab = new SharedArrayBuffer(64); |
104 var m2 = Module(this, {}, sab, offset); | 104 var m2 = Module(this, {}, sab, offset); |
105 testElement(m2, offset); | 105 testElement(m2, offset); |
OLD | NEW |