94 // Helper for ReduceInitialCardMarks. For performance, |
94 // Helper for ReduceInitialCardMarks. For performance, |
95 // compiled code may elide card-marks for initializing stores |
95 // compiled code may elide card-marks for initializing stores |
96 // to a newly allocated object along the fast-path. We |
96 // to a newly allocated object along the fast-path. We |
97 // compensate for such elided card-marks as follows: |
97 // compensate for such elided card-marks as follows: |
98 // (a) Generational, non-concurrent collectors, such as |
98 // (a) Generational, non-concurrent collectors, such as |
99 // GenCollectedHeap(ParNew,DefNew,Tenured) and |
99 // GenCollectedHeap(DefNew,Tenured) and |
100 // ParallelScavengeHeap(ParallelGC, ParallelOldGC) |
100 // ParallelScavengeHeap(ParallelGC, ParallelOldGC) |
101 // need the card-mark if and only if the region is |
101 // need the card-mark if and only if the region is |
102 // in the old gen, and do not care if the card-mark |
102 // in the old gen, and do not care if the card-mark |
103 // succeeds or precedes the initializing stores themselves, |
103 // succeeds or precedes the initializing stores themselves, |
104 // so long as the card-mark is completed before the next |
104 // so long as the card-mark is completed before the next |
105 // scavenge. For all these cases, we can do a card mark |
105 // scavenge. For all these cases, we can do a card mark |
106 // at the point at which we do a slow path allocation |
106 // at the point at which we do a slow path allocation |
107 // in the old gen, i.e. in this call. |
107 // in the old gen, i.e. in this call. |
108 // (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires |
108 // (b) G1CollectedHeap(G1) uses two kinds of write barriers. When a |
109 // in addition that the card-mark for an old gen allocated |
|
110 // object strictly follow any associated initializing stores. |
|
111 // In these cases, the memRegion remembered below is |
|
112 // used to card-mark the entire region either just before the next |
|
113 // slow-path allocation by this thread or just before the next scavenge or |
|
114 // CMS-associated safepoint, whichever of these events happens first. |
|
115 // (The implicit assumption is that the object has been fully |
|
116 // initialized by this point, a fact that we assert when doing the |
|
117 // card-mark.) |
|
118 // (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a |
|
119 // G1 concurrent marking is in progress an SATB (pre-write-)barrier |
109 // G1 concurrent marking is in progress an SATB (pre-write-)barrier |
120 // is used to remember the pre-value of any store. Initializing |
110 // is used to remember the pre-value of any store. Initializing |
121 // stores will not need this barrier, so we need not worry about |
111 // stores will not need this barrier, so we need not worry about |
122 // compensating for the missing pre-barrier here. Turning now |
112 // compensating for the missing pre-barrier here. Turning now |
123 // to the post-barrier, we note that G1 needs a RS update barrier |
113 // to the post-barrier, we note that G1 needs a RS update barrier |
124 // which simply enqueues a (sequence of) dirty cards which may |
114 // which simply enqueues a (sequence of) dirty cards which may |
125 // optionally be refined by the concurrent update threads. Note |
115 // optionally be refined by the concurrent update threads. Note |
126 // that this barrier need only be applied to a non-young write, |
116 // that this barrier need only be applied to a non-young write, |
127 // but, like in CMS, because of the presence of concurrent refinement |
117 // but, because of the presence of concurrent refinement, |
128 // (much like CMS' precleaning), must strictly follow the oop-store. |
118 // must strictly follow the oop-store. |
129 // Thus, using the same protocol for maintaining the intended |
|
130 // invariants turns out, serendepitously, to be the same for both |
|
131 // G1 and CMS. |
|
132 // |
119 // |
133 // For any future collector, this code should be reexamined with |
120 // For any future collector, this code should be reexamined with |
134 // that specific collector in mind, and the documentation above suitably |
121 // that specific collector in mind, and the documentation above suitably |
135 // extended and updated. |
122 // extended and updated. |
136 void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) { |
123 void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) { |