The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / test / mjsunit / lithium / StoreKeyedExternal.js @ f230a1cf

History | View | Annotate | Download (3.48 KB)

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

    
30
function foo_pixel(a, i, v) {
31
  a[0] = v;
32
  a[i] = v;
33
}
34

    
35
function foo_uint16(a, i, v) {
36
  a[0] = v;
37
  a[i] = v;
38
}
39

    
40
function foo_uint32(a, i, v) {
41
  a[0] = v;
42
  a[i] = v;
43
}
44

    
45
function foo_float(a, i, v) {
46
  a[0] = v;
47
  a[i] = v;
48
}
49

    
50
function foo_double(a, i, v) {
51
  a[0] = v;
52
  a[i] = v;
53
}
54

    
55
var A1_pixel = new Uint8ClampedArray(2);
56
var A2_pixel = new Uint8ClampedArray(2);
57
var A3_pixel = new Uint8ClampedArray(2);
58

    
59
var A1_uint16 = new Uint16Array(2);
60
var A2_uint16 = new Uint16Array(2);
61
var A3_uint16 = new Uint16Array(2);
62

    
63
var A1_uint32 = new Uint32Array(2);
64
var A2_uint32 = new Uint32Array(2);
65
var A3_uint32 = new Uint32Array(2);
66

    
67
var A1_float = new Float32Array(2);
68
var A2_float = new Float32Array(2);
69
var A3_float = new Float32Array(2);
70

    
71
var A1_double = new Float64Array(2);
72
var A2_double = new Float64Array(2);
73
var A3_double = new Float64Array(2);
74

    
75
foo_pixel(A1_pixel, 1, 34);
76
foo_pixel(A2_pixel, 1, 34);
77
%OptimizeFunctionOnNextCall(foo_pixel);
78
foo_pixel(A3_pixel, 1, 34);
79

    
80
foo_uint16(A1_uint16, 1, 3.4);
81
foo_uint16(A2_uint16, 1, 3.4);
82
%OptimizeFunctionOnNextCall(foo_uint16);
83
foo_uint16(A3_uint16, 1, 3.4);
84

    
85
foo_uint32(A1_uint32, 1, 3.4);
86
foo_uint32(A2_uint32, 1, 3.4);
87
%OptimizeFunctionOnNextCall(foo_uint32);
88
foo_uint32(A3_uint32, 1, 3.4);
89

    
90
foo_float(A1_float, 1, 3.4);
91
foo_float(A2_float, 1, 3.4);
92
%OptimizeFunctionOnNextCall(foo_float);
93
foo_float(A3_float, 1, 3.4);
94

    
95
foo_double(A1_double, 1, 3.4);
96
foo_double(A2_double, 1, 3.4);
97
%OptimizeFunctionOnNextCall(foo_double);
98
foo_double(A3_double, 1, 3.4);
99

    
100
assertEquals(A1_pixel[0], A3_pixel[0]);
101
assertEquals(A1_pixel[1], A3_pixel[1]);
102
assertEquals(A1_uint16[0], A3_uint16[0]);
103
assertEquals(A1_uint16[1], A3_uint16[1]);
104
assertEquals(A1_uint32[0], A3_uint32[0]);
105
assertEquals(A1_uint32[1], A3_uint32[1]);
106
assertEquals(A1_float[0], A3_float[0]);
107
assertEquals(A1_float[1], A3_float[1]);
108
assertEquals(A1_double[0], A3_double[0]);
109
assertEquals(A1_double[1], A3_double[1]);