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

Side by Side Diff: src/global-handles.cc

Issue 14175005: New GC related APIs: Implicit references. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Code review (mstarzinger) + test update Created 7 years, 8 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 | « src/global-handles.h ('k') | src/heap-snapshot-generator.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 848 }
849 #endif 849 #endif
850 if (length == 0) { 850 if (length == 0) {
851 if (info != NULL) info->Dispose(); 851 if (info != NULL) info->Dispose();
852 return; 852 return;
853 } 853 }
854 for (size_t i = 0; i < length; ++i) { 854 for (size_t i = 0; i < length; ++i) {
855 object_groups_.Add(ObjectGroupConnection( 855 object_groups_.Add(ObjectGroupConnection(
856 UniqueId(reinterpret_cast<intptr_t>(handles[0])), handles[i])); 856 UniqueId(reinterpret_cast<intptr_t>(handles[0])), handles[i]));
857 } 857 }
858 retainer_infos_.Add(ObjectGroupRetainerInfo( 858 for (size_t i = 0; i < length; ++i) {
859 UniqueId(reinterpret_cast<intptr_t>(handles[0])), info)); 859 if ((*handles[i])->IsHeapObject()) {
860 representative_objects_.Add(ObjectGroupRepresentative(
861 UniqueId(reinterpret_cast<intptr_t>(handles[0])),
862 reinterpret_cast<HeapObject**>(handles[i])));
863 break;
864 }
865 }
866 if (info != NULL) {
867 retainer_infos_.Add(ObjectGroupRetainerInfo(
868 UniqueId(reinterpret_cast<intptr_t>(handles[0])), info));
869 }
860 } 870 }
861 871
862 void GlobalHandles::SetObjectGroupId(Object** handle, 872 void GlobalHandles::SetObjectGroupId(Object** handle,
863 UniqueId id) { 873 UniqueId id) {
864 object_groups_.Add(ObjectGroupConnection(id, handle)); 874 object_groups_.Add(ObjectGroupConnection(id, handle));
865 } 875 }
866 876
867 877
868 void GlobalHandles::SetRetainedObjectInfo(UniqueId id, 878 void GlobalHandles::SetRetainedObjectInfo(UniqueId id,
869 RetainedObjectInfo* info) { 879 RetainedObjectInfo* info) {
870 retainer_infos_.Add(ObjectGroupRetainerInfo(id, info)); 880 retainer_infos_.Add(ObjectGroupRetainerInfo(id, info));
871 } 881 }
872 882
873 883
884 void GlobalHandles::SetObjectGroupRepresentative(
885 UniqueId id,
886 HeapObject** representative_object) {
887 representative_objects_.Add(
888 ObjectGroupRepresentative(id, representative_object));
889 }
890
874 void GlobalHandles::AddImplicitReferences(HeapObject** parent, 891 void GlobalHandles::AddImplicitReferences(HeapObject** parent,
875 Object*** children, 892 Object*** children,
876 size_t length) { 893 size_t length) {
877 #ifdef DEBUG 894 #ifdef DEBUG
878 ASSERT(!Node::FromLocation(BitCast<Object**>(parent))->is_independent()); 895 ASSERT(!Node::FromLocation(BitCast<Object**>(parent))->is_independent());
879 for (size_t i = 0; i < length; ++i) { 896 for (size_t i = 0; i < length; ++i) {
880 ASSERT(!Node::FromLocation(children[i])->is_independent()); 897 ASSERT(!Node::FromLocation(children[i])->is_independent());
881 } 898 }
882 #endif 899 #endif
883 if (length == 0) return; 900 for (size_t i = 0; i < length; ++i) {
884 implicit_ref_groups_.Add(ImplicitRefGroup::New(parent, children, length)); 901 implicit_ref_groups_.Add(ObjectGroupConnection(
902 UniqueId(reinterpret_cast<intptr_t>(parent)), children[i]));
903 }
885 } 904 }
886 905
887 906
907 void GlobalHandles::AddImplicitReference(UniqueId id, Object** child) {
908 ASSERT(!Node::FromLocation(child)->is_independent());
909 implicit_ref_groups_.Add(ObjectGroupConnection(id, child));
910 }
911
912
888 void GlobalHandles::RemoveObjectGroups() { 913 void GlobalHandles::RemoveObjectGroups() {
889 object_groups_.Clear(); 914 object_groups_.Clear();
890 for (int i = 0; i < retainer_infos_.length(); ++i) { 915 for (int i = 0; i < retainer_infos_.length(); ++i) {
891 if (retainer_infos_[i].info != NULL) 916 if (retainer_infos_[i].info != NULL)
892 retainer_infos_[i].info->Dispose(); 917 retainer_infos_[i].info->Dispose();
893 } 918 }
894 retainer_infos_.Clear(); 919 retainer_infos_.Clear();
895 } 920 }
896 921
897 922
898 void GlobalHandles::RemoveImplicitRefGroups() { 923 void GlobalHandles::RemoveImplicitRefGroups() {
899 for (int i = 0; i < implicit_ref_groups_.length(); i++) { 924 representative_objects_.Clear();
900 implicit_ref_groups_.at(i)->Dispose();
901 }
902 implicit_ref_groups_.Clear(); 925 implicit_ref_groups_.Clear();
903 } 926 }
904 927
905 928
906 void GlobalHandles::TearDown() { 929 void GlobalHandles::TearDown() {
907 // TODO(1428): invoke weak callbacks. 930 // TODO(1428): invoke weak callbacks.
908 } 931 }
909 932
910 933
911 } } // namespace v8::internal 934 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698