1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2018, SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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/heapRegion.hpp" 32 #include "gc/shared/collectedHeap.hpp" 33 #include "runtime/thread.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(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread); 53 } else { 54 guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); 55 __ lbz(R0, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread); 56 } 57 __ cmpdi(CCR0, R0, 0); 58 __ beq(CCR0, filtered); 59 60 __ save_LR_CR(R0); 61 __ push_frame(frame_size, R0); 62 int slot_nr = 0; 63 __ std(from, frame_size - (++slot_nr) * wordSize, R1_SP); 64 __ std(to, frame_size - (++slot_nr) * wordSize, R1_SP); 65 __ std(count, frame_size - (++slot_nr) * wordSize, R1_SP); 66 if (preserve1 != noreg) { __ std(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); } 67 if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); } 68 69 if (UseCompressedOops) { 70 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), to, count); 71 } else { 72 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), to, count); 73 } 74 75 slot_nr = 0; 76 __ ld(from, frame_size - (++slot_nr) * wordSize, R1_SP); 77 __ ld(to, frame_size - (++slot_nr) * wordSize, R1_SP); 78 __ ld(count, frame_size - (++slot_nr) * wordSize, R1_SP); 79 if (preserve1 != noreg) { __ ld(preserve1, frame_size - (++slot_nr) * wordSize, R1_SP); } 80 if (preserve2 != noreg) { __ ld(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); } 81 __ addi(R1_SP, R1_SP, frame_size); // pop_frame() 82 __ restore_LR_CR(R0); 83 84 __ bind(filtered); 85 } 86 } 87 88 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, 89 Register addr, Register count, Register preserve) { 90 int spill_slots = (preserve != noreg) ? 1 : 0; 91 const int frame_size = align_up(frame::abi_reg_args_size + spill_slots * BytesPerWord, frame::alignment_in_bytes); 92 93 __ save_LR_CR(R0); 94 __ push_frame(frame_size, R0); 95 if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); } 96 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), addr, count); 97 if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); } 98 __ addi(R1_SP, R1_SP, frame_size); // pop_frame(); 99 __ restore_LR_CR(R0); 100 }