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

Side by Side Diff: test/mjsunit/array-store-and-grow.js

Issue 9310117: Implement KeyedStoreICs to grow arrays on out-of-bound stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits Created 8 years, 10 months 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 | Annotate | Revision Log
« src/x64/stub-cache-x64.cc ('K') | « src/x64/stub-cache-x64.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 2012 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
Vyacheslav Egorov (Chromium) 2012/02/10 00:19:18 consider adding test that checks COW handling. lik
danno 2012/02/10 12:25:34 Done.
28 function array_store_1(a,b,c) {
29 return (a[b] = c);
30 }
31
32 var a = [];
33 // Call twice to make sure store is done with IC
34 array_store_1(a, 0, 1);
35 a = [];
36 array_store_1(a, 0, 1);
37 assertEquals(1, a[0]);
38 assertEquals(1, array_store_1([], 0, 1));
39
40 a = [];
41 for (x=0;x<100000;++x) {
42 assertEquals(x, array_store_1(a, x, x));
43 }
44
45 for (x=0;x<100000;++x) {
46 assertEquals(x, array_store_1([], 0, x));
47 }
48
49 function array_store_2(a,b,c) {
50 return (a[b] = c);
51 }
52
53 a = [];
54 array_store_2(a, 0, 0.5);
55 a = [];
56 array_store_2(a, 0, 0.5);
57 assertEquals(0.5, a[0]);
58 assertEquals(0.5, array_store_2([], 0, 0.5));
59
60 function array_store_3(a,b,c) {
61 return (a[b] = c);
62 }
63
64 x = new Object();
65 a = [];
66 array_store_3(a, 0, x);
67 a = [];
68 array_store_3(a, 0, x);
69 assertEquals(x, a[0]);
70 assertEquals(x, array_store_3([], 0, x));
71
72 function array_store_4(a,b,c) {
73 return (a[b] = c);
74 }
75
76 a = [1];
77 // Call twice to make sure store is done with IC
78 array_store_4(a, 1, 1);
79 a = [1];
80 array_store_4(a, 1, 1);
81 assertEquals(1, a[1]);
82 assertEquals(1, array_store_4([], 1, 1));
83
84 function array_store_5(a,b,c) {
85 return (a[b] = c);
86 }
87
88 a = [2];
89 array_store_5(a, 1, 0.5);
90 a = [2];
91 array_store_5(a, 1, 0.5);
92 assertEquals(0.5, a[1]);
93 assertEquals(0.5, array_store_5([], 1, 0.5));
94
95 function array_store_6(a,b,c) {
96 return (a[b] = c);
97 }
98
99 a = [3];
100 array_store_6(a, 1, x);
101 a = [3];
102 array_store_6(a, 1, x);
103 assertEquals(x, a[1]);
104 assertEquals(x, array_store_6([], 1, x));
105
106 a = new Array(1,2,3);
107 // Call twice to make sure store is done with IC
108 array_store_4(a, 3, 1);
109 a = new Array(1,2,3);
110 array_store_4(a, 3, 1);
111 assertEquals(1, a[3]);
112 assertEquals(1, array_store_4([], 3, 1));
113
114 function array_store_5(a,b,c) {
115 return (a[b] = c);
116 }
117
118 a = new Array(1,2,3);
119 array_store_5(a, 3, 0.5);
120 a = new Array(1,2,3);
121 array_store_5(a, 3, 0.5);
122 assertEquals(0.5, a[3]);
123 assertEquals(0.5, array_store_5([], 3, 0.5));
124
125 function array_store_6(a,b,c) {
126 return (a[b] = c);
127 }
128
129 a = new Array(1,2,3);
130 array_store_6(a, 3, x);
131 a = new Array(1,2,3);
132 array_store_6(a, 3, x);
133 assertEquals(x, a[3]);
134 assertEquals(x, array_store_6([], 3, x));
135
136 function array_store_7(a,b,c) {
137 return (a[b] = c);
138 }
139
140 var a = new Array(0.5, 1.5);
141 // Call twice to make sure store is done with IC
142 array_store_7(a, 2, .5);
143 a = new Array(0.5, 1.5);
144 array_store_7(a, 2, .5);
145 assertEquals(0.5, a[2]);
146 a = new Array(0.5, 1.5);
147 assertEquals(0.5, array_store_7(a, 2, 0.5));
148
149 for (x=0;x<100000;++x) {
150 a = new Array(0.5, 1.5);
151 assertEquals(x, array_store_7(a, 2, x));
152 }
153
154 function array_store_8(a,b,c) {
155 return (a[b] = c);
156 }
157
158 var a = new Array(0.5, 1.5);
159 // Call twice to make sure store is done with IC
160 array_store_8(a, 2, .5);
161 a = new Array(0.5, 1.5);
162 array_store_8(a, 10, .5);
163 assertEquals(0.5, a[10]);
164
165 // Grow the empty array with a double store.
166 function array_store_9(a,b,c) {
167 return (a[b] = c);
168 }
169
170 var a = [];
171 // Call twice to make sure store is done with IC
172 array_store_9(a, 0, 0.5);
173 a = [];
174 array_store_1(a, 0, 0.5);
Vyacheslav Egorov (Chromium) 2012/02/10 00:19:18 _9
175 assertEquals(0.5, a[0]);
176 assertEquals(0.5, array_store_1([], 0, 0.5));
OLDNEW
« src/x64/stub-cache-x64.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698