Home | History | Annotate | Download | only in asm
      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
      3 // found in the LICENSE file.
      4 
      5 var stdlib = this;
      6 var foreign = {};
      7 var heap = new ArrayBuffer(64 * 1024);
      8 
      9 
     10 var pm1 = (function(stdlib, foreign, heap) {
     11   "use asm";
     12   var HEAP8 = new stdlib.Int8Array(heap);
     13   const MASK1 = 1023;
     14   function load1(i) {
     15     i = i|0;
     16     var j = 0;
     17     j = HEAP8[(i & MASK1)]|0;
     18     return j|0;
     19   }
     20   function store1(i, j) {
     21     i = i|0;
     22     j = j|0;
     23     HEAP8[(i & MASK1)] = j;
     24   }
     25   return {load1: load1, store1: store1};
     26 })(stdlib, foreign, heap);
     27 
     28 assertEquals(0, pm1.load1(0));
     29 assertEquals(0, pm1.load1(1025));
     30 pm1.store1(0, 1);
     31 pm1.store1(1025, 127);
     32 assertEquals(1, pm1.load1(0));
     33 assertEquals(1, pm1.load1(1024));
     34 assertEquals(127, pm1.load1(1));
     35 assertEquals(127, pm1.load1(1025));
     36