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 #include "clang/AST/Attr.h" | 8 #include "clang/AST/Attr.h" |
9 | 9 |
10 using namespace clang; | 10 using namespace clang; |
11 using std::string; | 11 using std::string; |
12 | 12 |
13 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) | 13 RecordInfo::RecordInfo(CXXRecordDecl* record, RecordCache* cache) |
14 : cache_(cache), | 14 : cache_(cache), |
15 record_(record), | 15 record_(record), |
16 name_(record->getName()), | 16 name_(record->getName()), |
17 fields_need_tracing_(TracingStatus::Unknown()), | 17 fields_need_tracing_(TracingStatus::Unknown()), |
18 bases_(0), | 18 bases_(0), |
19 fields_(0), | 19 fields_(0), |
| 20 is_stack_allocated_(kNotComputed), |
20 determined_trace_methods_(false), | 21 determined_trace_methods_(false), |
21 trace_method_(0), | 22 trace_method_(0), |
22 trace_dispatch_method_(0), | 23 trace_dispatch_method_(0), |
23 finalize_dispatch_method_(0), | 24 finalize_dispatch_method_(0), |
24 is_gc_derived_(false), | 25 is_gc_derived_(false), |
25 base_paths_(0) {} | 26 base_paths_(0) {} |
26 | 27 |
27 RecordInfo::~RecordInfo() { | 28 RecordInfo::~RecordInfo() { |
28 delete fields_; | 29 delete fields_; |
29 delete bases_; | 30 delete bases_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (!record || IsAnnotated(record, "blink_gc_plugin_ignore")) | 146 if (!record || IsAnnotated(record, "blink_gc_plugin_ignore")) |
146 return 0; | 147 return 0; |
147 Cache::iterator it = cache_.find(record); | 148 Cache::iterator it = cache_.find(record); |
148 if (it != cache_.end()) | 149 if (it != cache_.end()) |
149 return &it->second; | 150 return &it->second; |
150 return &cache_.insert(std::make_pair(record, RecordInfo(record, this))) | 151 return &cache_.insert(std::make_pair(record, RecordInfo(record, this))) |
151 .first->second; | 152 .first->second; |
152 } | 153 } |
153 | 154 |
154 bool RecordInfo::IsStackAllocated() { | 155 bool RecordInfo::IsStackAllocated() { |
155 for (CXXRecordDecl::method_iterator it = record_->method_begin(); | 156 if (is_stack_allocated_ == kNotComputed) { |
156 it != record_->method_end(); | 157 is_stack_allocated_ = kFalse; |
157 ++it) { | 158 for (Bases::iterator it = GetBases().begin(); |
158 if (it->getNameAsString() == kNewOperatorName) | 159 it != GetBases().end(); |
159 return it->isDeleted() && IsAnnotated(*it, "blink_stack_allocated"); | 160 ++it) { |
| 161 if (it->second.info()->IsStackAllocated()) { |
| 162 is_stack_allocated_ = kTrue; |
| 163 break; |
| 164 } |
| 165 } |
| 166 for (CXXRecordDecl::method_iterator it = record_->method_begin(); |
| 167 it != record_->method_end(); |
| 168 ++it) { |
| 169 if (it->getNameAsString() == kNewOperatorName) { |
| 170 if (it->isDeleted() && IsAnnotated(*it, "blink_stack_allocated")) { |
| 171 is_stack_allocated_ = kTrue; |
| 172 break; |
| 173 } |
| 174 } |
| 175 } |
160 } | 176 } |
161 return false; | 177 return is_stack_allocated_; |
162 } | 178 } |
163 | 179 |
164 // An object requires a tracing method if it has any fields that need tracing. | 180 // An object requires a tracing method if it has any fields that need tracing. |
165 bool RecordInfo::RequiresTraceMethod() { | 181 bool RecordInfo::RequiresTraceMethod() { |
| 182 if (IsStackAllocated()) |
| 183 return false; |
166 GetFields(); | 184 GetFields(); |
167 return fields_need_tracing_.IsNeeded(); | 185 return fields_need_tracing_.IsNeeded(); |
168 } | 186 } |
169 | 187 |
170 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a | 188 // Get the actual tracing method (ie, can be traceAfterDispatch if there is a |
171 // dispatch method). | 189 // dispatch method). |
172 CXXMethodDecl* RecordInfo::GetTraceMethod() { | 190 CXXMethodDecl* RecordInfo::GetTraceMethod() { |
173 DetermineTracingMethods(); | 191 DetermineTracingMethods(); |
174 return trace_method_; | 192 return trace_method_; |
175 } | 193 } |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // We failed to create an edge so abort the entire edge construction. | 452 // We failed to create an edge so abort the entire edge construction. |
435 delete edge; // Will delete the already allocated members. | 453 delete edge; // Will delete the already allocated members. |
436 return 0; | 454 return 0; |
437 } | 455 } |
438 } | 456 } |
439 return edge; | 457 return edge; |
440 } | 458 } |
441 | 459 |
442 return new Value(info); | 460 return new Value(info); |
443 } | 461 } |
OLD | NEW |