• 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
5var stdlib = {};
6var foreign = {};
7var heap = new ArrayBuffer(64 * 1024);
8
9var rol = (function Module(stdlib, foreign, heap) {
10  "use asm";
11  function rol(x, y) {
12    x = x | 0;
13    y = y | 0;
14    return (x << y) | (x >>> (32 - y));
15  }
16  return { rol: rol };
17})(stdlib, foreign, heap).rol;
18
19assertEquals(10, rol(10, 0));
20assertEquals(2, rol(1, 1));
21assertEquals(0x40000000, rol(1, 30));
22assertEquals(-0x80000000, rol(1, 31));
23
24var ror = (function Module(stdlib, foreign, heap) {
25  "use asm";
26  function ror(x, y) {
27    x = x | 0;
28    y = y | 0;
29    return (x << (32 - y)) | (x >>> y);
30  }
31  return { ror: ror };
32})(stdlib, foreign, heap).ror;
33
34assertEquals(10, ror(10, 0));
35assertEquals(-0x80000000, ror(1, 1));
36assertEquals(0x40000000, ror(1, 2));
37assertEquals(2, ror(1, 31));
38