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

Side by Side Diff: test/cctest/heap/test-heap.cc

Issue 1949393006: Remove deprecated uses of WeakCallbackData from tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | test/cctest/heap/test-mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 571
572 CHECK_EQ(*h4, *h2); 572 CHECK_EQ(*h4, *h2);
573 GlobalHandles::Destroy(h2.location()); 573 GlobalHandles::Destroy(h2.location());
574 GlobalHandles::Destroy(h4.location()); 574 GlobalHandles::Destroy(h4.location());
575 } 575 }
576 576
577 577
578 static bool WeakPointerCleared = false; 578 static bool WeakPointerCleared = false;
579 579
580 static void TestWeakGlobalHandleCallback( 580 static void TestWeakGlobalHandleCallback(
581 const v8::WeakCallbackData<v8::Value, void>& data) { 581 const v8::WeakCallbackInfo<void>& data) {
582 std::pair<v8::Persistent<v8::Value>*, int>* p = 582 std::pair<v8::Persistent<v8::Value>*, int>* p =
583 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( 583 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
584 data.GetParameter()); 584 data.GetParameter());
585 if (p->second == 1234) WeakPointerCleared = true; 585 if (p->second == 1234) WeakPointerCleared = true;
586 p->first->Reset(); 586 p->first->Reset();
587 } 587 }
588 588
589 589
590 TEST(WeakGlobalHandlesScavenge) { 590 TEST(WeakGlobalHandlesScavenge) {
591 i::FLAG_stress_compaction = false; 591 i::FLAG_stress_compaction = false;
(...skipping 12 matching lines...) Expand all
604 HandleScope scope(isolate); 604 HandleScope scope(isolate);
605 605
606 Handle<Object> i = factory->NewStringFromStaticChars("fisk"); 606 Handle<Object> i = factory->NewStringFromStaticChars("fisk");
607 Handle<Object> u = factory->NewNumber(1.12344); 607 Handle<Object> u = factory->NewNumber(1.12344);
608 608
609 h1 = global_handles->Create(*i); 609 h1 = global_handles->Create(*i);
610 h2 = global_handles->Create(*u); 610 h2 = global_handles->Create(*u);
611 } 611 }
612 612
613 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); 613 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
614 GlobalHandles::MakeWeak(h2.location(), 614 GlobalHandles::MakeWeak(
615 reinterpret_cast<void*>(&handle_and_id), 615 h2.location(), reinterpret_cast<void*>(&handle_and_id),
616 &TestWeakGlobalHandleCallback); 616 &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter);
617 617
618 // Scavenge treats weak pointers as normal roots. 618 // Scavenge treats weak pointers as normal roots.
619 heap->CollectGarbage(NEW_SPACE); 619 heap->CollectGarbage(NEW_SPACE);
620 620
621 CHECK((*h1)->IsString()); 621 CHECK((*h1)->IsString());
622 CHECK((*h2)->IsHeapNumber()); 622 CHECK((*h2)->IsHeapNumber());
623 623
624 CHECK(!WeakPointerCleared); 624 CHECK(!WeakPointerCleared);
625 CHECK(!global_handles->IsNearDeath(h2.location())); 625 CHECK(!global_handles->IsNearDeath(h2.location()));
626 CHECK(!global_handles->IsNearDeath(h1.location())); 626 CHECK(!global_handles->IsNearDeath(h1.location()));
(...skipping 24 matching lines...) Expand all
651 h1 = global_handles->Create(*i); 651 h1 = global_handles->Create(*i);
652 h2 = global_handles->Create(*u); 652 h2 = global_handles->Create(*u);
653 } 653 }
654 654
655 // Make sure the objects are promoted. 655 // Make sure the objects are promoted.
656 heap->CollectGarbage(OLD_SPACE); 656 heap->CollectGarbage(OLD_SPACE);
657 heap->CollectGarbage(NEW_SPACE); 657 heap->CollectGarbage(NEW_SPACE);
658 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2)); 658 CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2));
659 659
660 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); 660 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
661 GlobalHandles::MakeWeak(h2.location(), 661 GlobalHandles::MakeWeak(
662 reinterpret_cast<void*>(&handle_and_id), 662 h2.location(), reinterpret_cast<void*>(&handle_and_id),
663 &TestWeakGlobalHandleCallback); 663 &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter);
664 CHECK(!GlobalHandles::IsNearDeath(h1.location())); 664 CHECK(!GlobalHandles::IsNearDeath(h1.location()));
665 CHECK(!GlobalHandles::IsNearDeath(h2.location())); 665 CHECK(!GlobalHandles::IsNearDeath(h2.location()));
666 666
667 // Incremental marking potentially marked handles before they turned weak. 667 // Incremental marking potentially marked handles before they turned weak.
668 heap->CollectAllGarbage(); 668 heap->CollectAllGarbage();
669 669
670 CHECK((*h1)->IsString()); 670 CHECK((*h1)->IsString());
671 671
672 CHECK(WeakPointerCleared); 672 CHECK(WeakPointerCleared);
673 CHECK(!GlobalHandles::IsNearDeath(h1.location())); 673 CHECK(!GlobalHandles::IsNearDeath(h1.location()));
(...skipping 15 matching lines...) Expand all
689 Handle<Object> h; 689 Handle<Object> h;
690 690
691 { 691 {
692 HandleScope scope(isolate); 692 HandleScope scope(isolate);
693 693
694 Handle<Object> i = factory->NewStringFromStaticChars("fisk"); 694 Handle<Object> i = factory->NewStringFromStaticChars("fisk");
695 h = global_handles->Create(*i); 695 h = global_handles->Create(*i);
696 } 696 }
697 697
698 std::pair<Handle<Object>*, int> handle_and_id(&h, 1234); 698 std::pair<Handle<Object>*, int> handle_and_id(&h, 1234);
699 GlobalHandles::MakeWeak(h.location(), 699 GlobalHandles::MakeWeak(h.location(), reinterpret_cast<void*>(&handle_and_id),
700 reinterpret_cast<void*>(&handle_and_id), 700 &TestWeakGlobalHandleCallback,
701 &TestWeakGlobalHandleCallback); 701 v8::WeakCallbackType::kParameter);
702 702
703 // Scanvenge does not recognize weak reference. 703 // Scanvenge does not recognize weak reference.
704 heap->CollectGarbage(NEW_SPACE); 704 heap->CollectGarbage(NEW_SPACE);
705 705
706 CHECK(!WeakPointerCleared); 706 CHECK(!WeakPointerCleared);
707 707
708 // Mark-compact treats weak reference properly. 708 // Mark-compact treats weak reference properly.
709 heap->CollectGarbage(OLD_SPACE); 709 heap->CollectGarbage(OLD_SPACE);
710 710
711 CHECK(WeakPointerCleared); 711 CHECK(WeakPointerCleared);
(...skipping 6026 matching lines...) Expand 10 before | Expand all | Expand 10 after
6738 // All objects need to be black after marking. If a white object crossed the 6738 // All objects need to be black after marking. If a white object crossed the
6739 // progress bar, we would fail here. 6739 // progress bar, we would fail here.
6740 for (int i = 0; i < arr.get()->length(); i++) { 6740 for (int i = 0; i < arr.get()->length(); i++) {
6741 CHECK(Marking::IsBlack( 6741 CHECK(Marking::IsBlack(
6742 Marking::MarkBitFrom(HeapObject::cast(arr.get()->get(i))))); 6742 Marking::MarkBitFrom(HeapObject::cast(arr.get()->get(i)))));
6743 } 6743 }
6744 } 6744 }
6745 6745
6746 } // namespace internal 6746 } // namespace internal
6747 } // namespace v8 6747 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/heap/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698