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/shared/barrierSetAssembler.hpp" 29 #include "interpreter/interp_masm.hpp" 30 31 #define __ masm-> 32 33 void BarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 34 Register dst, Register count, bool do_return) { 35 if (do_return) { __ z_br(Z_R14); } 36 } 37 38 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 39 const Address& addr, Register dst, Register tmp1, Register tmp2, Label *is_null) { 40 bool on_heap = (decorators & IN_HEAP) != 0; 41 bool on_root = (decorators & IN_ROOT) != 0; 42 assert(on_heap || on_root, "where?"); 43 44 switch (type) { 45 case T_ARRAY: 46 case T_OBJECT: { 47 if (UseCompressedOops && on_heap) { 48 __ z_llgf(dst, addr); 49 if (is_null) { 50 __ compareU32_and_branch(dst, (intptr_t)0, Assembler::bcondEqual, *is_null); 51 __ oop_decoder(dst, dst, false); 52 } else { 53 __ oop_decoder(dst, dst, true); 54 } 55 } else { 56 __ z_lg(dst, addr); 57 if (is_null) { 58 __ compareU64_and_branch(dst, (intptr_t)0, Assembler::bcondEqual, *is_null); 59 } 60 } 61 break; 62 } 63 default: Unimplemented(); 64 } 65 } 66 67 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 68 const Address& addr, Register val, Register tmp1, Register tmp2, Register tmp3) { 69 bool on_heap = (decorators & IN_HEAP) != 0; 70 bool on_root = (decorators & IN_ROOT) != 0; 71 bool not_null = (decorators & OOP_NOT_NULL) != 0; 72 assert(on_heap || on_root, "where?"); 73 assert_different_registers(val, tmp1, tmp2); 74 75 switch (type) { 76 case T_ARRAY: 77 case T_OBJECT: { 78 if (UseCompressedOops && on_heap) { 79 if (val == noreg) { 80 __ clear_mem(addr, 4); 81 } else if (Universe::narrow_oop_mode() == Universe::UnscaledNarrowOop) { 82 __ z_st(val, addr); 83 } else { 84 Register tmp = (tmp1 != Z_R1) ? tmp1 : tmp2; // Avoid tmp == Z_R1 (see oop_encoder). 85 __ oop_encoder(tmp, val, !not_null); 86 __ z_st(tmp, addr); 87 } 88 } else { 89 if (val == noreg) { 90 __ clear_mem(addr, 8); 91 } else { 92 __ z_stg(val, addr); 93 } 94 } 95 break; 96 } 97 default: Unimplemented(); 98 } 99 } 100 101 void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) { 102 NearLabel Ldone; 103 __ z_ltgr(tmp1, value); 104 __ z_bre(Ldone); // Use NULL result as-is. 105 106 __ z_nill(value, ~JNIHandles::weak_tag_mask); 107 __ z_lg(value, 0, value); // Resolve (untagged) jobject. 108 109 __ verify_oop(value); 110 __ bind(Ldone); 111 }