| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 literal[0] = value; | 121 literal[0] = value; |
| 122 return literal; | 122 return literal; |
| 123 } | 123 } |
| 124 | 124 |
| 125 function get_standard_literal() { | 125 function get_standard_literal() { |
| 126 var literal = [1, 2, 3]; | 126 var literal = [1, 2, 3]; |
| 127 return literal; | 127 return literal; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Case: [1,2,3] as allocation site | 130 // Case: [1,2,3] as allocation site |
| 131 get_standard_literal(); // Skip premonomorphic state. |
| 131 obj = fastliteralcase(get_standard_literal(), 1); | 132 obj = fastliteralcase(get_standard_literal(), 1); |
| 132 assertKind(elements_kind.fast_smi_only, obj); | 133 assertKind(elements_kind.fast_smi_only, obj); |
| 133 obj = fastliteralcase(get_standard_literal(), 1.5); | 134 obj = fastliteralcase(get_standard_literal(), 1.5); |
| 134 assertKind(elements_kind.fast_double, obj); | 135 assertKind(elements_kind.fast_double, obj); |
| 135 obj = fastliteralcase(get_standard_literal(), 2); | 136 obj = fastliteralcase(get_standard_literal(), 2); |
| 136 assertKind(elements_kind.fast_double, obj); | 137 assertKind(elements_kind.fast_double, obj); |
| 137 | 138 |
| 138 // The test below is in a loop because arrays that live | 139 // The test below is in a loop because arrays that live |
| 139 // at global scope without the chance of being recreated | 140 // at global scope without the chance of being recreated |
| 140 // don't have allocation site information attached. | 141 // don't have allocation site information attached. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 162 get_standard_literal(); | 163 get_standard_literal(); |
| 163 obj = get_standard_literal(); | 164 obj = get_standard_literal(); |
| 164 assertKind(elements_kind.fast, obj); | 165 assertKind(elements_kind.fast, obj); |
| 165 | 166 |
| 166 function fastliteralcase_smifast(value) { | 167 function fastliteralcase_smifast(value) { |
| 167 var literal = [1, 2, 3, 4]; | 168 var literal = [1, 2, 3, 4]; |
| 168 literal[0] = value; | 169 literal[0] = value; |
| 169 return literal; | 170 return literal; |
| 170 } | 171 } |
| 171 | 172 |
| 173 fastliteralcase_smifast(1); // Skip premonomorphic state. |
| 172 obj = fastliteralcase_smifast(1); | 174 obj = fastliteralcase_smifast(1); |
| 173 assertKind(elements_kind.fast_smi_only, obj); | 175 assertKind(elements_kind.fast_smi_only, obj); |
| 174 obj = fastliteralcase_smifast("carter"); | 176 obj = fastliteralcase_smifast("carter"); |
| 175 assertKind(elements_kind.fast, obj); | 177 assertKind(elements_kind.fast, obj); |
| 176 obj = fastliteralcase_smifast(2); | 178 obj = fastliteralcase_smifast(2); |
| 177 assertKind(elements_kind.fast, obj); | 179 assertKind(elements_kind.fast, obj); |
| 178 | 180 |
| 179 // Case: make sure transitions from packed to holey are tracked | 181 // Case: make sure transitions from packed to holey are tracked |
| 180 function fastliteralcase_smiholey(index, value) { | 182 function fastliteralcase_smiholey(index, value) { |
| 181 var literal = [1, 2, 3, 4]; | 183 var literal = [1, 2, 3, 4]; |
| 182 literal[index] = value; | 184 literal[index] = value; |
| 183 return literal; | 185 return literal; |
| 184 } | 186 } |
| 185 | 187 |
| 188 fastliteralcase_smiholey(5, 1); // Skip premonomorphic state. |
| 186 obj = fastliteralcase_smiholey(5, 1); | 189 obj = fastliteralcase_smiholey(5, 1); |
| 187 assertKind(elements_kind.fast_smi_only, obj); | 190 assertKind(elements_kind.fast_smi_only, obj); |
| 188 assertHoley(obj); | 191 assertHoley(obj); |
| 189 obj = fastliteralcase_smiholey(0, 1); | 192 obj = fastliteralcase_smiholey(0, 1); |
| 190 assertKind(elements_kind.fast_smi_only, obj); | 193 assertKind(elements_kind.fast_smi_only, obj); |
| 191 assertHoley(obj); | 194 assertHoley(obj); |
| 192 | 195 |
| 193 function newarraycase_smidouble(value) { | 196 function newarraycase_smidouble(value) { |
| 194 var a = new Array(); | 197 var a = new Array(); |
| 195 a[0] = value; | 198 a[0] = value; |
| 196 return a; | 199 return a; |
| 197 } | 200 } |
| 198 | 201 |
| 199 // Case: new Array() as allocation site, smi->double | 202 // Case: new Array() as allocation site, smi->double |
| 203 newarraycase_smidouble(1); // Skip premonomorphic state. |
| 200 obj = newarraycase_smidouble(1); | 204 obj = newarraycase_smidouble(1); |
| 201 assertKind(elements_kind.fast_smi_only, obj); | 205 assertKind(elements_kind.fast_smi_only, obj); |
| 202 obj = newarraycase_smidouble(1.5); | 206 obj = newarraycase_smidouble(1.5); |
| 203 assertKind(elements_kind.fast_double, obj); | 207 assertKind(elements_kind.fast_double, obj); |
| 204 obj = newarraycase_smidouble(2); | 208 obj = newarraycase_smidouble(2); |
| 205 assertKind(elements_kind.fast_double, obj); | 209 assertKind(elements_kind.fast_double, obj); |
| 206 | 210 |
| 207 function newarraycase_smiobj(value) { | 211 function newarraycase_smiobj(value) { |
| 208 var a = new Array(); | 212 var a = new Array(); |
| 209 a[0] = value; | 213 a[0] = value; |
| 210 return a; | 214 return a; |
| 211 } | 215 } |
| 212 | 216 |
| 213 // Case: new Array() as allocation site, smi->fast | 217 // Case: new Array() as allocation site, smi->fast |
| 218 newarraycase_smiobj(1); // Skip premonomorphic state. |
| 214 obj = newarraycase_smiobj(1); | 219 obj = newarraycase_smiobj(1); |
| 215 assertKind(elements_kind.fast_smi_only, obj); | 220 assertKind(elements_kind.fast_smi_only, obj); |
| 216 obj = newarraycase_smiobj("gloria"); | 221 obj = newarraycase_smiobj("gloria"); |
| 217 assertKind(elements_kind.fast, obj); | 222 assertKind(elements_kind.fast, obj); |
| 218 obj = newarraycase_smiobj(2); | 223 obj = newarraycase_smiobj(2); |
| 219 assertKind(elements_kind.fast, obj); | 224 assertKind(elements_kind.fast, obj); |
| 220 | 225 |
| 221 function newarraycase_length_smidouble(value) { | 226 function newarraycase_length_smidouble(value) { |
| 222 var a = new Array(3); | 227 var a = new Array(3); |
| 223 a[0] = value; | 228 a[0] = value; |
| 224 return a; | 229 return a; |
| 225 } | 230 } |
| 226 | 231 |
| 227 // Case: new Array(length) as allocation site | 232 // Case: new Array(length) as allocation site |
| 233 newarraycase_length_smidouble(1); // Skip premonomorphic state. |
| 228 obj = newarraycase_length_smidouble(1); | 234 obj = newarraycase_length_smidouble(1); |
| 229 assertKind(elements_kind.fast_smi_only, obj); | 235 assertKind(elements_kind.fast_smi_only, obj); |
| 230 obj = newarraycase_length_smidouble(1.5); | 236 obj = newarraycase_length_smidouble(1.5); |
| 231 assertKind(elements_kind.fast_double, obj); | 237 assertKind(elements_kind.fast_double, obj); |
| 232 obj = newarraycase_length_smidouble(2); | 238 obj = newarraycase_length_smidouble(2); |
| 233 assertKind(elements_kind.fast_double, obj); | 239 assertKind(elements_kind.fast_double, obj); |
| 234 | 240 |
| 235 // Try to continue the transition to fast object. This won't work for | 241 // Try to continue the transition to fast object. This won't work for |
| 236 // constructed arrays because constructor dispatch is done on the | 242 // constructed arrays because constructor dispatch is done on the |
| 237 // elements kind, and a DOUBLE array constructor won't create an allocation | 243 // elements kind, and a DOUBLE array constructor won't create an allocation |
| 238 // memento. | 244 // memento. |
| 239 obj = newarraycase_length_smidouble("coates"); | 245 obj = newarraycase_length_smidouble("coates"); |
| 240 assertKind(elements_kind.fast, obj); | 246 assertKind(elements_kind.fast, obj); |
| 241 obj = newarraycase_length_smidouble(2); | 247 obj = newarraycase_length_smidouble(2); |
| 242 assertKind(elements_kind.fast_double, obj); | 248 assertKind(elements_kind.fast_double, obj); |
| 243 | 249 |
| 244 function newarraycase_length_smiobj(value) { | 250 function newarraycase_length_smiobj(value) { |
| 245 var a = new Array(3); | 251 var a = new Array(3); |
| 246 a[0] = value; | 252 a[0] = value; |
| 247 return a; | 253 return a; |
| 248 } | 254 } |
| 249 | 255 |
| 250 // Case: new Array(<length>) as allocation site, smi->fast | 256 // Case: new Array(<length>) as allocation site, smi->fast |
| 257 newarraycase_length_smiobj(1); // Skip premonomorphic state. |
| 251 obj = newarraycase_length_smiobj(1); | 258 obj = newarraycase_length_smiobj(1); |
| 252 assertKind(elements_kind.fast_smi_only, obj); | 259 assertKind(elements_kind.fast_smi_only, obj); |
| 253 obj = newarraycase_length_smiobj("gloria"); | 260 obj = newarraycase_length_smiobj("gloria"); |
| 254 assertKind(elements_kind.fast, obj); | 261 assertKind(elements_kind.fast, obj); |
| 255 obj = newarraycase_length_smiobj(2); | 262 obj = newarraycase_length_smiobj(2); |
| 256 assertKind(elements_kind.fast, obj); | 263 assertKind(elements_kind.fast, obj); |
| 257 | 264 |
| 258 function newarraycase_list_smidouble(value) { | 265 function newarraycase_list_smidouble(value) { |
| 259 var a = new Array(1, 2, 3); | 266 var a = new Array(1, 2, 3); |
| 260 a[0] = value; | 267 a[0] = value; |
| 261 return a; | 268 return a; |
| 262 } | 269 } |
| 263 | 270 |
| 271 newarraycase_list_smidouble(1); // Skip premonomorphic state. |
| 264 obj = newarraycase_list_smidouble(1); | 272 obj = newarraycase_list_smidouble(1); |
| 265 assertKind(elements_kind.fast_smi_only, obj); | 273 assertKind(elements_kind.fast_smi_only, obj); |
| 266 obj = newarraycase_list_smidouble(1.5); | 274 obj = newarraycase_list_smidouble(1.5); |
| 267 assertKind(elements_kind.fast_double, obj); | 275 assertKind(elements_kind.fast_double, obj); |
| 268 obj = newarraycase_list_smidouble(2); | 276 obj = newarraycase_list_smidouble(2); |
| 269 assertKind(elements_kind.fast_double, obj); | 277 assertKind(elements_kind.fast_double, obj); |
| 270 | 278 |
| 271 function newarraycase_list_smiobj(value) { | 279 function newarraycase_list_smiobj(value) { |
| 272 var a = new Array(4, 5, 6); | 280 var a = new Array(4, 5, 6); |
| 273 a[0] = value; | 281 a[0] = value; |
| 274 return a; | 282 return a; |
| 275 } | 283 } |
| 276 | 284 |
| 285 newarraycase_list_smiobj(1); // Skip premonomorphic state. |
| 277 obj = newarraycase_list_smiobj(1); | 286 obj = newarraycase_list_smiobj(1); |
| 278 assertKind(elements_kind.fast_smi_only, obj); | 287 assertKind(elements_kind.fast_smi_only, obj); |
| 279 obj = newarraycase_list_smiobj("coates"); | 288 obj = newarraycase_list_smiobj("coates"); |
| 280 assertKind(elements_kind.fast, obj); | 289 assertKind(elements_kind.fast, obj); |
| 281 obj = newarraycase_list_smiobj(2); | 290 obj = newarraycase_list_smiobj(2); |
| 282 assertKind(elements_kind.fast, obj); | 291 assertKind(elements_kind.fast, obj); |
| 283 | 292 |
| 284 // Case: array constructor calls with out of date feedback. | 293 // Case: array constructor calls with out of date feedback. |
| 285 // The boilerplate should incorporate all feedback, but the input array | 294 // The boilerplate should incorporate all feedback, but the input array |
| 286 // should be minimally transitioned based on immediate need. | 295 // should be minimally transitioned based on immediate need. |
| 287 (function() { | 296 (function() { |
| 288 function foo(i) { | 297 function foo(i) { |
| 289 // We have two cases, one for literals one for constructed arrays. | 298 // We have two cases, one for literals one for constructed arrays. |
| 290 var a = (i == 0) | 299 var a = (i == 0) |
| 291 ? [1, 2, 3] | 300 ? [1, 2, 3] |
| 292 : new Array(1, 2, 3); | 301 : new Array(1, 2, 3); |
| 293 return a; | 302 return a; |
| 294 } | 303 } |
| 295 | 304 |
| 305 foo(0); foo(1); // Skip premonomorphic state. |
| 296 for (i = 0; i < 2; i++) { | 306 for (i = 0; i < 2; i++) { |
| 297 a = foo(i); | 307 a = foo(i); |
| 298 b = foo(i); | 308 b = foo(i); |
| 299 b[5] = 1; // boilerplate goes holey | 309 b[5] = 1; // boilerplate goes holey |
| 300 assertHoley(foo(i)); | 310 assertHoley(foo(i)); |
| 301 a[0] = 3.5; // boilerplate goes holey double | 311 a[0] = 3.5; // boilerplate goes holey double |
| 302 assertKind(elements_kind.fast_double, a); | 312 assertKind(elements_kind.fast_double, a); |
| 303 assertNotHoley(a); | 313 assertNotHoley(a); |
| 304 c = foo(i); | 314 c = foo(i); |
| 305 assertKind(elements_kind.fast_double, c); | 315 assertKind(elements_kind.fast_double, c); |
| 306 assertHoley(c); | 316 assertHoley(c); |
| 307 } | 317 } |
| 308 })(); | 318 })(); |
| 309 | 319 |
| 310 function newarraycase_onearg(len, value) { | 320 function newarraycase_onearg(len, value) { |
| 311 var a = new Array(len); | 321 var a = new Array(len); |
| 312 a[0] = value; | 322 a[0] = value; |
| 313 return a; | 323 return a; |
| 314 } | 324 } |
| 315 | 325 |
| 326 newarraycase_onearg(5, 3.5); // Skip premonomorphic state. |
| 316 obj = newarraycase_onearg(5, 3.5); | 327 obj = newarraycase_onearg(5, 3.5); |
| 317 assertKind(elements_kind.fast_double, obj); | 328 assertKind(elements_kind.fast_double, obj); |
| 318 obj = newarraycase_onearg(10, 5); | 329 obj = newarraycase_onearg(10, 5); |
| 319 assertKind(elements_kind.fast_double, obj); | 330 assertKind(elements_kind.fast_double, obj); |
| 320 obj = newarraycase_onearg(0, 5); | 331 obj = newarraycase_onearg(0, 5); |
| 321 assertKind(elements_kind.fast_double, obj); | 332 assertKind(elements_kind.fast_double, obj); |
| 322 // Now pass a length that forces the dictionary path. | 333 // Now pass a length that forces the dictionary path. |
| 323 obj = newarraycase_onearg(100000, 5); | 334 obj = newarraycase_onearg(100000, 5); |
| 324 assertKind(elements_kind.dictionary, obj); | 335 assertKind(elements_kind.dictionary, obj); |
| 325 assertTrue(obj.length == 100000); | 336 assertTrue(obj.length == 100000); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 392 |
| 382 // Case: make sure nested arrays benefit from allocation site feedback as | 393 // Case: make sure nested arrays benefit from allocation site feedback as |
| 383 // well. | 394 // well. |
| 384 (function() { | 395 (function() { |
| 385 // Make sure we handle nested arrays | 396 // Make sure we handle nested arrays |
| 386 function get_nested_literal() { | 397 function get_nested_literal() { |
| 387 var literal = [[1,2,3,4], [2], [3]]; | 398 var literal = [[1,2,3,4], [2], [3]]; |
| 388 return literal; | 399 return literal; |
| 389 } | 400 } |
| 390 | 401 |
| 402 get_nested_literal(); // Skip premonomorphic state. |
| 391 obj = get_nested_literal(); | 403 obj = get_nested_literal(); |
| 392 assertKind(elements_kind.fast, obj); | 404 assertKind(elements_kind.fast, obj); |
| 393 obj[0][0] = 3.5; | 405 obj[0][0] = 3.5; |
| 394 obj[2][0] = "hello"; | 406 obj[2][0] = "hello"; |
| 395 obj = get_nested_literal(); | 407 obj = get_nested_literal(); |
| 396 assertKind(elements_kind.fast_double, obj[0]); | 408 assertKind(elements_kind.fast_double, obj[0]); |
| 397 assertKind(elements_kind.fast_smi_only, obj[1]); | 409 assertKind(elements_kind.fast_smi_only, obj[1]); |
| 398 assertKind(elements_kind.fast, obj[2]); | 410 assertKind(elements_kind.fast, obj[2]); |
| 399 | 411 |
| 400 // A more complex nested literal case. | 412 // A more complex nested literal case. |
| 401 function get_deep_nested_literal() { | 413 function get_deep_nested_literal() { |
| 402 var literal = [[1], [[2], "hello"], 3, [4]]; | 414 var literal = [[1], [[2], "hello"], 3, [4]]; |
| 403 return literal; | 415 return literal; |
| 404 } | 416 } |
| 405 | 417 |
| 418 get_deep_nested_literal(); // Skip premonomorphic state. |
| 406 obj = get_deep_nested_literal(); | 419 obj = get_deep_nested_literal(); |
| 407 assertKind(elements_kind.fast_smi_only, obj[1][0]); | 420 assertKind(elements_kind.fast_smi_only, obj[1][0]); |
| 408 obj[0][0] = 3.5; | 421 obj[0][0] = 3.5; |
| 409 obj[1][0][0] = "goodbye"; | 422 obj[1][0][0] = "goodbye"; |
| 410 assertKind(elements_kind.fast_double, obj[0]); | 423 assertKind(elements_kind.fast_double, obj[0]); |
| 411 assertKind(elements_kind.fast, obj[1][0]); | 424 assertKind(elements_kind.fast, obj[1][0]); |
| 412 | 425 |
| 413 obj = get_deep_nested_literal(); | 426 obj = get_deep_nested_literal(); |
| 414 assertKind(elements_kind.fast_double, obj[0]); | 427 assertKind(elements_kind.fast_double, obj[0]); |
| 415 assertKind(elements_kind.fast, obj[1][0]); | 428 assertKind(elements_kind.fast, obj[1][0]); |
| 416 })(); | 429 })(); |
| 417 | 430 |
| 418 | 431 |
| 419 // Make sure object literals with array fields benefit from the type feedback | 432 // Make sure object literals with array fields benefit from the type feedback |
| 420 // that allocation mementos provide. | 433 // that allocation mementos provide. |
| 421 (function() { | 434 (function() { |
| 422 // A literal in an object | 435 // A literal in an object |
| 423 function get_object_literal() { | 436 function get_object_literal() { |
| 424 var literal = { | 437 var literal = { |
| 425 array: [1,2,3], | 438 array: [1,2,3], |
| 426 data: 3.5 | 439 data: 3.5 |
| 427 }; | 440 }; |
| 428 return literal; | 441 return literal; |
| 429 } | 442 } |
| 430 | 443 |
| 444 get_object_literal(); // Skip premonomorphic state. |
| 431 obj = get_object_literal(); | 445 obj = get_object_literal(); |
| 432 assertKind(elements_kind.fast_smi_only, obj.array); | 446 assertKind(elements_kind.fast_smi_only, obj.array); |
| 433 obj.array[1] = 3.5; | 447 obj.array[1] = 3.5; |
| 434 assertKind(elements_kind.fast_double, obj.array); | 448 assertKind(elements_kind.fast_double, obj.array); |
| 435 obj = get_object_literal(); | 449 obj = get_object_literal(); |
| 436 assertKind(elements_kind.fast_double, obj.array); | 450 assertKind(elements_kind.fast_double, obj.array); |
| 437 | 451 |
| 438 function get_nested_object_literal() { | 452 function get_nested_object_literal() { |
| 439 var literal = { | 453 var literal = { |
| 440 array: [[1],[2],[3]], | 454 array: [[1],[2],[3]], |
| 441 data: 3.5 | 455 data: 3.5 |
| 442 }; | 456 }; |
| 443 return literal; | 457 return literal; |
| 444 } | 458 } |
| 445 | 459 |
| 460 get_nested_object_literal(); // Skip premonomorphic state. |
| 446 obj = get_nested_object_literal(); | 461 obj = get_nested_object_literal(); |
| 447 assertKind(elements_kind.fast, obj.array); | 462 assertKind(elements_kind.fast, obj.array); |
| 448 assertKind(elements_kind.fast_smi_only, obj.array[1]); | 463 assertKind(elements_kind.fast_smi_only, obj.array[1]); |
| 449 obj.array[1][0] = 3.5; | 464 obj.array[1][0] = 3.5; |
| 450 assertKind(elements_kind.fast_double, obj.array[1]); | 465 assertKind(elements_kind.fast_double, obj.array[1]); |
| 451 obj = get_nested_object_literal(); | 466 obj = get_nested_object_literal(); |
| 452 assertKind(elements_kind.fast_double, obj.array[1]); | 467 assertKind(elements_kind.fast_double, obj.array[1]); |
| 453 | 468 |
| 454 %OptimizeFunctionOnNextCall(get_nested_object_literal); | 469 %OptimizeFunctionOnNextCall(get_nested_object_literal); |
| 455 get_nested_object_literal(); | 470 get_nested_object_literal(); |
| 456 obj = get_nested_object_literal(); | 471 obj = get_nested_object_literal(); |
| 457 assertKind(elements_kind.fast_double, obj.array[1]); | 472 assertKind(elements_kind.fast_double, obj.array[1]); |
| 458 | 473 |
| 459 // Make sure we handle nested arrays | 474 // Make sure we handle nested arrays |
| 460 function get_nested_literal() { | 475 function get_nested_literal() { |
| 461 var literal = [[1,2,3,4], [2], [3]]; | 476 var literal = [[1,2,3,4], [2], [3]]; |
| 462 return literal; | 477 return literal; |
| 463 } | 478 } |
| 464 | 479 |
| 480 get_nested_literal(); // Skip premonomorphic state. |
| 465 obj = get_nested_literal(); | 481 obj = get_nested_literal(); |
| 466 assertKind(elements_kind.fast, obj); | 482 assertKind(elements_kind.fast, obj); |
| 467 obj[0][0] = 3.5; | 483 obj[0][0] = 3.5; |
| 468 obj[2][0] = "hello"; | 484 obj[2][0] = "hello"; |
| 469 obj = get_nested_literal(); | 485 obj = get_nested_literal(); |
| 470 assertKind(elements_kind.fast_double, obj[0]); | 486 assertKind(elements_kind.fast_double, obj[0]); |
| 471 assertKind(elements_kind.fast_smi_only, obj[1]); | 487 assertKind(elements_kind.fast_smi_only, obj[1]); |
| 472 assertKind(elements_kind.fast, obj[2]); | 488 assertKind(elements_kind.fast, obj[2]); |
| 473 | 489 |
| 474 // A more complex nested literal case. | 490 // A more complex nested literal case. |
| 475 function get_deep_nested_literal() { | 491 function get_deep_nested_literal() { |
| 476 var literal = [[1], [[2], "hello"], 3, [4]]; | 492 var literal = [[1], [[2], "hello"], 3, [4]]; |
| 477 return literal; | 493 return literal; |
| 478 } | 494 } |
| 479 | 495 |
| 496 get_deep_nested_literal(); // Skip premonomorphic state. |
| 480 obj = get_deep_nested_literal(); | 497 obj = get_deep_nested_literal(); |
| 481 assertKind(elements_kind.fast_smi_only, obj[1][0]); | 498 assertKind(elements_kind.fast_smi_only, obj[1][0]); |
| 482 obj[0][0] = 3.5; | 499 obj[0][0] = 3.5; |
| 483 obj[1][0][0] = "goodbye"; | 500 obj[1][0][0] = "goodbye"; |
| 484 assertKind(elements_kind.fast_double, obj[0]); | 501 assertKind(elements_kind.fast_double, obj[0]); |
| 485 assertKind(elements_kind.fast, obj[1][0]); | 502 assertKind(elements_kind.fast, obj[1][0]); |
| 486 | 503 |
| 487 obj = get_deep_nested_literal(); | 504 obj = get_deep_nested_literal(); |
| 488 assertKind(elements_kind.fast_double, obj[0]); | 505 assertKind(elements_kind.fast_double, obj[0]); |
| 489 assertKind(elements_kind.fast, obj[1][0]); | 506 assertKind(elements_kind.fast, obj[1][0]); |
| 490 })(); | 507 })(); |
| 491 } | 508 } |
| OLD | NEW |