Thu, 06 Mar 2014 10:55:28 -0800
8035647: PPC64: Support for elf v2 abi.
Summary: ELFv2 ABI used by the little endian PowerPC64 on Linux.
Reviewed-by: kvn
Contributed-by: asmundak@google.com
goetz@6458 | 1 | /* |
goetz@6458 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
goetz@6458 | 3 | * Copyright 2012, 2013 SAP AG. All rights reserved. |
goetz@6458 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
goetz@6458 | 5 | * |
goetz@6458 | 6 | * This code is free software; you can redistribute it and/or modify it |
goetz@6458 | 7 | * under the terms of the GNU General Public License version 2 only, as |
goetz@6458 | 8 | * published by the Free Software Foundation. |
goetz@6458 | 9 | * |
goetz@6458 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
goetz@6458 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
goetz@6458 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
goetz@6458 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
goetz@6458 | 14 | * accompanied this code). |
goetz@6458 | 15 | * |
goetz@6458 | 16 | * You should have received a copy of the GNU General Public License version |
goetz@6458 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
goetz@6458 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
goetz@6458 | 19 | * |
goetz@6458 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
goetz@6458 | 21 | * or visit www.oracle.com if you need additional information or have any |
goetz@6458 | 22 | * questions. |
goetz@6458 | 23 | * |
goetz@6458 | 24 | */ |
goetz@6458 | 25 | |
goetz@6458 | 26 | #include "precompiled.hpp" |
goetz@6458 | 27 | #include "asm/assembler.hpp" |
goetz@6458 | 28 | #include "asm/macroAssembler.inline.hpp" |
goetz@6458 | 29 | #include "interpreter/bytecodeHistogram.hpp" |
goetz@6458 | 30 | #include "interpreter/interpreter.hpp" |
goetz@6458 | 31 | #include "interpreter/interpreterGenerator.hpp" |
goetz@6458 | 32 | #include "interpreter/interpreterRuntime.hpp" |
goetz@6458 | 33 | #include "interpreter/templateTable.hpp" |
goetz@6458 | 34 | #include "oops/arrayOop.hpp" |
goetz@6458 | 35 | #include "oops/methodData.hpp" |
goetz@6458 | 36 | #include "oops/method.hpp" |
goetz@6458 | 37 | #include "oops/oop.inline.hpp" |
goetz@6458 | 38 | #include "prims/jvmtiExport.hpp" |
goetz@6458 | 39 | #include "prims/jvmtiThreadState.hpp" |
goetz@6458 | 40 | #include "prims/methodHandles.hpp" |
goetz@6458 | 41 | #include "runtime/arguments.hpp" |
goetz@6458 | 42 | #include "runtime/deoptimization.hpp" |
goetz@6458 | 43 | #include "runtime/frame.inline.hpp" |
goetz@6458 | 44 | #include "runtime/sharedRuntime.hpp" |
goetz@6458 | 45 | #include "runtime/stubRoutines.hpp" |
goetz@6458 | 46 | #include "runtime/synchronizer.hpp" |
goetz@6458 | 47 | #include "runtime/timer.hpp" |
goetz@6458 | 48 | #include "runtime/vframeArray.hpp" |
goetz@6458 | 49 | #include "utilities/debug.hpp" |
goetz@6458 | 50 | #ifdef COMPILER1 |
goetz@6458 | 51 | #include "c1/c1_Runtime1.hpp" |
goetz@6458 | 52 | #endif |
goetz@6458 | 53 | |
goetz@6458 | 54 | #ifndef CC_INTERP |
goetz@6458 | 55 | #error "CC_INTERP must be defined on PPC" |
goetz@6458 | 56 | #endif |
goetz@6458 | 57 | |
goetz@6458 | 58 | #define __ _masm-> |
goetz@6458 | 59 | |
goetz@6458 | 60 | #ifdef PRODUCT |
goetz@6458 | 61 | #define BLOCK_COMMENT(str) // nothing |
goetz@6458 | 62 | #else |
goetz@6458 | 63 | #define BLOCK_COMMENT(str) __ block_comment(str) |
goetz@6458 | 64 | #endif |
goetz@6458 | 65 | |
goetz@6458 | 66 | #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") |
goetz@6458 | 67 | |
goetz@6458 | 68 | int AbstractInterpreter::BasicType_as_index(BasicType type) { |
goetz@6458 | 69 | int i = 0; |
goetz@6458 | 70 | switch (type) { |
goetz@6458 | 71 | case T_BOOLEAN: i = 0; break; |
goetz@6458 | 72 | case T_CHAR : i = 1; break; |
goetz@6458 | 73 | case T_BYTE : i = 2; break; |
goetz@6458 | 74 | case T_SHORT : i = 3; break; |
goetz@6458 | 75 | case T_INT : i = 4; break; |
goetz@6458 | 76 | case T_LONG : i = 5; break; |
goetz@6458 | 77 | case T_VOID : i = 6; break; |
goetz@6458 | 78 | case T_FLOAT : i = 7; break; |
goetz@6458 | 79 | case T_DOUBLE : i = 8; break; |
goetz@6458 | 80 | case T_OBJECT : i = 9; break; |
goetz@6458 | 81 | case T_ARRAY : i = 9; break; |
goetz@6458 | 82 | default : ShouldNotReachHere(); |
goetz@6458 | 83 | } |
goetz@6458 | 84 | assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds"); |
goetz@6458 | 85 | return i; |
goetz@6458 | 86 | } |
goetz@6458 | 87 | |
goetz@6458 | 88 | address AbstractInterpreterGenerator::generate_slow_signature_handler() { |
goetz@6458 | 89 | // Slow_signature handler that respects the PPC C calling conventions. |
goetz@6458 | 90 | // |
goetz@6458 | 91 | // We get called by the native entry code with our output register |
goetz@6458 | 92 | // area == 8. First we call InterpreterRuntime::get_result_handler |
goetz@6458 | 93 | // to copy the pointer to the signature string temporarily to the |
goetz@6458 | 94 | // first C-argument and to return the result_handler in |
goetz@6458 | 95 | // R3_RET. Since native_entry will copy the jni-pointer to the |
goetz@6458 | 96 | // first C-argument slot later on, it is OK to occupy this slot |
goetz@6458 | 97 | // temporarilly. Then we copy the argument list on the java |
goetz@6458 | 98 | // expression stack into native varargs format on the native stack |
goetz@6458 | 99 | // and load arguments into argument registers. Integer arguments in |
goetz@6458 | 100 | // the varargs vector will be sign-extended to 8 bytes. |
goetz@6458 | 101 | // |
goetz@6458 | 102 | // On entry: |
goetz@6458 | 103 | // R3_ARG1 - intptr_t* Address of java argument list in memory. |
goetz@6458 | 104 | // R15_prev_state - BytecodeInterpreter* Address of interpreter state for |
goetz@6458 | 105 | // this method |
goetz@6458 | 106 | // R19_method |
goetz@6458 | 107 | // |
goetz@6458 | 108 | // On exit (just before return instruction): |
goetz@6458 | 109 | // R3_RET - contains the address of the result_handler. |
goetz@6458 | 110 | // R4_ARG2 - is not updated for static methods and contains "this" otherwise. |
goetz@6458 | 111 | // R5_ARG3-R10_ARG8: - When the (i-2)th Java argument is not of type float or double, |
goetz@6458 | 112 | // ARGi contains this argument. Otherwise, ARGi is not updated. |
goetz@6458 | 113 | // F1_ARG1-F13_ARG13 - contain the first 13 arguments of type float or double. |
goetz@6458 | 114 | |
goetz@6458 | 115 | const int LogSizeOfTwoInstructions = 3; |
goetz@6458 | 116 | |
goetz@6458 | 117 | // FIXME: use Argument:: GL: Argument names different numbers! |
goetz@6458 | 118 | const int max_fp_register_arguments = 13; |
goetz@6458 | 119 | const int max_int_register_arguments = 6; // first 2 are reserved |
goetz@6458 | 120 | |
goetz@6458 | 121 | const Register arg_java = R21_tmp1; |
goetz@6458 | 122 | const Register arg_c = R22_tmp2; |
goetz@6458 | 123 | const Register signature = R23_tmp3; // is string |
goetz@6458 | 124 | const Register sig_byte = R24_tmp4; |
goetz@6458 | 125 | const Register fpcnt = R25_tmp5; |
goetz@6458 | 126 | const Register argcnt = R26_tmp6; |
goetz@6458 | 127 | const Register intSlot = R27_tmp7; |
goetz@6458 | 128 | const Register target_sp = R28_tmp8; |
goetz@6458 | 129 | const FloatRegister floatSlot = F0; |
goetz@6458 | 130 | |
goetz@6511 | 131 | address entry = __ function_entry(); |
goetz@6458 | 132 | |
goetz@6458 | 133 | __ save_LR_CR(R0); |
goetz@6458 | 134 | __ save_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14)); |
goetz@6458 | 135 | // We use target_sp for storing arguments in the C frame. |
goetz@6458 | 136 | __ mr(target_sp, R1_SP); |
goetz@6511 | 137 | __ push_frame_reg_args_nonvolatiles(0, R11_scratch1); |
goetz@6458 | 138 | |
goetz@6458 | 139 | __ mr(arg_java, R3_ARG1); |
goetz@6458 | 140 | |
goetz@6458 | 141 | __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_signature), R16_thread, R19_method); |
goetz@6458 | 142 | |
goetz@6458 | 143 | // Signature is in R3_RET. Signature is callee saved. |
goetz@6458 | 144 | __ mr(signature, R3_RET); |
goetz@6458 | 145 | |
goetz@6458 | 146 | // Reload method, it may have moved. |
goetz@6458 | 147 | #ifdef CC_INTERP |
goetz@6458 | 148 | __ ld(R19_method, state_(_method)); |
goetz@6458 | 149 | #else |
goetz@6458 | 150 | __ unimplemented("slow signature handler 1"); |
goetz@6458 | 151 | #endif |
goetz@6458 | 152 | |
goetz@6458 | 153 | // Get the result handler. |
goetz@6458 | 154 | __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_result_handler), R16_thread, R19_method); |
goetz@6458 | 155 | |
goetz@6458 | 156 | // Reload method, it may have moved. |
goetz@6458 | 157 | #ifdef CC_INTERP |
goetz@6458 | 158 | __ ld(R19_method, state_(_method)); |
goetz@6458 | 159 | #else |
goetz@6458 | 160 | __ unimplemented("slow signature handler 2"); |
goetz@6458 | 161 | #endif |
goetz@6458 | 162 | |
goetz@6458 | 163 | { |
goetz@6458 | 164 | Label L; |
goetz@6458 | 165 | // test if static |
goetz@6458 | 166 | // _access_flags._flags must be at offset 0. |
goetz@6458 | 167 | // TODO PPC port: requires change in shared code. |
goetz@6458 | 168 | //assert(in_bytes(AccessFlags::flags_offset()) == 0, |
goetz@6458 | 169 | // "MethodOopDesc._access_flags == MethodOopDesc._access_flags._flags"); |
goetz@6458 | 170 | // _access_flags must be a 32 bit value. |
goetz@6458 | 171 | assert(sizeof(AccessFlags) == 4, "wrong size"); |
goetz@6458 | 172 | __ lwa(R11_scratch1/*access_flags*/, method_(access_flags)); |
goetz@6458 | 173 | // testbit with condition register. |
goetz@6458 | 174 | __ testbitdi(CCR0, R0, R11_scratch1/*access_flags*/, JVM_ACC_STATIC_BIT); |
goetz@6458 | 175 | __ btrue(CCR0, L); |
goetz@6458 | 176 | // For non-static functions, pass "this" in R4_ARG2 and copy it |
goetz@6458 | 177 | // to 2nd C-arg slot. |
goetz@6458 | 178 | // We need to box the Java object here, so we use arg_java |
goetz@6458 | 179 | // (address of current Java stack slot) as argument and don't |
goetz@6458 | 180 | // dereference it as in case of ints, floats, etc. |
goetz@6458 | 181 | __ mr(R4_ARG2, arg_java); |
goetz@6458 | 182 | __ addi(arg_java, arg_java, -BytesPerWord); |
goetz@6458 | 183 | __ std(R4_ARG2, _abi(carg_2), target_sp); |
goetz@6458 | 184 | __ bind(L); |
goetz@6458 | 185 | } |
goetz@6458 | 186 | |
goetz@6458 | 187 | // Will be incremented directly after loop_start. argcnt=0 |
goetz@6458 | 188 | // corresponds to 3rd C argument. |
goetz@6458 | 189 | __ li(argcnt, -1); |
goetz@6458 | 190 | // arg_c points to 3rd C argument |
goetz@6458 | 191 | __ addi(arg_c, target_sp, _abi(carg_3)); |
goetz@6458 | 192 | // no floating-point args parsed so far |
goetz@6458 | 193 | __ li(fpcnt, 0); |
goetz@6458 | 194 | |
goetz@6458 | 195 | Label move_intSlot_to_ARG, move_floatSlot_to_FARG; |
goetz@6458 | 196 | Label loop_start, loop_end; |
goetz@6458 | 197 | Label do_int, do_long, do_float, do_double, do_dontreachhere, do_object, do_array, do_boxed; |
goetz@6458 | 198 | |
goetz@6458 | 199 | // signature points to '(' at entry |
goetz@6458 | 200 | #ifdef ASSERT |
goetz@6458 | 201 | __ lbz(sig_byte, 0, signature); |
goetz@6458 | 202 | __ cmplwi(CCR0, sig_byte, '('); |
goetz@6458 | 203 | __ bne(CCR0, do_dontreachhere); |
goetz@6458 | 204 | #endif |
goetz@6458 | 205 | |
goetz@6458 | 206 | __ bind(loop_start); |
goetz@6458 | 207 | |
goetz@6458 | 208 | __ addi(argcnt, argcnt, 1); |
goetz@6458 | 209 | __ lbzu(sig_byte, 1, signature); |
goetz@6458 | 210 | |
goetz@6458 | 211 | __ cmplwi(CCR0, sig_byte, ')'); // end of signature |
goetz@6458 | 212 | __ beq(CCR0, loop_end); |
goetz@6458 | 213 | |
goetz@6458 | 214 | __ cmplwi(CCR0, sig_byte, 'B'); // byte |
goetz@6458 | 215 | __ beq(CCR0, do_int); |
goetz@6458 | 216 | |
goetz@6458 | 217 | __ cmplwi(CCR0, sig_byte, 'C'); // char |
goetz@6458 | 218 | __ beq(CCR0, do_int); |
goetz@6458 | 219 | |
goetz@6458 | 220 | __ cmplwi(CCR0, sig_byte, 'D'); // double |
goetz@6458 | 221 | __ beq(CCR0, do_double); |
goetz@6458 | 222 | |
goetz@6458 | 223 | __ cmplwi(CCR0, sig_byte, 'F'); // float |
goetz@6458 | 224 | __ beq(CCR0, do_float); |
goetz@6458 | 225 | |
goetz@6458 | 226 | __ cmplwi(CCR0, sig_byte, 'I'); // int |
goetz@6458 | 227 | __ beq(CCR0, do_int); |
goetz@6458 | 228 | |
goetz@6458 | 229 | __ cmplwi(CCR0, sig_byte, 'J'); // long |
goetz@6458 | 230 | __ beq(CCR0, do_long); |
goetz@6458 | 231 | |
goetz@6458 | 232 | __ cmplwi(CCR0, sig_byte, 'S'); // short |
goetz@6458 | 233 | __ beq(CCR0, do_int); |
goetz@6458 | 234 | |
goetz@6458 | 235 | __ cmplwi(CCR0, sig_byte, 'Z'); // boolean |
goetz@6458 | 236 | __ beq(CCR0, do_int); |
goetz@6458 | 237 | |
goetz@6458 | 238 | __ cmplwi(CCR0, sig_byte, 'L'); // object |
goetz@6458 | 239 | __ beq(CCR0, do_object); |
goetz@6458 | 240 | |
goetz@6458 | 241 | __ cmplwi(CCR0, sig_byte, '['); // array |
goetz@6458 | 242 | __ beq(CCR0, do_array); |
goetz@6458 | 243 | |
goetz@6458 | 244 | // __ cmplwi(CCR0, sig_byte, 'V'); // void cannot appear since we do not parse the return type |
goetz@6458 | 245 | // __ beq(CCR0, do_void); |
goetz@6458 | 246 | |
goetz@6458 | 247 | __ bind(do_dontreachhere); |
goetz@6458 | 248 | |
goetz@6458 | 249 | __ unimplemented("ShouldNotReachHere in slow_signature_handler", 120); |
goetz@6458 | 250 | |
goetz@6458 | 251 | __ bind(do_array); |
goetz@6458 | 252 | |
goetz@6458 | 253 | { |
goetz@6458 | 254 | Label start_skip, end_skip; |
goetz@6458 | 255 | |
goetz@6458 | 256 | __ bind(start_skip); |
goetz@6458 | 257 | __ lbzu(sig_byte, 1, signature); |
goetz@6458 | 258 | __ cmplwi(CCR0, sig_byte, '['); |
goetz@6458 | 259 | __ beq(CCR0, start_skip); // skip further brackets |
goetz@6458 | 260 | __ cmplwi(CCR0, sig_byte, '9'); |
goetz@6458 | 261 | __ bgt(CCR0, end_skip); // no optional size |
goetz@6458 | 262 | __ cmplwi(CCR0, sig_byte, '0'); |
goetz@6458 | 263 | __ bge(CCR0, start_skip); // skip optional size |
goetz@6458 | 264 | __ bind(end_skip); |
goetz@6458 | 265 | |
goetz@6458 | 266 | __ cmplwi(CCR0, sig_byte, 'L'); |
goetz@6458 | 267 | __ beq(CCR0, do_object); // for arrays of objects, the name of the object must be skipped |
goetz@6458 | 268 | __ b(do_boxed); // otherwise, go directly to do_boxed |
goetz@6458 | 269 | } |
goetz@6458 | 270 | |
goetz@6458 | 271 | __ bind(do_object); |
goetz@6458 | 272 | { |
goetz@6458 | 273 | Label L; |
goetz@6458 | 274 | __ bind(L); |
goetz@6458 | 275 | __ lbzu(sig_byte, 1, signature); |
goetz@6458 | 276 | __ cmplwi(CCR0, sig_byte, ';'); |
goetz@6458 | 277 | __ bne(CCR0, L); |
goetz@6458 | 278 | } |
goetz@6458 | 279 | // Need to box the Java object here, so we use arg_java (address of |
goetz@6458 | 280 | // current Java stack slot) as argument and don't dereference it as |
goetz@6458 | 281 | // in case of ints, floats, etc. |
goetz@6458 | 282 | Label do_null; |
goetz@6458 | 283 | __ bind(do_boxed); |
goetz@6458 | 284 | __ ld(R0,0, arg_java); |
goetz@6458 | 285 | __ cmpdi(CCR0, R0, 0); |
goetz@6458 | 286 | __ li(intSlot,0); |
goetz@6458 | 287 | __ beq(CCR0, do_null); |
goetz@6458 | 288 | __ mr(intSlot, arg_java); |
goetz@6458 | 289 | __ bind(do_null); |
goetz@6458 | 290 | __ std(intSlot, 0, arg_c); |
goetz@6458 | 291 | __ addi(arg_java, arg_java, -BytesPerWord); |
goetz@6458 | 292 | __ addi(arg_c, arg_c, BytesPerWord); |
goetz@6458 | 293 | __ cmplwi(CCR0, argcnt, max_int_register_arguments); |
goetz@6458 | 294 | __ blt(CCR0, move_intSlot_to_ARG); |
goetz@6458 | 295 | __ b(loop_start); |
goetz@6458 | 296 | |
goetz@6458 | 297 | __ bind(do_int); |
goetz@6458 | 298 | __ lwa(intSlot, 0, arg_java); |
goetz@6458 | 299 | __ std(intSlot, 0, arg_c); |
goetz@6458 | 300 | __ addi(arg_java, arg_java, -BytesPerWord); |
goetz@6458 | 301 | __ addi(arg_c, arg_c, BytesPerWord); |
goetz@6458 | 302 | __ cmplwi(CCR0, argcnt, max_int_register_arguments); |
goetz@6458 | 303 | __ blt(CCR0, move_intSlot_to_ARG); |
goetz@6458 | 304 | __ b(loop_start); |
goetz@6458 | 305 | |
goetz@6458 | 306 | __ bind(do_long); |
goetz@6458 | 307 | __ ld(intSlot, -BytesPerWord, arg_java); |
goetz@6458 | 308 | __ std(intSlot, 0, arg_c); |
goetz@6458 | 309 | __ addi(arg_java, arg_java, - 2 * BytesPerWord); |
goetz@6458 | 310 | __ addi(arg_c, arg_c, BytesPerWord); |
goetz@6458 | 311 | __ cmplwi(CCR0, argcnt, max_int_register_arguments); |
goetz@6458 | 312 | __ blt(CCR0, move_intSlot_to_ARG); |
goetz@6458 | 313 | __ b(loop_start); |
goetz@6458 | 314 | |
goetz@6458 | 315 | __ bind(do_float); |
goetz@6458 | 316 | __ lfs(floatSlot, 0, arg_java); |
goetz@6458 | 317 | #if defined(LINUX) |
goetz@6458 | 318 | __ stfs(floatSlot, 4, arg_c); |
goetz@6458 | 319 | #elif defined(AIX) |
goetz@6458 | 320 | __ stfs(floatSlot, 0, arg_c); |
goetz@6458 | 321 | #else |
goetz@6458 | 322 | #error "unknown OS" |
goetz@6458 | 323 | #endif |
goetz@6458 | 324 | __ addi(arg_java, arg_java, -BytesPerWord); |
goetz@6458 | 325 | __ addi(arg_c, arg_c, BytesPerWord); |
goetz@6458 | 326 | __ cmplwi(CCR0, fpcnt, max_fp_register_arguments); |
goetz@6458 | 327 | __ blt(CCR0, move_floatSlot_to_FARG); |
goetz@6458 | 328 | __ b(loop_start); |
goetz@6458 | 329 | |
goetz@6458 | 330 | __ bind(do_double); |
goetz@6458 | 331 | __ lfd(floatSlot, - BytesPerWord, arg_java); |
goetz@6458 | 332 | __ stfd(floatSlot, 0, arg_c); |
goetz@6458 | 333 | __ addi(arg_java, arg_java, - 2 * BytesPerWord); |
goetz@6458 | 334 | __ addi(arg_c, arg_c, BytesPerWord); |
goetz@6458 | 335 | __ cmplwi(CCR0, fpcnt, max_fp_register_arguments); |
goetz@6458 | 336 | __ blt(CCR0, move_floatSlot_to_FARG); |
goetz@6458 | 337 | __ b(loop_start); |
goetz@6458 | 338 | |
goetz@6458 | 339 | __ bind(loop_end); |
goetz@6458 | 340 | |
goetz@6458 | 341 | __ pop_frame(); |
goetz@6458 | 342 | __ restore_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14)); |
goetz@6458 | 343 | __ restore_LR_CR(R0); |
goetz@6458 | 344 | |
goetz@6458 | 345 | __ blr(); |
goetz@6458 | 346 | |
goetz@6458 | 347 | Label move_int_arg, move_float_arg; |
goetz@6458 | 348 | __ bind(move_int_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions) |
goetz@6458 | 349 | __ mr(R5_ARG3, intSlot); __ b(loop_start); |
goetz@6458 | 350 | __ mr(R6_ARG4, intSlot); __ b(loop_start); |
goetz@6458 | 351 | __ mr(R7_ARG5, intSlot); __ b(loop_start); |
goetz@6458 | 352 | __ mr(R8_ARG6, intSlot); __ b(loop_start); |
goetz@6458 | 353 | __ mr(R9_ARG7, intSlot); __ b(loop_start); |
goetz@6458 | 354 | __ mr(R10_ARG8, intSlot); __ b(loop_start); |
goetz@6458 | 355 | |
goetz@6458 | 356 | __ bind(move_float_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions) |
goetz@6458 | 357 | __ fmr(F1_ARG1, floatSlot); __ b(loop_start); |
goetz@6458 | 358 | __ fmr(F2_ARG2, floatSlot); __ b(loop_start); |
goetz@6458 | 359 | __ fmr(F3_ARG3, floatSlot); __ b(loop_start); |
goetz@6458 | 360 | __ fmr(F4_ARG4, floatSlot); __ b(loop_start); |
goetz@6458 | 361 | __ fmr(F5_ARG5, floatSlot); __ b(loop_start); |
goetz@6458 | 362 | __ fmr(F6_ARG6, floatSlot); __ b(loop_start); |
goetz@6458 | 363 | __ fmr(F7_ARG7, floatSlot); __ b(loop_start); |
goetz@6458 | 364 | __ fmr(F8_ARG8, floatSlot); __ b(loop_start); |
goetz@6458 | 365 | __ fmr(F9_ARG9, floatSlot); __ b(loop_start); |
goetz@6458 | 366 | __ fmr(F10_ARG10, floatSlot); __ b(loop_start); |
goetz@6458 | 367 | __ fmr(F11_ARG11, floatSlot); __ b(loop_start); |
goetz@6458 | 368 | __ fmr(F12_ARG12, floatSlot); __ b(loop_start); |
goetz@6458 | 369 | __ fmr(F13_ARG13, floatSlot); __ b(loop_start); |
goetz@6458 | 370 | |
goetz@6458 | 371 | __ bind(move_intSlot_to_ARG); |
goetz@6458 | 372 | __ sldi(R0, argcnt, LogSizeOfTwoInstructions); |
goetz@6458 | 373 | __ load_const(R11_scratch1, move_int_arg); // Label must be bound here. |
goetz@6458 | 374 | __ add(R11_scratch1, R0, R11_scratch1); |
goetz@6458 | 375 | __ mtctr(R11_scratch1/*branch_target*/); |
goetz@6458 | 376 | __ bctr(); |
goetz@6458 | 377 | __ bind(move_floatSlot_to_FARG); |
goetz@6458 | 378 | __ sldi(R0, fpcnt, LogSizeOfTwoInstructions); |
goetz@6458 | 379 | __ addi(fpcnt, fpcnt, 1); |
goetz@6458 | 380 | __ load_const(R11_scratch1, move_float_arg); // Label must be bound here. |
goetz@6458 | 381 | __ add(R11_scratch1, R0, R11_scratch1); |
goetz@6458 | 382 | __ mtctr(R11_scratch1/*branch_target*/); |
goetz@6458 | 383 | __ bctr(); |
goetz@6458 | 384 | |
goetz@6458 | 385 | return entry; |
goetz@6458 | 386 | } |
goetz@6458 | 387 | |
goetz@6458 | 388 | address AbstractInterpreterGenerator::generate_result_handler_for(BasicType type) { |
goetz@6458 | 389 | // |
goetz@6458 | 390 | // Registers alive |
goetz@6458 | 391 | // R3_RET |
goetz@6458 | 392 | // LR |
goetz@6458 | 393 | // |
goetz@6458 | 394 | // Registers updated |
goetz@6458 | 395 | // R3_RET |
goetz@6458 | 396 | // |
goetz@6458 | 397 | |
goetz@6458 | 398 | Label done; |
goetz@6458 | 399 | address entry = __ pc(); |
goetz@6458 | 400 | |
goetz@6458 | 401 | switch (type) { |
goetz@6458 | 402 | case T_BOOLEAN: |
goetz@6495 | 403 | // convert !=0 to 1 |
goetz@6495 | 404 | __ neg(R0, R3_RET); |
goetz@6495 | 405 | __ orr(R0, R3_RET, R0); |
goetz@6495 | 406 | __ srwi(R3_RET, R0, 31); |
goetz@6458 | 407 | break; |
goetz@6458 | 408 | case T_BYTE: |
goetz@6458 | 409 | // sign extend 8 bits |
goetz@6458 | 410 | __ extsb(R3_RET, R3_RET); |
goetz@6458 | 411 | break; |
goetz@6458 | 412 | case T_CHAR: |
goetz@6458 | 413 | // zero extend 16 bits |
goetz@6458 | 414 | __ clrldi(R3_RET, R3_RET, 48); |
goetz@6458 | 415 | break; |
goetz@6458 | 416 | case T_SHORT: |
goetz@6458 | 417 | // sign extend 16 bits |
goetz@6458 | 418 | __ extsh(R3_RET, R3_RET); |
goetz@6458 | 419 | break; |
goetz@6458 | 420 | case T_INT: |
goetz@6458 | 421 | // sign extend 32 bits |
goetz@6458 | 422 | __ extsw(R3_RET, R3_RET); |
goetz@6458 | 423 | break; |
goetz@6458 | 424 | case T_LONG: |
goetz@6458 | 425 | break; |
goetz@6458 | 426 | case T_OBJECT: |
goetz@6458 | 427 | // unbox result if not null |
goetz@6458 | 428 | __ cmpdi(CCR0, R3_RET, 0); |
goetz@6458 | 429 | __ beq(CCR0, done); |
goetz@6458 | 430 | __ ld(R3_RET, 0, R3_RET); |
goetz@6458 | 431 | __ verify_oop(R3_RET); |
goetz@6458 | 432 | break; |
goetz@6458 | 433 | case T_FLOAT: |
goetz@6458 | 434 | break; |
goetz@6458 | 435 | case T_DOUBLE: |
goetz@6458 | 436 | break; |
goetz@6458 | 437 | case T_VOID: |
goetz@6458 | 438 | break; |
goetz@6458 | 439 | default: ShouldNotReachHere(); |
goetz@6458 | 440 | } |
goetz@6458 | 441 | |
goetz@6458 | 442 | __ BIND(done); |
goetz@6458 | 443 | __ blr(); |
goetz@6458 | 444 | |
goetz@6458 | 445 | return entry; |
goetz@6458 | 446 | } |
goetz@6458 | 447 | |
goetz@6458 | 448 | // Abstract method entry. |
goetz@6458 | 449 | // |
goetz@6458 | 450 | address InterpreterGenerator::generate_abstract_entry(void) { |
goetz@6458 | 451 | address entry = __ pc(); |
goetz@6458 | 452 | |
goetz@6458 | 453 | // |
goetz@6458 | 454 | // Registers alive |
goetz@6458 | 455 | // R16_thread - JavaThread* |
goetz@6458 | 456 | // R19_method - callee's methodOop (method to be invoked) |
goetz@6458 | 457 | // R1_SP - SP prepared such that caller's outgoing args are near top |
goetz@6458 | 458 | // LR - return address to caller |
goetz@6458 | 459 | // |
goetz@6458 | 460 | // Stack layout at this point: |
goetz@6458 | 461 | // |
goetz@6458 | 462 | // 0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP |
goetz@6458 | 463 | // alignment (optional) |
goetz@6458 | 464 | // [outgoing Java arguments] |
goetz@6458 | 465 | // ... |
goetz@6458 | 466 | // PARENT [PARENT_IJAVA_FRAME_ABI] |
goetz@6458 | 467 | // ... |
goetz@6458 | 468 | // |
goetz@6458 | 469 | |
goetz@6458 | 470 | // Can't use call_VM here because we have not set up a new |
goetz@6458 | 471 | // interpreter state. Make the call to the vm and make it look like |
goetz@6458 | 472 | // our caller set up the JavaFrameAnchor. |
goetz@6458 | 473 | __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/); |
goetz@6458 | 474 | |
goetz@6458 | 475 | // Push a new C frame and save LR. |
goetz@6458 | 476 | __ save_LR_CR(R0); |
goetz@6511 | 477 | __ push_frame_reg_args(0, R11_scratch1); |
goetz@6458 | 478 | |
goetz@6458 | 479 | // This is not a leaf but we have a JavaFrameAnchor now and we will |
goetz@6458 | 480 | // check (create) exceptions afterward so this is ok. |
goetz@6458 | 481 | __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
goetz@6458 | 482 | |
goetz@6458 | 483 | // Pop the C frame and restore LR. |
goetz@6458 | 484 | __ pop_frame(); |
goetz@6458 | 485 | __ restore_LR_CR(R0); |
goetz@6458 | 486 | |
goetz@6458 | 487 | // Reset JavaFrameAnchor from call_VM_leaf above. |
goetz@6458 | 488 | __ reset_last_Java_frame(); |
goetz@6458 | 489 | |
goetz@6495 | 490 | #ifdef CC_INTERP |
goetz@6458 | 491 | // Return to frame manager, it will handle the pending exception. |
goetz@6458 | 492 | __ blr(); |
goetz@6495 | 493 | #else |
goetz@6495 | 494 | Unimplemented(); |
goetz@6495 | 495 | #endif |
goetz@6458 | 496 | |
goetz@6458 | 497 | return entry; |
goetz@6458 | 498 | } |
goetz@6458 | 499 | |
goetz@6458 | 500 | // Call an accessor method (assuming it is resolved, otherwise drop into |
goetz@6458 | 501 | // vanilla (slow path) entry. |
goetz@6458 | 502 | address InterpreterGenerator::generate_accessor_entry(void) { |
goetz@6458 | 503 | if(!UseFastAccessorMethods && (!FLAG_IS_ERGO(UseFastAccessorMethods))) |
goetz@6458 | 504 | return NULL; |
goetz@6458 | 505 | |
goetz@6495 | 506 | Label Lslow_path, Lacquire; |
goetz@6458 | 507 | |
goetz@6495 | 508 | const Register |
goetz@6495 | 509 | Rclass_or_obj = R3_ARG1, |
goetz@6458 | 510 | Rconst_method = R4_ARG2, |
goetz@6458 | 511 | Rcodes = Rconst_method, |
goetz@6458 | 512 | Rcpool_cache = R5_ARG3, |
goetz@6458 | 513 | Rscratch = R11_scratch1, |
goetz@6458 | 514 | Rjvmti_mode = Rscratch, |
goetz@6458 | 515 | Roffset = R12_scratch2, |
goetz@6495 | 516 | Rflags = R6_ARG4, |
goetz@6495 | 517 | Rbtable = R7_ARG5; |
goetz@6495 | 518 | |
goetz@6495 | 519 | static address branch_table[number_of_states]; |
goetz@6458 | 520 | |
goetz@6458 | 521 | address entry = __ pc(); |
goetz@6458 | 522 | |
goetz@6458 | 523 | // Check for safepoint: |
goetz@6458 | 524 | // Ditch this, real man don't need safepoint checks. |
goetz@6458 | 525 | |
goetz@6458 | 526 | // Also check for JVMTI mode |
goetz@6458 | 527 | // Check for null obj, take slow path if so. |
goetz@6495 | 528 | __ ld(Rclass_or_obj, Interpreter::stackElementSize, CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp)); |
goetz@6458 | 529 | __ lwz(Rjvmti_mode, thread_(interp_only_mode)); |
goetz@6495 | 530 | __ cmpdi(CCR1, Rclass_or_obj, 0); |
goetz@6458 | 531 | __ cmpwi(CCR0, Rjvmti_mode, 0); |
goetz@6458 | 532 | __ crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); |
goetz@6458 | 533 | __ beq(CCR0, Lslow_path); // this==null or jvmti_mode!=0 |
goetz@6458 | 534 | |
goetz@6458 | 535 | // Do 2 things in parallel: |
goetz@6458 | 536 | // 1. Load the index out of the first instruction word, which looks like this: |
goetz@6458 | 537 | // <0x2a><0xb4><index (2 byte, native endianess)>. |
goetz@6458 | 538 | // 2. Load constant pool cache base. |
goetz@6458 | 539 | __ ld(Rconst_method, in_bytes(Method::const_offset()), R19_method); |
goetz@6458 | 540 | __ ld(Rcpool_cache, in_bytes(ConstMethod::constants_offset()), Rconst_method); |
goetz@6458 | 541 | |
goetz@6458 | 542 | __ lhz(Rcodes, in_bytes(ConstMethod::codes_offset()) + 2, Rconst_method); // Lower half of 32 bit field. |
goetz@6458 | 543 | __ ld(Rcpool_cache, ConstantPool::cache_offset_in_bytes(), Rcpool_cache); |
goetz@6458 | 544 | |
goetz@6458 | 545 | // Get the const pool entry by means of <index>. |
goetz@6458 | 546 | const int codes_shift = exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord); |
goetz@6458 | 547 | __ slwi(Rscratch, Rcodes, codes_shift); // (codes&0xFFFF)<<codes_shift |
goetz@6458 | 548 | __ add(Rcpool_cache, Rscratch, Rcpool_cache); |
goetz@6458 | 549 | |
goetz@6458 | 550 | // Check if cpool cache entry is resolved. |
goetz@6458 | 551 | // We are resolved if the indices offset contains the current bytecode. |
goetz@6458 | 552 | ByteSize cp_base_offset = ConstantPoolCache::base_offset(); |
goetz@6458 | 553 | // Big Endian: |
goetz@6458 | 554 | __ lbz(Rscratch, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::indices_offset()) + 7 - 2, Rcpool_cache); |
goetz@6458 | 555 | __ cmpwi(CCR0, Rscratch, Bytecodes::_getfield); |
goetz@6458 | 556 | __ bne(CCR0, Lslow_path); |
goetz@6458 | 557 | __ isync(); // Order succeeding loads wrt. load of _indices field from cpool_cache. |
goetz@6458 | 558 | |
goetz@6458 | 559 | // Finally, start loading the value: Get cp cache entry into regs. |
goetz@6458 | 560 | __ ld(Rflags, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::flags_offset()), Rcpool_cache); |
goetz@6458 | 561 | __ ld(Roffset, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::f2_offset()), Rcpool_cache); |
goetz@6458 | 562 | |
goetz@6495 | 563 | // Following code is from templateTable::getfield_or_static |
goetz@6495 | 564 | // Load pointer to branch table |
goetz@6495 | 565 | __ load_const_optimized(Rbtable, (address)branch_table, Rscratch); |
goetz@6495 | 566 | |
goetz@6495 | 567 | // Get volatile flag |
goetz@6495 | 568 | __ rldicl(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // extract volatile bit |
goetz@6495 | 569 | // note: sync is needed before volatile load on PPC64 |
goetz@6495 | 570 | |
goetz@6495 | 571 | // Check field type |
goetz@6458 | 572 | __ rldicl(Rflags, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits); |
goetz@6458 | 573 | |
goetz@6458 | 574 | #ifdef ASSERT |
goetz@6495 | 575 | Label LFlagInvalid; |
goetz@6495 | 576 | __ cmpldi(CCR0, Rflags, number_of_states); |
goetz@6495 | 577 | __ bge(CCR0, LFlagInvalid); |
goetz@6495 | 578 | |
goetz@6495 | 579 | __ ld(R9_ARG7, 0, R1_SP); |
goetz@6495 | 580 | __ ld(R10_ARG8, 0, R21_sender_SP); |
goetz@6495 | 581 | __ cmpd(CCR0, R9_ARG7, R10_ARG8); |
goetz@6495 | 582 | __ asm_assert_eq("backlink", 0x543); |
goetz@6458 | 583 | #endif // ASSERT |
goetz@6458 | 584 | __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. |
goetz@6458 | 585 | |
goetz@6495 | 586 | // Load from branch table and dispatch (volatile case: one instruction ahead) |
goetz@6495 | 587 | __ sldi(Rflags, Rflags, LogBytesPerWord); |
goetz@6495 | 588 | __ cmpwi(CCR6, Rscratch, 1); // volatile? |
goetz@6495 | 589 | __ sldi(Rscratch, Rscratch, exact_log2(BytesPerInstWord)); // volatile ? size of 1 instruction : 0 |
goetz@6495 | 590 | __ ldx(Rbtable, Rbtable, Rflags); |
goetz@6495 | 591 | |
goetz@6495 | 592 | __ subf(Rbtable, Rscratch, Rbtable); // point to volatile/non-volatile entry point |
goetz@6495 | 593 | __ mtctr(Rbtable); |
goetz@6495 | 594 | __ bctr(); |
goetz@6495 | 595 | |
goetz@6458 | 596 | #ifdef ASSERT |
goetz@6495 | 597 | __ bind(LFlagInvalid); |
goetz@6495 | 598 | __ stop("got invalid flag", 0x6541); |
goetz@6495 | 599 | |
goetz@6495 | 600 | bool all_uninitialized = true, |
goetz@6495 | 601 | all_initialized = true; |
goetz@6495 | 602 | for (int i = 0; i<number_of_states; ++i) { |
goetz@6495 | 603 | all_uninitialized = all_uninitialized && (branch_table[i] == NULL); |
goetz@6495 | 604 | all_initialized = all_initialized && (branch_table[i] != NULL); |
goetz@6495 | 605 | } |
goetz@6495 | 606 | assert(all_uninitialized != all_initialized, "consistency"); // either or |
goetz@6495 | 607 | |
goetz@6495 | 608 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 609 | if (branch_table[vtos] == 0) branch_table[vtos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 610 | if (branch_table[dtos] == 0) branch_table[dtos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 611 | if (branch_table[ftos] == 0) branch_table[ftos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 612 | __ stop("unexpected type", 0x6551); |
goetz@6458 | 613 | #endif |
goetz@6495 | 614 | |
goetz@6495 | 615 | if (branch_table[itos] == 0) { // generate only once |
goetz@6495 | 616 | __ align(32, 28, 28); // align load |
goetz@6495 | 617 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 618 | branch_table[itos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 619 | __ lwax(R3_RET, Rclass_or_obj, Roffset); |
goetz@6495 | 620 | __ beq(CCR6, Lacquire); |
goetz@6495 | 621 | __ blr(); |
goetz@6495 | 622 | } |
goetz@6495 | 623 | |
goetz@6495 | 624 | if (branch_table[ltos] == 0) { // generate only once |
goetz@6495 | 625 | __ align(32, 28, 28); // align load |
goetz@6495 | 626 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 627 | branch_table[ltos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 628 | __ ldx(R3_RET, Rclass_or_obj, Roffset); |
goetz@6495 | 629 | __ beq(CCR6, Lacquire); |
goetz@6495 | 630 | __ blr(); |
goetz@6495 | 631 | } |
goetz@6495 | 632 | |
goetz@6495 | 633 | if (branch_table[btos] == 0) { // generate only once |
goetz@6495 | 634 | __ align(32, 28, 28); // align load |
goetz@6495 | 635 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 636 | branch_table[btos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 637 | __ lbzx(R3_RET, Rclass_or_obj, Roffset); |
goetz@6495 | 638 | __ extsb(R3_RET, R3_RET); |
goetz@6495 | 639 | __ beq(CCR6, Lacquire); |
goetz@6495 | 640 | __ blr(); |
goetz@6495 | 641 | } |
goetz@6495 | 642 | |
goetz@6495 | 643 | if (branch_table[ctos] == 0) { // generate only once |
goetz@6495 | 644 | __ align(32, 28, 28); // align load |
goetz@6495 | 645 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 646 | branch_table[ctos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 647 | __ lhzx(R3_RET, Rclass_or_obj, Roffset); |
goetz@6495 | 648 | __ beq(CCR6, Lacquire); |
goetz@6495 | 649 | __ blr(); |
goetz@6495 | 650 | } |
goetz@6495 | 651 | |
goetz@6495 | 652 | if (branch_table[stos] == 0) { // generate only once |
goetz@6495 | 653 | __ align(32, 28, 28); // align load |
goetz@6495 | 654 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 655 | branch_table[stos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 656 | __ lhax(R3_RET, Rclass_or_obj, Roffset); |
goetz@6495 | 657 | __ beq(CCR6, Lacquire); |
goetz@6495 | 658 | __ blr(); |
goetz@6495 | 659 | } |
goetz@6495 | 660 | |
goetz@6495 | 661 | if (branch_table[atos] == 0) { // generate only once |
goetz@6495 | 662 | __ align(32, 28, 28); // align load |
goetz@6495 | 663 | __ sync(); // volatile entry point (one instruction before non-volatile_entry point) |
goetz@6495 | 664 | branch_table[atos] = __ pc(); // non-volatile_entry point |
goetz@6495 | 665 | __ load_heap_oop(R3_RET, (RegisterOrConstant)Roffset, Rclass_or_obj); |
goetz@6495 | 666 | __ verify_oop(R3_RET); |
goetz@6495 | 667 | //__ dcbt(R3_RET); // prefetch |
goetz@6495 | 668 | __ beq(CCR6, Lacquire); |
goetz@6495 | 669 | __ blr(); |
goetz@6495 | 670 | } |
goetz@6495 | 671 | |
goetz@6495 | 672 | __ align(32, 12); |
goetz@6495 | 673 | __ bind(Lacquire); |
goetz@6495 | 674 | __ twi_0(R3_RET); |
goetz@6495 | 675 | __ isync(); // acquire |
goetz@6458 | 676 | __ blr(); |
goetz@6458 | 677 | |
goetz@6495 | 678 | #ifdef ASSERT |
goetz@6495 | 679 | for (int i = 0; i<number_of_states; ++i) { |
goetz@6495 | 680 | assert(branch_table[i], "accessor_entry initialization"); |
goetz@6495 | 681 | //tty->print_cr("accessor_entry: branch_table[%d] = 0x%llx (opcode 0x%llx)", i, branch_table[i], *((unsigned int*)branch_table[i])); |
goetz@6495 | 682 | } |
goetz@6495 | 683 | #endif |
goetz@6458 | 684 | |
goetz@6458 | 685 | __ bind(Lslow_path); |
goetz@6458 | 686 | assert(Interpreter::entry_for_kind(Interpreter::zerolocals), "Normal entry must have been generated by now"); |
goetz@6458 | 687 | __ load_const_optimized(Rscratch, Interpreter::entry_for_kind(Interpreter::zerolocals), R0); |
goetz@6458 | 688 | __ mtctr(Rscratch); |
goetz@6458 | 689 | __ bctr(); |
goetz@6458 | 690 | __ flush(); |
goetz@6458 | 691 | |
goetz@6458 | 692 | return entry; |
goetz@6458 | 693 | } |
goetz@6458 | 694 | |
goetz@6458 | 695 | // Interpreter intrinsic for WeakReference.get(). |
goetz@6458 | 696 | // 1. Don't push a full blown frame and go on dispatching, but fetch the value |
goetz@6458 | 697 | // into R8 and return quickly |
goetz@6458 | 698 | // 2. If G1 is active we *must* execute this intrinsic for corrrectness: |
goetz@6458 | 699 | // It contains a GC barrier which puts the reference into the satb buffer |
goetz@6458 | 700 | // to indicate that someone holds a strong reference to the object the |
goetz@6458 | 701 | // weak ref points to! |
goetz@6458 | 702 | address InterpreterGenerator::generate_Reference_get_entry(void) { |
goetz@6458 | 703 | // Code: _aload_0, _getfield, _areturn |
goetz@6458 | 704 | // parameter size = 1 |
goetz@6458 | 705 | // |
goetz@6458 | 706 | // The code that gets generated by this routine is split into 2 parts: |
goetz@6458 | 707 | // 1. the "intrinsified" code for G1 (or any SATB based GC), |
goetz@6458 | 708 | // 2. the slow path - which is an expansion of the regular method entry. |
goetz@6458 | 709 | // |
goetz@6458 | 710 | // Notes: |
goetz@6458 | 711 | // * In the G1 code we do not check whether we need to block for |
goetz@6458 | 712 | // a safepoint. If G1 is enabled then we must execute the specialized |
goetz@6458 | 713 | // code for Reference.get (except when the Reference object is null) |
goetz@6458 | 714 | // so that we can log the value in the referent field with an SATB |
goetz@6458 | 715 | // update buffer. |
goetz@6458 | 716 | // If the code for the getfield template is modified so that the |
goetz@6458 | 717 | // G1 pre-barrier code is executed when the current method is |
goetz@6458 | 718 | // Reference.get() then going through the normal method entry |
goetz@6458 | 719 | // will be fine. |
goetz@6458 | 720 | // * The G1 code can, however, check the receiver object (the instance |
goetz@6458 | 721 | // of java.lang.Reference) and jump to the slow path if null. If the |
goetz@6458 | 722 | // Reference object is null then we obviously cannot fetch the referent |
goetz@6458 | 723 | // and so we don't need to call the G1 pre-barrier. Thus we can use the |
goetz@6458 | 724 | // regular method entry code to generate the NPE. |
goetz@6458 | 725 | // |
goetz@6458 | 726 | // This code is based on generate_accessor_enty. |
goetz@6458 | 727 | |
goetz@6458 | 728 | address entry = __ pc(); |
goetz@6458 | 729 | |
goetz@6458 | 730 | const int referent_offset = java_lang_ref_Reference::referent_offset; |
goetz@6458 | 731 | guarantee(referent_offset > 0, "referent offset not initialized"); |
goetz@6458 | 732 | |
goetz@6458 | 733 | if (UseG1GC) { |
goetz@6458 | 734 | Label slow_path; |
goetz@6458 | 735 | |
goetz@6458 | 736 | // Debugging not possible, so can't use __ skip_if_jvmti_mode(slow_path, GR31_SCRATCH); |
goetz@6458 | 737 | |
goetz@6458 | 738 | // In the G1 code we don't check if we need to reach a safepoint. We |
goetz@6458 | 739 | // continue and the thread will safepoint at the next bytecode dispatch. |
goetz@6458 | 740 | |
goetz@6458 | 741 | // If the receiver is null then it is OK to jump to the slow path. |
goetz@6495 | 742 | __ ld(R3_RET, Interpreter::stackElementSize, CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp)); // get receiver |
goetz@6458 | 743 | |
goetz@6458 | 744 | // Check if receiver == NULL and go the slow path. |
goetz@6458 | 745 | __ cmpdi(CCR0, R3_RET, 0); |
goetz@6458 | 746 | __ beq(CCR0, slow_path); |
goetz@6458 | 747 | |
goetz@6458 | 748 | // Load the value of the referent field. |
goetz@6495 | 749 | __ load_heap_oop(R3_RET, referent_offset, R3_RET); |
goetz@6458 | 750 | |
goetz@6458 | 751 | // Generate the G1 pre-barrier code to log the value of |
goetz@6458 | 752 | // the referent field in an SATB buffer. Note with |
goetz@6458 | 753 | // these parameters the pre-barrier does not generate |
goetz@6458 | 754 | // the load of the previous value. |
goetz@6458 | 755 | |
goetz@6458 | 756 | // Restore caller sp for c2i case. |
goetz@6458 | 757 | #ifdef ASSERT |
goetz@6458 | 758 | __ ld(R9_ARG7, 0, R1_SP); |
goetz@6458 | 759 | __ ld(R10_ARG8, 0, R21_sender_SP); |
goetz@6458 | 760 | __ cmpd(CCR0, R9_ARG7, R10_ARG8); |
goetz@6458 | 761 | __ asm_assert_eq("backlink", 0x544); |
goetz@6458 | 762 | #endif // ASSERT |
goetz@6458 | 763 | __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. |
goetz@6458 | 764 | |
goetz@6458 | 765 | __ g1_write_barrier_pre(noreg, // obj |
goetz@6458 | 766 | noreg, // offset |
goetz@6458 | 767 | R3_RET, // pre_val |
goetz@6458 | 768 | R11_scratch1, // tmp |
goetz@6458 | 769 | R12_scratch2, // tmp |
goetz@6458 | 770 | true); // needs_frame |
goetz@6458 | 771 | |
goetz@6458 | 772 | __ blr(); |
goetz@6458 | 773 | |
goetz@6458 | 774 | // Generate regular method entry. |
goetz@6458 | 775 | __ bind(slow_path); |
goetz@6458 | 776 | assert(Interpreter::entry_for_kind(Interpreter::zerolocals), "Normal entry must have been generated by now"); |
goetz@6458 | 777 | __ load_const_optimized(R11_scratch1, Interpreter::entry_for_kind(Interpreter::zerolocals), R0); |
goetz@6458 | 778 | __ mtctr(R11_scratch1); |
goetz@6458 | 779 | __ bctr(); |
goetz@6458 | 780 | __ flush(); |
goetz@6458 | 781 | |
goetz@6458 | 782 | return entry; |
goetz@6458 | 783 | } else { |
goetz@6458 | 784 | return generate_accessor_entry(); |
goetz@6458 | 785 | } |
goetz@6458 | 786 | } |
goetz@6458 | 787 | |
goetz@6458 | 788 | void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { |
goetz@6458 | 789 | // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in |
goetz@6458 | 790 | // the days we had adapter frames. When we deoptimize a situation where a |
goetz@6458 | 791 | // compiled caller calls a compiled caller will have registers it expects |
goetz@6458 | 792 | // to survive the call to the callee. If we deoptimize the callee the only |
goetz@6458 | 793 | // way we can restore these registers is to have the oldest interpreter |
goetz@6458 | 794 | // frame that we create restore these values. That is what this routine |
goetz@6458 | 795 | // will accomplish. |
goetz@6458 | 796 | |
goetz@6458 | 797 | // At the moment we have modified c2 to not have any callee save registers |
goetz@6458 | 798 | // so this problem does not exist and this routine is just a place holder. |
goetz@6458 | 799 | |
goetz@6458 | 800 | assert(f->is_interpreted_frame(), "must be interpreted"); |
goetz@6458 | 801 | } |