| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 static bool IsPersistent(const std::string& name) { | 51 static bool IsPersistent(const std::string& name) { |
| 52 return name == "Persistent"; | 52 return name == "Persistent"; |
| 53 } | 53 } |
| 54 | 54 |
| 55 static bool IsPersistentHandle(const std::string& name) { | 55 static bool IsPersistentHandle(const std::string& name) { |
| 56 return IsPersistent(name) || | 56 return IsPersistent(name) || |
| 57 IsPersistentGCCollection(name); | 57 IsPersistentGCCollection(name); |
| 58 } | 58 } |
| 59 | 59 |
| 60 static bool IsRawPtr(const std::string& name) { | |
| 61 return name == "RawPtr"; | |
| 62 } | |
| 63 | |
| 64 static bool IsRefPtr(const std::string& name) { | 60 static bool IsRefPtr(const std::string& name) { |
| 65 return name == "RefPtr"; | 61 return name == "RefPtr"; |
| 66 } | 62 } |
| 67 | 63 |
| 68 static bool IsOwnPtr(const std::string& name) { | 64 static bool IsOwnPtr(const std::string& name) { |
| 69 return name == "OwnPtr"; | 65 return name == "OwnPtr"; |
| 70 } | 66 } |
| 71 | 67 |
| 72 static bool IsWTFCollection(const std::string& name) { | 68 static bool IsWTFCollection(const std::string& name) { |
| 73 return name == "Vector" || | 69 return name == "Vector" || |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 name == "PersistentHeapHashCountedSet" || | 95 name == "PersistentHeapHashCountedSet" || |
| 100 name == "PersistentHeapHashMap"; | 96 name == "PersistentHeapHashMap"; |
| 101 } | 97 } |
| 102 | 98 |
| 103 static bool IsHashMap(const std::string& name) { | 99 static bool IsHashMap(const std::string& name) { |
| 104 return name == "HashMap" || | 100 return name == "HashMap" || |
| 105 name == "HeapHashMap" || | 101 name == "HeapHashMap" || |
| 106 name == "PersistentHeapHashMap"; | 102 name == "PersistentHeapHashMap"; |
| 107 } | 103 } |
| 108 | 104 |
| 109 // Following http://crrev.com/369633033 (Blink r177436), | |
| 110 // ignore blink::ScriptWrappable's destructor. | |
| 111 // TODO: remove when its non-Oilpan destructor is removed. | |
| 112 static bool HasIgnorableDestructor(const std::string& ns, | |
| 113 const std::string& name) { | |
| 114 return ns == "blink" && name == "ScriptWrappable"; | |
| 115 } | |
| 116 | |
| 117 // Assumes name is a valid collection name. | 105 // Assumes name is a valid collection name. |
| 118 static size_t CollectionDimension(const std::string& name) { | 106 static size_t CollectionDimension(const std::string& name) { |
| 119 return (IsHashMap(name) || name == "pair") ? 2 : 1; | 107 return (IsHashMap(name) || name == "pair") ? 2 : 1; |
| 120 } | 108 } |
| 121 | 109 |
| 122 static bool IsDummyBase(const std::string& name) { | |
| 123 return name == "DummyBase"; | |
| 124 } | |
| 125 | |
| 126 static bool IsRefCountedBase(const std::string& name) { | 110 static bool IsRefCountedBase(const std::string& name) { |
| 127 return name == "RefCounted" || | 111 return name == "RefCounted" || |
| 128 name == "ThreadSafeRefCounted"; | 112 name == "ThreadSafeRefCounted"; |
| 129 } | 113 } |
| 130 | 114 |
| 131 static bool IsGCMixinBase(const std::string& name) { | 115 static bool IsGCMixinBase(const std::string& name) { |
| 132 return name == "GarbageCollectedMixin"; | 116 return name == "GarbageCollectedMixin"; |
| 133 } | 117 } |
| 134 | 118 |
| 135 static bool IsGCFinalizedBase(const std::string& name) { | 119 static bool IsGCFinalizedBase(const std::string& name) { |
| 136 return name == "GarbageCollectedFinalized"; | 120 return name == "GarbageCollectedFinalized"; |
| 137 } | 121 } |
| 138 | 122 |
| 139 static bool IsGCBase(const std::string& name) { | 123 static bool IsGCBase(const std::string& name) { |
| 140 return name == "GarbageCollected" || | 124 return name == "GarbageCollected" || |
| 141 IsGCFinalizedBase(name) || | 125 IsGCFinalizedBase(name) || |
| 142 IsGCMixinBase(name); | 126 IsGCMixinBase(name); |
| 143 } | 127 } |
| 144 | 128 |
| 145 // Returns true of the base classes that do not need a vtable entry for trace | 129 // Returns true of the base classes that do not need a vtable entry for trace |
| 146 // because they cannot possibly initiate a GC during construction. | 130 // because they cannot possibly initiate a GC during construction. |
| 147 static bool IsSafePolymorphicBase(const std::string& name) { | 131 static bool IsSafePolymorphicBase(const std::string& name) { |
| 148 return IsGCBase(name) || IsDummyBase(name) || IsRefCountedBase(name); | 132 return IsGCBase(name) || IsRefCountedBase(name); |
| 149 } | 133 } |
| 150 | 134 |
| 151 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { | 135 static bool IsAnnotated(clang::Decl* decl, const std::string& anno) { |
| 152 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); | 136 clang::AnnotateAttr* attr = decl->getAttr<clang::AnnotateAttr>(); |
| 153 return attr && (attr->getAnnotation() == anno); | 137 return attr && (attr->getAnnotation() == anno); |
| 154 } | 138 } |
| 155 | 139 |
| 156 static bool IsStackAnnotated(clang::Decl* decl) { | 140 static bool IsStackAnnotated(clang::Decl* decl) { |
| 157 return IsAnnotated(decl, "blink_stack_allocated"); | 141 return IsAnnotated(decl, "blink_stack_allocated"); |
| 158 } | 142 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (suffix.size() > str.size()) | 245 if (suffix.size() > str.size()) |
| 262 return false; | 246 return false; |
| 263 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; | 247 return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; |
| 264 } | 248 } |
| 265 | 249 |
| 266 // Test if a template specialization is an instantiation. | 250 // Test if a template specialization is an instantiation. |
| 267 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); | 251 static bool IsTemplateInstantiation(clang::CXXRecordDecl* record); |
| 268 }; | 252 }; |
| 269 | 253 |
| 270 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ | 254 #endif // TOOLS_BLINK_GC_PLUGIN_CONFIG_H_ |
| OLD | NEW |