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