v8/test/mjsunit/compiler/regress-739902.js
Jaroslav Sevcik b1c1228981 [turbofan] Fix arm backend matching of (x >>> 24) & 0xffff.
We emitted rotation by 24 bits with bitwise and, but that is wrong
because the low 8 bits can wrap around and "leak" into the result.

Bug: chromium:739902
Change-Id: Id49251e89405afb1581b8c60cde808c2d8bf693d
Reviewed-on: https://chromium-review.googlesource.com/645848
Reviewed-by: Martyn Capewell <martyn.capewell@arm.com>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47746}
2017-08-31 13:50:07 +00:00

29 lines
566 B
JavaScript

// Copyright 2017 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.
// Flags: --allow-natives-syntax
(function() {
function f(x) {
return String.fromCharCode(x >>> 24);
};
var e = 0x41000001;
f(e);
%OptimizeFunctionOnNextCall(f);
assertEquals("A", f(e));
})();
(function() {
function f(x) {
return (x >>> 24) & 0xffff;
};
f(1);
%OptimizeFunctionOnNextCall(f);
assertEquals(0, f(1));
assertEquals(100, f((100 << 24) + 42));
})();