• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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
28var m = Module(this, {}, new ArrayBuffer(2));
29
30m.store(-1000, 4);
31assertEquals(0, m.load(-1000));
32assertEquals(0, m.loadm1());
33m.storem1(1);
34assertEquals(0, m.loadm1());
35m.store(0, 32767);
36for (var i = 1; i < 64; ++i) {
37  m.store(i * 2 * 32 * 1024, i);
38}
39assertEquals(32767, m.load(0));
40for (var i = 1; i < 64; ++i) {
41  assertEquals(0, m.load(i * 2 * 32 * 1024));
42}
43