2014-11-20 13:09:04 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
var stdlib = {};
|
|
|
|
var foreign = {};
|
|
|
|
var heap = new ArrayBuffer(64 * 1024);
|
|
|
|
|
|
|
|
var rol = (function Module(stdlib, foreign, heap) {
|
|
|
|
"use asm";
|
|
|
|
function rol(x, y) {
|
|
|
|
x = x | 0;
|
|
|
|
y = y | 0;
|
2017-02-14 09:26:52 +00:00
|
|
|
return (x << y) | (x >>> (32 - y)) | 0;
|
2014-11-20 13:09:04 +00:00
|
|
|
}
|
|
|
|
return { rol: rol };
|
|
|
|
})(stdlib, foreign, heap).rol;
|
|
|
|
|
|
|
|
assertEquals(10, rol(10, 0));
|
|
|
|
assertEquals(2, rol(1, 1));
|
|
|
|
assertEquals(0x40000000, rol(1, 30));
|
|
|
|
assertEquals(-0x80000000, rol(1, 31));
|
2014-11-26 11:49:35 +00:00
|
|
|
|
|
|
|
var ror = (function Module(stdlib, foreign, heap) {
|
|
|
|
"use asm";
|
|
|
|
function ror(x, y) {
|
|
|
|
x = x | 0;
|
|
|
|
y = y | 0;
|
2017-02-14 09:26:52 +00:00
|
|
|
return (x << (32 - y)) | (x >>> y) | 0;
|
2014-11-26 11:49:35 +00:00
|
|
|
}
|
|
|
|
return { ror: ror };
|
|
|
|
})(stdlib, foreign, heap).ror;
|
|
|
|
|
|
|
|
assertEquals(10, ror(10, 0));
|
|
|
|
assertEquals(-0x80000000, ror(1, 1));
|
|
|
|
assertEquals(0x40000000, ror(1, 2));
|
|
|
|
assertEquals(2, ror(1, 31));
|