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

Side by Side Diff: test/cctest/test-feedback-vector.cc

Issue 1424153003: VectorICs: Remove --vector-stores flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Response to Hannes comment. Created 5 years, 1 month 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
« no previous file with comments | « test/cctest/interpreter/test-interpreter.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
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(mvstanton): Remove this define after this flag is turned on globally 5 // TODO(mvstanton): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 10
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 "}" 453 "}"
454 "a = 3;" 454 "a = 3;"
455 "testvar({});"); 455 "testvar({});");
456 456
457 Handle<JSFunction> f = GetFunction("testvar"); 457 Handle<JSFunction> f = GetFunction("testvar");
458 458
459 // There should be two LOAD_ICs, one for a and one for y at the end. 459 // There should be two LOAD_ICs, one for a and one for y at the end.
460 Handle<TypeFeedbackVector> feedback_vector = 460 Handle<TypeFeedbackVector> feedback_vector =
461 handle(f->shared()->feedback_vector(), isolate); 461 handle(f->shared()->feedback_vector(), isolate);
462 FeedbackVectorHelper helper(feedback_vector); 462 FeedbackVectorHelper helper(feedback_vector);
463 if (FLAG_vector_stores) { 463 CHECK_EQ(4, helper.slot_count());
464 CHECK_EQ(4, helper.slot_count()); 464 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::STORE_IC);
465 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::STORE_IC); 465 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC);
466 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC); 466 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC);
467 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); 467 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::LOAD_IC);
468 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::LOAD_IC);
469 } else {
470 CHECK_EQ(2, helper.slot_count());
471 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC);
472 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC);
473 }
474 } 468 }
475 469
476 { 470 {
477 CompileRun( 471 CompileRun(
478 "function testprop(x) {" 472 "function testprop(x) {"
479 " x.blue = a;" 473 " x.blue = a;"
480 "}" 474 "}"
481 "testprop({ blue: 3 });"); 475 "testprop({ blue: 3 });");
482 476
483 Handle<JSFunction> f = GetFunction("testprop"); 477 Handle<JSFunction> f = GetFunction("testprop");
484 478
485 // There should be one LOAD_IC, for the load of a. 479 // There should be one LOAD_IC, for the load of a.
486 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 480 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
487 FeedbackVectorHelper helper(feedback_vector); 481 FeedbackVectorHelper helper(feedback_vector);
488 if (FLAG_vector_stores) { 482 CHECK_EQ(2, helper.slot_count());
489 CHECK_EQ(2, helper.slot_count());
490 } else {
491 CHECK_EQ(1, helper.slot_count());
492 }
493 } 483 }
494 484
495 { 485 {
496 CompileRun( 486 CompileRun(
497 "function testpropfunc(x) {" 487 "function testpropfunc(x) {"
498 " x().blue = a;" 488 " x().blue = a;"
499 " return x().blue;" 489 " return x().blue;"
500 "}" 490 "}"
501 "function makeresult() { return { blue: 3 }; }" 491 "function makeresult() { return { blue: 3 }; }"
502 "testpropfunc(makeresult);"); 492 "testpropfunc(makeresult);");
503 493
504 Handle<JSFunction> f = GetFunction("testpropfunc"); 494 Handle<JSFunction> f = GetFunction("testpropfunc");
505 495
506 // There should be 2 LOAD_ICs and 2 CALL_ICs. 496 // There should be 2 LOAD_ICs and 2 CALL_ICs.
507 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 497 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
508 FeedbackVectorHelper helper(feedback_vector); 498 FeedbackVectorHelper helper(feedback_vector);
509 if (FLAG_vector_stores) { 499 CHECK_EQ(5, helper.slot_count());
510 CHECK_EQ(5, helper.slot_count()); 500 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::CALL_IC);
511 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::CALL_IC); 501 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC);
512 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC); 502 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC);
513 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); 503 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::CALL_IC);
514 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::CALL_IC); 504 CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC);
515 CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC);
516 } else {
517 CHECK_EQ(4, helper.slot_count());
518 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::CALL_IC);
519 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC);
520 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::CALL_IC);
521 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::LOAD_IC);
522 }
523 } 505 }
524 506
525 { 507 {
526 CompileRun( 508 CompileRun(
527 "function testkeyedprop(x) {" 509 "function testkeyedprop(x) {"
528 " x[0] = a;" 510 " x[0] = a;"
529 " return x[0];" 511 " return x[0];"
530 "}" 512 "}"
531 "testkeyedprop([0, 1, 2]);"); 513 "testkeyedprop([0, 1, 2]);");
532 514
533 Handle<JSFunction> f = GetFunction("testkeyedprop"); 515 Handle<JSFunction> f = GetFunction("testkeyedprop");
534 516
535 // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for 517 // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for
536 // the load of x[0] in the return statement. 518 // the load of x[0] in the return statement.
537 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 519 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
538 FeedbackVectorHelper helper(feedback_vector); 520 FeedbackVectorHelper helper(feedback_vector);
539 if (FLAG_vector_stores) { 521 CHECK_EQ(3, helper.slot_count());
540 CHECK_EQ(3, helper.slot_count()); 522 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC);
541 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC); 523 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::KEYED_STORE_IC);
542 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::KEYED_STORE_IC); 524 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::KEYED_LOAD_IC);
543 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::KEYED_LOAD_IC);
544 } else {
545 CHECK_EQ(2, helper.slot_count());
546 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC);
547 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::KEYED_LOAD_IC);
548 }
549 } 525 }
550 526
551 { 527 {
552 CompileRun( 528 CompileRun(
553 "function testcompound(x) {" 529 "function testcompound(x) {"
554 " x.old = x.young = x.in_between = a;" 530 " x.old = x.young = x.in_between = a;"
555 " return x.old + x.young;" 531 " return x.old + x.young;"
556 "}" 532 "}"
557 "testcompound({ old: 3, young: 3, in_between: 3 });"); 533 "testcompound({ old: 3, young: 3, in_between: 3 });");
558 534
559 Handle<JSFunction> f = GetFunction("testcompound"); 535 Handle<JSFunction> f = GetFunction("testcompound");
560 536
561 // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young. 537 // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young.
562 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 538 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
563 FeedbackVectorHelper helper(feedback_vector); 539 FeedbackVectorHelper helper(feedback_vector);
564 if (FLAG_vector_stores) { 540 CHECK_EQ(6, helper.slot_count());
565 CHECK_EQ(6, helper.slot_count()); 541 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC);
566 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC); 542 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::STORE_IC);
567 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::STORE_IC); 543 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC);
568 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::STORE_IC); 544 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::STORE_IC);
569 CHECK_SLOT_KIND(helper, 3, FeedbackVectorSlotKind::STORE_IC); 545 CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC);
570 CHECK_SLOT_KIND(helper, 4, FeedbackVectorSlotKind::LOAD_IC); 546 CHECK_SLOT_KIND(helper, 5, FeedbackVectorSlotKind::LOAD_IC);
571 CHECK_SLOT_KIND(helper, 5, FeedbackVectorSlotKind::LOAD_IC);
572 } else {
573 CHECK_EQ(3, helper.slot_count());
574 CHECK_SLOT_KIND(helper, 0, FeedbackVectorSlotKind::LOAD_IC);
575 CHECK_SLOT_KIND(helper, 1, FeedbackVectorSlotKind::LOAD_IC);
576 CHECK_SLOT_KIND(helper, 2, FeedbackVectorSlotKind::LOAD_IC);
577 }
578 } 547 }
579 } 548 }
580 549
581 550
582 TEST(VectorStoreICBasic) { 551 TEST(VectorStoreICBasic) {
583 if (i::FLAG_always_opt) return; 552 if (i::FLAG_always_opt) return;
584 if (!i::FLAG_vector_stores) return;
585 553
586 CcTest::InitializeVM(); 554 CcTest::InitializeVM();
587 LocalContext context; 555 LocalContext context;
588 v8::HandleScope scope(context->GetIsolate()); 556 v8::HandleScope scope(context->GetIsolate());
589 557
590 CompileRun( 558 CompileRun(
591 "function f(a) {" 559 "function f(a) {"
592 " a.foo = 5;" 560 " a.foo = 5;"
593 "}" 561 "}"
594 "var a = { foo: 3 };" 562 "var a = { foo: 3 };"
595 "f(a);" 563 "f(a);"
596 "f(a);" 564 "f(a);"
597 "f(a);"); 565 "f(a);");
598 Handle<JSFunction> f = GetFunction("f"); 566 Handle<JSFunction> f = GetFunction("f");
599 // There should be one IC slot. 567 // There should be one IC slot.
600 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 568 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
601 FeedbackVectorHelper helper(feedback_vector); 569 FeedbackVectorHelper helper(feedback_vector);
602 CHECK_EQ(1, helper.slot_count()); 570 CHECK_EQ(1, helper.slot_count());
603 FeedbackVectorSlot slot(0); 571 FeedbackVectorSlot slot(0);
604 StoreICNexus nexus(feedback_vector, slot); 572 StoreICNexus nexus(feedback_vector, slot);
605 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 573 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
606 } 574 }
607 575
608 } // namespace 576 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698