13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.inline.hpp"
28 #include "gc/g1/g1BarrierSet.hpp"
29 #include "gc/g1/g1CardTable.hpp"
30 #include "gc/g1/g1BarrierSetAssembler.hpp"
31 #include "gc/g1/g1ThreadLocalData.hpp"
32 #include "gc/g1/heapRegion.hpp"
33 #include "gc/shared/collectedHeap.hpp"
34 #include "interpreter/interp_masm.hpp"
35
36 #define __ masm->
37
38 void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
39 Register from, Register to, Register count,
40 Register preserve1, Register preserve2) {
41 bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
42 // With G1, don't generate the call if we statically know that the target in uninitialized
43 if (!dest_uninitialized) {
44 int spill_slots = 3;
45 if (preserve1 != noreg) { spill_slots++; }
46 if (preserve2 != noreg) { spill_slots++; }
47 const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
48 Label filtered;
49
50 // Is marking active?
51 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
52 __ lwz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
53 } else {
187
188 if (pre_val->is_volatile() && preloaded) { __ mr(nv_save, pre_val); } // Save pre_val across C call if it was preloaded.
189 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, R16_thread);
190 if (pre_val->is_volatile() && preloaded) { __ mr(pre_val, nv_save); } // restore
191
192 if (needs_frame) {
193 __ pop_frame();
194 __ restore_LR_CR(tmp1);
195 }
196
197 __ bind(filtered);
198 }
199
200 void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val,
201 Register tmp1, Register tmp2, Register tmp3) {
202 bool not_null = (decorators & OOP_NOT_NULL) != 0;
203
204 Label runtime, filtered;
205 assert_different_registers(store_addr, new_val, tmp1, tmp2);
206
207 CardTableBarrierSet* ct = barrier_set_cast<CardTableBarrierSet>(Universe::heap()->barrier_set());
208 assert(sizeof(*ct->card_table()->byte_map_base()) == sizeof(jbyte), "adjust this code");
209
210 // Does store cross heap regions?
211 if (G1RSBarrierRegionFilter) {
212 __ xorr(tmp1, store_addr, new_val);
213 __ srdi_(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
214 __ beq(CCR0, filtered);
215 }
216
217 // Crosses regions, storing NULL?
218 if (not_null) {
219 #ifdef ASSERT
220 __ cmpdi(CCR0, new_val, 0);
221 __ asm_assert_ne("null oop not allowed (G1 post)", 0x322); // Checked by caller.
222 #endif
223 } else {
224 __ cmpdi(CCR0, new_val, 0);
225 __ beq(CCR0, filtered);
226 }
227
|
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.inline.hpp"
28 #include "gc/g1/g1BarrierSet.hpp"
29 #include "gc/g1/g1CardTable.hpp"
30 #include "gc/g1/g1BarrierSetAssembler.hpp"
31 #include "gc/g1/g1ThreadLocalData.hpp"
32 #include "gc/g1/heapRegion.hpp"
33 #include "interpreter/interp_masm.hpp"
34
35 #define __ masm->
36
37 void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
38 Register from, Register to, Register count,
39 Register preserve1, Register preserve2) {
40 bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
41 // With G1, don't generate the call if we statically know that the target in uninitialized
42 if (!dest_uninitialized) {
43 int spill_slots = 3;
44 if (preserve1 != noreg) { spill_slots++; }
45 if (preserve2 != noreg) { spill_slots++; }
46 const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes);
47 Label filtered;
48
49 // Is marking active?
50 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
51 __ lwz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread);
52 } else {
186
187 if (pre_val->is_volatile() && preloaded) { __ mr(nv_save, pre_val); } // Save pre_val across C call if it was preloaded.
188 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, R16_thread);
189 if (pre_val->is_volatile() && preloaded) { __ mr(pre_val, nv_save); } // restore
190
191 if (needs_frame) {
192 __ pop_frame();
193 __ restore_LR_CR(tmp1);
194 }
195
196 __ bind(filtered);
197 }
198
199 void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val,
200 Register tmp1, Register tmp2, Register tmp3) {
201 bool not_null = (decorators & OOP_NOT_NULL) != 0;
202
203 Label runtime, filtered;
204 assert_different_registers(store_addr, new_val, tmp1, tmp2);
205
206 CardTableBarrierSet* ct = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
207 assert(sizeof(*ct->card_table()->byte_map_base()) == sizeof(jbyte), "adjust this code");
208
209 // Does store cross heap regions?
210 if (G1RSBarrierRegionFilter) {
211 __ xorr(tmp1, store_addr, new_val);
212 __ srdi_(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
213 __ beq(CCR0, filtered);
214 }
215
216 // Crosses regions, storing NULL?
217 if (not_null) {
218 #ifdef ASSERT
219 __ cmpdi(CCR0, new_val, 0);
220 __ asm_assert_ne("null oop not allowed (G1 post)", 0x322); // Checked by caller.
221 #endif
222 } else {
223 __ cmpdi(CCR0, new_val, 0);
224 __ beq(CCR0, filtered);
225 }
226
|