1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "asm/macroAssembler.inline.hpp" 27 #include "gc/g1/g1BarrierSet.hpp" 28 #include "gc/g1/g1CardTable.hpp" 29 #include "gc/g1/g1BSCodeGen.hpp" 30 #include "gc/g1/heapRegion.hpp" 31 #include "gc/shared/collectedHeap.hpp" 32 #include "interpreter/interp_masm.hpp" 33 #include "runtime/sharedRuntime.hpp" 34 #include "runtime/thread.hpp" 35 #include "utilities/macros.hpp" 36 37 #define __ masm-> 38 39 void G1BSCodeGen::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count) { 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 __ save_frame(0); 44 // Save the necessary global regs... will be used after. 45 if (addr->is_global()) { 46 __ mov(addr, L0); 47 } 48 if (count->is_global()) { 49 __ mov(count, L1); 50 } 51 __ mov(addr->after_save(), O0); 52 // Get the count into O1 53 address slowpath = UseCompressedOops ? CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry) 54 : CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry); 55 __ call(slowpath); 56 __ delayed()->mov(count->after_save(), O1); 57 if (addr->is_global()) { 58 __ mov(L0, addr); 59 } 60 if (count->is_global()) { 61 __ mov(L1, count); 62 } 63 __ restore(); 64 } 65 } 66 67 void G1BSCodeGen::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, Register tmp) { 68 // Get some new fresh output registers. 69 __ save_frame(0); 70 __ mov(addr->after_save(), O0); 71 __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry)); 72 __ delayed()->mov(count->after_save(), O1); 73 __ restore(); 74 }