Chromium Code Reviews| 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 provides a wrapper for CXXRecordDecl that accumulates GC related | 5 // This file provides a wrapper for CXXRecordDecl that accumulates GC related |
| 6 // information about a class. Accumulated information is memoized and the info | 6 // information about a class. Accumulated information is memoized and the info |
| 7 // objects are stored in a RecordCache. | 7 // objects are stored in a RecordCache. |
| 8 | 8 |
| 9 #ifndef TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ | 9 #ifndef TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ |
| 10 #define TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ | 10 #define TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 clang::FieldDecl* field_; | 62 clang::FieldDecl* field_; |
| 63 Edge* edge_; | 63 Edge* edge_; |
| 64 | 64 |
| 65 friend class RecordCache; | 65 friend class RecordCache; |
| 66 void deleteEdge() { delete edge_; } | 66 void deleteEdge() { delete edge_; } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Wrapper class to lazily collect information about a C++ record. | 69 // Wrapper class to lazily collect information about a C++ record. |
| 70 class RecordInfo { | 70 class RecordInfo { |
| 71 public: | 71 public: |
| 72 typedef std::map<clang::CXXRecordDecl*, BasePoint> Bases; | 72 typedef std::pair<clang::CXXRecordDecl*, BasePoint> Base; |
|
Nico
2016/01/29 03:10:08
would giving the map a custom comparator that comp
hans
2016/01/29 04:49:14
For Bases, a map doesn't seem to buy as anything a
sof
2016/01/29 09:00:19
What you propose makes the most sense to me, use a
| |
| 73 typedef std::map<clang::FieldDecl*, FieldPoint> Fields; | 73 typedef std::vector<Base> Bases; |
| 74 typedef std::pair<clang::FieldDecl*, FieldPoint> Field; | |
| 75 typedef std::vector<Field> Fields; | |
| 74 typedef std::vector<const clang::Type*> TemplateArgs; | 76 typedef std::vector<const clang::Type*> TemplateArgs; |
| 75 | 77 |
| 76 ~RecordInfo(); | 78 ~RecordInfo(); |
| 77 | 79 |
| 78 clang::CXXRecordDecl* record() const { return record_; } | 80 clang::CXXRecordDecl* record() const { return record_; } |
| 79 const std::string& name() const { return name_; } | 81 const std::string& name() const { return name_; } |
| 82 | |
| 80 Fields& GetFields(); | 83 Fields& GetFields(); |
| 84 bool HasField(clang::FieldDecl*); | |
| 85 Field& GetField(clang::FieldDecl*); | |
| 81 Bases& GetBases(); | 86 Bases& GetBases(); |
| 87 | |
| 82 clang::CXXMethodDecl* GetTraceMethod(); | 88 clang::CXXMethodDecl* GetTraceMethod(); |
| 83 clang::CXXMethodDecl* GetTraceDispatchMethod(); | 89 clang::CXXMethodDecl* GetTraceDispatchMethod(); |
| 84 clang::CXXMethodDecl* GetFinalizeDispatchMethod(); | 90 clang::CXXMethodDecl* GetFinalizeDispatchMethod(); |
| 85 | 91 |
| 86 bool GetTemplateArgs(size_t count, TemplateArgs* output_args); | 92 bool GetTemplateArgs(size_t count, TemplateArgs* output_args); |
| 87 | 93 |
| 88 bool IsHeapAllocatedCollection(); | 94 bool IsHeapAllocatedCollection(); |
| 89 bool IsGCDerived(); | 95 bool IsGCDerived(); |
| 90 bool IsGCAllocated(); | 96 bool IsGCAllocated(); |
| 91 bool IsGCFinalized(); | 97 bool IsGCFinalized(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 108 clang::CXXMethodDecl* InheritsNonVirtualTrace(); | 114 clang::CXXMethodDecl* InheritsNonVirtualTrace(); |
| 109 bool IsConsideredAbstract(); | 115 bool IsConsideredAbstract(); |
| 110 | 116 |
| 111 static clang::CXXRecordDecl* GetDependentTemplatedDecl(const clang::Type&); | 117 static clang::CXXRecordDecl* GetDependentTemplatedDecl(const clang::Type&); |
| 112 | 118 |
| 113 private: | 119 private: |
| 114 RecordInfo(clang::CXXRecordDecl* record, RecordCache* cache); | 120 RecordInfo(clang::CXXRecordDecl* record, RecordCache* cache); |
| 115 | 121 |
| 116 void walkBases(); | 122 void walkBases(); |
| 117 | 123 |
| 118 Fields* CollectFields(); | 124 void CollectFields(); |
| 119 Bases* CollectBases(); | 125 void CollectBases(); |
| 120 void DetermineTracingMethods(); | 126 void DetermineTracingMethods(); |
| 121 bool InheritsTrace(); | 127 bool InheritsTrace(); |
| 122 | 128 |
| 123 Edge* CreateEdge(const clang::Type* type); | 129 Edge* CreateEdge(const clang::Type* type); |
| 124 | 130 |
| 125 RecordCache* cache_; | 131 RecordCache* cache_; |
| 126 clang::CXXRecordDecl* record_; | 132 clang::CXXRecordDecl* record_; |
| 127 const std::string name_; | 133 const std::string name_; |
| 128 TracingStatus fields_need_tracing_; | 134 TracingStatus fields_need_tracing_; |
| 129 Bases* bases_; | 135 Bases* bases_; |
| 130 Fields* fields_; | 136 Fields* fields_; |
| 137 std::map<clang::FieldDecl*, size_t>* field_map_; | |
| 131 | 138 |
| 132 enum CachedBool { kFalse = 0, kTrue = 1, kNotComputed = 2 }; | 139 enum CachedBool { kFalse = 0, kTrue = 1, kNotComputed = 2 }; |
| 133 CachedBool is_stack_allocated_; | 140 CachedBool is_stack_allocated_; |
| 134 CachedBool is_non_newable_; | 141 CachedBool is_non_newable_; |
| 135 CachedBool is_only_placement_newable_; | 142 CachedBool is_only_placement_newable_; |
| 136 CachedBool does_need_finalization_; | 143 CachedBool does_need_finalization_; |
| 137 CachedBool has_gc_mixin_methods_; | 144 CachedBool has_gc_mixin_methods_; |
| 138 CachedBool is_declaring_local_trace_; | 145 CachedBool is_declaring_local_trace_; |
| 139 CachedBool is_eagerly_finalized_; | 146 CachedBool is_eagerly_finalized_; |
| 140 | 147 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 188 } |
| 182 } | 189 } |
| 183 } | 190 } |
| 184 | 191 |
| 185 private: | 192 private: |
| 186 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; | 193 typedef std::map<clang::CXXRecordDecl*, RecordInfo> Cache; |
| 187 Cache cache_; | 194 Cache cache_; |
| 188 }; | 195 }; |
| 189 | 196 |
| 190 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ | 197 #endif // TOOLS_BLINK_GC_PLUGIN_RECORD_INFO_H_ |
| OLD | NEW |