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 #include "Config.h" | 5 #include "Config.h" |
6 #include "RecordInfo.h" | 6 #include "RecordInfo.h" |
7 | 7 |
8 using namespace clang; | 8 using namespace clang; |
9 using std::string; | 9 using std::string; |
10 | 10 |
11 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) | 11 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) |
12 : cache_(cache), | 12 : cache_(cache), |
13 record_(record), | 13 record_(record), |
14 name_(record->getName()), | 14 name_(record->getName()), |
15 fields_need_tracing_(TracingStatus::Unknown()), | 15 fields_need_tracing_(TracingStatus::Unknown()), |
16 bases_(0), | 16 bases_(0), |
17 fields_(0), | 17 fields_(0), |
18 is_stack_allocated_(kNotComputed), | 18 is_stack_allocated_(kNotComputed), |
19 is_non_newable_(kNotComputed), | 19 is_non_newable_(kNotComputed), |
20 is_only_placement_newable_(kNotComputed), | 20 is_only_placement_newable_(kNotComputed), |
21 does_need_finalization_(kNotComputed), | 21 does_need_finalization_(kNotComputed), |
22 has_gc_mixin_methods_(kNotComputed), | 22 has_gc_mixin_methods_(kNotComputed), |
23 is_declaring_local_trace_(kNotComputed), | 23 is_declaring_local_trace_(kNotComputed), |
| 24 is_eagerly_finalized_(kNotComputed), |
24 determined_trace_methods_(false), | 25 determined_trace_methods_(false), |
25 trace_method_(0), | 26 trace_method_(0), |
26 trace_dispatch_method_(0), | 27 trace_dispatch_method_(0), |
27 finalize_dispatch_method_(0), | 28 finalize_dispatch_method_(0), |
28 is_gc_derived_(false) {} | 29 is_gc_derived_(false) {} |
29 | 30 |
30 RecordInfo::~RecordInfo() { | 31 RecordInfo::~RecordInfo() { |
31 delete fields_; | 32 delete fields_; |
32 delete bases_; | 33 delete bases_; |
33 } | 34 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 162 } |
162 // This is a mixin if all GC bases are mixins. | 163 // This is a mixin if all GC bases are mixins. |
163 return true; | 164 return true; |
164 } | 165 } |
165 | 166 |
166 // Test if a record is allocated on the managed heap. | 167 // Test if a record is allocated on the managed heap. |
167 bool RecordInfo::IsGCAllocated() { | 168 bool RecordInfo::IsGCAllocated() { |
168 return IsGCDerived() || IsHeapAllocatedCollection(); | 169 return IsGCDerived() || IsHeapAllocatedCollection(); |
169 } | 170 } |
170 | 171 |
| 172 bool RecordInfo::IsEagerlyFinalized() { |
| 173 if (is_eagerly_finalized_ == kNotComputed) { |
| 174 is_eagerly_finalized_ = kFalse; |
| 175 if (IsGCFinalized()) { |
| 176 for (Decl* decl : record_->decls()) { |
| 177 if (TypedefDecl* typedef_decl = dyn_cast<TypedefDecl>(decl)) { |
| 178 if (typedef_decl->getNameAsString() == kIsEagerlyFinalizedName) { |
| 179 is_eagerly_finalized_ = kTrue; |
| 180 break; |
| 181 } |
| 182 } |
| 183 } |
| 184 } |
| 185 } |
| 186 return is_eagerly_finalized_; |
| 187 } |
| 188 |
171 RecordInfo* RecordCache::Lookup(CXXRecordDecl* record) { | 189 RecordInfo* RecordCache::Lookup(CXXRecordDecl* record) { |
172 // Ignore classes annotated with the GC_PLUGIN_IGNORE macro. | 190 // Ignore classes annotated with the GC_PLUGIN_IGNORE macro. |
173 if (!record || Config::IsIgnoreAnnotated(record)) | 191 if (!record || Config::IsIgnoreAnnotated(record)) |
174 return 0; | 192 return 0; |
175 Cache::iterator it = cache_.find(record); | 193 Cache::iterator it = cache_.find(record); |
176 if (it != cache_.end()) | 194 if (it != cache_.end()) |
177 return &it->second; | 195 return &it->second; |
178 return &cache_.insert(std::make_pair(record, RecordInfo(record, this))) | 196 return &cache_.insert(std::make_pair(record, RecordInfo(record, this))) |
179 .first->second; | 197 .first->second; |
180 } | 198 } |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 edge->members().push_back(member); | 660 edge->members().push_back(member); |
643 } | 661 } |
644 // TODO: Handle the case where we fail to create an edge (eg, if the | 662 // TODO: Handle the case where we fail to create an edge (eg, if the |
645 // argument is a primitive type or just not fully known yet). | 663 // argument is a primitive type or just not fully known yet). |
646 } | 664 } |
647 return edge; | 665 return edge; |
648 } | 666 } |
649 | 667 |
650 return new Value(info); | 668 return new Value(info); |
651 } | 669 } |
OLD | NEW |