1 /* 2 * Copyright (c) 2004, 2010, 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 "incls/_precompiled.incl" 26 # include "incls/_jniFastGetField_sparc.cpp.incl" 27 28 // TSO ensures that loads are blocking and ordered with respect to 29 // to earlier loads, so we don't need LoadLoad membars. 30 31 #define __ masm-> 32 33 #define BUFFER_SIZE 30*sizeof(jint) 34 35 // Common register usage: 36 // O0: env 37 // O1: obj 38 // O2: jfieldID 39 // O4: offset (O2 >> 2) 40 // G4: old safepoint counter 41 42 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { 43 const char *name; 44 switch (type) { 45 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break; 46 case T_BYTE: name = "jni_fast_GetByteField"; break; 47 case T_CHAR: name = "jni_fast_GetCharField"; break; 48 case T_SHORT: name = "jni_fast_GetShortField"; break; 49 case T_INT: name = "jni_fast_GetIntField"; break; 50 default: ShouldNotReachHere(); 51 } 52 ResourceMark rm; 53 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); 54 CodeBuffer cbuf(blob); 55 MacroAssembler* masm = new MacroAssembler(&cbuf); 56 address fast_entry = __ pc(); 57 58 Label label1, label2; 59 60 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); 61 __ sethi (cnt_addrlit, O3); 62 Address cnt_addr(O3, cnt_addrlit.low10()); 63 __ ld (cnt_addr, G4); 64 __ andcc (G4, 1, G0); 65 __ br (Assembler::notZero, false, Assembler::pn, label1); 66 __ delayed()->srl (O2, 2, O4); 67 __ ld_ptr (O1, 0, O5); 68 69 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); 70 speculative_load_pclist[count] = __ pc(); 71 switch (type) { 72 case T_BOOLEAN: __ ldub (O5, O4, G3); break; 73 case T_BYTE: __ ldsb (O5, O4, G3); break; 74 case T_CHAR: __ lduh (O5, O4, G3); break; 75 case T_SHORT: __ ldsh (O5, O4, G3); break; 76 case T_INT: __ ld (O5, O4, G3); break; 77 default: ShouldNotReachHere(); 78 } 79 80 __ ld (cnt_addr, O5); 81 __ cmp (O5, G4); 82 __ br (Assembler::notEqual, false, Assembler::pn, label2); 83 __ delayed()->mov (O7, G1); 84 __ retl (); 85 __ delayed()->mov (G3, O0); 86 87 slowcase_entry_pclist[count++] = __ pc(); 88 __ bind (label1); 89 __ mov (O7, G1); 90 91 address slow_case_addr; 92 switch (type) { 93 case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break; 94 case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break; 95 case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break; 96 case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break; 97 case T_INT: slow_case_addr = jni_GetIntField_addr(); break; 98 default: ShouldNotReachHere(); 99 } 100 __ bind (label2); 101 __ call (slow_case_addr, relocInfo::none); 102 __ delayed()->mov (G1, O7); 103 104 __ flush (); 105 106 return fast_entry; 107 } 108 109 address JNI_FastGetField::generate_fast_get_boolean_field() { 110 return generate_fast_get_int_field0(T_BOOLEAN); 111 } 112 113 address JNI_FastGetField::generate_fast_get_byte_field() { 114 return generate_fast_get_int_field0(T_BYTE); 115 } 116 117 address JNI_FastGetField::generate_fast_get_char_field() { 118 return generate_fast_get_int_field0(T_CHAR); 119 } 120 121 address JNI_FastGetField::generate_fast_get_short_field() { 122 return generate_fast_get_int_field0(T_SHORT); 123 } 124 125 address JNI_FastGetField::generate_fast_get_int_field() { 126 return generate_fast_get_int_field0(T_INT); 127 } 128 129 address JNI_FastGetField::generate_fast_get_long_field() { 130 const char *name = "jni_fast_GetLongField"; 131 ResourceMark rm; 132 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); 133 CodeBuffer cbuf(blob); 134 MacroAssembler* masm = new MacroAssembler(&cbuf); 135 address fast_entry = __ pc(); 136 137 Label label1, label2; 138 139 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); 140 __ sethi (cnt_addrlit, G3); 141 Address cnt_addr(G3, cnt_addrlit.low10()); 142 __ ld (cnt_addr, G4); 143 __ andcc (G4, 1, G0); 144 __ br (Assembler::notZero, false, Assembler::pn, label1); 145 __ delayed()->srl (O2, 2, O4); 146 __ ld_ptr (O1, 0, O5); 147 __ add (O5, O4, O5); 148 149 #ifndef _LP64 150 assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small"); 151 speculative_load_pclist[count++] = __ pc(); 152 __ ld (O5, 0, G2); 153 154 speculative_load_pclist[count] = __ pc(); 155 __ ld (O5, 4, O3); 156 #else 157 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); 158 speculative_load_pclist[count] = __ pc(); 159 __ ldx (O5, 0, O3); 160 #endif 161 162 __ ld (cnt_addr, G1); 163 __ cmp (G1, G4); 164 __ br (Assembler::notEqual, false, Assembler::pn, label2); 165 __ delayed()->mov (O7, G1); 166 167 #ifndef _LP64 168 __ mov (G2, O0); 169 __ retl (); 170 __ delayed()->mov (O3, O1); 171 #else 172 __ retl (); 173 __ delayed()->mov (O3, O0); 174 #endif 175 176 #ifndef _LP64 177 slowcase_entry_pclist[count-1] = __ pc(); 178 slowcase_entry_pclist[count++] = __ pc() ; 179 #else 180 slowcase_entry_pclist[count++] = __ pc(); 181 #endif 182 183 __ bind (label1); 184 __ mov (O7, G1); 185 186 address slow_case_addr = jni_GetLongField_addr(); 187 __ bind (label2); 188 __ call (slow_case_addr, relocInfo::none); 189 __ delayed()->mov (G1, O7); 190 191 __ flush (); 192 193 return fast_entry; 194 } 195 196 address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) { 197 const char *name; 198 switch (type) { 199 case T_FLOAT: name = "jni_fast_GetFloatField"; break; 200 case T_DOUBLE: name = "jni_fast_GetDoubleField"; break; 201 default: ShouldNotReachHere(); 202 } 203 ResourceMark rm; 204 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); 205 CodeBuffer cbuf(blob); 206 MacroAssembler* masm = new MacroAssembler(&cbuf); 207 address fast_entry = __ pc(); 208 209 Label label1, label2; 210 211 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); 212 __ sethi (cnt_addrlit, O3); 213 Address cnt_addr(O3, cnt_addrlit.low10()); 214 __ ld (cnt_addr, G4); 215 __ andcc (G4, 1, G0); 216 __ br (Assembler::notZero, false, Assembler::pn, label1); 217 __ delayed()->srl (O2, 2, O4); 218 __ ld_ptr (O1, 0, O5); 219 220 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); 221 speculative_load_pclist[count] = __ pc(); 222 switch (type) { 223 case T_FLOAT: __ ldf (FloatRegisterImpl::S, O5, O4, F0); break; 224 case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break; 225 default: ShouldNotReachHere(); 226 } 227 228 __ ld (cnt_addr, O5); 229 __ cmp (O5, G4); 230 __ br (Assembler::notEqual, false, Assembler::pn, label2); 231 __ delayed()->mov (O7, G1); 232 233 __ retl (); 234 __ delayed()-> nop (); 235 236 slowcase_entry_pclist[count++] = __ pc(); 237 __ bind (label1); 238 __ mov (O7, G1); 239 240 address slow_case_addr; 241 switch (type) { 242 case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break; 243 case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break; 244 default: ShouldNotReachHere(); 245 } 246 __ bind (label2); 247 __ call (slow_case_addr, relocInfo::none); 248 __ delayed()->mov (G1, O7); 249 250 __ flush (); 251 252 return fast_entry; 253 } 254 255 address JNI_FastGetField::generate_fast_get_float_field() { 256 return generate_fast_get_float_field0(T_FLOAT); 257 } 258 259 address JNI_FastGetField::generate_fast_get_double_field() { 260 return generate_fast_get_float_field0(T_DOUBLE); 261 }