OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 // This file defines the names used by GC infrastructure. | 5 // This file defines the names used by GC infrastructure. |
6 | 6 |
7 // TODO: Restructure the name determination to use fully qualified names (ala, | 7 // TODO: Restructure the name determination to use fully qualified names (ala, |
8 // blink::Foo) so that the plugin can be enabled for all of chromium. Doing so | 8 // blink::Foo) so that the plugin can be enabled for all of chromium. Doing so |
9 // would allow us to catch errors with structures outside of blink that might | 9 // would allow us to catch errors with structures outside of blink that might |
10 // have unsafe pointers to GC allocated blink structures. | 10 // have unsafe pointers to GC allocated blink structures. |
(...skipping 14 matching lines...) Expand all Loading... |
25 const char kTraceAfterDispatchName[] = "traceAfterDispatch"; | 25 const char kTraceAfterDispatchName[] = "traceAfterDispatch"; |
26 const char kTraceAfterDispatchImplName[] = "traceAfterDispatchImpl"; | 26 const char kTraceAfterDispatchImplName[] = "traceAfterDispatchImpl"; |
27 const char kRegisterWeakMembersName[] = "registerWeakMembers"; | 27 const char kRegisterWeakMembersName[] = "registerWeakMembers"; |
28 const char kHeapAllocatorName[] = "HeapAllocator"; | 28 const char kHeapAllocatorName[] = "HeapAllocator"; |
29 const char kTraceIfNeededName[] = "TraceIfNeeded"; | 29 const char kTraceIfNeededName[] = "TraceIfNeeded"; |
30 const char kVisitorDispatcherName[] = "VisitorDispatcher"; | 30 const char kVisitorDispatcherName[] = "VisitorDispatcher"; |
31 const char kVisitorVarName[] = "visitor"; | 31 const char kVisitorVarName[] = "visitor"; |
32 const char kAdjustAndMarkName[] = "adjustAndMark"; | 32 const char kAdjustAndMarkName[] = "adjustAndMark"; |
33 const char kIsHeapObjectAliveName[] = "isHeapObjectAlive"; | 33 const char kIsHeapObjectAliveName[] = "isHeapObjectAlive"; |
34 const char kIsEagerlyFinalizedName[] = "IsEagerlyFinalizedMarker"; | 34 const char kIsEagerlyFinalizedName[] = "IsEagerlyFinalizedMarker"; |
| 35 const char kConstIteratorName[] = "const_iterator"; |
| 36 const char kIteratorName[] = "iterator"; |
| 37 const char kConstReverseIteratorName[] = "const_reverse_iterator"; |
| 38 const char kReverseIteratorName[] = "reverse_iterator"; |
35 | 39 |
36 class Config { | 40 class Config { |
37 public: | 41 public: |
38 static bool IsMember(const std::string& name) { | 42 static bool IsMember(const std::string& name) { |
39 return name == "Member"; | 43 return name == "Member"; |
40 } | 44 } |
41 | 45 |
42 static bool IsWeakMember(const std::string& name) { | 46 static bool IsWeakMember(const std::string& name) { |
43 return name == "WeakMember"; | 47 return name == "WeakMember"; |
44 } | 48 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 static bool IsPersistentGCCollection(const std::string& name) { | 98 static bool IsPersistentGCCollection(const std::string& name) { |
95 return name == "PersistentHeapVector" || | 99 return name == "PersistentHeapVector" || |
96 name == "PersistentHeapDeque" || | 100 name == "PersistentHeapDeque" || |
97 name == "PersistentHeapHashSet" || | 101 name == "PersistentHeapHashSet" || |
98 name == "PersistentHeapListHashSet" || | 102 name == "PersistentHeapListHashSet" || |
99 name == "PersistentHeapLinkedHashSet" || | 103 name == "PersistentHeapLinkedHashSet" || |
100 name == "PersistentHeapHashCountedSet" || | 104 name == "PersistentHeapHashCountedSet" || |
101 name == "PersistentHeapHashMap"; | 105 name == "PersistentHeapHashMap"; |
102 } | 106 } |
103 | 107 |
| 108 static bool IsGCCollectionWithUnsafeIterator(const std::string& name) { |
| 109 if (!IsGCCollection(name)) |
| 110 return false; |
| 111 // The list hash set iterators refer to the set, not the |
| 112 // backing store and are consequently safe. |
| 113 if (name == "HeapListHashSet" || name == "PersistentHeapListHashSet") |
| 114 return false; |
| 115 return true; |
| 116 } |
| 117 |
104 static bool IsHashMap(const std::string& name) { | 118 static bool IsHashMap(const std::string& name) { |
105 return name == "HashMap" || | 119 return name == "HashMap" || |
106 name == "HeapHashMap" || | 120 name == "HeapHashMap" || |
107 name == "PersistentHeapHashMap"; | 121 name == "PersistentHeapHashMap"; |
108 } | 122 } |
109 | 123 |
110 // Assumes name is a valid collection name. | 124 // Assumes name is a valid collection name. |
111 static size_t CollectionDimension(const std::string& name) { | 125 static size_t CollectionDimension(const std::string& name) { |
112 return (IsHashMap(name) || name == "pair") ? 2 : 1; | 126 return (IsHashMap(name) || name == "pair") ? 2 : 1; |
113 } | 127 } |
(...skipping 10 matching lines...) Expand all Loading... |
124 static bool IsGCFinalizedBase(const std::string& name) { | 138 static bool IsGCFinalizedBase(const std::string& name) { |
125 return name == "GarbageCollectedFinalized"; | 139 return name == "GarbageCollectedFinalized"; |
126 } | 140 } |
127 | 141 |
128 static bool IsGCBase(const std::string& name) { | 142 static bool IsGCBase(const std::string& name) { |
129 return name == "GarbageCollected" || | 143 return name == "GarbageCollected" || |
130 IsGCFinalizedBase(name) || | 144 IsGCFinalizedBase(name) || |
131 IsGCMixinBase(name); | 145 IsGCMixinBase(name); |
132 } | 146 } |
133 | 147 |
| 148 static bool IsIterator(const std::string& name) { |
| 149 return name == kIteratorName || name == kConstIteratorName || |
| 150 name == kReverseIteratorName || name == kConstReverseIteratorName; |
| 151 } |
| 152 |
134 // Returns true of the base classes that do not need a vtable entry for trace | 153 // Returns true of the base classes that do not need a vtable entry for trace |
135 // because they cannot possibly initiate a GC during construction. | 154 // because they cannot possibly initiate a GC during construction. |
136 static bool IsSafePolymorphicBase(const std::string& name) { | 155 static bool IsSafePolymorphicBase(const std::string& name) { |
137 return IsGCBase(name) || IsRefCountedBase(name); | 156 return IsGCBase(name) || IsRefCountedBase(name); |
138 } | 157 } |
139 | 158 |
140 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { | 159 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { |
141 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); | 160 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); |
142 return attr && (attr->getAnnotation() == anno); | 161 return attr && (attr->getAnnotation() == anno); |
143 } | 162 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 if (suffix.size() > str.size()) | 269 if (suffix.size() > str.size()) |
251 return false; | 270 return false; |
252 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; | 271 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; |
253 } | 272 } |
254 | 273 |
255 // Test if a template specialization is an instantiation. | 274 // Test if a template specialization is an instantiation. |
256 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); | 275 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); |
257 }; | 276 }; |
258 | 277 |
259 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 278 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
OLD | NEW |