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

Side by Side Diff: test/mjsunit/allocation-site-info.js

Issue 24250005: AllocationSites for all literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 2 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
OLDNEW
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 %DeoptimizeFunction(instanceof_check); 372 %DeoptimizeFunction(instanceof_check);
373 %ClearFunctionTypeFeedback(instanceof_check); 373 %ClearFunctionTypeFeedback(instanceof_check);
374 instanceof_check(Array); 374 instanceof_check(Array);
375 instanceof_check(Array); 375 instanceof_check(Array);
376 %OptimizeFunctionOnNextCall(instanceof_check); 376 %OptimizeFunctionOnNextCall(instanceof_check);
377 instanceof_check(Array); 377 instanceof_check(Array);
378 assertOptimized(instanceof_check); 378 assertOptimized(instanceof_check);
379 379
380 instanceof_check(realmBArray); 380 instanceof_check(realmBArray);
381 assertUnoptimized(instanceof_check); 381 assertUnoptimized(instanceof_check);
382
383 // Case: make sure nested arrays benefit from allocation site feedback as
384 // well.
385 (function() {
386 // Make sure we handle nested arrays
387 function get_nested_literal() {
388 var literal = [[1,2,3,4], [2], [3]];
389 return literal;
390 }
391
392 obj = get_nested_literal();
393 assertKind(elements_kind.fast, obj);
394 obj[0][0] = 3.5;
395 obj[2][0] = "hello";
396 obj = get_nested_literal();
397 assertKind(elements_kind.fast_double, obj[0]);
398 assertKind(elements_kind.fast_smi_only, obj[1]);
399 assertKind(elements_kind.fast, obj[2]);
400
401 // A more complex nested literal case.
402 function get_deep_nested_literal() {
403 var literal = [[1], [[2], "hello"], 3, [4]];
404 return literal;
405 }
406
407 obj = get_deep_nested_literal();
408 assertKind(elements_kind.fast_smi_only, obj[1][0]);
409 obj[0][0] = 3.5;
410 obj[1][0][0] = "goodbye";
411 assertKind(elements_kind.fast_double, obj[0]);
412 assertKind(elements_kind.fast, obj[1][0]);
413
414 obj = get_deep_nested_literal();
415 assertKind(elements_kind.fast_double, obj[0]);
416 assertKind(elements_kind.fast, obj[1][0]);
417 })();
418
419
420 // Make sure object literals with array fields benefit from the type feedback
421 // that allocation mementos provide.
422 (function() {
423 // A literal in an object
424 function get_object_literal() {
425 var literal = {
426 array: [1,2,3],
427 data: 3.5
428 };
429 return literal;
430 }
431
432 obj = get_object_literal();
433 assertKind(elements_kind.fast_smi_only, obj.array);
434 obj.array[1] = 3.5;
435 assertKind(elements_kind.fast_double, obj.array);
436 obj = get_object_literal();
437 assertKind(elements_kind.fast_double, obj.array);
438
439 function get_nested_object_literal() {
440 var literal = {
441 array: [[1],[2],[3]],
442 data: 3.5
443 };
444 return literal;
445 }
446
447 obj = get_nested_object_literal();
448 assertKind(elements_kind.fast, obj.array);
449 assertKind(elements_kind.fast_smi_only, obj.array[1]);
450 obj.array[1][0] = 3.5;
451 assertKind(elements_kind.fast_double, obj.array[1]);
452 obj = get_nested_object_literal();
453 assertKind(elements_kind.fast_double, obj.array[1]);
454
455 %OptimizeFunctionOnNextCall(get_nested_object_literal);
456 get_nested_object_literal();
457 obj = get_nested_object_literal();
458 assertKind(elements_kind.fast_double, obj.array[1]);
459
460 // Make sure we handle nested arrays
461 function get_nested_literal() {
462 var literal = [[1,2,3,4], [2], [3]];
463 return literal;
464 }
465
466 obj = get_nested_literal();
467 assertKind(elements_kind.fast, obj);
468 obj[0][0] = 3.5;
469 obj[2][0] = "hello";
470 obj = get_nested_literal();
471 assertKind(elements_kind.fast_double, obj[0]);
472 assertKind(elements_kind.fast_smi_only, obj[1]);
473 assertKind(elements_kind.fast, obj[2]);
474
475 // A more complex nested literal case.
476 function get_deep_nested_literal() {
477 var literal = [[1], [[2], "hello"], 3, [4]];
478 return literal;
479 }
480
481 obj = get_deep_nested_literal();
482 assertKind(elements_kind.fast_smi_only, obj[1][0]);
483 obj[0][0] = 3.5;
484 obj[1][0][0] = "goodbye";
485 assertKind(elements_kind.fast_double, obj[0]);
486 assertKind(elements_kind.fast, obj[1][0]);
487
488 obj = get_deep_nested_literal();
489 assertKind(elements_kind.fast_double, obj[0]);
490 assertKind(elements_kind.fast, obj[1][0]);
491 })();
382 } 492 }
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698