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 "gc/shared/barrierSetAssembler.hpp" 27 28 #define __ masm-> 29 30 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 31 Register dst, Address src, Register tmp1, Register tmp2, Register tmp3) { 32 bool in_heap = (decorators & IN_HEAP) != 0; 33 bool in_native = (decorators & IN_NATIVE) != 0; 34 switch (type) { 35 case T_OBJECT: 36 case T_ARRAY: { 37 if (in_heap) { 38 { 39 __ ldr(dst, src); 40 } 41 } else { 42 assert(in_native, "why else?"); 43 __ ldr(dst, src); 44 } 45 break; 46 } 47 case T_BOOLEAN: __ ldrb (dst, src); break; 48 case T_BYTE: __ ldrsb (dst, src); break; 49 case T_CHAR: __ ldrh (dst, src); break; 50 case T_SHORT: __ ldrsh (dst, src); break; 51 case T_INT: __ ldr_s32 (dst, src); break; 52 case T_ADDRESS: __ ldr (dst, src); break; 53 case T_LONG: 54 assert(dst == noreg, "only to ltos"); 55 __ add (src.index(), src.index(), src.base()); 56 __ ldmia (src.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi)); 57 break; 58 #ifdef __SOFTFP__ 59 case T_FLOAT: 60 assert(dst == noreg, "only to ftos"); 61 __ ldr (R0_tos, src); 62 break; 63 case T_DOUBLE: 64 assert(dst == noreg, "only to dtos"); 65 __ add (src.index(), src.index(), src.base()); 66 __ ldmia (src.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi)); 67 break; 68 #else 69 case T_FLOAT: 70 assert(dst == noreg, "only to ftos"); 71 __ add(src.index(), src.index(), src.base()); 72 __ ldr_float (S0_tos, src.index()); 73 break; 74 case T_DOUBLE: 75 assert(dst == noreg, "only to dtos"); 76 __ add (src.index(), src.index(), src.base()); 77 __ ldr_double (D0_tos, src.index()); 78 break; 79 #endif 80 default: Unimplemented(); 81 } 82 83 } 84 85 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, 86 Address obj, Register val, Register tmp1, Register tmp2, Register tmp3, bool is_null) { 87 bool in_heap = (decorators & IN_HEAP) != 0; 88 bool in_native = (decorators & IN_NATIVE) != 0; 89 switch (type) { 90 case T_OBJECT: 91 case T_ARRAY: { 92 if (in_heap) { 93 { 94 __ str(val, obj); 95 } 96 } else { 97 assert(in_native, "why else?"); 98 __ str(val, obj); 99 } 100 break; 101 } 102 case T_BOOLEAN: 103 __ and_32(val, val, 1); 104 __ strb(val, obj); 105 break; 106 case T_BYTE: __ strb (val, obj); break; 107 case T_CHAR: __ strh (val, obj); break; 108 case T_SHORT: __ strh (val, obj); break; 109 case T_INT: __ str (val, obj); break; 110 case T_ADDRESS: __ str (val, obj); break; 111 case T_LONG: 112 assert(val == noreg, "only tos"); 113 __ add (obj.index(), obj.index(), obj.base()); 114 __ stmia (obj.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi)); 115 break; 116 #ifdef __SOFTFP__ 117 case T_FLOAT: 118 assert(val == noreg, "only tos"); 119 __ str (R0_tos, obj); 120 break; 121 case T_DOUBLE: 122 assert(val == noreg, "only tos"); 123 __ add (obj.index(), obj.index(), obj.base()); 124 __ stmia (obj.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi)); 125 break; 126 #else 127 case T_FLOAT: 128 assert(val == noreg, "only tos"); 129 __ add (obj.index(), obj.index(), obj.base()); 130 __ str_float (S0_tos, obj.index()); 131 break; 132 case T_DOUBLE: 133 assert(val == noreg, "only tos"); 134 __ add (obj.index(), obj.index(), obj.base()); 135 __ str_double (D0_tos, obj.index()); 136 break; 137 #endif 138 default: Unimplemented(); 139 } 140 } 141