comparison src/share/vm/memory/iterator.hpp @ 342:37f87013dfd8

6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
author ysr
date Thu, 05 Jun 2008 15:57:56 -0700
parents ba764ed4b6f2
children 1ee8caae33af
comparison
equal deleted inserted replaced
189:0b27f3512f9e 342:37f87013dfd8
24 24
25 // The following classes are C++ `closures` for iterating over objects, roots and spaces 25 // The following classes are C++ `closures` for iterating over objects, roots and spaces
26 26
27 class ReferenceProcessor; 27 class ReferenceProcessor;
28 28
29 // Closure provides abortability.
30
31 class Closure : public StackObj {
32 protected:
33 bool _abort;
34 void set_abort() { _abort = true; }
35 public:
36 Closure() : _abort(false) {}
37 // A subtype can use this mechanism to indicate to some iterator mapping
38 // functions that the iteration should cease.
39 bool abort() { return _abort; }
40 void clear_abort() { _abort = false; }
41 };
42
29 // OopClosure is used for iterating through roots (oop*) 43 // OopClosure is used for iterating through roots (oop*)
30 44
31 class OopClosure : public StackObj { 45 class OopClosure : public Closure {
32 public: 46 public:
33 ReferenceProcessor* _ref_processor; 47 ReferenceProcessor* _ref_processor;
34 OopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } 48 OopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
35 OopClosure() : _ref_processor(NULL) { } 49 OopClosure() : _ref_processor(NULL) { }
36 virtual void do_oop(oop* o) = 0; 50 virtual void do_oop(oop* o) = 0;
53 bool do_header() { return true; } // Note that this is non-virtual. 67 bool do_header() { return true; } // Note that this is non-virtual.
54 // Controls how prefetching is done for invocations of this closure. 68 // Controls how prefetching is done for invocations of this closure.
55 Prefetch::style prefetch_style() { // Note that this is non-virtual. 69 Prefetch::style prefetch_style() { // Note that this is non-virtual.
56 return Prefetch::do_none; 70 return Prefetch::do_none;
57 } 71 }
72
73 // True iff this closure may be safely applied more than once to an oop
74 // location without an intervening "major reset" (like the end of a GC).
75 virtual bool idempotent() { return false; }
76 virtual bool apply_to_weak_ref_discovered_field() { return false; }
58 }; 77 };
59 78
60 // ObjectClosure is used for iterating through an object space 79 // ObjectClosure is used for iterating through an object space
61 80
62 class ObjectClosure : public StackObj { 81 class ObjectClosure : public Closure {
63 public: 82 public:
64 // Called for each object. 83 // Called for each object.
65 virtual void do_object(oop obj) = 0; 84 virtual void do_object(oop obj) = 0;
66 }; 85 };
67 86