blob: abd7d6b2f8da45991e1e3b6c72582bc716d63efb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2021 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() {
const arr = new Uint32Array([2**31]);
function foo() {
return (arr[0] ^ 0) + 1;
}
%PrepareFunctionForOptimization(foo);
assertEquals(-(2**31) + 1, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(-(2**31) + 1, foo());
});
// The remaining tests already passed without the bugfix.
(function() {
const arr = new Uint16Array([2**15]);
function foo() {
return (arr[0] ^ 0) + 1;
}
%PrepareFunctionForOptimization(foo);
assertEquals(2**15 + 1, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(2**15 + 1, foo());
})();
(function() {
const arr = new Uint8Array([2**7]);
function foo() {
return (arr[0] ^ 0) + 1;
}
%PrepareFunctionForOptimization(foo);
assertEquals(2**7 + 1, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(2**7 + 1, foo());
})();
(function() {
const arr = new Int32Array([-(2**31)]);
function foo() {
return (arr[0] >>> 0) + 1;
}
%PrepareFunctionForOptimization(foo);
assertEquals(2**31 + 1, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(2**31 + 1, foo());
})();
|