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

Unified Diff: tools/clang/blink_gc_plugin/Edge.h

Issue 2588943002: Disallow heap objects containing unsafe on-heap iterators. (Closed)
Patch Set: formatting Created 4 years 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
Index: tools/clang/blink_gc_plugin/Edge.h
diff --git a/tools/clang/blink_gc_plugin/Edge.h b/tools/clang/blink_gc_plugin/Edge.h
index 79aa409ca1db5cea3c804aeaa8e9f89efe85e6c9..d7af335dc63cb3d1098c9355e120e81c4d85cf68 100644
--- a/tools/clang/blink_gc_plugin/Edge.h
+++ b/tools/clang/blink_gc_plugin/Edge.h
@@ -16,6 +16,7 @@ class RecordInfo;
class Edge;
class Collection;
class CrossThreadPersistent;
+class Iterator;
class Member;
class OwnPtr;
class Persistent;
@@ -39,6 +40,7 @@ class EdgeVisitor {
virtual void VisitPersistent(Persistent*) {}
virtual void VisitCrossThreadPersistent(CrossThreadPersistent*) {}
virtual void VisitCollection(Collection*) {}
+ virtual void VisitIterator(Iterator*) {}
};
// Recursive edge visitor. The traversed path is accessible in context.
@@ -55,6 +57,7 @@ class RecursiveEdgeVisitor : public EdgeVisitor {
void VisitPersistent(Persistent*) override;
void VisitCrossThreadPersistent(CrossThreadPersistent*) override;
void VisitCollection(Collection*) override;
+ void VisitIterator(Iterator*) override;
protected:
typedef std::deque<Edge*> Context;
@@ -74,6 +77,7 @@ class RecursiveEdgeVisitor : public EdgeVisitor {
virtual void AtPersistent(Persistent*);
virtual void AtCrossThreadPersistent(CrossThreadPersistent*);
virtual void AtCollection(Collection*);
+ virtual void AtIterator(Iterator*);
private:
Context context_;
@@ -281,4 +285,30 @@ class Collection : public Edge {
bool is_root_;
};
+// An iterator edge is a direct edge to some iterator type.
+class Iterator : public Edge {
+ public:
+ Iterator(RecordInfo* info, bool on_heap, bool is_unsafe)
+ : info_(info), on_heap_(on_heap), is_unsafe_(is_unsafe) {}
+ ~Iterator() {}
+
+ void Accept(EdgeVisitor* visitor) { visitor->VisitIterator(this); }
+ LivenessKind Kind() override { return kStrong; }
+ bool NeedsFinalization() { return false; }
+ TracingStatus NeedsTracing(NeedsTracingOption) {
+ if (on_heap_)
+ return TracingStatus::Needed();
+ return TracingStatus::Unneeded();
+ }
+
+ RecordInfo* info() const { return info_; }
+
+ bool IsUnsafe() const { return is_unsafe_; }
+
+ private:
+ RecordInfo* info_;
+ bool on_heap_;
+ bool is_unsafe_;
+};
+
#endif // TOOLS_BLINK_GC_PLUGIN_EDGE_H_

Powered by Google App Engine
This is Rietveld 408576698