Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/satbQueue.hpp @ 4787:2ace1c4ee8da
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
Summary: This change simplifies the interaction between GC and concurrent marking. By disabling survivor spaces during the initial-mark pause we don't need to propagate marks of objects we copy during each GC (since we never need to copy an explicitly marked object).
Reviewed-by: johnc, brutisso
author | tonyp |
---|---|
date | Tue, 10 Jan 2012 18:58:13 -0500 |
parents | 7e37af9d69ef |
children | 89ac31a5a7a7 |
comparison
equal
deleted
inserted
replaced
4786:1d6185f732aa | 4787:2ace1c4ee8da |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
27 | 27 |
28 #include "gc_implementation/g1/ptrQueue.hpp" | 28 #include "gc_implementation/g1/ptrQueue.hpp" |
29 | 29 |
30 class ObjectClosure; | 30 class ObjectClosure; |
31 class JavaThread; | 31 class JavaThread; |
32 class SATBMarkQueueSet; | |
32 | 33 |
33 // A ptrQueue whose elements are "oops", pointers to object heads. | 34 // A ptrQueue whose elements are "oops", pointers to object heads. |
34 class ObjPtrQueue: public PtrQueue { | 35 class ObjPtrQueue: public PtrQueue { |
36 friend class SATBMarkQueueSet; | |
37 | |
38 private: | |
39 // Filter out unwanted entries from the buffer. | |
40 void filter(); | |
41 | |
42 // Apply the closure to all elements. | |
43 void apply_closure(ObjectClosure* cl); | |
44 | |
45 // Apply the closure to all elements and empty the buffer; | |
46 void apply_closure_and_empty(ObjectClosure* cl); | |
47 | |
48 // Apply the closure to all elements of "buf", down to "index" (inclusive.) | |
49 static void apply_closure_to_buffer(ObjectClosure* cl, | |
50 void** buf, size_t index, size_t sz); | |
51 | |
35 public: | 52 public: |
36 ObjPtrQueue(PtrQueueSet* qset, bool perm = false) : | 53 ObjPtrQueue(PtrQueueSet* qset, bool perm = false) : |
37 // SATB queues are only active during marking cycles. We create | 54 // SATB queues are only active during marking cycles. We create |
38 // them with their active field set to false. If a thread is | 55 // them with their active field set to false. If a thread is |
39 // created during a cycle and its SATB queue needs to be activated | 56 // created during a cycle and its SATB queue needs to be activated |
40 // before the thread starts running, we'll need to set its active | 57 // before the thread starts running, we'll need to set its active |
41 // field to true. This is done in JavaThread::initialize_queues(). | 58 // field to true. This is done in JavaThread::initialize_queues(). |
42 PtrQueue(qset, perm, false /* active */) { } | 59 PtrQueue(qset, perm, false /* active */) { } |
43 | 60 |
61 // Overrides PtrQueue::flush() so that it can filter the buffer | |
62 // before it is flushed. | |
63 virtual void flush(); | |
64 | |
44 // Overrides PtrQueue::should_enqueue_buffer(). See the method's | 65 // Overrides PtrQueue::should_enqueue_buffer(). See the method's |
45 // definition for more information. | 66 // definition for more information. |
46 virtual bool should_enqueue_buffer(); | 67 virtual bool should_enqueue_buffer(); |
47 | 68 |
48 // Apply the closure to all elements, and reset the index to make the | 69 #ifndef PRODUCT |
49 // buffer empty. | 70 // Helpful for debugging |
50 void apply_closure(ObjectClosure* cl); | 71 void print(const char* name); |
51 | 72 static void print(const char* name, void** buf, size_t index, size_t sz); |
52 // Apply the closure to all elements of "buf", down to "index" (inclusive.) | 73 #endif // PRODUCT |
53 static void apply_closure_to_buffer(ObjectClosure* cl, | |
54 void** buf, size_t index, size_t sz); | |
55 | 74 |
56 void verify_oops_in_buffer() NOT_DEBUG_RETURN; | 75 void verify_oops_in_buffer() NOT_DEBUG_RETURN; |
57 }; | 76 }; |
58 | |
59 | |
60 | 77 |
61 class SATBMarkQueueSet: public PtrQueueSet { | 78 class SATBMarkQueueSet: public PtrQueueSet { |
62 ObjectClosure* _closure; | 79 ObjectClosure* _closure; |
63 ObjectClosure** _par_closures; // One per ParGCThread. | 80 ObjectClosure** _par_closures; // One per ParGCThread. |
64 | 81 |
86 // called only with the world stopped. The method will assert that the | 103 // called only with the world stopped. The method will assert that the |
87 // SATB queues of all threads it visits, as well as the SATB queue | 104 // SATB queues of all threads it visits, as well as the SATB queue |
88 // set itself, has an active value same as expected_active. | 105 // set itself, has an active value same as expected_active. |
89 void set_active_all_threads(bool b, bool expected_active); | 106 void set_active_all_threads(bool b, bool expected_active); |
90 | 107 |
108 // Filter all the currently-active SATB buffers. | |
109 void filter_thread_buffers(); | |
110 | |
91 // Register "blk" as "the closure" for all queues. Only one such closure | 111 // Register "blk" as "the closure" for all queues. Only one such closure |
92 // is allowed. The "apply_closure_to_completed_buffer" method will apply | 112 // is allowed. The "apply_closure_to_completed_buffer" method will apply |
93 // this closure to a completed buffer, and "iterate_closure_all_threads" | 113 // this closure to a completed buffer, and "iterate_closure_all_threads" |
94 // applies it to partially-filled buffers (the latter should only be done | 114 // applies it to partially-filled buffers (the latter should only be done |
95 // with the world stopped). | 115 // with the world stopped). |
96 void set_closure(ObjectClosure* closure); | 116 void set_closure(ObjectClosure* closure); |
97 // Set the parallel closures: pointer is an array of pointers to | 117 // Set the parallel closures: pointer is an array of pointers to |
98 // closures, one for each parallel GC thread. | 118 // closures, one for each parallel GC thread. |
99 void set_par_closure(int i, ObjectClosure* closure); | 119 void set_par_closure(int i, ObjectClosure* closure); |
100 | 120 |
101 // If there is a registered closure for buffers, apply it to all entries | 121 // Apply the registered closure to all entries on each |
102 // in all currently-active buffers. This should only be applied at a | 122 // currently-active buffer and then empty the buffer. It should only |
103 // safepoint. (Currently must not be called in parallel; this should | 123 // be called serially and at a safepoint. |
104 // change in the future.) | |
105 void iterate_closure_all_threads(); | 124 void iterate_closure_all_threads(); |
106 // Parallel version of the above. | 125 // Parallel version of the above. |
107 void par_iterate_closure_all_threads(int worker); | 126 void par_iterate_closure_all_threads(int worker); |
108 | 127 |
109 // If there exists some completed buffer, pop it, then apply the | 128 // If there exists some completed buffer, pop it, then apply the |
115 // Parallel version of the above. | 134 // Parallel version of the above. |
116 bool par_apply_closure_to_completed_buffer(int worker) { | 135 bool par_apply_closure_to_completed_buffer(int worker) { |
117 return apply_closure_to_completed_buffer_work(true, worker); | 136 return apply_closure_to_completed_buffer_work(true, worker); |
118 } | 137 } |
119 | 138 |
139 // Apply the given closure on enqueued and currently-active buffers | |
140 // respectively. Both methods are read-only, i.e., they do not | |
141 // modify any of the buffers. | |
142 void iterate_completed_buffers_read_only(ObjectClosure* cl); | |
143 void iterate_thread_buffers_read_only(ObjectClosure* cl); | |
144 | |
145 #ifndef PRODUCT | |
146 // Helpful for debugging | |
147 void print_all(const char* msg); | |
148 #endif // PRODUCT | |
149 | |
120 ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; } | 150 ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; } |
121 | 151 |
122 // If a marking is being abandoned, reset any unprocessed log buffers. | 152 // If a marking is being abandoned, reset any unprocessed log buffers. |
123 void abandon_partial_marking(); | 153 void abandon_partial_marking(); |
124 | |
125 }; | 154 }; |
126 | 155 |
127 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP | 156 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP |