Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Side by Side Diff: test/mjsunit/compiler/uint8-clamped-array.js

Issue 2489563004: [turbofan] Add support for accessing Uint8ClampedArrays. (Closed)
Patch Set: Fix typing rule. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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
5 // Flags: --allow-natives-syntax
6
7 (function() {
8 function foo(a, v) {
9 a[0] = v & 0xff;
10 }
11
12 var a = new Uint8ClampedArray(4);
13 foo(a, 1);
14 foo(a, 2);
15 %OptimizeFunctionOnNextCall(foo);
16 foo(a, 256);
17 assertOptimized(foo);
18 assertEquals(0, a[0]);
19 })();
20
21 (function() {
22 function foo(a, v) {
23 a[0] = v >>> 0;
24 }
25
26 var a = new Uint8ClampedArray(4);
27 foo(a, 1);
28 foo(a, 2);
29 %OptimizeFunctionOnNextCall(foo);
30 foo(a, 256);
31 assertOptimized(foo);
32 assertEquals(255, a[0]);
33 })();
34
35 (function() {
36 function foo(a, v) {
37 a[0] = v | 0;
38 }
39
40 var a = new Uint8ClampedArray(4);
41 foo(a, 1);
42 foo(a, 2);
43 %OptimizeFunctionOnNextCall(foo);
44 foo(a, 256);
45 assertOptimized(foo);
46 assertEquals(255, a[0]);
47 foo(a, -1);
48 assertOptimized(foo);
49 assertEquals(0, a[0]);
50 })();
51
52 (function() {
53 function foo(a, v) {
54 a[0] = v;
55 }
56
57 var a = new Uint8ClampedArray(4);
58 foo(a, 1);
59 foo(a, 2);
60 %OptimizeFunctionOnNextCall(foo);
61 foo(a, Infinity);
62 assertOptimized(foo);
63 assertEquals(255, a[0]);
64 foo(a, -Infinity);
65 assertOptimized(foo);
66 assertEquals(0, a[0]);
67 foo(a, 0.5);
68 assertOptimized(foo);
69 assertEquals(0, a[0]);
70 foo(a, 1.5);
71 assertOptimized(foo);
72 assertEquals(2, a[0]);
73 })();
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698