Home | History | Annotate | Download | only in asm
      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 function Module(stdlib, foreign, heap) {
      6   "use asm";
      7   var MEM16 = new stdlib.Int16Array(heap);
      8   function load(i) {
      9     i = i|0;
     10     i = MEM16[i >> 1] | 0;
     11     return i;
     12   }
     13   function loadm1() {
     14     return MEM16[-1] | 0;
     15   }
     16   function store(i, v) {
     17     i = i|0;
     18     v = v|0;
     19     MEM16[i >> 1] = v;
     20   }
     21   function storem1(v) {
     22     v = v|0;
     23     MEM16[-1] = v;
     24   }
     25   return {load: load, loadm1: loadm1, store: store, storem1: storem1};
     26 }
     27 
     28 var m = Module(this, {}, new ArrayBuffer(2));
     29 
     30 m.store(-1000, 4);
     31 assertEquals(0, m.load(-1000));
     32 assertEquals(0, m.loadm1());
     33 m.storem1(1);
     34 assertEquals(0, m.loadm1());
     35 m.store(0, 32767);
     36 for (var i = 1; i < 64; ++i) {
     37   m.store(i * 2 * 32 * 1024, i);
     38 }
     39 assertEquals(32767, m.load(0));
     40 for (var i = 1; i < 64; ++i) {
     41   assertEquals(0, m.load(i * 2 * 32 * 1024));
     42 }
     43