Avi Drissman | dfd88085 | 2022-09-15 20:11:09 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_ |
| 6 | #define TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_ |
| 7 | |
| 8 | #include <set> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "Edge.h" |
| 12 | #include "RecordInfo.h" |
| 13 | |
Omer Katz | f155ae1 | 2022-01-05 17:46:39 | [diff] [blame] | 14 | struct BlinkGCPluginOptions; |
| 15 | |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 16 | // This visitor checks that the fields of a class and the fields of |
| 17 | // its part objects don't define GC roots. |
| 18 | class CheckGCRootsVisitor : public RecursiveEdgeVisitor { |
| 19 | public: |
| 20 | typedef std::vector<FieldPoint*> RootPath; |
| 21 | typedef std::set<RecordInfo*> VisitingSet; |
| 22 | typedef std::vector<RootPath> Errors; |
| 23 | |
Omer Katz | f155ae1 | 2022-01-05 17:46:39 | [diff] [blame] | 24 | explicit CheckGCRootsVisitor(const BlinkGCPluginOptions&); |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 25 | |
| 26 | Errors& gc_roots(); |
Omer Katz | 550795dfe | 2023-06-09 09:50:56 | [diff] [blame] | 27 | Errors& gc_root_refs(); |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 28 | |
| 29 | bool ContainsGCRoots(RecordInfo* info); |
| 30 | |
| 31 | void VisitValue(Value* edge) override; |
Omer Katz | f155ae1 | 2022-01-05 17:46:39 | [diff] [blame] | 32 | void VisitUniquePtr(UniquePtr*) override; |
Omer Katz | 550795dfe | 2023-06-09 09:50:56 | [diff] [blame] | 33 | void VisitRawPtr(RawPtr*) override; |
| 34 | void VisitRefPtr(RefPtr*) override; |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 35 | void VisitPersistent(Persistent* edge) override; |
Paul Semel | 1fd727f | 2023-01-05 10:31:38 | [diff] [blame] | 36 | void VisitCollection(Collection* edge) override; |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 37 | |
| 38 | private: |
| 39 | RootPath current_; |
| 40 | VisitingSet visiting_set_; |
| 41 | Errors gc_roots_; |
Omer Katz | 550795dfe | 2023-06-09 09:50:56 | [diff] [blame] | 42 | Errors gc_root_refs_; |
| 43 | bool is_ref_ = false; |
Omer Katz | f155ae1 | 2022-01-05 17:46:39 | [diff] [blame] | 44 | |
| 45 | bool should_check_unique_ptrs_; |
yutak | 41e9c2d | 2015-09-18 14:37:43 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_ |