v8/test/mjsunit/asm/sign-extend.js
bmeurer@chromium.org 8977e3d5e4 [arm] Recognize SXTB, SXTH, UXTB and UXTH.
TEST=cctest,msjunit/asm,unittests
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/709123005

Cr-Commit-Position: refs/heads/master@{#25228}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25228 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-11-10 05:49:17 +00:00

46 lines
1.1 KiB
JavaScript

// 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 = this;
var buffer = new ArrayBuffer(64 * 1024);
var foreign = {}
var sext8 = (function Module(stdlib, foreign, heap) {
"use asm";
function sext8(i) {
i = i|0;
i = i << 24 >> 24;
return i|0;
}
return { sext8: sext8 };
})(stdlib, foreign, buffer).sext8;
assertEquals(-128, sext8(128));
assertEquals(-1, sext8(-1));
assertEquals(-1, sext8(255));
assertEquals(0, sext8(0));
assertEquals(0, sext8(256));
assertEquals(42, sext8(42));
assertEquals(127, sext8(127));
var sext16 = (function Module(stdlib, foreign, heap) {
"use asm";
function sext16(i) {
i = i|0;
i = i << 16 >> 16;
return i|0;
}
return { sext16: sext16 };
})(stdlib, foreign, buffer).sext16;
assertEquals(-32768, sext16(32768));
assertEquals(-1, sext16(-1));
assertEquals(-1, sext16(65535));
assertEquals(0, sext16(0));
assertEquals(0, sext16(65536));
assertEquals(128, sext16(128));
assertEquals(32767, sext16(32767));