OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 function Module(stdlib, foreign, heap) { | 5 function Module(stdlib, foreign, heap) { |
6 "use asm"; | 6 "use asm"; |
7 var MEM32 = new stdlib.Int32Array(heap); | 7 var MEM32 = new stdlib.Int32Array(heap); |
| 8 function loadm4194304() { |
| 9 return MEM32[-4194304]; |
| 10 } |
| 11 function loadm0() { |
| 12 return MEM32[-0]; |
| 13 } |
8 function load0() { | 14 function load0() { |
9 return MEM32[0]; | 15 return MEM32[0]; |
10 } | 16 } |
11 function load4() { | 17 function load4() { |
12 return MEM32[4]; | 18 return MEM32[4]; |
13 } | 19 } |
| 20 function storem4194304(v) { |
| 21 MEM32[-4194304] = v; |
| 22 } |
| 23 function storem0(v) { |
| 24 MEM32[-0] = v; |
| 25 } |
14 function store0(v) { | 26 function store0(v) { |
15 MEM32[0] = v; | 27 MEM32[0] = v; |
16 } | 28 } |
17 function store4(v) { | 29 function store4(v) { |
18 MEM32[4] = v; | 30 MEM32[4] = v; |
19 } | 31 } |
20 return { load0: load0, store0: store0, load4: load4, store4: store4 }; | 32 return { loadm4194304: loadm4194304, storem4194304: storem4194304, |
| 33 loadm0: loadm0, storem0: storem0, load0: load0, store0: store0, |
| 34 load4: load4, store4: store4 }; |
21 } | 35 } |
22 | 36 |
23 var m = Module(this, {}, new ArrayBuffer(4)); | 37 var m = Module(this, {}, new ArrayBuffer(4)); |
24 | 38 |
| 39 assertEquals(undefined, m.loadm4194304()); |
| 40 assertEquals(0, m.loadm0()); |
25 assertEquals(0, m.load0()); | 41 assertEquals(0, m.load0()); |
26 assertEquals(undefined, m.load4()); | 42 assertEquals(undefined, m.load4()); |
| 43 m.storem4194304(123456789); |
| 44 assertEquals(undefined, m.loadm4194304()); |
| 45 assertEquals(0, m.loadm0()); |
| 46 assertEquals(0, m.load0()); |
| 47 assertEquals(undefined, m.load4()); |
| 48 m.storem0(987654321); |
| 49 assertEquals(undefined, m.loadm4194304()); |
| 50 assertEquals(987654321, m.loadm0()); |
| 51 assertEquals(987654321, m.load0()); |
| 52 assertEquals(undefined, m.load4()); |
27 m.store0(0x12345678); | 53 m.store0(0x12345678); |
| 54 assertEquals(undefined, m.loadm4194304()); |
| 55 assertEquals(0x12345678, m.loadm0()); |
28 assertEquals(0x12345678, m.load0()); | 56 assertEquals(0x12345678, m.load0()); |
29 assertEquals(undefined, m.load4()); | 57 assertEquals(undefined, m.load4()); |
30 m.store4(43); | 58 m.store4(43); |
| 59 assertEquals(undefined, m.loadm4194304()); |
| 60 assertEquals(0x12345678, m.loadm0()); |
31 assertEquals(0x12345678, m.load0()); | 61 assertEquals(0x12345678, m.load0()); |
32 assertEquals(undefined, m.load4()); | 62 assertEquals(undefined, m.load4()); |
OLD | NEW |