src/cpu/ppc/vm/interpreter_ppc.cpp

Wed, 15 Apr 2020 11:49:55 +0800

author
aoqi
date
Wed, 15 Apr 2020 11:49:55 +0800
changeset 9852
70aa912cebe5
parent 9703
2fdf635bcf28
permissions
-rw-r--r--

Merge

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

mercurial