equal
deleted
inserted
replaced
27 |
27 |
28 #include "gc/g1/ptrQueue.hpp" |
28 #include "gc/g1/ptrQueue.hpp" |
29 #include "memory/allocation.hpp" |
29 #include "memory/allocation.hpp" |
30 |
30 |
31 class FreeIdSet; |
31 class FreeIdSet; |
|
32 class DirtyCardQueueSet; |
32 |
33 |
33 // A closure class for processing card table entries. Note that we don't |
34 // A closure class for processing card table entries. Note that we don't |
34 // require these closure objects to be stack-allocated. |
35 // require these closure objects to be stack-allocated. |
35 class CardTableEntryClosure: public CHeapObj<mtGC> { |
36 class CardTableEntryClosure: public CHeapObj<mtGC> { |
36 public: |
37 public: |
40 }; |
41 }; |
41 |
42 |
42 // A ptrQueue whose elements are "oops", pointers to object heads. |
43 // A ptrQueue whose elements are "oops", pointers to object heads. |
43 class DirtyCardQueue: public PtrQueue { |
44 class DirtyCardQueue: public PtrQueue { |
44 public: |
45 public: |
45 DirtyCardQueue(PtrQueueSet* qset_, bool perm = false) : |
46 DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent = false); |
46 // Dirty card queues are always active, so we create them with their |
|
47 // active field set to true. |
|
48 PtrQueue(qset_, perm, true /* active */) { } |
|
49 |
47 |
50 // Flush before destroying; queue may be used to capture pending work while |
48 // Flush before destroying; queue may be used to capture pending work while |
51 // doing something else, with auto-flush on completion. |
49 // doing something else, with auto-flush on completion. |
52 ~DirtyCardQueue() { if (!is_permanent()) flush(); } |
50 ~DirtyCardQueue(); |
53 |
51 |
54 // Process queue entries and release resources. |
52 // Process queue entries and release resources. |
55 void flush() { flush_impl(); } |
53 void flush() { flush_impl(); } |
56 |
54 |
57 // Apply the closure to all elements, and reset the index to make the |
55 // Apply the closure to all elements, and reset the index to make the |
70 static bool apply_closure_to_buffer(CardTableEntryClosure* cl, |
68 static bool apply_closure_to_buffer(CardTableEntryClosure* cl, |
71 void** buf, size_t index, size_t sz, |
69 void** buf, size_t index, size_t sz, |
72 bool consume = true, |
70 bool consume = true, |
73 uint worker_i = 0); |
71 uint worker_i = 0); |
74 void **get_buf() { return _buf;} |
72 void **get_buf() { return _buf;} |
75 void set_buf(void **buf) {_buf = buf;} |
|
76 size_t get_index() { return _index;} |
73 size_t get_index() { return _index;} |
77 void reinitialize() { _buf = 0; _sz = 0; _index = 0;} |
74 void reinitialize() { _buf = 0; _sz = 0; _index = 0;} |
78 }; |
75 }; |
79 |
76 |
80 |
77 |
99 // Current buffer node used for parallel iteration. |
96 // Current buffer node used for parallel iteration. |
100 BufferNode* volatile _cur_par_buffer_node; |
97 BufferNode* volatile _cur_par_buffer_node; |
101 public: |
98 public: |
102 DirtyCardQueueSet(bool notify_when_complete = true); |
99 DirtyCardQueueSet(bool notify_when_complete = true); |
103 |
100 |
104 void initialize(CardTableEntryClosure* cl, Monitor* cbl_mon, Mutex* fl_lock, |
101 void initialize(CardTableEntryClosure* cl, |
|
102 Monitor* cbl_mon, |
|
103 Mutex* fl_lock, |
105 int process_completed_threshold, |
104 int process_completed_threshold, |
106 int max_completed_queue, |
105 int max_completed_queue, |
107 Mutex* lock, PtrQueueSet* fl_owner = NULL); |
106 Mutex* lock, |
|
107 DirtyCardQueueSet* fl_owner = NULL); |
108 |
108 |
109 // The number of parallel ids that can be claimed to allow collector or |
109 // The number of parallel ids that can be claimed to allow collector or |
110 // mutator threads to do card-processing work. |
110 // mutator threads to do card-processing work. |
111 static uint num_par_ids(); |
111 static uint num_par_ids(); |
112 |
112 |