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 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 7 #ifndef TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
8 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 8 #define TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
9 | 9 |
10 #include "clang/AST/AST.h" | 10 #include "clang/AST/AST.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 static bool HasIgnorableDestructor(const std::string& ns, | 98 static bool HasIgnorableDestructor(const std::string& ns, |
99 const std::string& name) { | 99 const std::string& name) { |
100 return ns == "blink" && name == "ScriptWrappable"; | 100 return ns == "blink" && name == "ScriptWrappable"; |
101 } | 101 } |
102 | 102 |
103 // Assumes name is a valid collection name. | 103 // Assumes name is a valid collection name. |
104 static size_t CollectionDimension(const std::string& name) { | 104 static size_t CollectionDimension(const std::string& name) { |
105 return (IsHashMap(name) || name == "pair") ? 2 : 1; | 105 return (IsHashMap(name) || name == "pair") ? 2 : 1; |
106 } | 106 } |
107 | 107 |
| 108 static bool IsDummyBase(const std::string& name) { |
| 109 return name == "DummyBase"; |
| 110 } |
| 111 |
| 112 static bool IsRefCountedBase(const std::string& name) { |
| 113 return name == "RefCounted" || |
| 114 name == "ThreadSafeRefCounted"; |
| 115 } |
| 116 |
108 static bool IsGCMixinBase(const std::string& name) { | 117 static bool IsGCMixinBase(const std::string& name) { |
109 return name == "GarbageCollectedMixin"; | 118 return name == "GarbageCollectedMixin"; |
110 } | 119 } |
111 | 120 |
112 static bool IsGCFinalizedBase(const std::string& name) { | 121 static bool IsGCFinalizedBase(const std::string& name) { |
113 return name == "GarbageCollectedFinalized" || | 122 return name == "GarbageCollectedFinalized" || |
114 name == "RefCountedGarbageCollected"; | 123 name == "RefCountedGarbageCollected" || |
| 124 name == "ThreadSafeRefCountedGarbageCollected"; |
115 } | 125 } |
116 | 126 |
117 static bool IsGCBase(const std::string& name) { | 127 static bool IsGCBase(const std::string& name) { |
118 return name == "GarbageCollected" || | 128 return name == "GarbageCollected" || |
119 IsGCFinalizedBase(name) || | 129 IsGCFinalizedBase(name) || |
120 IsGCMixinBase(name); | 130 IsGCMixinBase(name); |
121 } | 131 } |
122 | 132 |
| 133 // Returns true of the base classes that do not need a vtable entry for trace |
| 134 // because they cannot possibly initiate a GC during construction. |
| 135 static bool IsSafePolymorphicBase(const std::string& name) { |
| 136 return IsGCBase(name) || IsDummyBase(name) || IsRefCountedBase(name); |
| 137 } |
| 138 |
123 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { | 139 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { |
124 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); | 140 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); |
125 return attr && (attr->getAnnotation() == anno); | 141 return attr && (attr->getAnnotation() == anno); |
126 } | 142 } |
127 | 143 |
128 static bool IsStackAnnotated(clang::Decl* decl) { | 144 static bool IsStackAnnotated(clang::Decl* decl) { |
129 return IsAnnotated(decl, "blink_stack_allocated"); | 145 return IsAnnotated(decl, "blink_stack_allocated"); |
130 } | 146 } |
131 | 147 |
132 static bool IsIgnoreAnnotated(clang::Decl* decl) { | 148 static bool IsIgnoreAnnotated(clang::Decl* decl) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 189 } |
174 | 190 |
175 static bool EndsWith(const std::string& str, const std::string& suffix) { | 191 static bool EndsWith(const std::string& str, const std::string& suffix) { |
176 if (suffix.size() > str.size()) | 192 if (suffix.size() > str.size()) |
177 return false; | 193 return false; |
178 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; | 194 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; |
179 } | 195 } |
180 }; | 196 }; |
181 | 197 |
182 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 198 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
OLD | NEW |