• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2013 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6//     * Redistributions of source code must retain the above copyright
7//       notice, this list of conditions and the following disclaimer.
8//     * Redistributions in binary form must reproduce the above
9//       copyright notice, this list of conditions and the following
10//       disclaimer in the documentation and/or other materials provided
11//       with the distribution.
12//     * Neither the name of Google Inc. nor the names of its
13//       contributors may be used to endorse or promote products derived
14//       from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28// Flags: --allow-natives-syntax --no-use-osr
29
30function foo_pixel(a, i, v) {
31  a[0] = v;
32  a[i] = v;
33}
34
35function foo_uint16(a, i, v) {
36  a[0] = v;
37  a[i] = v;
38}
39
40function foo_uint32(a, i, v) {
41  a[0] = v;
42  a[i] = v;
43}
44
45function foo_float(a, i, v) {
46  a[0] = v;
47  a[i] = v;
48}
49
50function foo_double(a, i, v) {
51  a[0] = v;
52  a[i] = v;
53}
54
55var A1_pixel = new Uint8ClampedArray(2);
56var A2_pixel = new Uint8ClampedArray(2);
57var A3_pixel = new Uint8ClampedArray(2);
58
59var A1_uint16 = new Uint16Array(2);
60var A2_uint16 = new Uint16Array(2);
61var A3_uint16 = new Uint16Array(2);
62
63var A1_uint32 = new Uint32Array(2);
64var A2_uint32 = new Uint32Array(2);
65var A3_uint32 = new Uint32Array(2);
66
67var A1_float = new Float32Array(2);
68var A2_float = new Float32Array(2);
69var A3_float = new Float32Array(2);
70
71var A1_double = new Float64Array(2);
72var A2_double = new Float64Array(2);
73var A3_double = new Float64Array(2);
74
75foo_pixel(A1_pixel, 1, 34);
76foo_pixel(A2_pixel, 1, 34);
77%OptimizeFunctionOnNextCall(foo_pixel);
78foo_pixel(A3_pixel, 1, 34);
79
80foo_uint16(A1_uint16, 1, 3.4);
81foo_uint16(A2_uint16, 1, 3.4);
82%OptimizeFunctionOnNextCall(foo_uint16);
83foo_uint16(A3_uint16, 1, 3.4);
84
85foo_uint32(A1_uint32, 1, 3.4);
86foo_uint32(A2_uint32, 1, 3.4);
87%OptimizeFunctionOnNextCall(foo_uint32);
88foo_uint32(A3_uint32, 1, 3.4);
89
90foo_float(A1_float, 1, 3.4);
91foo_float(A2_float, 1, 3.4);
92%OptimizeFunctionOnNextCall(foo_float);
93foo_float(A3_float, 1, 3.4);
94
95foo_double(A1_double, 1, 3.4);
96foo_double(A2_double, 1, 3.4);
97%OptimizeFunctionOnNextCall(foo_double);
98foo_double(A3_double, 1, 3.4);
99
100assertEquals(A1_pixel[0], A3_pixel[0]);
101assertEquals(A1_pixel[1], A3_pixel[1]);
102assertEquals(A1_uint16[0], A3_uint16[0]);
103assertEquals(A1_uint16[1], A3_uint16[1]);
104assertEquals(A1_uint32[0], A3_uint32[0]);
105assertEquals(A1_uint32[1], A3_uint32[1]);
106assertEquals(A1_float[0], A3_float[0]);
107assertEquals(A1_float[1], A3_float[1]);
108assertEquals(A1_double[0], A3_double[0]);
109assertEquals(A1_double[1], A3_double[1]);
110