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 "registerSaver_s390.hpp" 29 #include "gc/g1/g1CardTable.hpp" 30 #include "gc/g1/g1BarrierSet.hpp" 31 #include "gc/g1/g1BarrierSetCodeGen.hpp" 32 #include "gc/g1/heapRegion.hpp" 33 #include "gc/shared/collectedHeap.hpp" 34 #include "runtime/thread.hpp" 35 #include "interpreter/interp_masm.hpp" 36 37 #define __ masm-> 38 39 #define BLOCK_COMMENT(str) if (PrintAssembly) __ block_comment(str) 40 41 void G1BarrierSetCodeGen::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count) { 42 bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0; 43 44 // With G1, don't generate the call if we statically know that the target is uninitialized. 45 if (!dest_uninitialized) { 46 // Is marking active? 47 Label filtered; 48 assert_different_registers(addr, Z_R0_scratch); // would be destroyed by push_frame() 49 assert_different_registers(count, Z_R0_scratch); // would be destroyed by push_frame() 50 Register Rtmp1 = Z_R0_scratch; 51 const int active_offset = in_bytes(JavaThread::satb_mark_queue_offset() + 52 SATBMarkQueue::byte_offset_of_active()); 53 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { 54 __ load_and_test_int(Rtmp1, Address(Z_thread, active_offset)); 55 } else { 56 guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); 57 __ load_and_test_byte(Rtmp1, Address(Z_thread, active_offset)); 58 } 59 __ z_bre(filtered); // Activity indicator is zero, so there is no marking going on currently. 60 61 RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame. 62 63 if (UseCompressedOops) { 64 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), addr, count); 65 } else { 66 __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), addr, count); 67 } 68 69 RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers); 70 71 __ bind(filtered); 72 } 73 } 74 75 void G1BarrierSetCodeGen::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, 76 bool do_return) { 77 address entry_point = CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry); 78 if (!do_return) { 79 assert_different_registers(addr, Z_R0_scratch); // would be destroyed by push_frame() 80 assert_different_registers(count, Z_R0_scratch); // would be destroyed by push_frame() 81 RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame. 82 __ call_VM_leaf(entry_point, addr, count); 83 RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers); 84 } else { 85 // Tail call: call c and return to stub caller. 86 __ lgr_if_needed(Z_ARG1, addr); 87 __ lgr_if_needed(Z_ARG2, count); 88 __ load_const(Z_R1, entry_point); 89 __ z_br(Z_R1); // Branch without linking, callee will return to stub caller. 90 } 91 }