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::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 34 Register base, RegisterOrConstant ind_or_offs, Register val, 35 Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { 36 bool on_heap = (decorators & IN_HEAP) != 0; 37 bool in_native = (decorators & IN_NATIVE) != 0; 38 bool not_null = (decorators & OOP_NOT_NULL) != 0; 39 assert(on_heap || in_native, "where?"); 40 assert_different_registers(base, val, tmp1, tmp2, R0); 41 42 switch (type) { 43 case T_ARRAY: 44 case T_OBJECT: { 45 if (UseCompressedOops && on_heap) { 46 Register co = tmp1; 47 if (val == noreg) { 48 __ li(co, 0); 49 } else { 50 co = not_null ? __ encode_heap_oop_not_null(tmp1, val) : __ encode_heap_oop(tmp1, val); 51 } 52 __ stw(co, ind_or_offs, base, tmp2); 53 } else { 54 if (val == noreg) { 55 val = tmp1; 56 __ li(val, 0); 57 } 58 __ std(val, ind_or_offs, base, tmp2); 59 } 60 break; 61 } 62 default: Unimplemented(); 63 } 64 } 65 66 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 67 Register base, RegisterOrConstant ind_or_offs, Register dst, 68 Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null) { 69 bool on_heap = (decorators & IN_HEAP) != 0; 70 bool in_native = (decorators & IN_NATIVE) != 0; 71 bool not_null = (decorators & OOP_NOT_NULL) != 0; 72 assert(on_heap || in_native, "where?"); 73 assert_different_registers(ind_or_offs.register_or_noreg(), dst, R0); 74 75 switch (type) { 76 case T_ARRAY: 77 case T_OBJECT: { 78 if (UseCompressedOops && on_heap) { 79 if (L_handle_null != NULL) { // Label provided. 80 __ lwz(dst, ind_or_offs, base); 81 __ cmpwi(CCR0, dst, 0); 82 __ beq(CCR0, *L_handle_null); 83 __ decode_heap_oop_not_null(dst); 84 } else if (not_null) { // Guaranteed to be not null. 85 Register narrowOop = (tmp1 != noreg && Universe::narrow_oop_base_disjoint()) ? tmp1 : dst; 86 __ lwz(narrowOop, ind_or_offs, base); 87 __ decode_heap_oop_not_null(dst, narrowOop); 88 } else { // Any oop. 89 __ lwz(dst, ind_or_offs, base); 90 __ decode_heap_oop(dst); 91 } 92 } else { 93 __ ld(dst, ind_or_offs, base); 94 if (L_handle_null != NULL) { 95 __ cmpdi(CCR0, dst, 0); 96 __ beq(CCR0, *L_handle_null); 97 } 98 } 99 break; 100 } 101 default: Unimplemented(); 102 } 103 } 104 105 void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, 106 Register tmp1, Register tmp2, bool needs_frame) { 107 Label done; 108 __ cmpdi(CCR0, value, 0); 109 __ beq(CCR0, done); // Use NULL as-is. 110 111 __ clrrdi(tmp1, value, JNIHandles::weak_tag_size); 112 __ ld(value, 0, tmp1); // Resolve (untagged) jobject. 113 114 __ verify_oop(value); 115 __ bind(done); 116 }