Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp

Issue 1385193002: Bisect clang Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 246985 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h ('k') | tools/clang/blink_gc_plugin/CheckTraceVisitor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp
diff --git a/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp b/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab2d2601bc3e527a39e144b1b0d6ccb022a4f7de
--- /dev/null
+++ b/tools/clang/blink_gc_plugin/CheckGCRootsVisitor.cpp
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "CheckGCRootsVisitor.h"
+
+CheckGCRootsVisitor::CheckGCRootsVisitor() {
+}
+
+CheckGCRootsVisitor::Errors& CheckGCRootsVisitor::gc_roots() {
+ return gc_roots_;
+}
+
+bool CheckGCRootsVisitor::ContainsGCRoots(RecordInfo* info) {
+ for (RecordInfo::Fields::iterator it = info->GetFields().begin();
+ it != info->GetFields().end();
+ ++it) {
+ current_.push_back(&it->second);
+ it->second.edge()->Accept(this);
+ current_.pop_back();
+ }
+ return !gc_roots_.empty();
+}
+
+void CheckGCRootsVisitor::VisitValue(Value* edge) {
+ // TODO: what should we do to check unions?
+ if (edge->value()->record()->isUnion())
+ return;
+
+ // Prevent infinite regress for cyclic part objects.
+ if (visiting_set_.find(edge->value()) != visiting_set_.end())
+ return;
+
+ visiting_set_.insert(edge->value());
+ // If the value is a part object, then continue checking for roots.
+ for (Context::iterator it = context().begin();
+ it != context().end();
+ ++it) {
+ if (!(*it)->IsCollection())
+ return;
+ }
+ ContainsGCRoots(edge->value());
+ visiting_set_.erase(edge->value());
+}
+
+void CheckGCRootsVisitor::VisitPersistent(Persistent* edge) {
+ gc_roots_.push_back(current_);
+}
+
+void CheckGCRootsVisitor::AtCollection(Collection* edge) {
+ if (edge->is_root())
+ gc_roots_.push_back(current_);
+}
« no previous file with comments | « tools/clang/blink_gc_plugin/CheckGCRootsVisitor.h ('k') | tools/clang/blink_gc_plugin/CheckTraceVisitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698