OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return (a[b] = c); | 180 return (a[b] = c); |
181 } | 181 } |
182 | 182 |
183 var a = []; | 183 var a = []; |
184 array_store_9(a, 0, 0.5); | 184 array_store_9(a, 0, 0.5); |
185 a = []; | 185 a = []; |
186 array_store_1(a, 0, 0.5); | 186 array_store_1(a, 0, 0.5); |
187 assertEquals(0.5, a[0]); | 187 assertEquals(0.5, a[0]); |
188 assertEquals(0.5, array_store_1([], 0, 0.5)); | 188 assertEquals(0.5, array_store_1([], 0, 0.5)); |
189 | 189 |
| 190 |
190 // Verify that a grow store will deoptimize if the max gap (difference between | 191 // Verify that a grow store will deoptimize if the max gap (difference between |
191 // the end of an array capacity and a new index) is passed. The wrapper is to | 192 // the end of an array capacity and a new index) is passed. The wrapper is to |
192 // make sure array_store_10 isn't inlined. | 193 // make sure array_store_10 isn't inlined. |
193 | 194 |
194 (function() { | 195 (function() { |
195 function grow_store(a,b,c) { | 196 function grow_store(a,b,c) { |
196 a[b] = c; | 197 a[b] = c; |
197 } | 198 } |
198 | 199 |
199 a = new Array(1); | 200 a = new Array(1); |
200 grow_store(a,1,1); | 201 grow_store(a,1,1); |
201 grow_store(a,2,1); | 202 grow_store(a,2,1); |
202 %OptimizeFunctionOnNextCall(grow_store); | 203 %OptimizeFunctionOnNextCall(grow_store); |
203 grow_store(a,10,1); | 204 grow_store(a,10,1); |
204 assertOptimized(grow_store); | 205 assertOptimized(grow_store); |
205 grow_store(a,2048,1); | 206 grow_store(a,2048,1); |
206 assertUnoptimized(grow_store); | 207 assertUnoptimized(grow_store); |
207 %ClearFunctionTypeFeedback(grow_store); | 208 %ClearFunctionTypeFeedback(grow_store); |
208 })(); | 209 })(); |
209 | 210 |
| 211 |
| 212 // Verify that a polymorphic store and grow IC when crankshafted is still |
| 213 // a grow IC (earlier it would revert to a standard store in the polymorphic |
| 214 // case). |
| 215 (function() { |
| 216 function f(o, k, v) { |
| 217 o[k] = v; |
| 218 } |
| 219 |
| 220 a = [3.5]; |
| 221 f(a, 1, "hi"); // DOUBLE packed array -> tagged packed grow |
| 222 a = {}; |
| 223 a.p = "property"; |
| 224 a[0] = 1; |
| 225 f(a, 0, 5.4); |
| 226 |
| 227 %OptimizeFunctionOnNextCall(f); |
| 228 // Should be a polymorphic grow stub. If not a grow stub it will deopt. |
| 229 f(new Array("hi"), 1, 3); |
| 230 assertOptimized(f); |
| 231 %ClearFunctionTypeFeedback(f); |
| 232 })(); |
| 233 |
| 234 |
| 235 // Now verify that a polymorphic store (non-growing) IC when crankshafted WILL |
| 236 // deopt if you pass an element out of bounds. |
| 237 (function() { |
| 238 function f(o, k, v) { |
| 239 o[k] = v; |
| 240 } |
| 241 |
| 242 a = [3.5]; |
| 243 f(a, 0, "hi"); // DOUBLE packed array -> tagged packed grow |
| 244 a = {}; |
| 245 a.p = "property"; |
| 246 a[0] = 1; |
| 247 f(a, 0, 5.4); |
| 248 |
| 249 %OptimizeFunctionOnNextCall(f); |
| 250 f(new Array("hi"), 0, 3); |
| 251 assertOptimized(f); |
| 252 // An attempt to grow should cause deopt |
| 253 f(new Array("hi"), 1, 3); |
| 254 assertUnoptimized(f); |
| 255 %ClearFunctionTypeFeedback(f); |
| 256 })(); |
OLD | NEW |