src/cpu/ppc/vm/cppInterpreter_ppc.cpp

Tue, 01 Apr 2014 09:36:49 +0200

author
roland
date
Tue, 01 Apr 2014 09:36:49 +0200
changeset 6723
0bf37f737702
parent 6660
63c5920a038d
child 6876
710a3c8b516e
permissions
-rw-r--r--

8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by: twisti, kvn

goetz@6660 1
goetz@6458 2 /*
roland@6723 3 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
roland@6723 4 * Copyright 2012, 2014 SAP AG. All rights reserved.
goetz@6458 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
goetz@6458 6 *
goetz@6458 7 * This code is free software; you can redistribute it and/or modify it
goetz@6458 8 * under the terms of the GNU General Public License version 2 only, as
goetz@6458 9 * published by the Free Software Foundation.
goetz@6458 10 *
goetz@6458 11 * This code is distributed in the hope that it will be useful, but WITHOUT
goetz@6458 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
goetz@6458 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
goetz@6458 14 * version 2 for more details (a copy is included in the LICENSE file that
goetz@6458 15 * accompanied this code).
goetz@6458 16 *
goetz@6458 17 * You should have received a copy of the GNU General Public License version
goetz@6458 18 * 2 along with this work; if not, write to the Free Software Foundation,
goetz@6458 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
goetz@6458 20 *
goetz@6458 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
goetz@6458 22 * or visit www.oracle.com if you need additional information or have any
goetz@6458 23 * questions.
goetz@6458 24 *
goetz@6458 25 */
goetz@6458 26
goetz@6458 27 #include "precompiled.hpp"
goetz@6458 28 #include "asm/assembler.hpp"
goetz@6458 29 #include "asm/macroAssembler.inline.hpp"
goetz@6458 30 #include "interpreter/bytecodeHistogram.hpp"
goetz@6458 31 #include "interpreter/cppInterpreter.hpp"
goetz@6458 32 #include "interpreter/interpreter.hpp"
goetz@6458 33 #include "interpreter/interpreterGenerator.hpp"
goetz@6458 34 #include "interpreter/interpreterRuntime.hpp"
goetz@6458 35 #include "oops/arrayOop.hpp"
goetz@6458 36 #include "oops/methodData.hpp"
goetz@6458 37 #include "oops/method.hpp"
goetz@6458 38 #include "oops/oop.inline.hpp"
goetz@6458 39 #include "prims/jvmtiExport.hpp"
goetz@6458 40 #include "prims/jvmtiThreadState.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/interfaceSupport.hpp"
goetz@6458 45 #include "runtime/sharedRuntime.hpp"
goetz@6458 46 #include "runtime/stubRoutines.hpp"
goetz@6458 47 #include "runtime/synchronizer.hpp"
goetz@6458 48 #include "runtime/timer.hpp"
goetz@6458 49 #include "runtime/vframeArray.hpp"
goetz@6458 50 #include "utilities/debug.hpp"
goetz@6458 51 #ifdef SHARK
goetz@6458 52 #include "shark/shark_globals.hpp"
goetz@6458 53 #endif
goetz@6458 54
goetz@6458 55 #ifdef CC_INTERP
goetz@6458 56
goetz@6458 57 #define __ _masm->
goetz@6458 58
goetz@6458 59 // Contains is used for identifying interpreter frames during a stack-walk.
goetz@6458 60 // A frame with a PC in InterpretMethod must be identified as a normal C frame.
goetz@6458 61 bool CppInterpreter::contains(address pc) {
goetz@6458 62 return _code->contains(pc);
goetz@6458 63 }
goetz@6458 64
goetz@6458 65 #ifdef PRODUCT
goetz@6458 66 #define BLOCK_COMMENT(str) // nothing
goetz@6458 67 #else
goetz@6458 68 #define BLOCK_COMMENT(str) __ block_comment(str)
goetz@6458 69 #endif
goetz@6458 70
goetz@6458 71 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
goetz@6458 72
goetz@6458 73 static address interpreter_frame_manager = NULL;
goetz@6458 74 static address frame_manager_specialized_return = NULL;
goetz@6458 75 static address native_entry = NULL;
goetz@6458 76
goetz@6458 77 static address interpreter_return_address = NULL;
goetz@6458 78
goetz@6458 79 static address unctrap_frame_manager_entry = NULL;
goetz@6458 80
goetz@6458 81 static address deopt_frame_manager_return_atos = NULL;
goetz@6458 82 static address deopt_frame_manager_return_btos = NULL;
goetz@6458 83 static address deopt_frame_manager_return_itos = NULL;
goetz@6458 84 static address deopt_frame_manager_return_ltos = NULL;
goetz@6458 85 static address deopt_frame_manager_return_ftos = NULL;
goetz@6458 86 static address deopt_frame_manager_return_dtos = NULL;
goetz@6458 87 static address deopt_frame_manager_return_vtos = NULL;
goetz@6458 88
goetz@6458 89 // A result handler converts/unboxes a native call result into
goetz@6458 90 // a java interpreter/compiler result. The current frame is an
goetz@6458 91 // interpreter frame.
goetz@6458 92 address CppInterpreterGenerator::generate_result_handler_for(BasicType type) {
goetz@6458 93 return AbstractInterpreterGenerator::generate_result_handler_for(type);
goetz@6458 94 }
goetz@6458 95
goetz@6458 96 // tosca based result to c++ interpreter stack based result.
goetz@6458 97 address CppInterpreterGenerator::generate_tosca_to_stack_converter(BasicType type) {
goetz@6458 98 //
goetz@6458 99 // A result is in the native abi result register from a native
goetz@6458 100 // method call. We need to return this result to the interpreter by
goetz@6458 101 // pushing the result on the interpreter's stack.
goetz@6458 102 //
goetz@6458 103 // Registers alive:
goetz@6458 104 // R3_ARG1(R3_RET)/F1_ARG1(F1_RET) - result to move
goetz@6458 105 // R4_ARG2 - address of tos
goetz@6458 106 // LR
goetz@6458 107 //
goetz@6458 108 // Registers updated:
goetz@6458 109 // R3_RET(R3_ARG1) - address of new tos (== R17_tos for T_VOID)
goetz@6458 110 //
goetz@6458 111
goetz@6458 112 int number_of_used_slots = 1;
goetz@6458 113
goetz@6458 114 const Register tos = R4_ARG2;
goetz@6458 115 Label done;
goetz@6458 116 Label is_false;
goetz@6458 117
goetz@6458 118 address entry = __ pc();
goetz@6458 119
goetz@6458 120 switch (type) {
goetz@6458 121 case T_BOOLEAN:
goetz@6458 122 __ cmpwi(CCR0, R3_RET, 0);
goetz@6458 123 __ beq(CCR0, is_false);
goetz@6458 124 __ li(R3_RET, 1);
goetz@6458 125 __ stw(R3_RET, 0, tos);
goetz@6458 126 __ b(done);
goetz@6458 127 __ bind(is_false);
goetz@6458 128 __ li(R3_RET, 0);
goetz@6458 129 __ stw(R3_RET, 0, tos);
goetz@6458 130 break;
goetz@6458 131 case T_BYTE:
goetz@6458 132 case T_CHAR:
goetz@6458 133 case T_SHORT:
goetz@6458 134 case T_INT:
goetz@6458 135 __ stw(R3_RET, 0, tos);
goetz@6458 136 break;
goetz@6458 137 case T_LONG:
goetz@6458 138 number_of_used_slots = 2;
goetz@6458 139 // mark unused slot for debugging
goetz@6458 140 // long goes to topmost slot
goetz@6458 141 __ std(R3_RET, -BytesPerWord, tos);
goetz@6458 142 __ li(R3_RET, 0);
goetz@6458 143 __ std(R3_RET, 0, tos);
goetz@6458 144 break;
goetz@6458 145 case T_OBJECT:
goetz@6458 146 __ verify_oop(R3_RET);
goetz@6458 147 __ std(R3_RET, 0, tos);
goetz@6458 148 break;
goetz@6458 149 case T_FLOAT:
goetz@6458 150 __ stfs(F1_RET, 0, tos);
goetz@6458 151 break;
goetz@6458 152 case T_DOUBLE:
goetz@6458 153 number_of_used_slots = 2;
goetz@6458 154 // mark unused slot for debugging
goetz@6458 155 __ li(R3_RET, 0);
goetz@6458 156 __ std(R3_RET, 0, tos);
goetz@6458 157 // double goes to topmost slot
goetz@6458 158 __ stfd(F1_RET, -BytesPerWord, tos);
goetz@6458 159 break;
goetz@6458 160 case T_VOID:
goetz@6458 161 number_of_used_slots = 0;
goetz@6458 162 break;
goetz@6458 163 default:
goetz@6458 164 ShouldNotReachHere();
goetz@6458 165 }
goetz@6458 166
goetz@6458 167 __ BIND(done);
goetz@6458 168
goetz@6458 169 // new expression stack top
goetz@6458 170 __ addi(R3_RET, tos, -BytesPerWord * number_of_used_slots);
goetz@6458 171
goetz@6458 172 __ blr();
goetz@6458 173
goetz@6458 174 return entry;
goetz@6458 175 }
goetz@6458 176
goetz@6458 177 address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) {
goetz@6458 178 //
goetz@6458 179 // Copy the result from the callee's stack to the caller's stack,
goetz@6458 180 // caller and callee both being interpreted.
goetz@6458 181 //
goetz@6458 182 // Registers alive
goetz@6458 183 // R3_ARG1 - address of callee's tos + BytesPerWord
goetz@6458 184 // R4_ARG2 - address of caller's tos [i.e. free location]
goetz@6458 185 // LR
goetz@6458 186 //
goetz@6458 187 // stack grows upwards, memory grows downwards.
goetz@6458 188 //
goetz@6458 189 // [ free ] <-- callee's tos
goetz@6458 190 // [ optional result ] <-- R3_ARG1
goetz@6458 191 // [ optional dummy ]
goetz@6458 192 // ...
goetz@6458 193 // [ free ] <-- caller's tos, R4_ARG2
goetz@6458 194 // ...
goetz@6458 195 // Registers updated
goetz@6458 196 // R3_RET(R3_ARG1) - address of caller's new tos
goetz@6458 197 //
goetz@6458 198 // stack grows upwards, memory grows downwards.
goetz@6458 199 //
goetz@6458 200 // [ free ] <-- current tos, R3_RET
goetz@6458 201 // [ optional result ]
goetz@6458 202 // [ optional dummy ]
goetz@6458 203 // ...
goetz@6458 204 //
goetz@6458 205
goetz@6458 206 const Register from = R3_ARG1;
goetz@6458 207 const Register ret = R3_ARG1;
goetz@6458 208 const Register tos = R4_ARG2;
goetz@6458 209 const Register tmp1 = R21_tmp1;
goetz@6458 210 const Register tmp2 = R22_tmp2;
goetz@6458 211
goetz@6458 212 address entry = __ pc();
goetz@6458 213
goetz@6458 214 switch (type) {
goetz@6458 215 case T_BOOLEAN:
goetz@6458 216 case T_BYTE:
goetz@6458 217 case T_CHAR:
goetz@6458 218 case T_SHORT:
goetz@6458 219 case T_INT:
goetz@6458 220 case T_FLOAT:
goetz@6458 221 __ lwz(tmp1, 0, from);
goetz@6458 222 __ stw(tmp1, 0, tos);
goetz@6458 223 // New expression stack top.
goetz@6458 224 __ addi(ret, tos, - BytesPerWord);
goetz@6458 225 break;
goetz@6458 226 case T_LONG:
goetz@6458 227 case T_DOUBLE:
goetz@6458 228 // Move both entries for debug purposes even though only one is live.
goetz@6458 229 __ ld(tmp1, BytesPerWord, from);
goetz@6458 230 __ ld(tmp2, 0, from);
goetz@6458 231 __ std(tmp1, 0, tos);
goetz@6458 232 __ std(tmp2, -BytesPerWord, tos);
goetz@6458 233 // New expression stack top.
goetz@6458 234 __ addi(ret, tos, - 2 * BytesPerWord); // two slots
goetz@6458 235 break;
goetz@6458 236 case T_OBJECT:
goetz@6458 237 __ ld(tmp1, 0, from);
goetz@6458 238 __ verify_oop(tmp1);
goetz@6458 239 __ std(tmp1, 0, tos);
goetz@6458 240 // New expression stack top.
goetz@6458 241 __ addi(ret, tos, - BytesPerWord);
goetz@6458 242 break;
goetz@6458 243 case T_VOID:
goetz@6458 244 // New expression stack top.
goetz@6458 245 __ mr(ret, tos);
goetz@6458 246 break;
goetz@6458 247 default:
goetz@6458 248 ShouldNotReachHere();
goetz@6458 249 }
goetz@6458 250
goetz@6458 251 __ blr();
goetz@6458 252
goetz@6458 253 return entry;
goetz@6458 254 }
goetz@6458 255
goetz@6458 256 address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicType type) {
goetz@6458 257 //
goetz@6458 258 // Load a result from the callee's stack into the caller's expecting
goetz@6458 259 // return register, callee being interpreted, caller being call stub
goetz@6458 260 // or jit code.
goetz@6458 261 //
goetz@6458 262 // Registers alive
goetz@6458 263 // R3_ARG1 - callee expression tos + BytesPerWord
goetz@6458 264 // LR
goetz@6458 265 //
goetz@6458 266 // stack grows upwards, memory grows downwards.
goetz@6458 267 //
goetz@6458 268 // [ free ] <-- callee's tos
goetz@6458 269 // [ optional result ] <-- R3_ARG1
goetz@6458 270 // [ optional dummy ]
goetz@6458 271 // ...
goetz@6458 272 //
goetz@6458 273 // Registers updated
goetz@6458 274 // R3_RET(R3_ARG1)/F1_RET - result
goetz@6458 275 //
goetz@6458 276
goetz@6458 277 const Register from = R3_ARG1;
goetz@6458 278 const Register ret = R3_ARG1;
goetz@6458 279 const FloatRegister fret = F1_ARG1;
goetz@6458 280
goetz@6458 281 address entry = __ pc();
goetz@6458 282
goetz@6458 283 // Implemented uniformly for both kinds of endianness. The interpreter
goetz@6458 284 // implements boolean, byte, char, and short as jint (4 bytes).
goetz@6458 285 switch (type) {
goetz@6458 286 case T_BOOLEAN:
goetz@6458 287 case T_CHAR:
goetz@6458 288 // zero extension
goetz@6458 289 __ lwz(ret, 0, from);
goetz@6458 290 break;
goetz@6458 291 case T_BYTE:
goetz@6458 292 case T_SHORT:
goetz@6458 293 case T_INT:
goetz@6458 294 // sign extension
goetz@6458 295 __ lwa(ret, 0, from);
goetz@6458 296 break;
goetz@6458 297 case T_LONG:
goetz@6458 298 __ ld(ret, 0, from);
goetz@6458 299 break;
goetz@6458 300 case T_OBJECT:
goetz@6458 301 __ ld(ret, 0, from);
goetz@6458 302 __ verify_oop(ret);
goetz@6458 303 break;
goetz@6458 304 case T_FLOAT:
goetz@6458 305 __ lfs(fret, 0, from);
goetz@6458 306 break;
goetz@6458 307 case T_DOUBLE:
goetz@6458 308 __ lfd(fret, 0, from);
goetz@6458 309 break;
goetz@6458 310 case T_VOID:
goetz@6458 311 break;
goetz@6458 312 default:
goetz@6458 313 ShouldNotReachHere();
goetz@6458 314 }
goetz@6458 315
goetz@6458 316 __ blr();
goetz@6458 317
goetz@6458 318 return entry;
goetz@6458 319 }
goetz@6458 320
goetz@6476 321 address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
goetz@6458 322 assert(interpreter_return_address != NULL, "Not initialized");
goetz@6458 323 return interpreter_return_address;
goetz@6458 324 }
goetz@6458 325
goetz@6458 326 address CppInterpreter::deopt_entry(TosState state, int length) {
goetz@6458 327 address ret = NULL;
goetz@6458 328 if (length != 0) {
goetz@6458 329 switch (state) {
goetz@6458 330 case atos: ret = deopt_frame_manager_return_atos; break;
goetz@6458 331 case btos: ret = deopt_frame_manager_return_itos; break;
goetz@6458 332 case ctos:
goetz@6458 333 case stos:
goetz@6458 334 case itos: ret = deopt_frame_manager_return_itos; break;
goetz@6458 335 case ltos: ret = deopt_frame_manager_return_ltos; break;
goetz@6458 336 case ftos: ret = deopt_frame_manager_return_ftos; break;
goetz@6458 337 case dtos: ret = deopt_frame_manager_return_dtos; break;
goetz@6458 338 case vtos: ret = deopt_frame_manager_return_vtos; break;
goetz@6458 339 default: ShouldNotReachHere();
goetz@6458 340 }
goetz@6458 341 } else {
goetz@6458 342 ret = unctrap_frame_manager_entry; // re-execute the bytecode (e.g. uncommon trap, popframe)
goetz@6458 343 }
goetz@6458 344 assert(ret != NULL, "Not initialized");
goetz@6458 345 return ret;
goetz@6458 346 }
goetz@6458 347
goetz@6458 348 //
goetz@6458 349 // Helpers for commoning out cases in the various type of method entries.
goetz@6458 350 //
goetz@6458 351
goetz@6458 352 //
goetz@6458 353 // Registers alive
goetz@6458 354 // R16_thread - JavaThread*
goetz@6458 355 // R1_SP - old stack pointer
goetz@6458 356 // R19_method - callee's Method
goetz@6458 357 // R17_tos - address of caller's tos (prepushed)
goetz@6458 358 // R15_prev_state - address of caller's BytecodeInterpreter or 0
goetz@6458 359 // return_pc in R21_tmp15 (only when called within generate_native_entry)
goetz@6458 360 //
goetz@6458 361 // Registers updated
goetz@6458 362 // R14_state - address of callee's interpreter state
goetz@6458 363 // R1_SP - new stack pointer
goetz@6458 364 // CCR4_is_synced - current method is synchronized
goetz@6458 365 //
goetz@6458 366 void CppInterpreterGenerator::generate_compute_interpreter_state(Label& stack_overflow_return) {
goetz@6458 367 //
goetz@6458 368 // Stack layout at this point:
goetz@6458 369 //
goetz@6458 370 // F1 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 371 // alignment (optional)
goetz@6458 372 // [F1's outgoing Java arguments] <-- R17_tos
goetz@6458 373 // ...
goetz@6458 374 // F2 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 375 // ...
goetz@6458 376
goetz@6458 377 //=============================================================================
goetz@6458 378 // Allocate space for locals other than the parameters, the
goetz@6458 379 // interpreter state, monitors, and the expression stack.
goetz@6458 380
goetz@6458 381 const Register local_count = R21_tmp1;
goetz@6458 382 const Register parameter_count = R22_tmp2;
goetz@6458 383 const Register max_stack = R23_tmp3;
goetz@6458 384 // Must not be overwritten within this method!
goetz@6458 385 // const Register return_pc = R29_tmp9;
goetz@6458 386
goetz@6458 387 const ConditionRegister is_synced = CCR4_is_synced;
goetz@6458 388 const ConditionRegister is_native = CCR6;
goetz@6458 389 const ConditionRegister is_static = CCR7;
goetz@6458 390
goetz@6458 391 assert(is_synced != is_native, "condition code registers must be distinct");
goetz@6458 392 assert(is_synced != is_static, "condition code registers must be distinct");
goetz@6458 393 assert(is_native != is_static, "condition code registers must be distinct");
goetz@6458 394
goetz@6458 395 {
goetz@6458 396
goetz@6458 397 // Local registers
goetz@6458 398 const Register top_frame_size = R24_tmp4;
goetz@6458 399 const Register access_flags = R25_tmp5;
goetz@6458 400 const Register state_offset = R26_tmp6;
goetz@6458 401 Register mem_stack_limit = R27_tmp7;
goetz@6458 402 const Register page_size = R28_tmp8;
goetz@6458 403
goetz@6458 404 BLOCK_COMMENT("compute_interpreter_state {");
goetz@6458 405
goetz@6458 406 // access_flags = method->access_flags();
goetz@6660 407 // TODO: PPC port: assert(4 == sizeof(AccessFlags), "unexpected field size");
goetz@6458 408 __ lwa(access_flags, method_(access_flags));
goetz@6458 409
goetz@6458 410 // parameter_count = method->constMethod->size_of_parameters();
goetz@6458 411 // TODO: PPC port: assert(2 == ConstMethod::sz_size_of_parameters(), "unexpected field size");
goetz@6458 412 __ ld(max_stack, in_bytes(Method::const_offset()), R19_method); // Max_stack holds constMethod for a while.
goetz@6458 413 __ lhz(parameter_count, in_bytes(ConstMethod::size_of_parameters_offset()), max_stack);
goetz@6458 414
goetz@6458 415 // local_count = method->constMethod()->max_locals();
goetz@6458 416 // TODO: PPC port: assert(2 == ConstMethod::sz_max_locals(), "unexpected field size");
goetz@6458 417 __ lhz(local_count, in_bytes(ConstMethod::size_of_locals_offset()), max_stack);
goetz@6458 418
goetz@6458 419 // max_stack = method->constMethod()->max_stack();
goetz@6458 420 // TODO: PPC port: assert(2 == ConstMethod::sz_max_stack(), "unexpected field size");
goetz@6458 421 __ lhz(max_stack, in_bytes(ConstMethod::max_stack_offset()), max_stack);
goetz@6458 422
goetz@6458 423 if (EnableInvokeDynamic) {
goetz@6458 424 // Take into account 'extra_stack_entries' needed by method handles (see method.hpp).
goetz@6458 425 __ addi(max_stack, max_stack, Method::extra_stack_entries());
goetz@6458 426 }
goetz@6458 427
goetz@6458 428 // mem_stack_limit = thread->stack_limit();
goetz@6458 429 __ ld(mem_stack_limit, thread_(stack_overflow_limit));
goetz@6458 430
goetz@6458 431 // Point locals at the first argument. Method's locals are the
goetz@6458 432 // parameters on top of caller's expression stack.
goetz@6458 433
goetz@6458 434 // tos points past last Java argument
goetz@6458 435 __ sldi(R18_locals, parameter_count, Interpreter::logStackElementSize);
goetz@6458 436 __ add(R18_locals, R17_tos, R18_locals);
goetz@6458 437
goetz@6458 438 // R18_locals - i*BytesPerWord points to i-th Java local (i starts at 0)
goetz@6458 439
goetz@6458 440 // Set is_native, is_synced, is_static - will be used later.
goetz@6458 441 __ testbitdi(is_native, R0, access_flags, JVM_ACC_NATIVE_BIT);
goetz@6458 442 __ testbitdi(is_synced, R0, access_flags, JVM_ACC_SYNCHRONIZED_BIT);
goetz@6458 443 assert(is_synced->is_nonvolatile(), "is_synced must be non-volatile");
goetz@6458 444 __ testbitdi(is_static, R0, access_flags, JVM_ACC_STATIC_BIT);
goetz@6458 445
goetz@6458 446 // PARENT_IJAVA_FRAME_ABI
goetz@6458 447 //
goetz@6458 448 // frame_size =
goetz@6458 449 // round_to((local_count - parameter_count)*BytesPerWord +
goetz@6458 450 // 2*BytesPerWord +
goetz@6458 451 // alignment +
goetz@6458 452 // frame::interpreter_frame_cinterpreterstate_size_in_bytes()
goetz@6458 453 // sizeof(PARENT_IJAVA_FRAME_ABI)
goetz@6458 454 // method->is_synchronized() ? sizeof(BasicObjectLock) : 0 +
goetz@6458 455 // max_stack*BytesPerWord,
goetz@6458 456 // 16)
goetz@6458 457 //
goetz@6458 458 // Note that this calculation is exactly mirrored by
goetz@6458 459 // AbstractInterpreter::layout_activation_impl() [ and
goetz@6458 460 // AbstractInterpreter::size_activation() ]. Which is used by
goetz@6458 461 // deoptimization so that it can allocate the proper sized
goetz@6458 462 // frame. This only happens for interpreted frames so the extra
goetz@6458 463 // notes below about max_stack below are not important. The other
goetz@6458 464 // thing to note is that for interpreter frames other than the
goetz@6458 465 // current activation the size of the stack is the size of the live
goetz@6458 466 // portion of the stack at the particular bcp and NOT the maximum
goetz@6458 467 // stack that the method might use.
goetz@6458 468 //
goetz@6458 469 // If we're calling a native method, we replace max_stack (which is
goetz@6458 470 // zero) with space for the worst-case signature handler varargs
goetz@6458 471 // vector, which is:
goetz@6458 472 //
goetz@6458 473 // max_stack = max(Argument::n_register_parameters, parameter_count+2);
goetz@6458 474 //
goetz@6458 475 // We add two slots to the parameter_count, one for the jni
goetz@6458 476 // environment and one for a possible native mirror. We allocate
goetz@6458 477 // space for at least the number of ABI registers, even though
goetz@6458 478 // InterpreterRuntime::slow_signature_handler won't write more than
goetz@6458 479 // parameter_count+2 words when it creates the varargs vector at the
goetz@6458 480 // top of the stack. The generated slow signature handler will just
goetz@6458 481 // load trash into registers beyond the necessary number. We're
goetz@6458 482 // still going to cut the stack back by the ABI register parameter
goetz@6458 483 // count so as to get SP+16 pointing at the ABI outgoing parameter
goetz@6458 484 // area, so we need to allocate at least that much even though we're
goetz@6458 485 // going to throw it away.
goetz@6458 486 //
goetz@6458 487
goetz@6458 488 // Adjust max_stack for native methods:
goetz@6458 489 Label skip_native_calculate_max_stack;
goetz@6458 490 __ bfalse(is_native, skip_native_calculate_max_stack);
goetz@6458 491 // if (is_native) {
goetz@6458 492 // max_stack = max(Argument::n_register_parameters, parameter_count+2);
goetz@6458 493 __ addi(max_stack, parameter_count, 2*Interpreter::stackElementWords);
goetz@6458 494 __ cmpwi(CCR0, max_stack, Argument::n_register_parameters);
goetz@6458 495 __ bge(CCR0, skip_native_calculate_max_stack);
goetz@6458 496 __ li(max_stack, Argument::n_register_parameters);
goetz@6458 497 // }
goetz@6458 498 __ bind(skip_native_calculate_max_stack);
goetz@6458 499 // max_stack is now in bytes
goetz@6458 500 __ slwi(max_stack, max_stack, Interpreter::logStackElementSize);
goetz@6458 501
goetz@6458 502 // Calculate number of non-parameter locals (in slots):
goetz@6458 503 Label not_java;
goetz@6458 504 __ btrue(is_native, not_java);
goetz@6458 505 // if (!is_native) {
goetz@6458 506 // local_count = non-parameter local count
goetz@6458 507 __ sub(local_count, local_count, parameter_count);
goetz@6458 508 // } else {
goetz@6458 509 // // nothing to do: method->max_locals() == 0 for native methods
goetz@6458 510 // }
goetz@6458 511 __ bind(not_java);
goetz@6458 512
goetz@6458 513
goetz@6458 514 // Calculate top_frame_size and parent_frame_resize.
goetz@6458 515 {
goetz@6458 516 const Register parent_frame_resize = R12_scratch2;
goetz@6458 517
goetz@6458 518 BLOCK_COMMENT("Compute top_frame_size.");
goetz@6458 519 // top_frame_size = TOP_IJAVA_FRAME_ABI
goetz@6458 520 // + size of interpreter state
goetz@6458 521 __ li(top_frame_size, frame::top_ijava_frame_abi_size
goetz@6458 522 + frame::interpreter_frame_cinterpreterstate_size_in_bytes());
goetz@6458 523 // + max_stack
goetz@6458 524 __ add(top_frame_size, top_frame_size, max_stack);
goetz@6458 525 // + stack slots for a BasicObjectLock for synchronized methods
goetz@6458 526 {
goetz@6458 527 Label not_synced;
goetz@6458 528 __ bfalse(is_synced, not_synced);
goetz@6458 529 __ addi(top_frame_size, top_frame_size, frame::interpreter_frame_monitor_size_in_bytes());
goetz@6458 530 __ bind(not_synced);
goetz@6458 531 }
goetz@6458 532 // align
goetz@6458 533 __ round_to(top_frame_size, frame::alignment_in_bytes);
goetz@6458 534
goetz@6458 535
goetz@6458 536 BLOCK_COMMENT("Compute parent_frame_resize.");
goetz@6458 537 // parent_frame_resize = R1_SP - R17_tos
goetz@6458 538 __ sub(parent_frame_resize, R1_SP, R17_tos);
goetz@6458 539 //__ li(parent_frame_resize, 0);
goetz@6458 540 // + PARENT_IJAVA_FRAME_ABI
goetz@6458 541 // + extra two slots for the no-parameter/no-locals
goetz@6458 542 // method result
goetz@6458 543 __ addi(parent_frame_resize, parent_frame_resize,
goetz@6458 544 frame::parent_ijava_frame_abi_size
goetz@6458 545 + 2*Interpreter::stackElementSize);
goetz@6458 546 // + (locals_count - params_count)
goetz@6458 547 __ sldi(R0, local_count, Interpreter::logStackElementSize);
goetz@6458 548 __ add(parent_frame_resize, parent_frame_resize, R0);
goetz@6458 549 // align
goetz@6458 550 __ round_to(parent_frame_resize, frame::alignment_in_bytes);
goetz@6458 551
goetz@6458 552 //
goetz@6458 553 // Stack layout at this point:
goetz@6458 554 //
goetz@6458 555 // The new frame F0 hasn't yet been pushed, F1 is still the top frame.
goetz@6458 556 //
goetz@6458 557 // F0 [TOP_IJAVA_FRAME_ABI]
goetz@6458 558 // alignment (optional)
goetz@6458 559 // [F0's full operand stack]
goetz@6458 560 // [F0's monitors] (optional)
goetz@6458 561 // [F0's BytecodeInterpreter object]
goetz@6458 562 // F1 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 563 // alignment (optional)
goetz@6458 564 // [F0's Java result]
goetz@6458 565 // [F0's non-arg Java locals]
goetz@6458 566 // [F1's outgoing Java arguments] <-- R17_tos
goetz@6458 567 // ...
goetz@6458 568 // F2 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 569 // ...
goetz@6458 570
goetz@6458 571
goetz@6458 572 // Calculate new R14_state
goetz@6458 573 // and
goetz@6458 574 // test that the new memory stack pointer is above the limit,
goetz@6458 575 // throw a StackOverflowError otherwise.
goetz@6458 576 __ sub(R11_scratch1/*F1's SP*/, R1_SP, parent_frame_resize);
goetz@6458 577 __ addi(R14_state, R11_scratch1/*F1's SP*/,
goetz@6458 578 -frame::interpreter_frame_cinterpreterstate_size_in_bytes());
goetz@6458 579 __ sub(R11_scratch1/*F0's SP*/,
goetz@6458 580 R11_scratch1/*F1's SP*/, top_frame_size);
goetz@6458 581
goetz@6458 582 BLOCK_COMMENT("Test for stack overflow:");
goetz@6458 583 __ cmpld(CCR0/*is_stack_overflow*/, R11_scratch1, mem_stack_limit);
goetz@6458 584 __ blt(CCR0/*is_stack_overflow*/, stack_overflow_return);
goetz@6458 585
goetz@6458 586
goetz@6458 587 //=============================================================================
goetz@6458 588 // Frame_size doesn't overflow the stack. Allocate new frame and
goetz@6458 589 // initialize interpreter state.
goetz@6458 590
goetz@6458 591 // Register state
goetz@6458 592 //
goetz@6458 593 // R15 - local_count
goetz@6458 594 // R16 - parameter_count
goetz@6458 595 // R17 - max_stack
goetz@6458 596 //
goetz@6458 597 // R18 - frame_size
goetz@6458 598 // R19 - access_flags
goetz@6458 599 // CCR4_is_synced - is_synced
goetz@6458 600 //
goetz@6458 601 // GR_Lstate - pointer to the uninitialized new BytecodeInterpreter.
goetz@6458 602
goetz@6458 603 // _last_Java_pc just needs to be close enough that we can identify
goetz@6458 604 // the frame as an interpreted frame. It does not need to be the
goetz@6458 605 // exact return address from either calling
goetz@6458 606 // BytecodeInterpreter::InterpretMethod or the call to a jni native method.
goetz@6458 607 // So we can initialize it here with a value of a bundle in this
goetz@6458 608 // code fragment. We only do this initialization for java frames
goetz@6458 609 // where InterpretMethod needs a a way to get a good pc value to
goetz@6458 610 // store in the thread state. For interpreter frames used to call
goetz@6458 611 // jni native code we just zero the value in the state and move an
goetz@6458 612 // ip as needed in the native entry code.
goetz@6458 613 //
goetz@6458 614 // const Register last_Java_pc_addr = GR24_SCRATCH; // QQQ 27
goetz@6458 615 // const Register last_Java_pc = GR26_SCRATCH;
goetz@6458 616
goetz@6458 617 // Must reference stack before setting new SP since Windows
goetz@6458 618 // will not be able to deliver the exception on a bad SP.
goetz@6458 619 // Windows also insists that we bang each page one at a time in order
goetz@6458 620 // for the OS to map in the reserved pages. If we bang only
goetz@6458 621 // the final page, Windows stops delivering exceptions to our
goetz@6458 622 // VectoredExceptionHandler and terminates our program.
goetz@6458 623 // Linux only requires a single bang but it's rare to have
goetz@6458 624 // to bang more than 1 page so the code is enabled for both OS's.
goetz@6458 625
goetz@6458 626 // BANG THE STACK
goetz@6458 627 //
goetz@6458 628 // Nothing to do for PPC, because updating the SP will automatically
goetz@6458 629 // bang the page.
goetz@6458 630
goetz@6458 631 // Up to here we have calculated the delta for the new C-frame and
goetz@6458 632 // checked for a stack-overflow. Now we can savely update SP and
goetz@6458 633 // resize the C-frame.
goetz@6458 634
goetz@6458 635 // R14_state has already been calculated.
goetz@6458 636 __ push_interpreter_frame(top_frame_size, parent_frame_resize,
goetz@6458 637 R25_tmp5, R26_tmp6, R27_tmp7, R28_tmp8);
goetz@6458 638
goetz@6458 639 }
goetz@6458 640
goetz@6458 641 //
goetz@6458 642 // Stack layout at this point:
goetz@6458 643 //
goetz@6458 644 // F0 has been been pushed!
goetz@6458 645 //
goetz@6458 646 // F0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 647 // alignment (optional) (now it's here, if required)
goetz@6458 648 // [F0's full operand stack]
goetz@6458 649 // [F0's monitors] (optional)
goetz@6458 650 // [F0's BytecodeInterpreter object]
goetz@6458 651 // F1 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 652 // alignment (optional) (now it's here, if required)
goetz@6458 653 // [F0's Java result]
goetz@6458 654 // [F0's non-arg Java locals]
goetz@6458 655 // [F1's outgoing Java arguments]
goetz@6458 656 // ...
goetz@6458 657 // F2 [PARENT_IJAVA_FRAME_ABI]
goetz@6458 658 // ...
goetz@6458 659 //
goetz@6458 660 // R14_state points to F0's BytecodeInterpreter object.
goetz@6458 661 //
goetz@6458 662
goetz@6458 663 }
goetz@6458 664
goetz@6458 665 //=============================================================================
goetz@6458 666 // new BytecodeInterpreter-object is save, let's initialize it:
goetz@6458 667 BLOCK_COMMENT("New BytecodeInterpreter-object is save.");
goetz@6458 668
goetz@6458 669 {
goetz@6458 670 // Locals
goetz@6458 671 const Register bytecode_addr = R24_tmp4;
goetz@6458 672 const Register constants = R25_tmp5;
goetz@6458 673 const Register tos = R26_tmp6;
goetz@6458 674 const Register stack_base = R27_tmp7;
goetz@6458 675 const Register local_addr = R28_tmp8;
goetz@6458 676 {
goetz@6458 677 Label L;
goetz@6458 678 __ btrue(is_native, L);
goetz@6458 679 // if (!is_native) {
goetz@6458 680 // bytecode_addr = constMethod->codes();
goetz@6458 681 __ ld(bytecode_addr, method_(const));
goetz@6458 682 __ addi(bytecode_addr, bytecode_addr, in_bytes(ConstMethod::codes_offset()));
goetz@6458 683 // }
goetz@6458 684 __ bind(L);
goetz@6458 685 }
goetz@6458 686
goetz@6458 687 __ ld(constants, in_bytes(Method::const_offset()), R19_method);
goetz@6458 688 __ ld(constants, in_bytes(ConstMethod::constants_offset()), constants);
goetz@6458 689
goetz@6458 690 // state->_prev_link = prev_state;
goetz@6458 691 __ std(R15_prev_state, state_(_prev_link));
goetz@6458 692
goetz@6458 693 // For assertions only.
goetz@6458 694 // TODO: not needed anyway because it coincides with `_monitor_base'. remove!
goetz@6458 695 // state->_self_link = state;
goetz@6458 696 DEBUG_ONLY(__ std(R14_state, state_(_self_link));)
goetz@6458 697
goetz@6458 698 // state->_thread = thread;
goetz@6458 699 __ std(R16_thread, state_(_thread));
goetz@6458 700
goetz@6458 701 // state->_method = method;
goetz@6458 702 __ std(R19_method, state_(_method));
goetz@6458 703
goetz@6458 704 // state->_locals = locals;
goetz@6458 705 __ std(R18_locals, state_(_locals));
goetz@6458 706
goetz@6458 707 // state->_oop_temp = NULL;
goetz@6458 708 __ li(R0, 0);
goetz@6458 709 __ std(R0, state_(_oop_temp));
goetz@6458 710
goetz@6458 711 // state->_last_Java_fp = *R1_SP // Use *R1_SP as fp
goetz@6458 712 __ ld(R0, _abi(callers_sp), R1_SP);
goetz@6458 713 __ std(R0, state_(_last_Java_fp));
goetz@6458 714
goetz@6458 715 BLOCK_COMMENT("load Stack base:");
goetz@6458 716 {
goetz@6458 717 // Stack_base.
goetz@6458 718 // if (!method->synchronized()) {
goetz@6458 719 // stack_base = state;
goetz@6458 720 // } else {
goetz@6458 721 // stack_base = (uintptr_t)state - sizeof(BasicObjectLock);
goetz@6458 722 // }
goetz@6458 723 Label L;
goetz@6458 724 __ mr(stack_base, R14_state);
goetz@6458 725 __ bfalse(is_synced, L);
goetz@6458 726 __ addi(stack_base, stack_base, -frame::interpreter_frame_monitor_size_in_bytes());
goetz@6458 727 __ bind(L);
goetz@6458 728 }
goetz@6458 729
goetz@6458 730 // state->_mdx = NULL;
goetz@6458 731 __ li(R0, 0);
goetz@6458 732 __ std(R0, state_(_mdx));
goetz@6458 733
goetz@6458 734 {
goetz@6458 735 // if (method->is_native()) state->_bcp = NULL;
goetz@6458 736 // else state->_bcp = bytecode_addr;
goetz@6458 737 Label label1, label2;
goetz@6458 738 __ bfalse(is_native, label1);
goetz@6458 739 __ std(R0, state_(_bcp));
goetz@6458 740 __ b(label2);
goetz@6458 741 __ bind(label1);
goetz@6458 742 __ std(bytecode_addr, state_(_bcp));
goetz@6458 743 __ bind(label2);
goetz@6458 744 }
goetz@6458 745
goetz@6458 746
goetz@6458 747 // state->_result._to_call._callee = NULL;
goetz@6458 748 __ std(R0, state_(_result._to_call._callee));
goetz@6458 749
goetz@6458 750 // state->_monitor_base = state;
goetz@6458 751 __ std(R14_state, state_(_monitor_base));
goetz@6458 752
goetz@6458 753 // state->_msg = BytecodeInterpreter::method_entry;
goetz@6458 754 __ li(R0, BytecodeInterpreter::method_entry);
goetz@6458 755 __ stw(R0, state_(_msg));
goetz@6458 756
goetz@6458 757 // state->_last_Java_sp = R1_SP;
goetz@6458 758 __ std(R1_SP, state_(_last_Java_sp));
goetz@6458 759
goetz@6458 760 // state->_stack_base = stack_base;
goetz@6458 761 __ std(stack_base, state_(_stack_base));
goetz@6458 762
goetz@6458 763 // tos = stack_base - 1 slot (prepushed);
goetz@6458 764 // state->_stack.Tos(tos);
goetz@6458 765 __ addi(tos, stack_base, - Interpreter::stackElementSize);
goetz@6458 766 __ std(tos, state_(_stack));
goetz@6458 767
goetz@6458 768
goetz@6458 769 {
goetz@6458 770 BLOCK_COMMENT("get last_Java_pc:");
goetz@6458 771 // if (!is_native) state->_last_Java_pc = <some_ip_in_this_code_buffer>;
goetz@6458 772 // else state->_last_Java_pc = NULL; (just for neatness)
goetz@6458 773 Label label1, label2;
goetz@6458 774 __ btrue(is_native, label1);
goetz@6458 775 __ get_PC_trash_LR(R0);
goetz@6458 776 __ std(R0, state_(_last_Java_pc));
goetz@6458 777 __ b(label2);
goetz@6458 778 __ bind(label1);
goetz@6458 779 __ li(R0, 0);
goetz@6458 780 __ std(R0, state_(_last_Java_pc));
goetz@6458 781 __ bind(label2);
goetz@6458 782 }
goetz@6458 783
goetz@6458 784
goetz@6458 785 // stack_limit = tos - max_stack;
goetz@6458 786 __ sub(R0, tos, max_stack);
goetz@6458 787 // state->_stack_limit = stack_limit;
goetz@6458 788 __ std(R0, state_(_stack_limit));
goetz@6458 789
goetz@6458 790
goetz@6458 791 // cache = method->constants()->cache();
goetz@6458 792 __ ld(R0, ConstantPool::cache_offset_in_bytes(), constants);
goetz@6458 793 // state->_constants = method->constants()->cache();
goetz@6458 794 __ std(R0, state_(_constants));
goetz@6458 795
goetz@6458 796
goetz@6458 797
goetz@6458 798 //=============================================================================
goetz@6458 799 // synchronized method, allocate and initialize method object lock.
goetz@6458 800 // if (!method->is_synchronized()) goto fill_locals_with_0x0s;
goetz@6458 801 Label fill_locals_with_0x0s;
goetz@6458 802 __ bfalse(is_synced, fill_locals_with_0x0s);
goetz@6458 803
goetz@6458 804 // pool_holder = method->constants()->pool_holder();
goetz@6458 805 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
goetz@6458 806 {
goetz@6458 807 Label label1, label2;
goetz@6458 808 // lockee = NULL; for java methods, correct value will be inserted in BytecodeInterpretMethod.hpp
goetz@6458 809 __ li(R0,0);
goetz@6458 810 __ bfalse(is_native, label2);
goetz@6458 811
goetz@6458 812 __ bfalse(is_static, label1);
goetz@6458 813 // if (method->is_static()) lockee =
goetz@6458 814 // pool_holder->klass_part()->java_mirror();
goetz@6458 815 __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(), constants);
goetz@6458 816 __ ld(R0/*lockee*/, mirror_offset, R11_scratch1/*pool_holder*/);
goetz@6458 817 __ b(label2);
goetz@6458 818
goetz@6458 819 __ bind(label1);
goetz@6458 820 // else lockee = *(oop*)locals;
goetz@6458 821 __ ld(R0/*lockee*/, 0, R18_locals);
goetz@6458 822 __ bind(label2);
goetz@6458 823
goetz@6458 824 // monitor->set_obj(lockee);
goetz@6458 825 __ std(R0/*lockee*/, BasicObjectLock::obj_offset_in_bytes(), stack_base);
goetz@6458 826 }
goetz@6458 827
goetz@6458 828 // See if we need to zero the locals
goetz@6458 829 __ BIND(fill_locals_with_0x0s);
goetz@6458 830
goetz@6458 831
goetz@6458 832 //=============================================================================
goetz@6458 833 // fill locals with 0x0s
goetz@6458 834 Label locals_zeroed;
goetz@6458 835 __ btrue(is_native, locals_zeroed);
goetz@6458 836
goetz@6458 837 if (true /* zerolocals */ || ClearInterpreterLocals) {
goetz@6458 838 // local_count is already num_locals_slots - num_param_slots
goetz@6458 839 __ sldi(R0, parameter_count, Interpreter::logStackElementSize);
goetz@6458 840 __ sub(local_addr, R18_locals, R0);
goetz@6458 841 __ cmpdi(CCR0, local_count, 0);
goetz@6458 842 __ ble(CCR0, locals_zeroed);
goetz@6458 843
goetz@6458 844 __ mtctr(local_count);
goetz@6458 845 //__ ld_const_addr(R0, (address) 0xcafe0000babe);
goetz@6458 846 __ li(R0, 0);
goetz@6458 847
goetz@6458 848 Label zero_slot;
goetz@6458 849 __ bind(zero_slot);
goetz@6458 850
goetz@6458 851 // first local is at local_addr
goetz@6458 852 __ std(R0, 0, local_addr);
goetz@6458 853 __ addi(local_addr, local_addr, -BytesPerWord);
goetz@6458 854 __ bdnz(zero_slot);
goetz@6458 855 }
goetz@6458 856
goetz@6458 857 __ BIND(locals_zeroed);
goetz@6458 858
goetz@6458 859 }
goetz@6458 860 BLOCK_COMMENT("} compute_interpreter_state");
goetz@6458 861 }
goetz@6458 862
goetz@6458 863 // Generate code to initiate compilation on invocation counter overflow.
goetz@6458 864 void CppInterpreterGenerator::generate_counter_overflow(Label& continue_entry) {
goetz@6458 865 // Registers alive
goetz@6458 866 // R14_state
goetz@6458 867 // R16_thread
goetz@6458 868 //
goetz@6458 869 // Registers updated
goetz@6458 870 // R14_state
goetz@6458 871 // R3_ARG1 (=R3_RET)
goetz@6458 872 // R4_ARG2
goetz@6458 873
goetz@6458 874 // After entering the vm we remove the activation and retry the
goetz@6458 875 // entry point in case the compilation is complete.
goetz@6458 876
goetz@6458 877 // InterpreterRuntime::frequency_counter_overflow takes one argument
goetz@6458 878 // that indicates if the counter overflow occurs at a backwards
goetz@6458 879 // branch (NULL bcp). We pass zero. The call returns the address
goetz@6458 880 // of the verified entry point for the method or NULL if the
goetz@6458 881 // compilation did not complete (either went background or bailed
goetz@6458 882 // out).
goetz@6458 883 __ li(R4_ARG2, 0);
goetz@6458 884
goetz@6458 885 // Pass false to call_VM so it doesn't check for pending exceptions,
goetz@6458 886 // since at this point in the method invocation the exception
goetz@6458 887 // handler would try to exit the monitor of synchronized methods
goetz@6458 888 // which haven't been entered yet.
goetz@6458 889 //
goetz@6458 890 // Returns verified_entry_point or NULL, we don't care which.
goetz@6458 891 //
goetz@6458 892 // Do not use the variant `frequency_counter_overflow' that returns
goetz@6458 893 // a structure, because this will change the argument list by a
goetz@6458 894 // hidden parameter (gcc 4.1).
goetz@6458 895
goetz@6458 896 __ call_VM(noreg,
goetz@6458 897 CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow),
goetz@6458 898 R4_ARG2,
goetz@6458 899 false);
goetz@6458 900 // Returns verified_entry_point or NULL, we don't care which as we ignore it
goetz@6458 901 // and run interpreted.
goetz@6458 902
goetz@6458 903 // Reload method, it may have moved.
goetz@6458 904 __ ld(R19_method, state_(_method));
goetz@6458 905
goetz@6458 906 // We jump now to the label "continue_after_compile".
goetz@6458 907 __ b(continue_entry);
goetz@6458 908 }
goetz@6458 909
goetz@6458 910 // Increment invocation count and check for overflow.
goetz@6458 911 //
goetz@6458 912 // R19_method must contain Method* of method to profile.
goetz@6458 913 void CppInterpreterGenerator::generate_counter_incr(Label& overflow) {
goetz@6458 914 Label done;
goetz@6458 915 const Register Rcounters = R12_scratch2;
goetz@6458 916 const Register iv_be_count = R11_scratch1;
goetz@6458 917 const Register invocation_limit = R12_scratch2;
goetz@6458 918 const Register invocation_limit_addr = invocation_limit;
goetz@6458 919
goetz@6458 920 // Load and ev. allocate MethodCounters object.
goetz@6458 921 __ get_method_counters(R19_method, Rcounters, done);
goetz@6458 922
goetz@6458 923 // Update standard invocation counters.
goetz@6458 924 __ increment_invocation_counter(Rcounters, iv_be_count, R0);
goetz@6458 925
goetz@6458 926 // Compare against limit.
goetz@6458 927 BLOCK_COMMENT("Compare counter against limit:");
goetz@6458 928 assert(4 == sizeof(InvocationCounter::InterpreterInvocationLimit),
goetz@6458 929 "must be 4 bytes");
goetz@6458 930 __ load_const(invocation_limit_addr, (address)&InvocationCounter::InterpreterInvocationLimit);
goetz@6458 931 __ lwa(invocation_limit, 0, invocation_limit_addr);
goetz@6458 932 __ cmpw(CCR0, iv_be_count, invocation_limit);
goetz@6458 933 __ bge(CCR0, overflow);
goetz@6458 934 __ bind(done);
goetz@6458 935 }
goetz@6458 936
goetz@6458 937 //
goetz@6458 938 // Call a JNI method.
goetz@6458 939 //
goetz@6458 940 // Interpreter stub for calling a native method. (C++ interpreter)
goetz@6458 941 // This sets up a somewhat different looking stack for calling the native method
goetz@6458 942 // than the typical interpreter frame setup.
goetz@6458 943 //
goetz@6458 944 address CppInterpreterGenerator::generate_native_entry(void) {
goetz@6458 945 if (native_entry != NULL) return native_entry;
goetz@6458 946 address entry = __ pc();
goetz@6458 947
goetz@6458 948 // Read
goetz@6458 949 // R16_thread
goetz@6458 950 // R15_prev_state - address of caller's BytecodeInterpreter, if this snippet
goetz@6458 951 // gets called by the frame manager.
goetz@6458 952 // R19_method - callee's Method
goetz@6458 953 // R17_tos - address of caller's tos
goetz@6458 954 // R1_SP - caller's stack pointer
goetz@6458 955 // R21_sender_SP - initial caller sp
goetz@6458 956 //
goetz@6458 957 // Update
goetz@6458 958 // R14_state - address of caller's BytecodeInterpreter
goetz@6458 959 // R3_RET - integer result, if any.
goetz@6458 960 // F1_RET - float result, if any.
goetz@6458 961 //
goetz@6458 962 //
goetz@6458 963 // Stack layout at this point:
goetz@6458 964 //
goetz@6458 965 // 0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 966 // alignment (optional)
goetz@6458 967 // [outgoing Java arguments] <-- R17_tos
goetz@6458 968 // ...
goetz@6458 969 // PARENT [PARENT_IJAVA_FRAME_ABI]
goetz@6458 970 // ...
goetz@6458 971 //
goetz@6458 972
goetz@6458 973 const bool inc_counter = UseCompiler || CountCompiledCalls;
goetz@6458 974
goetz@6458 975 const Register signature_handler_fd = R21_tmp1;
goetz@6458 976 const Register pending_exception = R22_tmp2;
goetz@6458 977 const Register result_handler_addr = R23_tmp3;
goetz@6458 978 const Register native_method_fd = R24_tmp4;
goetz@6458 979 const Register access_flags = R25_tmp5;
goetz@6458 980 const Register active_handles = R26_tmp6;
goetz@6458 981 const Register sync_state = R27_tmp7;
goetz@6458 982 const Register sync_state_addr = sync_state; // Address is dead after use.
goetz@6458 983 const Register suspend_flags = R24_tmp4;
goetz@6458 984
goetz@6458 985 const Register return_pc = R28_tmp8; // Register will be locked for some time.
goetz@6458 986
goetz@6458 987 const ConditionRegister is_synced = CCR4_is_synced; // Live-on-exit from compute_interpreter_state.
goetz@6458 988
goetz@6458 989
goetz@6458 990 // R1_SP still points to caller's SP at this point.
goetz@6458 991
goetz@6458 992 // Save initial_caller_sp to caller's abi. The caller frame must be
goetz@6458 993 // resized before returning to get rid of the c2i arguments (if
goetz@6458 994 // any).
goetz@6458 995 // Override the saved SP with the senderSP so we can pop c2i
goetz@6458 996 // arguments (if any) off when we return
goetz@6458 997 __ std(R21_sender_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
goetz@6458 998
goetz@6458 999 // Save LR to caller's frame. We don't use _abi(lr) here, because it is not safe.
goetz@6458 1000 __ mflr(return_pc);
goetz@6458 1001 __ std(return_pc, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1002
goetz@6458 1003 assert(return_pc->is_nonvolatile(), "return_pc must be a non-volatile register");
goetz@6458 1004
goetz@6458 1005 __ verify_method_ptr(R19_method);
goetz@6458 1006
goetz@6458 1007 //=============================================================================
goetz@6458 1008
goetz@6458 1009 // If this snippet gets called by the frame manager (at label
goetz@6458 1010 // `call_special'), then R15_prev_state is valid. If this snippet
goetz@6458 1011 // is not called by the frame manager, but e.g. by the call stub or
goetz@6458 1012 // by compiled code, then R15_prev_state is invalid.
goetz@6458 1013 {
goetz@6458 1014 // Set R15_prev_state to 0 if we don't return to the frame
goetz@6458 1015 // manager; we will return to the call_stub or to compiled code
goetz@6458 1016 // instead. If R15_prev_state is 0 there will be only one
goetz@6458 1017 // interpreter frame (we will set this up later) in this C frame!
goetz@6458 1018 // So we must take care about retrieving prev_state_(_prev_link)
goetz@6458 1019 // and restoring R1_SP when popping that interpreter.
goetz@6458 1020 Label prev_state_is_valid;
goetz@6458 1021
goetz@6458 1022 __ load_const(R11_scratch1/*frame_manager_returnpc_addr*/, (address)&frame_manager_specialized_return);
goetz@6458 1023 __ ld(R12_scratch2/*frame_manager_returnpc*/, 0, R11_scratch1/*frame_manager_returnpc_addr*/);
goetz@6458 1024 __ cmpd(CCR0, return_pc, R12_scratch2/*frame_manager_returnpc*/);
goetz@6458 1025 __ beq(CCR0, prev_state_is_valid);
goetz@6458 1026
goetz@6458 1027 __ li(R15_prev_state, 0);
goetz@6458 1028
goetz@6458 1029 __ BIND(prev_state_is_valid);
goetz@6458 1030 }
goetz@6458 1031
goetz@6458 1032 //=============================================================================
goetz@6458 1033 // Allocate new frame and initialize interpreter state.
goetz@6458 1034
goetz@6458 1035 Label exception_return;
goetz@6458 1036 Label exception_return_sync_check;
goetz@6458 1037 Label stack_overflow_return;
goetz@6458 1038
goetz@6458 1039 // Generate new interpreter state and jump to stack_overflow_return in case of
goetz@6458 1040 // a stack overflow.
goetz@6458 1041 generate_compute_interpreter_state(stack_overflow_return);
goetz@6458 1042
goetz@6458 1043 //=============================================================================
goetz@6458 1044 // Increment invocation counter. On overflow, entry to JNI method
goetz@6458 1045 // will be compiled.
goetz@6458 1046 Label invocation_counter_overflow;
goetz@6458 1047 if (inc_counter) {
goetz@6458 1048 generate_counter_incr(invocation_counter_overflow);
goetz@6458 1049 }
goetz@6458 1050
goetz@6458 1051 Label continue_after_compile;
goetz@6458 1052 __ BIND(continue_after_compile);
goetz@6458 1053
goetz@6458 1054 // access_flags = method->access_flags();
goetz@6458 1055 // Load access flags.
goetz@6458 1056 assert(access_flags->is_nonvolatile(),
goetz@6458 1057 "access_flags must be in a non-volatile register");
goetz@6458 1058 // Type check.
goetz@6660 1059 // TODO: PPC port: assert(4 == sizeof(AccessFlags), "unexpected field size");
goetz@6458 1060 __ lwz(access_flags, method_(access_flags));
goetz@6458 1061
goetz@6458 1062 // We don't want to reload R19_method and access_flags after calls
goetz@6458 1063 // to some helper functions.
goetz@6458 1064 assert(R19_method->is_nonvolatile(), "R19_method must be a non-volatile register");
goetz@6458 1065
goetz@6458 1066 // Check for synchronized methods. Must happen AFTER invocation counter
goetz@6458 1067 // check, so method is not locked if counter overflows.
goetz@6458 1068
goetz@6458 1069 {
goetz@6458 1070 Label method_is_not_synced;
goetz@6458 1071 // Is_synced is still alive.
goetz@6458 1072 assert(is_synced->is_nonvolatile(), "is_synced must be non-volatile");
goetz@6458 1073 __ bfalse(is_synced, method_is_not_synced);
goetz@6458 1074
goetz@6458 1075 lock_method();
goetz@6458 1076 // Reload method, it may have moved.
goetz@6458 1077 __ ld(R19_method, state_(_method));
goetz@6458 1078
goetz@6458 1079 __ BIND(method_is_not_synced);
goetz@6458 1080 }
goetz@6458 1081
goetz@6458 1082 // jvmti/jvmpi support
goetz@6458 1083 __ notify_method_entry();
goetz@6458 1084
goetz@6458 1085 // Reload method, it may have moved.
goetz@6458 1086 __ ld(R19_method, state_(_method));
goetz@6458 1087
goetz@6458 1088 //=============================================================================
goetz@6458 1089 // Get and call the signature handler
goetz@6458 1090
goetz@6458 1091 __ ld(signature_handler_fd, method_(signature_handler));
goetz@6458 1092 Label call_signature_handler;
goetz@6458 1093
goetz@6458 1094 __ cmpdi(CCR0, signature_handler_fd, 0);
goetz@6458 1095 __ bne(CCR0, call_signature_handler);
goetz@6458 1096
goetz@6458 1097 // Method has never been called. Either generate a specialized
goetz@6458 1098 // handler or point to the slow one.
goetz@6458 1099 //
goetz@6458 1100 // Pass parameter 'false' to avoid exception check in call_VM.
goetz@6458 1101 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R19_method, false);
goetz@6458 1102
goetz@6458 1103 // Check for an exception while looking up the target method. If we
goetz@6458 1104 // incurred one, bail.
goetz@6458 1105 __ ld(pending_exception, thread_(pending_exception));
goetz@6458 1106 __ cmpdi(CCR0, pending_exception, 0);
goetz@6458 1107 __ bne(CCR0, exception_return_sync_check); // has pending exception
goetz@6458 1108
goetz@6458 1109 // reload method
goetz@6458 1110 __ ld(R19_method, state_(_method));
goetz@6458 1111
goetz@6458 1112 // Reload signature handler, it may have been created/assigned in the meanwhile
goetz@6458 1113 __ ld(signature_handler_fd, method_(signature_handler));
goetz@6458 1114
goetz@6458 1115 __ BIND(call_signature_handler);
goetz@6458 1116
goetz@6458 1117 // Before we call the signature handler we push a new frame to
goetz@6458 1118 // protect the interpreter frame volatile registers when we return
goetz@6458 1119 // from jni but before we can get back to Java.
goetz@6458 1120
goetz@6458 1121 // First set the frame anchor while the SP/FP registers are
goetz@6458 1122 // convenient and the slow signature handler can use this same frame
goetz@6458 1123 // anchor.
goetz@6458 1124
goetz@6458 1125 // We have a TOP_IJAVA_FRAME here, which belongs to us.
goetz@6458 1126 __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
goetz@6458 1127
goetz@6458 1128 // Now the interpreter frame (and its call chain) have been
goetz@6458 1129 // invalidated and flushed. We are now protected against eager
goetz@6458 1130 // being enabled in native code. Even if it goes eager the
goetz@6458 1131 // registers will be reloaded as clean and we will invalidate after
goetz@6458 1132 // the call so no spurious flush should be possible.
goetz@6458 1133
goetz@6458 1134 // Call signature handler and pass locals address.
goetz@6458 1135 //
goetz@6458 1136 // Our signature handlers copy required arguments to the C stack
goetz@6458 1137 // (outgoing C args), R3_ARG1 to R10_ARG8, and F1_ARG1 to
goetz@6458 1138 // F13_ARG13.
goetz@6458 1139 __ mr(R3_ARG1, R18_locals);
goetz@6511 1140 #if !defined(ABI_ELFv2)
goetz@6458 1141 __ ld(signature_handler_fd, 0, signature_handler_fd);
goetz@6511 1142 #endif
goetz@6458 1143 __ call_stub(signature_handler_fd);
goetz@6458 1144 // reload method
goetz@6458 1145 __ ld(R19_method, state_(_method));
goetz@6458 1146
goetz@6458 1147 // Remove the register parameter varargs slots we allocated in
goetz@6458 1148 // compute_interpreter_state. SP+16 ends up pointing to the ABI
goetz@6458 1149 // outgoing argument area.
goetz@6458 1150 //
goetz@6458 1151 // Not needed on PPC64.
goetz@6458 1152 //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
goetz@6458 1153
goetz@6458 1154 assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
goetz@6458 1155 // Save across call to native method.
goetz@6458 1156 __ mr(result_handler_addr, R3_RET);
goetz@6458 1157
goetz@6458 1158 // Set up fixed parameters and call the native method.
goetz@6458 1159 // If the method is static, get mirror into R4_ARG2.
goetz@6458 1160
goetz@6458 1161 {
goetz@6458 1162 Label method_is_not_static;
goetz@6458 1163 // access_flags is non-volatile and still, no need to restore it
goetz@6458 1164
goetz@6458 1165 // restore access flags
goetz@6458 1166 __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT);
goetz@6458 1167 __ bfalse(CCR0, method_is_not_static);
goetz@6458 1168
goetz@6458 1169 // constants = method->constants();
goetz@6458 1170 __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
goetz@6458 1171 __ ld(R11_scratch1/*constants*/, in_bytes(ConstMethod::constants_offset()), R11_scratch1);
goetz@6458 1172 // pool_holder = method->constants()->pool_holder();
goetz@6458 1173 __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(),
goetz@6458 1174 R11_scratch1/*constants*/);
goetz@6458 1175
goetz@6458 1176 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
goetz@6458 1177
goetz@6458 1178 // mirror = pool_holder->klass_part()->java_mirror();
goetz@6458 1179 __ ld(R0/*mirror*/, mirror_offset, R11_scratch1/*pool_holder*/);
goetz@6458 1180 // state->_native_mirror = mirror;
goetz@6458 1181 __ std(R0/*mirror*/, state_(_oop_temp));
goetz@6458 1182 // R4_ARG2 = &state->_oop_temp;
goetz@6458 1183 __ addir(R4_ARG2, state_(_oop_temp));
goetz@6458 1184
goetz@6458 1185 __ BIND(method_is_not_static);
goetz@6458 1186 }
goetz@6458 1187
goetz@6458 1188 // At this point, arguments have been copied off the stack into
goetz@6458 1189 // their JNI positions. Oops are boxed in-place on the stack, with
goetz@6458 1190 // handles copied to arguments. The result handler address is in a
goetz@6458 1191 // register.
goetz@6458 1192
goetz@6458 1193 // pass JNIEnv address as first parameter
goetz@6458 1194 __ addir(R3_ARG1, thread_(jni_environment));
goetz@6458 1195
goetz@6458 1196 // Load the native_method entry before we change the thread state.
goetz@6458 1197 __ ld(native_method_fd, method_(native_function));
goetz@6458 1198
goetz@6458 1199 //=============================================================================
goetz@6458 1200 // Transition from _thread_in_Java to _thread_in_native. As soon as
goetz@6458 1201 // we make this change the safepoint code needs to be certain that
goetz@6458 1202 // the last Java frame we established is good. The pc in that frame
goetz@6458 1203 // just needs to be near here not an actual return address.
goetz@6458 1204
goetz@6458 1205 // We use release_store_fence to update values like the thread state, where
goetz@6458 1206 // we don't want the current thread to continue until all our prior memory
goetz@6458 1207 // accesses (including the new thread state) are visible to other threads.
goetz@6458 1208 __ li(R0, _thread_in_native);
goetz@6458 1209 __ release();
goetz@6458 1210
goetz@6458 1211 // TODO: PPC port: assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
goetz@6458 1212 __ stw(R0, thread_(thread_state));
goetz@6458 1213
goetz@6458 1214 if (UseMembar) {
goetz@6458 1215 __ fence();
goetz@6458 1216 }
goetz@6458 1217
goetz@6458 1218 //=============================================================================
goetz@6458 1219 // Call the native method. Argument registers must not have been
goetz@6458 1220 // overwritten since "__ call_stub(signature_handler);" (except for
goetz@6458 1221 // ARG1 and ARG2 for static methods)
goetz@6458 1222 __ call_c(native_method_fd);
goetz@6458 1223
goetz@6458 1224 __ std(R3_RET, state_(_native_lresult));
goetz@6458 1225 __ stfd(F1_RET, state_(_native_fresult));
goetz@6458 1226
goetz@6458 1227 // The frame_manager_lr field, which we use for setting the last
goetz@6458 1228 // java frame, gets overwritten by the signature handler. Restore
goetz@6458 1229 // it now.
goetz@6458 1230 __ get_PC_trash_LR(R11_scratch1);
goetz@6458 1231 __ std(R11_scratch1, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1232
goetz@6458 1233 // Because of GC R19_method may no longer be valid.
goetz@6458 1234
goetz@6458 1235 // Block, if necessary, before resuming in _thread_in_Java state.
goetz@6458 1236 // In order for GC to work, don't clear the last_Java_sp until after
goetz@6458 1237 // blocking.
goetz@6458 1238
goetz@6458 1239
goetz@6458 1240
goetz@6458 1241 //=============================================================================
goetz@6458 1242 // Switch thread to "native transition" state before reading the
goetz@6458 1243 // synchronization state. This additional state is necessary
goetz@6458 1244 // because reading and testing the synchronization state is not
goetz@6458 1245 // atomic w.r.t. GC, as this scenario demonstrates: Java thread A,
goetz@6458 1246 // in _thread_in_native state, loads _not_synchronized and is
goetz@6458 1247 // preempted. VM thread changes sync state to synchronizing and
goetz@6458 1248 // suspends threads for GC. Thread A is resumed to finish this
goetz@6458 1249 // native method, but doesn't block here since it didn't see any
goetz@6458 1250 // synchronization in progress, and escapes.
goetz@6458 1251
goetz@6458 1252 // We use release_store_fence to update values like the thread state, where
goetz@6458 1253 // we don't want the current thread to continue until all our prior memory
goetz@6458 1254 // accesses (including the new thread state) are visible to other threads.
goetz@6458 1255 __ li(R0/*thread_state*/, _thread_in_native_trans);
goetz@6458 1256 __ release();
goetz@6458 1257 __ stw(R0/*thread_state*/, thread_(thread_state));
goetz@6458 1258 if (UseMembar) {
goetz@6458 1259 __ fence();
goetz@6458 1260 }
goetz@6458 1261 // Write serialization page so that the VM thread can do a pseudo remote
goetz@6458 1262 // membar. We use the current thread pointer to calculate a thread
goetz@6458 1263 // specific offset to write to within the page. This minimizes bus
goetz@6458 1264 // traffic due to cache line collision.
goetz@6458 1265 else {
goetz@6458 1266 __ serialize_memory(R16_thread, R11_scratch1, R12_scratch2);
goetz@6458 1267 }
goetz@6458 1268
goetz@6458 1269 // Now before we return to java we must look for a current safepoint
goetz@6458 1270 // (a new safepoint can not start since we entered native_trans).
goetz@6458 1271 // We must check here because a current safepoint could be modifying
goetz@6458 1272 // the callers registers right this moment.
goetz@6458 1273
goetz@6458 1274 // Acquire isn't strictly necessary here because of the fence, but
goetz@6458 1275 // sync_state is declared to be volatile, so we do it anyway.
goetz@6458 1276 __ load_const(sync_state_addr, SafepointSynchronize::address_of_state());
goetz@6458 1277
goetz@6458 1278 // TODO: PPC port: assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
goetz@6458 1279 __ lwz(sync_state, 0, sync_state_addr);
goetz@6458 1280
goetz@6458 1281 // TODO: PPC port: assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
goetz@6458 1282 __ lwz(suspend_flags, thread_(suspend_flags));
goetz@6458 1283
goetz@6458 1284 __ acquire();
goetz@6458 1285
goetz@6458 1286 Label sync_check_done;
goetz@6458 1287 Label do_safepoint;
goetz@6458 1288 // No synchronization in progress nor yet synchronized
goetz@6458 1289 __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
goetz@6458 1290 // not suspended
goetz@6458 1291 __ cmpwi(CCR1, suspend_flags, 0);
goetz@6458 1292
goetz@6458 1293 __ bne(CCR0, do_safepoint);
goetz@6458 1294 __ beq(CCR1, sync_check_done);
goetz@6458 1295 __ bind(do_safepoint);
goetz@6458 1296 // Block. We do the call directly and leave the current
goetz@6458 1297 // last_Java_frame setup undisturbed. We must save any possible
goetz@6458 1298 // native result acrosss the call. No oop is present
goetz@6458 1299
goetz@6458 1300 __ mr(R3_ARG1, R16_thread);
goetz@6511 1301 #if defined(ABI_ELFv2)
goetz@6511 1302 __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
goetz@6511 1303 relocInfo::none);
goetz@6511 1304 #else
goetz@6458 1305 __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
goetz@6458 1306 relocInfo::none);
goetz@6511 1307 #endif
goetz@6458 1308 __ bind(sync_check_done);
goetz@6458 1309
goetz@6458 1310 //=============================================================================
goetz@6458 1311 // <<<<<< Back in Interpreter Frame >>>>>
goetz@6458 1312
goetz@6458 1313 // We are in thread_in_native_trans here and back in the normal
goetz@6458 1314 // interpreter frame. We don't have to do anything special about
goetz@6458 1315 // safepoints and we can switch to Java mode anytime we are ready.
goetz@6458 1316
goetz@6458 1317 // Note: frame::interpreter_frame_result has a dependency on how the
goetz@6458 1318 // method result is saved across the call to post_method_exit. For
goetz@6458 1319 // native methods it assumes that the non-FPU/non-void result is
goetz@6458 1320 // saved in _native_lresult and a FPU result in _native_fresult. If
goetz@6458 1321 // this changes then the interpreter_frame_result implementation
goetz@6458 1322 // will need to be updated too.
goetz@6458 1323
goetz@6458 1324 // On PPC64, we have stored the result directly after the native call.
goetz@6458 1325
goetz@6458 1326 //=============================================================================
goetz@6458 1327 // back in Java
goetz@6458 1328
goetz@6458 1329 // We use release_store_fence to update values like the thread state, where
goetz@6458 1330 // we don't want the current thread to continue until all our prior memory
goetz@6458 1331 // accesses (including the new thread state) are visible to other threads.
goetz@6458 1332 __ li(R0/*thread_state*/, _thread_in_Java);
goetz@6458 1333 __ release();
goetz@6458 1334 __ stw(R0/*thread_state*/, thread_(thread_state));
goetz@6458 1335 if (UseMembar) {
goetz@6458 1336 __ fence();
goetz@6458 1337 }
goetz@6458 1338
goetz@6458 1339 __ reset_last_Java_frame();
goetz@6458 1340
goetz@6458 1341 // Reload GR27_method, call killed it. We can't look at
goetz@6458 1342 // state->_method until we're back in java state because in java
goetz@6458 1343 // state gc can't happen until we get to a safepoint.
goetz@6458 1344 //
goetz@6458 1345 // We've set thread_state to _thread_in_Java already, so restoring
goetz@6458 1346 // R19_method from R14_state works; R19_method is invalid, because
goetz@6458 1347 // GC may have happened.
goetz@6458 1348 __ ld(R19_method, state_(_method)); // reload method, may have moved
goetz@6458 1349
goetz@6458 1350 // jvmdi/jvmpi support. Whether we've got an exception pending or
goetz@6458 1351 // not, and whether unlocking throws an exception or not, we notify
goetz@6458 1352 // on native method exit. If we do have an exception, we'll end up
goetz@6458 1353 // in the caller's context to handle it, so if we don't do the
goetz@6458 1354 // notify here, we'll drop it on the floor.
goetz@6458 1355
goetz@6458 1356 __ notify_method_exit(true/*native method*/,
goetz@6512 1357 ilgl /*illegal state (not used for native methods)*/,
goetz@6512 1358 InterpreterMacroAssembler::NotifyJVMTI,
goetz@6512 1359 false /*check_exceptions*/);
goetz@6458 1360
goetz@6458 1361 //=============================================================================
goetz@6458 1362 // Handle exceptions
goetz@6458 1363
goetz@6458 1364 // See if we must unlock.
goetz@6458 1365 //
goetz@6458 1366 {
goetz@6458 1367 Label method_is_not_synced;
goetz@6458 1368 // is_synced is still alive
goetz@6458 1369 assert(is_synced->is_nonvolatile(), "is_synced must be non-volatile");
goetz@6458 1370 __ bfalse(is_synced, method_is_not_synced);
goetz@6458 1371
goetz@6458 1372 unlock_method();
goetz@6458 1373
goetz@6458 1374 __ bind(method_is_not_synced);
goetz@6458 1375 }
goetz@6458 1376
goetz@6458 1377 // Reset active handles after returning from native.
goetz@6458 1378 // thread->active_handles()->clear();
goetz@6458 1379 __ ld(active_handles, thread_(active_handles));
goetz@6458 1380 // JNIHandleBlock::_top is an int.
goetz@6458 1381 // TODO: PPC port: assert(4 == JNIHandleBlock::top_size_in_bytes(), "unexpected field size");
goetz@6458 1382 __ li(R0, 0);
goetz@6458 1383 __ stw(R0, JNIHandleBlock::top_offset_in_bytes(), active_handles);
goetz@6458 1384
goetz@6458 1385 Label no_pending_exception_from_native_method;
goetz@6458 1386 __ ld(R0/*pending_exception*/, thread_(pending_exception));
goetz@6458 1387 __ cmpdi(CCR0, R0/*pending_exception*/, 0);
goetz@6458 1388 __ beq(CCR0, no_pending_exception_from_native_method);
goetz@6458 1389
goetz@6458 1390
goetz@6458 1391 //-----------------------------------------------------------------------------
goetz@6458 1392 // An exception is pending. We call into the runtime only if the
goetz@6458 1393 // caller was not interpreted. If it was interpreted the
goetz@6458 1394 // interpreter will do the correct thing. If it isn't interpreted
goetz@6458 1395 // (call stub/compiled code) we will change our return and continue.
goetz@6458 1396 __ BIND(exception_return);
goetz@6458 1397
goetz@6458 1398 Label return_to_initial_caller_with_pending_exception;
goetz@6458 1399 __ cmpdi(CCR0, R15_prev_state, 0);
goetz@6458 1400 __ beq(CCR0, return_to_initial_caller_with_pending_exception);
goetz@6458 1401
goetz@6458 1402 // We are returning to an interpreter activation, just pop the state,
goetz@6458 1403 // pop our frame, leave the exception pending, and return.
goetz@6458 1404 __ pop_interpreter_state(/*prev_state_may_be_0=*/false);
goetz@6458 1405 __ pop_interpreter_frame(R11_scratch1, R12_scratch2, R21_tmp1 /* set to return pc */, R22_tmp2);
goetz@6458 1406 __ mtlr(R21_tmp1);
goetz@6458 1407 __ blr();
goetz@6458 1408
goetz@6458 1409 __ BIND(exception_return_sync_check);
goetz@6458 1410
goetz@6458 1411 assert(is_synced->is_nonvolatile(), "is_synced must be non-volatile");
goetz@6458 1412 __ bfalse(is_synced, exception_return);
goetz@6458 1413 unlock_method();
goetz@6458 1414 __ b(exception_return);
goetz@6458 1415
goetz@6458 1416
goetz@6458 1417 __ BIND(return_to_initial_caller_with_pending_exception);
goetz@6458 1418 // We are returning to a c2i-adapter / call-stub, get the address of the
goetz@6458 1419 // exception handler, pop the frame and return to the handler.
goetz@6458 1420
goetz@6458 1421 // First, pop to caller's frame.
goetz@6458 1422 __ pop_interpreter_frame(R11_scratch1, R12_scratch2, R21_tmp1 /* set to return pc */, R22_tmp2);
goetz@6458 1423
goetz@6511 1424 __ push_frame_reg_args(0, R11_scratch1);
goetz@6458 1425 // Get the address of the exception handler.
goetz@6458 1426 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
goetz@6458 1427 R16_thread,
goetz@6458 1428 R21_tmp1 /* return pc */);
goetz@6458 1429 __ pop_frame();
goetz@6458 1430
goetz@6458 1431 // Load the PC of the the exception handler into LR.
goetz@6458 1432 __ mtlr(R3_RET);
goetz@6458 1433
goetz@6458 1434 // Load exception into R3_ARG1 and clear pending exception in thread.
goetz@6458 1435 __ ld(R3_ARG1/*exception*/, thread_(pending_exception));
goetz@6458 1436 __ li(R4_ARG2, 0);
goetz@6458 1437 __ std(R4_ARG2, thread_(pending_exception));
goetz@6458 1438
goetz@6458 1439 // Load the original return pc into R4_ARG2.
goetz@6458 1440 __ mr(R4_ARG2/*issuing_pc*/, R21_tmp1);
goetz@6458 1441
goetz@6458 1442 // Resize frame to get rid of a potential extension.
goetz@6458 1443 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 1444
goetz@6458 1445 // Return to exception handler.
goetz@6458 1446 __ blr();
goetz@6458 1447
goetz@6458 1448
goetz@6458 1449 //-----------------------------------------------------------------------------
goetz@6458 1450 // No exception pending.
goetz@6458 1451 __ BIND(no_pending_exception_from_native_method);
goetz@6458 1452
goetz@6458 1453 // Move native method result back into proper registers and return.
goetz@6458 1454 // Invoke result handler (may unbox/promote).
goetz@6458 1455 __ ld(R3_RET, state_(_native_lresult));
goetz@6458 1456 __ lfd(F1_RET, state_(_native_fresult));
goetz@6458 1457 __ call_stub(result_handler_addr);
goetz@6458 1458
goetz@6458 1459 // We have created a new BytecodeInterpreter object, now we must destroy it.
goetz@6458 1460 //
goetz@6458 1461 // Restore previous R14_state and caller's SP. R15_prev_state may
goetz@6458 1462 // be 0 here, because our caller may be the call_stub or compiled
goetz@6458 1463 // code.
goetz@6458 1464 __ pop_interpreter_state(/*prev_state_may_be_0=*/true);
goetz@6458 1465 __ pop_interpreter_frame(R11_scratch1, R12_scratch2, R21_tmp1 /* set to return pc */, R22_tmp2);
goetz@6458 1466 // Resize frame to get rid of a potential extension.
goetz@6458 1467 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 1468
goetz@6458 1469 // Must use the return pc which was loaded from the caller's frame
goetz@6458 1470 // as the VM uses return-pc-patching for deoptimization.
goetz@6458 1471 __ mtlr(R21_tmp1);
goetz@6458 1472 __ blr();
goetz@6458 1473
goetz@6458 1474
goetz@6458 1475
goetz@6458 1476 //=============================================================================
goetz@6458 1477 // We encountered an exception while computing the interpreter
goetz@6458 1478 // state, so R14_state isn't valid. Act as if we just returned from
goetz@6458 1479 // the callee method with a pending exception.
goetz@6458 1480 __ BIND(stack_overflow_return);
goetz@6458 1481
goetz@6458 1482 //
goetz@6458 1483 // Register state:
goetz@6458 1484 // R14_state invalid; trashed by compute_interpreter_state
goetz@6458 1485 // R15_prev_state valid, but may be 0
goetz@6458 1486 //
goetz@6458 1487 // R1_SP valid, points to caller's SP; wasn't yet updated by
goetz@6458 1488 // compute_interpreter_state
goetz@6458 1489 //
goetz@6458 1490
goetz@6458 1491 // Create exception oop and make it pending.
goetz@6458 1492
goetz@6458 1493 // Throw the exception via RuntimeStub "throw_StackOverflowError_entry".
goetz@6458 1494 //
goetz@6458 1495 // Previously, we called C-Code directly. As a consequence, a
goetz@6458 1496 // possible GC tried to process the argument oops of the top frame
goetz@6458 1497 // (see RegisterMap::clear, which sets the corresponding flag to
goetz@6458 1498 // true). This lead to crashes because:
goetz@6458 1499 // 1. The top register map did not contain locations for the argument registers
goetz@6458 1500 // 2. The arguments are dead anyway, could be already overwritten in the worst case
goetz@6458 1501 // Solution: Call via special runtime stub that pushes it's own
goetz@6458 1502 // frame. This runtime stub has the flag "CodeBlob::caller_must_gc_arguments()"
goetz@6458 1503 // set to "false", what prevents the dead arguments getting GC'd.
goetz@6458 1504 //
goetz@6458 1505 // 2 cases exist:
goetz@6458 1506 // 1. We were called by the c2i adapter / call stub
goetz@6458 1507 // 2. We were called by the frame manager
goetz@6458 1508 //
goetz@6458 1509 // Both cases are handled by this code:
goetz@6458 1510 // 1. - initial_caller_sp was saved in both cases on entry, so it's safe to load it back even if it was not changed.
goetz@6458 1511 // - control flow will be:
goetz@6458 1512 // throw_stackoverflow_stub->VM->throw_stackoverflow_stub->forward_excep->excp_blob of caller method
goetz@6458 1513 // 2. - control flow will be:
goetz@6458 1514 // throw_stackoverflow_stub->VM->throw_stackoverflow_stub->forward_excep->rethrow_excp_entry of frame manager->resume_method
goetz@6458 1515 // Since we restored the caller SP above, the rethrow_excp_entry can restore the original interpreter state
goetz@6458 1516 // registers using the stack and resume the calling method with a pending excp.
goetz@6458 1517
goetz@6458 1518 // Pop any c2i extension from the stack, restore LR just to be sure
goetz@6458 1519 __ ld(R0, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1520 __ mtlr(R0);
goetz@6458 1521 // Resize frame to get rid of a potential extension.
goetz@6458 1522 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 1523
goetz@6501 1524 assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
goetz@6458 1525 // Load target address of the runtime stub.
goetz@6458 1526 __ load_const(R12_scratch2, (StubRoutines::throw_StackOverflowError_entry()));
goetz@6458 1527 __ mtctr(R12_scratch2);
goetz@6458 1528 __ bctr();
goetz@6458 1529
goetz@6458 1530
goetz@6458 1531 //=============================================================================
goetz@6458 1532 // Counter overflow.
goetz@6458 1533
goetz@6458 1534 if (inc_counter) {
goetz@6458 1535 // Handle invocation counter overflow
goetz@6458 1536 __ bind(invocation_counter_overflow);
goetz@6458 1537
goetz@6458 1538 generate_counter_overflow(continue_after_compile);
goetz@6458 1539 }
goetz@6458 1540
goetz@6458 1541 native_entry = entry;
goetz@6458 1542 return entry;
goetz@6458 1543 }
goetz@6458 1544
goetz@6458 1545 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
goetz@6458 1546 // No special entry points that preclude compilation.
goetz@6458 1547 return true;
goetz@6458 1548 }
goetz@6458 1549
goetz@6458 1550 // Unlock the current method.
goetz@6458 1551 //
goetz@6458 1552 void CppInterpreterGenerator::unlock_method(void) {
goetz@6458 1553 // Find preallocated monitor and unlock method. Method monitor is
goetz@6458 1554 // the first one.
goetz@6458 1555
goetz@6458 1556 // Registers alive
goetz@6458 1557 // R14_state
goetz@6458 1558 //
goetz@6458 1559 // Registers updated
goetz@6458 1560 // volatiles
goetz@6458 1561 //
goetz@6458 1562 const Register monitor = R4_ARG2;
goetz@6458 1563
goetz@6458 1564 // Pass address of initial monitor we allocated.
goetz@6458 1565 //
goetz@6458 1566 // First monitor.
goetz@6458 1567 __ addi(monitor, R14_state, -frame::interpreter_frame_monitor_size_in_bytes());
goetz@6458 1568
goetz@6458 1569 // Unlock method
goetz@6458 1570 __ unlock_object(monitor);
goetz@6458 1571 }
goetz@6458 1572
goetz@6458 1573 // Lock the current method.
goetz@6458 1574 //
goetz@6458 1575 void CppInterpreterGenerator::lock_method(void) {
goetz@6458 1576 // Find preallocated monitor and lock method. Method monitor is the
goetz@6458 1577 // first one.
goetz@6458 1578
goetz@6458 1579 //
goetz@6458 1580 // Registers alive
goetz@6458 1581 // R14_state
goetz@6458 1582 //
goetz@6458 1583 // Registers updated
goetz@6458 1584 // volatiles
goetz@6458 1585 //
goetz@6458 1586
goetz@6458 1587 const Register monitor = R4_ARG2;
goetz@6458 1588 const Register object = R5_ARG3;
goetz@6458 1589
goetz@6458 1590 // Pass address of initial monitor we allocated.
goetz@6458 1591 __ addi(monitor, R14_state, -frame::interpreter_frame_monitor_size_in_bytes());
goetz@6458 1592
goetz@6458 1593 // Pass object address.
goetz@6458 1594 __ ld(object, BasicObjectLock::obj_offset_in_bytes(), monitor);
goetz@6458 1595
goetz@6458 1596 // Lock method.
goetz@6458 1597 __ lock_object(monitor, object);
goetz@6458 1598 }
goetz@6458 1599
goetz@6458 1600 // Generate code for handling resuming a deopted method.
goetz@6458 1601 void CppInterpreterGenerator::generate_deopt_handling(Register result_index) {
goetz@6458 1602
goetz@6458 1603 //=============================================================================
goetz@6458 1604 // Returning from a compiled method into a deopted method. The
goetz@6458 1605 // bytecode at the bcp has completed. The result of the bytecode is
goetz@6458 1606 // in the native abi (the tosca for the template based
goetz@6458 1607 // interpreter). Any stack space that was used by the bytecode that
goetz@6458 1608 // has completed has been removed (e.g. parameters for an invoke) so
goetz@6458 1609 // all that we have to do is place any pending result on the
goetz@6458 1610 // expression stack and resume execution on the next bytecode.
goetz@6458 1611
goetz@6458 1612 Label return_from_deopt_common;
goetz@6458 1613
goetz@6458 1614 // R3_RET and F1_RET are live here! Load the array index of the
goetz@6458 1615 // required result stub address and continue at return_from_deopt_common.
goetz@6458 1616
goetz@6458 1617 // Deopt needs to jump to here to enter the interpreter (return a result).
goetz@6458 1618 deopt_frame_manager_return_atos = __ pc();
goetz@6458 1619 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_OBJECT));
goetz@6458 1620 __ b(return_from_deopt_common);
goetz@6458 1621
goetz@6458 1622 deopt_frame_manager_return_btos = __ pc();
goetz@6458 1623 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_BOOLEAN));
goetz@6458 1624 __ b(return_from_deopt_common);
goetz@6458 1625
goetz@6458 1626 deopt_frame_manager_return_itos = __ pc();
goetz@6458 1627 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_INT));
goetz@6458 1628 __ b(return_from_deopt_common);
goetz@6458 1629
goetz@6458 1630 deopt_frame_manager_return_ltos = __ pc();
goetz@6458 1631 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_LONG));
goetz@6458 1632 __ b(return_from_deopt_common);
goetz@6458 1633
goetz@6458 1634 deopt_frame_manager_return_ftos = __ pc();
goetz@6458 1635 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_FLOAT));
goetz@6458 1636 __ b(return_from_deopt_common);
goetz@6458 1637
goetz@6458 1638 deopt_frame_manager_return_dtos = __ pc();
goetz@6458 1639 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_DOUBLE));
goetz@6458 1640 __ b(return_from_deopt_common);
goetz@6458 1641
goetz@6458 1642 deopt_frame_manager_return_vtos = __ pc();
goetz@6458 1643 __ li(result_index, AbstractInterpreter::BasicType_as_index(T_VOID));
goetz@6458 1644 // Last one, fall-through to return_from_deopt_common.
goetz@6458 1645
goetz@6458 1646 // Deopt return common. An index is present that lets us move any
goetz@6458 1647 // possible result being return to the interpreter's stack.
goetz@6458 1648 //
goetz@6458 1649 __ BIND(return_from_deopt_common);
goetz@6458 1650
goetz@6458 1651 }
goetz@6458 1652
goetz@6458 1653 // Generate the code to handle a more_monitors message from the c++ interpreter.
goetz@6458 1654 void CppInterpreterGenerator::generate_more_monitors() {
goetz@6458 1655
goetz@6458 1656 //
goetz@6458 1657 // Registers alive
goetz@6458 1658 // R16_thread - JavaThread*
goetz@6458 1659 // R15_prev_state - previous BytecodeInterpreter or 0
goetz@6458 1660 // R14_state - BytecodeInterpreter* address of receiver's interpreter state
goetz@6458 1661 // R1_SP - old stack pointer
goetz@6458 1662 //
goetz@6458 1663 // Registers updated
goetz@6458 1664 // R1_SP - new stack pointer
goetz@6458 1665 //
goetz@6458 1666
goetz@6458 1667 // Very-local scratch registers.
goetz@6458 1668 const Register old_tos = R21_tmp1;
goetz@6458 1669 const Register new_tos = R22_tmp2;
goetz@6458 1670 const Register stack_base = R23_tmp3;
goetz@6458 1671 const Register stack_limit = R24_tmp4;
goetz@6458 1672 const Register slot = R25_tmp5;
goetz@6458 1673 const Register n_slots = R25_tmp5;
goetz@6458 1674
goetz@6458 1675 // Interpreter state fields.
goetz@6458 1676 const Register msg = R24_tmp4;
goetz@6458 1677
goetz@6458 1678 // Load up relevant interpreter state.
goetz@6458 1679
goetz@6458 1680 __ ld(stack_base, state_(_stack_base)); // Old stack_base
goetz@6458 1681 __ ld(old_tos, state_(_stack)); // Old tos
goetz@6458 1682 __ ld(stack_limit, state_(_stack_limit)); // Old stack_limit
goetz@6458 1683
goetz@6458 1684 // extracted monitor_size
goetz@6458 1685 int monitor_size = frame::interpreter_frame_monitor_size_in_bytes();
goetz@6458 1686 assert(Assembler::is_aligned((unsigned int)monitor_size,
goetz@6458 1687 (unsigned int)frame::alignment_in_bytes),
goetz@6458 1688 "size of a monitor must respect alignment of SP");
goetz@6458 1689
goetz@6458 1690 // Save and restore top LR
goetz@6458 1691 __ ld(R12_scratch2, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1692 __ resize_frame(-monitor_size, R11_scratch1);// Allocate space for new monitor
goetz@6458 1693 __ std(R12_scratch2, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1694 // Initial_caller_sp is used as unextended_sp for non initial callers.
goetz@6458 1695 __ std(R1_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
goetz@6458 1696 __ addi(stack_base, stack_base, -monitor_size); // New stack_base
goetz@6458 1697 __ addi(new_tos, old_tos, -monitor_size); // New tos
goetz@6458 1698 __ addi(stack_limit, stack_limit, -monitor_size); // New stack_limit
goetz@6458 1699
goetz@6458 1700 __ std(R1_SP, state_(_last_Java_sp)); // Update frame_bottom
goetz@6458 1701
goetz@6458 1702 __ std(stack_base, state_(_stack_base)); // Update stack_base
goetz@6458 1703 __ std(new_tos, state_(_stack)); // Update tos
goetz@6458 1704 __ std(stack_limit, state_(_stack_limit)); // Update stack_limit
goetz@6458 1705
goetz@6458 1706 __ li(msg, BytecodeInterpreter::got_monitors); // Tell interpreter we allocated the lock
goetz@6458 1707 __ stw(msg, state_(_msg));
goetz@6458 1708
goetz@6458 1709 // Shuffle expression stack down. Recall that stack_base points
goetz@6458 1710 // just above the new expression stack bottom. Old_tos and new_tos
goetz@6458 1711 // are used to scan thru the old and new expression stacks.
goetz@6458 1712
goetz@6458 1713 Label copy_slot, copy_slot_finished;
goetz@6458 1714 __ sub(n_slots, stack_base, new_tos);
goetz@6458 1715 __ srdi_(n_slots, n_slots, LogBytesPerWord); // compute number of slots to copy
goetz@6458 1716 assert(LogBytesPerWord == 3, "conflicts assembler instructions");
goetz@6458 1717 __ beq(CCR0, copy_slot_finished); // nothing to copy
goetz@6458 1718
goetz@6458 1719 __ mtctr(n_slots);
goetz@6458 1720
goetz@6458 1721 // loop
goetz@6458 1722 __ bind(copy_slot);
goetz@6458 1723 __ ldu(slot, BytesPerWord, old_tos); // slot = *++old_tos;
goetz@6458 1724 __ stdu(slot, BytesPerWord, new_tos); // *++new_tos = slot;
goetz@6458 1725 __ bdnz(copy_slot);
goetz@6458 1726
goetz@6458 1727 __ bind(copy_slot_finished);
goetz@6458 1728
goetz@6458 1729 // Restart interpreter
goetz@6458 1730 __ li(R0, 0);
goetz@6458 1731 __ std(R0, BasicObjectLock::obj_offset_in_bytes(), stack_base); // Mark lock as unused
goetz@6458 1732 }
goetz@6458 1733
goetz@6458 1734 address CppInterpreterGenerator::generate_normal_entry(void) {
goetz@6458 1735 if (interpreter_frame_manager != NULL) return interpreter_frame_manager;
goetz@6458 1736
goetz@6458 1737 address entry = __ pc();
goetz@6458 1738
goetz@6458 1739 address return_from_native_pc = (address) NULL;
goetz@6458 1740
goetz@6458 1741 // Initial entry to frame manager (from call_stub or c2i_adapter)
goetz@6458 1742
goetz@6458 1743 //
goetz@6458 1744 // Registers alive
goetz@6458 1745 // R16_thread - JavaThread*
goetz@6458 1746 // R19_method - callee's Method (method to be invoked)
goetz@6458 1747 // R17_tos - address of sender tos (prepushed)
goetz@6458 1748 // R1_SP - SP prepared by call stub such that caller's outgoing args are near top
goetz@6458 1749 // LR - return address to caller (call_stub or c2i_adapter)
goetz@6458 1750 // R21_sender_SP - initial caller sp
goetz@6458 1751 //
goetz@6458 1752 // Registers updated
goetz@6458 1753 // R15_prev_state - 0
goetz@6458 1754 //
goetz@6458 1755 // Stack layout at this point:
goetz@6458 1756 //
goetz@6458 1757 // 0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 1758 // alignment (optional)
goetz@6458 1759 // [outgoing Java arguments] <-- R17_tos
goetz@6458 1760 // ...
goetz@6458 1761 // PARENT [PARENT_IJAVA_FRAME_ABI]
goetz@6458 1762 // ...
goetz@6458 1763 //
goetz@6458 1764
goetz@6458 1765 // Save initial_caller_sp to caller's abi.
goetz@6458 1766 // The caller frame must be resized before returning to get rid of
goetz@6458 1767 // the c2i part on top of the calling compiled frame (if any).
goetz@6458 1768 // R21_tmp1 must match sender_sp in gen_c2i_adapter.
goetz@6458 1769 // Now override the saved SP with the senderSP so we can pop c2i
goetz@6458 1770 // arguments (if any) off when we return.
goetz@6458 1771 __ std(R21_sender_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
goetz@6458 1772
goetz@6458 1773 // Save LR to caller's frame. We don't use _abi(lr) here,
goetz@6458 1774 // because it is not safe.
goetz@6458 1775 __ mflr(R0);
goetz@6458 1776 __ std(R0, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 1777
goetz@6458 1778 // If we come here, it is the first invocation of the frame manager.
goetz@6458 1779 // So there is no previous interpreter state.
goetz@6458 1780 __ li(R15_prev_state, 0);
goetz@6458 1781
goetz@6458 1782
goetz@6458 1783 // Fall through to where "recursive" invocations go.
goetz@6458 1784
goetz@6458 1785 //=============================================================================
goetz@6458 1786 // Dispatch an instance of the interpreter. Recursive activations
goetz@6458 1787 // come here.
goetz@6458 1788
goetz@6458 1789 Label re_dispatch;
goetz@6458 1790 __ BIND(re_dispatch);
goetz@6458 1791
goetz@6458 1792 //
goetz@6458 1793 // Registers alive
goetz@6458 1794 // R16_thread - JavaThread*
goetz@6458 1795 // R19_method - callee's Method
goetz@6458 1796 // R17_tos - address of caller's tos (prepushed)
goetz@6458 1797 // R15_prev_state - address of caller's BytecodeInterpreter or 0
goetz@6458 1798 // R1_SP - caller's SP trimmed such that caller's outgoing args are near top.
goetz@6458 1799 //
goetz@6458 1800 // Stack layout at this point:
goetz@6458 1801 //
goetz@6458 1802 // 0 [TOP_IJAVA_FRAME_ABI]
goetz@6458 1803 // alignment (optional)
goetz@6458 1804 // [outgoing Java arguments]
goetz@6458 1805 // ...
goetz@6458 1806 // PARENT [PARENT_IJAVA_FRAME_ABI]
goetz@6458 1807 // ...
goetz@6458 1808
goetz@6458 1809 // fall through to interpreted execution
goetz@6458 1810
goetz@6458 1811 //=============================================================================
goetz@6458 1812 // Allocate a new Java frame and initialize the new interpreter state.
goetz@6458 1813
goetz@6458 1814 Label stack_overflow_return;
goetz@6458 1815
goetz@6458 1816 // Create a suitable new Java frame plus a new BytecodeInterpreter instance
goetz@6458 1817 // in the current (frame manager's) C frame.
goetz@6458 1818 generate_compute_interpreter_state(stack_overflow_return);
goetz@6458 1819
goetz@6458 1820 // fall through
goetz@6458 1821
goetz@6458 1822 //=============================================================================
goetz@6458 1823 // Interpreter dispatch.
goetz@6458 1824
goetz@6458 1825 Label call_interpreter;
goetz@6458 1826 __ BIND(call_interpreter);
goetz@6458 1827
goetz@6458 1828 //
goetz@6458 1829 // Registers alive
goetz@6458 1830 // R16_thread - JavaThread*
goetz@6458 1831 // R15_prev_state - previous BytecodeInterpreter or 0
goetz@6458 1832 // R14_state - address of receiver's BytecodeInterpreter
goetz@6458 1833 // R1_SP - receiver's stack pointer
goetz@6458 1834 //
goetz@6458 1835
goetz@6458 1836 // Thread fields.
goetz@6458 1837 const Register pending_exception = R21_tmp1;
goetz@6458 1838
goetz@6458 1839 // Interpreter state fields.
goetz@6458 1840 const Register msg = R24_tmp4;
goetz@6458 1841
goetz@6660 1842 // Method fields.
goetz@6458 1843 const Register parameter_count = R25_tmp5;
goetz@6458 1844 const Register result_index = R26_tmp6;
goetz@6458 1845
goetz@6458 1846 const Register dummy = R28_tmp8;
goetz@6458 1847
goetz@6458 1848 // Address of various interpreter stubs.
goetz@6458 1849 // R29_tmp9 is reserved.
goetz@6458 1850 const Register stub_addr = R27_tmp7;
goetz@6458 1851
goetz@6458 1852 // Uncommon trap needs to jump to here to enter the interpreter
goetz@6458 1853 // (re-execute current bytecode).
goetz@6458 1854 unctrap_frame_manager_entry = __ pc();
goetz@6458 1855
goetz@6458 1856 // If we are profiling, store our fp (BSP) in the thread so we can
goetz@6458 1857 // find it during a tick.
goetz@6458 1858 if (Arguments::has_profile()) {
goetz@6458 1859 // On PPC64 we store the pointer to the current BytecodeInterpreter,
goetz@6458 1860 // instead of the bsp of ia64. This should suffice to be able to
goetz@6458 1861 // find all interesting information.
goetz@6458 1862 __ std(R14_state, thread_(last_interpreter_fp));
goetz@6458 1863 }
goetz@6458 1864
goetz@6458 1865 // R16_thread, R14_state and R15_prev_state are nonvolatile
goetz@6458 1866 // registers. There is no need to save these. If we needed to save
goetz@6458 1867 // some state in the current Java frame, this could be a place to do
goetz@6458 1868 // so.
goetz@6458 1869
goetz@6458 1870 // Call Java bytecode dispatcher passing "BytecodeInterpreter* istate".
goetz@6458 1871 __ call_VM_leaf(CAST_FROM_FN_PTR(address,
goetz@6458 1872 JvmtiExport::can_post_interpreter_events()
goetz@6458 1873 ? BytecodeInterpreter::runWithChecks
goetz@6458 1874 : BytecodeInterpreter::run),
goetz@6458 1875 R14_state);
goetz@6458 1876
goetz@6458 1877 interpreter_return_address = __ last_calls_return_pc();
goetz@6458 1878
goetz@6458 1879 // R16_thread, R14_state and R15_prev_state have their values preserved.
goetz@6458 1880
goetz@6458 1881 // If we are profiling, clear the fp in the thread to tell
goetz@6458 1882 // the profiler that we are no longer in the interpreter.
goetz@6458 1883 if (Arguments::has_profile()) {
goetz@6458 1884 __ li(R11_scratch1, 0);
goetz@6458 1885 __ std(R11_scratch1, thread_(last_interpreter_fp));
goetz@6458 1886 }
goetz@6458 1887
goetz@6458 1888 // Load message from bytecode dispatcher.
goetz@6458 1889 // TODO: PPC port: guarantee(4 == BytecodeInterpreter::sz_msg(), "unexpected field size");
goetz@6458 1890 __ lwz(msg, state_(_msg));
goetz@6458 1891
goetz@6458 1892
goetz@6458 1893 Label more_monitors;
goetz@6458 1894 Label return_from_native;
goetz@6458 1895 Label return_from_native_common;
goetz@6458 1896 Label return_from_native_no_exception;
goetz@6458 1897 Label return_from_interpreted_method;
goetz@6458 1898 Label return_from_recursive_activation;
goetz@6458 1899 Label unwind_recursive_activation;
goetz@6458 1900 Label resume_interpreter;
goetz@6458 1901 Label return_to_initial_caller;
goetz@6458 1902 Label unwind_initial_activation;
goetz@6458 1903 Label unwind_initial_activation_pending_exception;
goetz@6458 1904 Label call_method;
goetz@6458 1905 Label call_special;
goetz@6458 1906 Label retry_method;
goetz@6458 1907 Label retry_method_osr;
goetz@6458 1908 Label popping_frame;
goetz@6458 1909 Label throwing_exception;
goetz@6458 1910
goetz@6458 1911 // Branch according to the received message
goetz@6458 1912
goetz@6458 1913 __ cmpwi(CCR1, msg, BytecodeInterpreter::call_method);
goetz@6458 1914 __ cmpwi(CCR2, msg, BytecodeInterpreter::return_from_method);
goetz@6458 1915
goetz@6458 1916 __ beq(CCR1, call_method);
goetz@6458 1917 __ beq(CCR2, return_from_interpreted_method);
goetz@6458 1918
goetz@6458 1919 __ cmpwi(CCR3, msg, BytecodeInterpreter::more_monitors);
goetz@6458 1920 __ cmpwi(CCR4, msg, BytecodeInterpreter::throwing_exception);
goetz@6458 1921
goetz@6458 1922 __ beq(CCR3, more_monitors);
goetz@6458 1923 __ beq(CCR4, throwing_exception);
goetz@6458 1924
goetz@6458 1925 __ cmpwi(CCR5, msg, BytecodeInterpreter::popping_frame);
goetz@6458 1926 __ cmpwi(CCR6, msg, BytecodeInterpreter::do_osr);
goetz@6458 1927
goetz@6458 1928 __ beq(CCR5, popping_frame);
goetz@6458 1929 __ beq(CCR6, retry_method_osr);
goetz@6458 1930
goetz@6458 1931 __ stop("bad message from interpreter");
goetz@6458 1932
goetz@6458 1933
goetz@6458 1934 //=============================================================================
goetz@6458 1935 // Add a monitor just below the existing one(s). State->_stack_base
goetz@6458 1936 // points to the lowest existing one, so we insert the new one just
goetz@6458 1937 // below it and shuffle the expression stack down. Ref. the above
goetz@6458 1938 // stack layout picture, we must update _stack_base, _stack, _stack_limit
goetz@6458 1939 // and _last_Java_sp in the interpreter state.
goetz@6458 1940
goetz@6458 1941 __ BIND(more_monitors);
goetz@6458 1942
goetz@6458 1943 generate_more_monitors();
goetz@6458 1944 __ b(call_interpreter);
goetz@6458 1945
goetz@6458 1946 generate_deopt_handling(result_index);
goetz@6458 1947
goetz@6458 1948 // Restoring the R14_state is already done by the deopt_blob.
goetz@6458 1949
goetz@6458 1950 // Current tos includes no parameter slots.
goetz@6458 1951 __ ld(R17_tos, state_(_stack));
goetz@6458 1952 __ li(msg, BytecodeInterpreter::deopt_resume);
goetz@6458 1953 __ b(return_from_native_common);
goetz@6458 1954
goetz@6458 1955 // We are sent here when we are unwinding from a native method or
goetz@6458 1956 // adapter with an exception pending. We need to notify the interpreter
goetz@6458 1957 // that there is an exception to process.
goetz@6458 1958 // We arrive here also if the frame manager called an (interpreted) target
goetz@6458 1959 // which returns with a StackOverflow exception.
goetz@6458 1960 // The control flow is in this case is:
goetz@6458 1961 // frame_manager->throw_excp_stub->forward_excp->rethrow_excp_entry
goetz@6458 1962
goetz@6458 1963 AbstractInterpreter::_rethrow_exception_entry = __ pc();
goetz@6458 1964
goetz@6458 1965 // Restore R14_state.
goetz@6458 1966 __ ld(R14_state, 0, R1_SP);
goetz@6458 1967 __ addi(R14_state, R14_state,
goetz@6458 1968 -frame::interpreter_frame_cinterpreterstate_size_in_bytes());
goetz@6458 1969
goetz@6458 1970 // Store exception oop into thread object.
goetz@6458 1971 __ std(R3_RET, thread_(pending_exception));
goetz@6458 1972 __ li(msg, BytecodeInterpreter::method_resume /*rethrow_exception*/);
goetz@6458 1973 //
goetz@6458 1974 // NOTE: the interpreter frame as setup be deopt does NOT include
goetz@6458 1975 // any parameter slots (good thing since we have no callee here
goetz@6458 1976 // and couldn't remove them) so we don't have to do any calculations
goetz@6458 1977 // here to figure it out.
goetz@6458 1978 //
goetz@6458 1979 __ ld(R17_tos, state_(_stack));
goetz@6458 1980 __ b(return_from_native_common);
goetz@6458 1981
goetz@6458 1982
goetz@6458 1983 //=============================================================================
goetz@6458 1984 // Returning from a native method. Result is in the native abi
goetz@6458 1985 // location so we must move it to the java expression stack.
goetz@6458 1986
goetz@6458 1987 __ BIND(return_from_native);
goetz@6458 1988 guarantee(return_from_native_pc == (address) NULL, "precondition");
goetz@6458 1989 return_from_native_pc = __ pc();
goetz@6458 1990
goetz@6458 1991 // Restore R14_state.
goetz@6458 1992 __ ld(R14_state, 0, R1_SP);
goetz@6495 1993 __ addi(R14_state, R14_state, -frame::interpreter_frame_cinterpreterstate_size_in_bytes());
goetz@6458 1994
goetz@6458 1995 //
goetz@6458 1996 // Registers alive
goetz@6458 1997 // R16_thread
goetz@6458 1998 // R14_state - address of caller's BytecodeInterpreter.
goetz@6458 1999 // R3_RET - integer result, if any.
goetz@6458 2000 // F1_RET - float result, if any.
goetz@6458 2001 //
goetz@6458 2002 // Registers updated
goetz@6458 2003 // R19_method - callee's Method
goetz@6458 2004 // R17_tos - caller's tos, with outgoing args popped
goetz@6458 2005 // result_index - index of result handler.
goetz@6458 2006 // msg - message for resuming interpreter.
goetz@6458 2007 //
goetz@6458 2008
goetz@6458 2009 // Very-local scratch registers.
goetz@6458 2010
goetz@6458 2011 const ConditionRegister have_pending_exception = CCR0;
goetz@6458 2012
goetz@6458 2013 // Load callee Method, gc may have moved it.
goetz@6458 2014 __ ld(R19_method, state_(_result._to_call._callee));
goetz@6458 2015
goetz@6458 2016 // Load address of caller's tos. includes parameter slots.
goetz@6458 2017 __ ld(R17_tos, state_(_stack));
goetz@6458 2018
goetz@6458 2019 // Pop callee's parameters.
goetz@6458 2020
goetz@6458 2021 __ ld(parameter_count, in_bytes(Method::const_offset()), R19_method);
goetz@6458 2022 __ lhz(parameter_count, in_bytes(ConstMethod::size_of_parameters_offset()), parameter_count);
goetz@6458 2023 __ sldi(parameter_count, parameter_count, Interpreter::logStackElementSize);
goetz@6458 2024 __ add(R17_tos, R17_tos, parameter_count);
goetz@6458 2025
goetz@6458 2026 // Result stub address array index
goetz@6660 2027 // TODO: PPC port: assert(4 == sizeof(AccessFlags), "unexpected field size");
goetz@6458 2028 __ lwa(result_index, method_(result_index));
goetz@6458 2029
goetz@6458 2030 __ li(msg, BytecodeInterpreter::method_resume);
goetz@6458 2031
goetz@6458 2032 //
goetz@6458 2033 // Registers alive
goetz@6458 2034 // R16_thread
goetz@6458 2035 // R14_state - address of caller's BytecodeInterpreter.
goetz@6458 2036 // R17_tos - address of caller's tos with outgoing args already popped
goetz@6458 2037 // R3_RET - integer return value, if any.
goetz@6458 2038 // F1_RET - float return value, if any.
goetz@6458 2039 // result_index - index of result handler.
goetz@6458 2040 // msg - message for resuming interpreter.
goetz@6458 2041 //
goetz@6458 2042 // Registers updated
goetz@6458 2043 // R3_RET - new address of caller's tos, including result, if any
goetz@6458 2044 //
goetz@6458 2045
goetz@6458 2046 __ BIND(return_from_native_common);
goetz@6458 2047
goetz@6458 2048 // Check for pending exception
goetz@6458 2049 __ ld(pending_exception, thread_(pending_exception));
goetz@6458 2050 __ cmpdi(CCR0, pending_exception, 0);
goetz@6458 2051 __ beq(CCR0, return_from_native_no_exception);
goetz@6458 2052
goetz@6458 2053 // If there's a pending exception, we really have no result, so
goetz@6458 2054 // R3_RET is dead. Resume_interpreter assumes the new tos is in
goetz@6458 2055 // R3_RET.
goetz@6458 2056 __ mr(R3_RET, R17_tos);
goetz@6458 2057 // `resume_interpreter' expects R15_prev_state to be alive.
goetz@6458 2058 __ ld(R15_prev_state, state_(_prev_link));
goetz@6458 2059 __ b(resume_interpreter);
goetz@6458 2060
goetz@6458 2061 __ BIND(return_from_native_no_exception);
goetz@6458 2062
goetz@6458 2063 // No pending exception, copy method result from native ABI register
goetz@6458 2064 // to tos.
goetz@6458 2065
goetz@6458 2066 // Address of stub descriptor address array.
goetz@6458 2067 __ load_const(stub_addr, CppInterpreter::tosca_result_to_stack());
goetz@6458 2068
goetz@6458 2069 // Pass address of tos to stub.
goetz@6458 2070 __ mr(R4_ARG2, R17_tos);
goetz@6458 2071
goetz@6458 2072 // Address of stub descriptor address.
goetz@6458 2073 __ sldi(result_index, result_index, LogBytesPerWord);
goetz@6458 2074 __ add(stub_addr, stub_addr, result_index);
goetz@6458 2075
goetz@6458 2076 // Stub descriptor address.
goetz@6458 2077 __ ld(stub_addr, 0, stub_addr);
goetz@6458 2078
goetz@6458 2079 // TODO: don't do this via a call, do it in place!
goetz@6458 2080 //
goetz@6458 2081 // call stub via descriptor
goetz@6458 2082 // in R3_ARG1/F1_ARG1: result value (R3_RET or F1_RET)
goetz@6458 2083 __ call_stub(stub_addr);
goetz@6458 2084
goetz@6458 2085 // new tos = result of call in R3_RET
goetz@6458 2086
goetz@6458 2087 // `resume_interpreter' expects R15_prev_state to be alive.
goetz@6458 2088 __ ld(R15_prev_state, state_(_prev_link));
goetz@6458 2089 __ b(resume_interpreter);
goetz@6458 2090
goetz@6458 2091 //=============================================================================
goetz@6458 2092 // We encountered an exception while computing the interpreter
goetz@6458 2093 // state, so R14_state isn't valid. Act as if we just returned from
goetz@6458 2094 // the callee method with a pending exception.
goetz@6458 2095 __ BIND(stack_overflow_return);
goetz@6458 2096
goetz@6458 2097 //
goetz@6458 2098 // Registers alive
goetz@6458 2099 // R16_thread - JavaThread*
goetz@6458 2100 // R1_SP - old stack pointer
goetz@6458 2101 // R19_method - callee's Method
goetz@6458 2102 // R17_tos - address of caller's tos (prepushed)
goetz@6458 2103 // R15_prev_state - address of caller's BytecodeInterpreter or 0
goetz@6458 2104 // R18_locals - address of callee's locals array
goetz@6458 2105 //
goetz@6458 2106 // Registers updated
goetz@6458 2107 // R3_RET - address of resuming tos, if recursive unwind
goetz@6458 2108
goetz@6458 2109 Label Lskip_unextend_SP;
goetz@6458 2110
goetz@6458 2111 {
goetz@6458 2112 const ConditionRegister is_initial_call = CCR0;
goetz@6458 2113 const Register tos_save = R21_tmp1;
goetz@6458 2114 const Register tmp = R22_tmp2;
goetz@6458 2115
goetz@6458 2116 assert(tos_save->is_nonvolatile(), "need a nonvolatile");
goetz@6458 2117
goetz@6458 2118 // Is the exception thrown in the initial Java frame of this frame
goetz@6458 2119 // manager frame?
goetz@6458 2120 __ cmpdi(is_initial_call, R15_prev_state, 0);
goetz@6458 2121 __ bne(is_initial_call, Lskip_unextend_SP);
goetz@6458 2122
goetz@6458 2123 // Pop any c2i extension from the stack. This is necessary in the
goetz@6458 2124 // non-recursive case (that is we were called by the c2i adapter,
goetz@6458 2125 // meaning we have to prev state). In this case we entered the frame
goetz@6458 2126 // manager through a special entry which pushes the orignal
goetz@6458 2127 // unextended SP to the stack. Here we load it back.
goetz@6458 2128 __ ld(R0, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
goetz@6458 2129 __ mtlr(R0);
goetz@6458 2130 // Resize frame to get rid of a potential extension.
goetz@6458 2131 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 2132
goetz@6458 2133 // Fall through
goetz@6458 2134
goetz@6458 2135 __ bind(Lskip_unextend_SP);
goetz@6458 2136
goetz@6458 2137 // Throw the exception via RuntimeStub "throw_StackOverflowError_entry".
goetz@6458 2138 //
goetz@6458 2139 // Previously, we called C-Code directly. As a consequence, a
goetz@6458 2140 // possible GC tried to process the argument oops of the top frame
goetz@6458 2141 // (see RegisterMap::clear, which sets the corresponding flag to
goetz@6458 2142 // true). This lead to crashes because:
goetz@6458 2143 // 1. The top register map did not contain locations for the argument registers
goetz@6458 2144 // 2. The arguments are dead anyway, could be already overwritten in the worst case
goetz@6458 2145 // Solution: Call via special runtime stub that pushes it's own frame. This runtime stub has the flag
goetz@6458 2146 // "CodeBlob::caller_must_gc_arguments()" set to "false", what prevents the dead arguments getting GC'd.
goetz@6458 2147 //
goetz@6458 2148 // 2 cases exist:
goetz@6458 2149 // 1. We were called by the c2i adapter / call stub
goetz@6458 2150 // 2. We were called by the frame manager
goetz@6458 2151 //
goetz@6458 2152 // Both cases are handled by this code:
goetz@6458 2153 // 1. - initial_caller_sp was saved on stack => Load it back and we're ok
goetz@6458 2154 // - control flow will be:
goetz@6458 2155 // throw_stackoverflow_stub->VM->throw_stackoverflow_stub->forward_excep->excp_blob of calling method
goetz@6458 2156 // 2. - control flow will be:
goetz@6458 2157 // throw_stackoverflow_stub->VM->throw_stackoverflow_stub->forward_excep->
goetz@6458 2158 // ->rethrow_excp_entry of frame manager->resume_method
goetz@6458 2159 // Since we restored the caller SP above, the rethrow_excp_entry can restore the original interpreter state
goetz@6458 2160 // registers using the stack and resume the calling method with a pending excp.
goetz@6458 2161
goetz@6501 2162 assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
goetz@6458 2163 __ load_const(R3_ARG1, (StubRoutines::throw_StackOverflowError_entry()));
goetz@6458 2164 __ mtctr(R3_ARG1);
goetz@6458 2165 __ bctr();
goetz@6458 2166 }
goetz@6458 2167 //=============================================================================
goetz@6458 2168 // We have popped a frame from an interpreted call. We are assured
goetz@6458 2169 // of returning to an interpreted call by the popframe abi. We have
goetz@6458 2170 // no return value all we have to do is pop the current frame and
goetz@6458 2171 // then make sure that the top of stack (of the caller) gets set to
goetz@6458 2172 // where it was when we entered the callee (i.e. the args are still
goetz@6458 2173 // in place). Or we are returning to the interpreter. In the first
goetz@6458 2174 // case we must extract result (if any) from the java expression
goetz@6458 2175 // stack and store it in the location the native abi would expect
goetz@6458 2176 // for a call returning this type. In the second case we must simply
goetz@6458 2177 // do a stack to stack move as we unwind.
goetz@6458 2178
goetz@6458 2179 __ BIND(popping_frame);
goetz@6458 2180
goetz@6458 2181 // Registers alive
goetz@6458 2182 // R14_state
goetz@6458 2183 // R15_prev_state
goetz@6458 2184 // R17_tos
goetz@6458 2185 //
goetz@6458 2186 // Registers updated
goetz@6458 2187 // R19_method
goetz@6458 2188 // R3_RET
goetz@6458 2189 // msg
goetz@6458 2190 {
goetz@6458 2191 Label L;
goetz@6458 2192
goetz@6458 2193 // Reload callee method, gc may have moved it.
goetz@6458 2194 __ ld(R19_method, state_(_method));
goetz@6458 2195
goetz@6458 2196 // We may be returning to a deoptimized frame in which case the
goetz@6458 2197 // usual assumption of a recursive return is not true.
goetz@6458 2198
goetz@6458 2199 // not equal = is recursive call
goetz@6458 2200 __ cmpdi(CCR0, R15_prev_state, 0);
goetz@6458 2201
goetz@6458 2202 __ bne(CCR0, L);
goetz@6458 2203
goetz@6458 2204 // Pop_frame capability.
goetz@6458 2205 // The pop_frame api says that the underlying frame is a Java frame, in this case
goetz@6458 2206 // (prev_state==null) it must be a compiled frame:
goetz@6458 2207 //
goetz@6458 2208 // Stack at this point: I, C2I + C, ...
goetz@6458 2209 //
goetz@6458 2210 // The outgoing arguments of the call have just been copied (popframe_preserve_args).
goetz@6458 2211 // By the pop_frame api, we must end up in an interpreted frame. So the compiled frame
goetz@6458 2212 // will be deoptimized. Deoptimization will restore the outgoing arguments from
goetz@6458 2213 // popframe_preserve_args, adjust the tos such that it includes the popframe_preserve_args,
goetz@6458 2214 // and adjust the bci such that the call will be executed again.
goetz@6458 2215 // We have no results, just pop the interpreter frame, resize the compiled frame to get rid
goetz@6458 2216 // of the c2i extension and return to the deopt_handler.
goetz@6458 2217 __ b(unwind_initial_activation);
goetz@6458 2218
goetz@6458 2219 // is recursive call
goetz@6458 2220 __ bind(L);
goetz@6458 2221
goetz@6458 2222 // Resume_interpreter expects the original tos in R3_RET.
goetz@6458 2223 __ ld(R3_RET, prev_state_(_stack));
goetz@6458 2224
goetz@6458 2225 // We're done.
goetz@6458 2226 __ li(msg, BytecodeInterpreter::popping_frame);
goetz@6458 2227
goetz@6458 2228 __ b(unwind_recursive_activation);
goetz@6458 2229 }
goetz@6458 2230
goetz@6458 2231
goetz@6458 2232 //=============================================================================
goetz@6458 2233
goetz@6458 2234 // We have finished an interpreted call. We are either returning to
goetz@6458 2235 // native (call_stub/c2) or we are returning to the interpreter.
goetz@6458 2236 // When returning to native, we must extract the result (if any)
goetz@6458 2237 // from the java expression stack and store it in the location the
goetz@6458 2238 // native abi expects. When returning to the interpreter we must
goetz@6458 2239 // simply do a stack to stack move as we unwind.
goetz@6458 2240
goetz@6458 2241 __ BIND(return_from_interpreted_method);
goetz@6458 2242
goetz@6458 2243 //
goetz@6458 2244 // Registers alive
goetz@6458 2245 // R16_thread - JavaThread*
goetz@6458 2246 // R15_prev_state - address of caller's BytecodeInterpreter or 0
goetz@6458 2247 // R14_state - address of callee's interpreter state
goetz@6458 2248 // R1_SP - callee's stack pointer
goetz@6458 2249 //
goetz@6458 2250 // Registers updated
goetz@6458 2251 // R19_method - callee's method
goetz@6458 2252 // R3_RET - address of result (new caller's tos),
goetz@6458 2253 //
goetz@6458 2254 // if returning to interpreted
goetz@6458 2255 // msg - message for interpreter,
goetz@6458 2256 // if returning to interpreted
goetz@6458 2257 //
goetz@6458 2258
goetz@6458 2259 // Check if this is the initial invocation of the frame manager.
goetz@6458 2260 // If so, R15_prev_state will be null.
goetz@6458 2261 __ cmpdi(CCR0, R15_prev_state, 0);
goetz@6458 2262
goetz@6458 2263 // Reload callee method, gc may have moved it.
goetz@6458 2264 __ ld(R19_method, state_(_method));
goetz@6458 2265
goetz@6458 2266 // Load the method's result type.
goetz@6458 2267 __ lwz(result_index, method_(result_index));
goetz@6458 2268
goetz@6458 2269 // Go to return_to_initial_caller if R15_prev_state is null.
goetz@6458 2270 __ beq(CCR0, return_to_initial_caller);
goetz@6458 2271
goetz@6458 2272 // Copy callee's result to caller's expression stack via inline stack-to-stack
goetz@6458 2273 // converters.
goetz@6458 2274 {
goetz@6458 2275 Register new_tos = R3_RET;
goetz@6458 2276 Register from_temp = R4_ARG2;
goetz@6458 2277 Register from = R5_ARG3;
goetz@6458 2278 Register tos = R6_ARG4;
goetz@6458 2279 Register tmp1 = R7_ARG5;
goetz@6458 2280 Register tmp2 = R8_ARG6;
goetz@6458 2281
goetz@6458 2282 ConditionRegister result_type_is_void = CCR1;
goetz@6458 2283 ConditionRegister result_type_is_long = CCR2;
goetz@6458 2284 ConditionRegister result_type_is_double = CCR3;
goetz@6458 2285
goetz@6458 2286 Label stack_to_stack_void;
goetz@6458 2287 Label stack_to_stack_double_slot; // T_LONG, T_DOUBLE
goetz@6458 2288 Label stack_to_stack_single_slot; // T_BOOLEAN, T_BYTE, T_CHAR, T_SHORT, T_INT, T_FLOAT, T_OBJECT
goetz@6458 2289 Label stack_to_stack_done;
goetz@6458 2290
goetz@6458 2291 // Pass callee's address of tos + BytesPerWord
goetz@6458 2292 __ ld(from_temp, state_(_stack));
goetz@6458 2293
goetz@6458 2294 // result type: void
goetz@6458 2295 __ cmpwi(result_type_is_void, result_index, AbstractInterpreter::BasicType_as_index(T_VOID));
goetz@6458 2296
goetz@6458 2297 // Pass caller's tos == callee's locals address
goetz@6458 2298 __ ld(tos, state_(_locals));
goetz@6458 2299
goetz@6458 2300 // result type: long
goetz@6458 2301 __ cmpwi(result_type_is_long, result_index, AbstractInterpreter::BasicType_as_index(T_LONG));
goetz@6458 2302
goetz@6458 2303 __ addi(from, from_temp, Interpreter::stackElementSize);
goetz@6458 2304
goetz@6458 2305 // !! don't branch above this line !!
goetz@6458 2306
goetz@6458 2307 // handle void
goetz@6458 2308 __ beq(result_type_is_void, stack_to_stack_void);
goetz@6458 2309
goetz@6458 2310 // result type: double
goetz@6458 2311 __ cmpwi(result_type_is_double, result_index, AbstractInterpreter::BasicType_as_index(T_DOUBLE));
goetz@6458 2312
goetz@6458 2313 // handle long or double
goetz@6458 2314 __ beq(result_type_is_long, stack_to_stack_double_slot);
goetz@6458 2315 __ beq(result_type_is_double, stack_to_stack_double_slot);
goetz@6458 2316
goetz@6458 2317 // fall through to single slot types (incl. object)
goetz@6458 2318
goetz@6458 2319 {
goetz@6458 2320 __ BIND(stack_to_stack_single_slot);
goetz@6458 2321 // T_BOOLEAN, T_BYTE, T_CHAR, T_SHORT, T_INT, T_FLOAT, T_OBJECT
goetz@6458 2322
goetz@6458 2323 __ ld(tmp1, 0, from);
goetz@6458 2324 __ std(tmp1, 0, tos);
goetz@6458 2325 // New expression stack top
goetz@6458 2326 __ addi(new_tos, tos, - BytesPerWord);
goetz@6458 2327
goetz@6458 2328 __ b(stack_to_stack_done);
goetz@6458 2329 }
goetz@6458 2330
goetz@6458 2331 {
goetz@6458 2332 __ BIND(stack_to_stack_double_slot);
goetz@6458 2333 // T_LONG, T_DOUBLE
goetz@6458 2334
goetz@6458 2335 // Move both entries for debug purposes even though only one is live
goetz@6458 2336 __ ld(tmp1, BytesPerWord, from);
goetz@6458 2337 __ ld(tmp2, 0, from);
goetz@6458 2338 __ std(tmp1, 0, tos);
goetz@6458 2339 __ std(tmp2, -BytesPerWord, tos);
goetz@6458 2340
goetz@6458 2341 // new expression stack top
goetz@6458 2342 __ addi(new_tos, tos, - 2 * BytesPerWord); // two slots
goetz@6458 2343 __ b(stack_to_stack_done);
goetz@6458 2344 }
goetz@6458 2345
goetz@6458 2346 {
goetz@6458 2347 __ BIND(stack_to_stack_void);
goetz@6458 2348 // T_VOID
goetz@6458 2349
goetz@6458 2350 // new expression stack top
goetz@6458 2351 __ mr(new_tos, tos);
goetz@6458 2352 // fall through to stack_to_stack_done
goetz@6458 2353 }
goetz@6458 2354
goetz@6458 2355 __ BIND(stack_to_stack_done);
goetz@6458 2356 }
goetz@6458 2357
goetz@6458 2358 // new tos = R3_RET
goetz@6458 2359
goetz@6458 2360 // Get the message for the interpreter
goetz@6458 2361 __ li(msg, BytecodeInterpreter::method_resume);
goetz@6458 2362
goetz@6458 2363 // And fall thru
goetz@6458 2364
goetz@6458 2365
goetz@6458 2366 //=============================================================================
goetz@6458 2367 // Restore caller's interpreter state and pass pointer to caller's
goetz@6458 2368 // new tos to caller.
goetz@6458 2369
goetz@6458 2370 __ BIND(unwind_recursive_activation);
goetz@6458 2371
goetz@6458 2372 //
goetz@6458 2373 // Registers alive
goetz@6458 2374 // R15_prev_state - address of caller's BytecodeInterpreter
goetz@6458 2375 // R3_RET - address of caller's tos
goetz@6458 2376 // msg - message for caller's BytecodeInterpreter
goetz@6458 2377 // R1_SP - callee's stack pointer
goetz@6458 2378 //
goetz@6458 2379 // Registers updated
goetz@6458 2380 // R14_state - address of caller's BytecodeInterpreter
goetz@6458 2381 // R15_prev_state - address of its parent or 0
goetz@6458 2382 //
goetz@6458 2383
goetz@6458 2384 // Pop callee's interpreter and set R14_state to caller's interpreter.
goetz@6458 2385 __ pop_interpreter_state(/*prev_state_may_be_0=*/false);
goetz@6458 2386
goetz@6458 2387 // And fall thru
goetz@6458 2388
goetz@6458 2389
goetz@6458 2390 //=============================================================================
goetz@6458 2391 // Resume the (calling) interpreter after a call.
goetz@6458 2392
goetz@6458 2393 __ BIND(resume_interpreter);
goetz@6458 2394
goetz@6458 2395 //
goetz@6458 2396 // Registers alive
goetz@6458 2397 // R14_state - address of resuming BytecodeInterpreter
goetz@6458 2398 // R15_prev_state - address of its parent or 0
goetz@6458 2399 // R3_RET - address of resuming tos
goetz@6458 2400 // msg - message for resuming interpreter
goetz@6458 2401 // R1_SP - callee's stack pointer
goetz@6458 2402 //
goetz@6458 2403 // Registers updated
goetz@6458 2404 // R1_SP - caller's stack pointer
goetz@6458 2405 //
goetz@6458 2406
goetz@6458 2407 // Restore C stack pointer of caller (resuming interpreter),
goetz@6458 2408 // R14_state already points to the resuming BytecodeInterpreter.
goetz@6458 2409 __ pop_interpreter_frame_to_state(R14_state, R21_tmp1, R11_scratch1, R12_scratch2);
goetz@6458 2410
goetz@6458 2411 // Store new address of tos (holding return value) in interpreter state.
goetz@6458 2412 __ std(R3_RET, state_(_stack));
goetz@6458 2413
goetz@6458 2414 // Store message for interpreter.
goetz@6458 2415 __ stw(msg, state_(_msg));
goetz@6458 2416
goetz@6458 2417 __ b(call_interpreter);
goetz@6458 2418
goetz@6458 2419 //=============================================================================
goetz@6458 2420 // Interpreter returning to native code (call_stub/c1/c2) from
goetz@6458 2421 // initial activation. Convert stack result and unwind activation.
goetz@6458 2422
goetz@6458 2423 __ BIND(return_to_initial_caller);
goetz@6458 2424
goetz@6458 2425 //
goetz@6458 2426 // Registers alive
goetz@6458 2427 // R19_method - callee's Method
goetz@6458 2428 // R14_state - address of callee's interpreter state
goetz@6458 2429 // R16_thread - JavaThread
goetz@6458 2430 // R1_SP - callee's stack pointer
goetz@6458 2431 //
goetz@6458 2432 // Registers updated
goetz@6458 2433 // R3_RET/F1_RET - result in expected output register
goetz@6458 2434 //
goetz@6458 2435
goetz@6458 2436 // If we have an exception pending we have no result and we
goetz@6458 2437 // must figure out where to really return to.
goetz@6458 2438 //
goetz@6458 2439 __ ld(pending_exception, thread_(pending_exception));
goetz@6458 2440 __ cmpdi(CCR0, pending_exception, 0);
goetz@6458 2441 __ bne(CCR0, unwind_initial_activation_pending_exception);
goetz@6458 2442
goetz@6458 2443 __ lwa(result_index, method_(result_index));
goetz@6458 2444
goetz@6458 2445 // Address of stub descriptor address array.
goetz@6458 2446 __ load_const(stub_addr, CppInterpreter::stack_result_to_native());
goetz@6458 2447
goetz@6458 2448 // Pass address of callee's tos + BytesPerWord.
goetz@6458 2449 // Will then point directly to result.
goetz@6458 2450 __ ld(R3_ARG1, state_(_stack));
goetz@6458 2451 __ addi(R3_ARG1, R3_ARG1, Interpreter::stackElementSize);
goetz@6458 2452
goetz@6458 2453 // Address of stub descriptor address
goetz@6458 2454 __ sldi(result_index, result_index, LogBytesPerWord);
goetz@6458 2455 __ add(stub_addr, stub_addr, result_index);
goetz@6458 2456
goetz@6458 2457 // Stub descriptor address
goetz@6458 2458 __ ld(stub_addr, 0, stub_addr);
goetz@6458 2459
goetz@6458 2460 // TODO: don't do this via a call, do it in place!
goetz@6458 2461 //
goetz@6458 2462 // call stub via descriptor
goetz@6458 2463 __ call_stub(stub_addr);
goetz@6458 2464
goetz@6458 2465 __ BIND(unwind_initial_activation);
goetz@6458 2466
goetz@6458 2467 // Unwind from initial activation. No exception is pending.
goetz@6458 2468
goetz@6458 2469 //
goetz@6458 2470 // Stack layout at this point:
goetz@6458 2471 //
goetz@6458 2472 // 0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 2473 // ...
goetz@6458 2474 // CALLER [PARENT_IJAVA_FRAME_ABI]
goetz@6458 2475 // ...
goetz@6458 2476 // CALLER [unextended ABI]
goetz@6458 2477 // ...
goetz@6458 2478 //
goetz@6458 2479 // The CALLER frame has a C2I adapter or is an entry-frame.
goetz@6458 2480 //
goetz@6458 2481
goetz@6458 2482 // An interpreter frame exists, we may pop the TOP_IJAVA_FRAME and
goetz@6458 2483 // turn the caller's PARENT_IJAVA_FRAME back into a TOP_IJAVA_FRAME.
goetz@6458 2484 // But, we simply restore the return pc from the caller's frame and
goetz@6458 2485 // use the caller's initial_caller_sp as the new SP which pops the
goetz@6458 2486 // interpreter frame and "resizes" the caller's frame to its "unextended"
goetz@6458 2487 // size.
goetz@6458 2488
goetz@6458 2489 // get rid of top frame
goetz@6458 2490 __ pop_frame();
goetz@6458 2491
goetz@6458 2492 // Load return PC from parent frame.
goetz@6458 2493 __ ld(R21_tmp1, _parent_ijava_frame_abi(lr), R1_SP);
goetz@6458 2494
goetz@6458 2495 // Resize frame to get rid of a potential extension.
goetz@6458 2496 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 2497
goetz@6458 2498 // update LR
goetz@6458 2499 __ mtlr(R21_tmp1);
goetz@6458 2500
goetz@6458 2501 // return
goetz@6458 2502 __ blr();
goetz@6458 2503
goetz@6458 2504 //=============================================================================
goetz@6458 2505 // Unwind from initial activation. An exception is pending
goetz@6458 2506
goetz@6458 2507 __ BIND(unwind_initial_activation_pending_exception);
goetz@6458 2508
goetz@6458 2509 //
goetz@6458 2510 // Stack layout at this point:
goetz@6458 2511 //
goetz@6458 2512 // 0 [TOP_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 2513 // ...
goetz@6458 2514 // CALLER [PARENT_IJAVA_FRAME_ABI]
goetz@6458 2515 // ...
goetz@6458 2516 // CALLER [unextended ABI]
goetz@6458 2517 // ...
goetz@6458 2518 //
goetz@6458 2519 // The CALLER frame has a C2I adapter or is an entry-frame.
goetz@6458 2520 //
goetz@6458 2521
goetz@6458 2522 // An interpreter frame exists, we may pop the TOP_IJAVA_FRAME and
goetz@6458 2523 // turn the caller's PARENT_IJAVA_FRAME back into a TOP_IJAVA_FRAME.
goetz@6458 2524 // But, we just pop the current TOP_IJAVA_FRAME and fall through
goetz@6458 2525
goetz@6458 2526 __ pop_frame();
goetz@6458 2527 __ ld(R3_ARG1, _top_ijava_frame_abi(lr), R1_SP);
goetz@6458 2528
goetz@6458 2529 //
goetz@6458 2530 // Stack layout at this point:
goetz@6458 2531 //
goetz@6458 2532 // CALLER [PARENT_IJAVA_FRAME_ABI] <-- R1_SP
goetz@6458 2533 // ...
goetz@6458 2534 // CALLER [unextended ABI]
goetz@6458 2535 // ...
goetz@6458 2536 //
goetz@6458 2537 // The CALLER frame has a C2I adapter or is an entry-frame.
goetz@6458 2538 //
goetz@6458 2539 // Registers alive
goetz@6458 2540 // R16_thread
goetz@6458 2541 // R3_ARG1 - return address to caller
goetz@6458 2542 //
goetz@6458 2543 // Registers updated
goetz@6458 2544 // R3_ARG1 - address of pending exception
goetz@6458 2545 // R4_ARG2 - issuing pc = return address to caller
goetz@6458 2546 // LR - address of exception handler stub
goetz@6458 2547 //
goetz@6458 2548
goetz@6458 2549 // Resize frame to get rid of a potential extension.
goetz@6458 2550 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 2551
goetz@6458 2552 __ mr(R14, R3_ARG1); // R14 := ARG1
goetz@6458 2553 __ mr(R4_ARG2, R3_ARG1); // ARG2 := ARG1
goetz@6458 2554
goetz@6458 2555 // Find the address of the "catch_exception" stub.
goetz@6511 2556 __ push_frame_reg_args(0, R11_scratch1);
goetz@6458 2557 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
goetz@6458 2558 R16_thread,
goetz@6458 2559 R4_ARG2);
goetz@6458 2560 __ pop_frame();
goetz@6458 2561
goetz@6458 2562 // Load continuation address into LR.
goetz@6458 2563 __ mtlr(R3_RET);
goetz@6458 2564
goetz@6458 2565 // Load address of pending exception and clear it in thread object.
goetz@6458 2566 __ ld(R3_ARG1/*R3_RET*/, thread_(pending_exception));
goetz@6458 2567 __ li(R4_ARG2, 0);
goetz@6458 2568 __ std(R4_ARG2, thread_(pending_exception));
goetz@6458 2569
goetz@6458 2570 // re-load issuing pc
goetz@6458 2571 __ mr(R4_ARG2, R14);
goetz@6458 2572
goetz@6458 2573 // Branch to found exception handler.
goetz@6458 2574 __ blr();
goetz@6458 2575
goetz@6458 2576 //=============================================================================
goetz@6458 2577 // Call a new method. Compute new args and trim the expression stack
goetz@6458 2578 // to only what we are currently using and then recurse.
goetz@6458 2579
goetz@6458 2580 __ BIND(call_method);
goetz@6458 2581
goetz@6458 2582 //
goetz@6458 2583 // Registers alive
goetz@6458 2584 // R16_thread
goetz@6458 2585 // R14_state - address of caller's BytecodeInterpreter
goetz@6458 2586 // R1_SP - caller's stack pointer
goetz@6458 2587 //
goetz@6458 2588 // Registers updated
goetz@6458 2589 // R15_prev_state - address of caller's BytecodeInterpreter
goetz@6458 2590 // R17_tos - address of caller's tos
goetz@6458 2591 // R19_method - callee's Method
goetz@6458 2592 // R1_SP - trimmed back
goetz@6458 2593 //
goetz@6458 2594
goetz@6458 2595 // Very-local scratch registers.
goetz@6458 2596
goetz@6458 2597 const Register offset = R21_tmp1;
goetz@6458 2598 const Register tmp = R22_tmp2;
goetz@6458 2599 const Register self_entry = R23_tmp3;
goetz@6458 2600 const Register stub_entry = R24_tmp4;
goetz@6458 2601
goetz@6458 2602 const ConditionRegister cr = CCR0;
goetz@6458 2603
goetz@6458 2604 // Load the address of the frame manager.
goetz@6458 2605 __ load_const(self_entry, &interpreter_frame_manager);
goetz@6458 2606 __ ld(self_entry, 0, self_entry);
goetz@6458 2607
goetz@6458 2608 // Load BytecodeInterpreter._result._to_call._callee (callee's Method).
goetz@6458 2609 __ ld(R19_method, state_(_result._to_call._callee));
goetz@6458 2610 // Load BytecodeInterpreter._stack (outgoing tos).
goetz@6458 2611 __ ld(R17_tos, state_(_stack));
goetz@6458 2612
goetz@6458 2613 // Save address of caller's BytecodeInterpreter.
goetz@6458 2614 __ mr(R15_prev_state, R14_state);
goetz@6458 2615
goetz@6458 2616 // Load the callee's entry point.
goetz@6458 2617 // Load BytecodeInterpreter._result._to_call._callee_entry_point.
goetz@6458 2618 __ ld(stub_entry, state_(_result._to_call._callee_entry_point));
goetz@6458 2619
goetz@6458 2620 // Check whether stub_entry is equal to self_entry.
goetz@6458 2621 __ cmpd(cr, self_entry, stub_entry);
goetz@6458 2622 // if (self_entry == stub_entry)
goetz@6458 2623 // do a re-dispatch
goetz@6458 2624 __ beq(cr, re_dispatch);
goetz@6458 2625 // else
goetz@6458 2626 // call the specialized entry (adapter for jni or compiled code)
goetz@6458 2627 __ BIND(call_special);
goetz@6458 2628
goetz@6458 2629 //
goetz@6458 2630 // Call the entry generated by `InterpreterGenerator::generate_native_entry'.
goetz@6458 2631 //
goetz@6458 2632 // Registers alive
goetz@6458 2633 // R16_thread
goetz@6458 2634 // R15_prev_state - address of caller's BytecodeInterpreter
goetz@6458 2635 // R19_method - callee's Method
goetz@6458 2636 // R17_tos - address of caller's tos
goetz@6458 2637 // R1_SP - caller's stack pointer
goetz@6458 2638 //
goetz@6458 2639
goetz@6458 2640 // Mark return from specialized entry for generate_native_entry.
goetz@6458 2641 guarantee(return_from_native_pc != (address) NULL, "precondition");
goetz@6458 2642 frame_manager_specialized_return = return_from_native_pc;
goetz@6458 2643
goetz@6458 2644 // Set sender_SP in case we call interpreter native wrapper which
goetz@6458 2645 // will expect it. Compiled code should not care.
goetz@6458 2646 __ mr(R21_sender_SP, R1_SP);
goetz@6458 2647
goetz@6458 2648 // Do a tail call here, and let the link register point to
goetz@6458 2649 // frame_manager_specialized_return which is return_from_native_pc.
goetz@6458 2650 __ load_const(tmp, frame_manager_specialized_return);
goetz@6458 2651 __ call_stub_and_return_to(stub_entry, tmp /* return_pc=tmp */);
goetz@6458 2652
goetz@6458 2653
goetz@6458 2654 //=============================================================================
goetz@6458 2655 //
goetz@6458 2656 // InterpretMethod triggered OSR compilation of some Java method M
goetz@6458 2657 // and now asks to run the compiled code. We call this code the
goetz@6458 2658 // `callee'.
goetz@6458 2659 //
goetz@6458 2660 // This is our current idea on how OSR should look like on PPC64:
goetz@6458 2661 //
goetz@6458 2662 // While interpreting a Java method M the stack is:
goetz@6458 2663 //
goetz@6458 2664 // (InterpretMethod (M), IJAVA_FRAME (M), ANY_FRAME, ...).
goetz@6458 2665 //
goetz@6458 2666 // After having OSR compiled M, `InterpretMethod' returns to the
goetz@6458 2667 // frame manager, sending the message `retry_method_osr'. The stack
goetz@6458 2668 // is:
goetz@6458 2669 //
goetz@6458 2670 // (IJAVA_FRAME (M), ANY_FRAME, ...).
goetz@6458 2671 //
goetz@6458 2672 // The compiler will have generated an `nmethod' suitable for
goetz@6458 2673 // continuing execution of M at the bytecode index at which OSR took
goetz@6458 2674 // place. So now the frame manager calls the OSR entry. The OSR
goetz@6458 2675 // entry sets up a JIT_FRAME for M and continues execution of M with
goetz@6458 2676 // initial state determined by the IJAVA_FRAME.
goetz@6458 2677 //
goetz@6458 2678 // (JIT_FRAME (M), IJAVA_FRAME (M), ANY_FRAME, ...).
goetz@6458 2679 //
goetz@6458 2680
goetz@6458 2681 __ BIND(retry_method_osr);
goetz@6458 2682 {
goetz@6458 2683 //
goetz@6458 2684 // Registers alive
goetz@6458 2685 // R16_thread
goetz@6458 2686 // R15_prev_state - address of caller's BytecodeInterpreter
goetz@6458 2687 // R14_state - address of callee's BytecodeInterpreter
goetz@6458 2688 // R1_SP - callee's SP before call to InterpretMethod
goetz@6458 2689 //
goetz@6458 2690 // Registers updated
goetz@6458 2691 // R17 - pointer to callee's locals array
goetz@6458 2692 // (declared via `interpreter_arg_ptr_reg' in the AD file)
goetz@6458 2693 // R19_method - callee's Method
goetz@6458 2694 // R1_SP - callee's SP (will become SP of OSR adapter frame)
goetz@6458 2695 //
goetz@6458 2696
goetz@6458 2697 // Provide a debugger breakpoint in the frame manager if breakpoints
goetz@6458 2698 // in osr'd methods are requested.
goetz@6458 2699 #ifdef COMPILER2
goetz@6458 2700 NOT_PRODUCT( if (OptoBreakpointOSR) { __ illtrap(); } )
goetz@6458 2701 #endif
goetz@6458 2702
goetz@6458 2703 // Load callee's pointer to locals array from callee's state.
goetz@6458 2704 // __ ld(R17, state_(_locals));
goetz@6458 2705
goetz@6458 2706 // Load osr entry.
goetz@6458 2707 __ ld(R12_scratch2, state_(_result._osr._osr_entry));
goetz@6458 2708
goetz@6458 2709 // Load address of temporary osr buffer to arg1.
goetz@6458 2710 __ ld(R3_ARG1, state_(_result._osr._osr_buf));
goetz@6458 2711 __ mtctr(R12_scratch2);
goetz@6458 2712
goetz@6660 2713 // Load method, gc may move it during execution of osr'd method.
goetz@6458 2714 __ ld(R22_tmp2, state_(_method));
goetz@6458 2715 // Load message 'call_method'.
goetz@6458 2716 __ li(R23_tmp3, BytecodeInterpreter::call_method);
goetz@6458 2717
goetz@6458 2718 {
goetz@6458 2719 // Pop the IJAVA frame of the method which we are going to call osr'd.
goetz@6458 2720 Label no_state, skip_no_state;
goetz@6458 2721 __ pop_interpreter_state(/*prev_state_may_be_0=*/true);
goetz@6458 2722 __ cmpdi(CCR0, R14_state,0);
goetz@6458 2723 __ beq(CCR0, no_state);
goetz@6458 2724 // return to interpreter
goetz@6458 2725 __ pop_interpreter_frame_to_state(R14_state, R11_scratch1, R12_scratch2, R21_tmp1);
goetz@6458 2726
goetz@6458 2727 // Init _result._to_call._callee and tell gc that it contains a valid oop
goetz@6458 2728 // by setting _msg to 'call_method'.
goetz@6458 2729 __ std(R22_tmp2, state_(_result._to_call._callee));
goetz@6458 2730 // TODO: PPC port: assert(4 == BytecodeInterpreter::sz_msg(), "unexpected field size");
goetz@6458 2731 __ stw(R23_tmp3, state_(_msg));
goetz@6458 2732
goetz@6458 2733 __ load_const(R21_tmp1, frame_manager_specialized_return);
goetz@6458 2734 __ b(skip_no_state);
goetz@6458 2735 __ bind(no_state);
goetz@6458 2736
goetz@6458 2737 // Return to initial caller.
goetz@6458 2738
goetz@6458 2739 // Get rid of top frame.
goetz@6458 2740 __ pop_frame();
goetz@6458 2741
goetz@6458 2742 // Load return PC from parent frame.
goetz@6458 2743 __ ld(R21_tmp1, _parent_ijava_frame_abi(lr), R1_SP);
goetz@6458 2744
goetz@6458 2745 // Resize frame to get rid of a potential extension.
goetz@6458 2746 __ resize_frame_to_initial_caller(R11_scratch1, R12_scratch2);
goetz@6458 2747
goetz@6458 2748 __ bind(skip_no_state);
goetz@6458 2749
goetz@6458 2750 // Update LR with return pc.
goetz@6458 2751 __ mtlr(R21_tmp1);
goetz@6458 2752 }
goetz@6458 2753 // Jump to the osr entry point.
goetz@6458 2754 __ bctr();
goetz@6458 2755
goetz@6458 2756 }
goetz@6458 2757
goetz@6458 2758 //=============================================================================
goetz@6458 2759 // Interpreted method "returned" with an exception, pass it on.
goetz@6458 2760 // Pass no result, unwind activation and continue/return to
goetz@6458 2761 // interpreter/call_stub/c2.
goetz@6458 2762
goetz@6458 2763 __ BIND(throwing_exception);
goetz@6458 2764
goetz@6458 2765 // Check if this is the initial invocation of the frame manager. If
goetz@6458 2766 // so, previous interpreter state in R15_prev_state will be null.
goetz@6458 2767
goetz@6458 2768 // New tos of caller is callee's first parameter address, that is
goetz@6458 2769 // callee's incoming arguments are popped.
goetz@6458 2770 __ ld(R3_RET, state_(_locals));
goetz@6458 2771
goetz@6458 2772 // Check whether this is an initial call.
goetz@6458 2773 __ cmpdi(CCR0, R15_prev_state, 0);
goetz@6458 2774 // Yes, called from the call stub or from generated code via a c2i frame.
goetz@6458 2775 __ beq(CCR0, unwind_initial_activation_pending_exception);
goetz@6458 2776
goetz@6458 2777 // Send resume message, interpreter will see the exception first.
goetz@6458 2778
goetz@6458 2779 __ li(msg, BytecodeInterpreter::method_resume);
goetz@6458 2780 __ b(unwind_recursive_activation);
goetz@6458 2781
goetz@6458 2782
goetz@6458 2783 //=============================================================================
goetz@6458 2784 // Push the last instruction out to the code buffer.
goetz@6458 2785
goetz@6458 2786 {
goetz@6458 2787 __ unimplemented("end of InterpreterGenerator::generate_normal_entry", 128);
goetz@6458 2788 }
goetz@6458 2789
goetz@6458 2790 interpreter_frame_manager = entry;
goetz@6458 2791 return interpreter_frame_manager;
goetz@6458 2792 }
goetz@6458 2793
goetz@6458 2794 // Generate code for various sorts of method entries
goetz@6458 2795 //
goetz@6458 2796 address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) {
goetz@6458 2797 address entry_point = NULL;
goetz@6458 2798
goetz@6458 2799 switch (kind) {
goetz@6458 2800 case Interpreter::zerolocals : break;
goetz@6458 2801 case Interpreter::zerolocals_synchronized : break;
goetz@6458 2802 case Interpreter::native : // Fall thru
goetz@6458 2803 case Interpreter::native_synchronized : entry_point = ((CppInterpreterGenerator*)this)->generate_native_entry(); break;
goetz@6458 2804 case Interpreter::empty : break;
goetz@6458 2805 case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break;
goetz@6458 2806 case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break;
goetz@6458 2807 // These are special interpreter intrinsics which we don't support so far.
goetz@6458 2808 case Interpreter::java_lang_math_sin : break;
goetz@6458 2809 case Interpreter::java_lang_math_cos : break;
goetz@6458 2810 case Interpreter::java_lang_math_tan : break;
goetz@6458 2811 case Interpreter::java_lang_math_abs : break;
goetz@6458 2812 case Interpreter::java_lang_math_log : break;
goetz@6458 2813 case Interpreter::java_lang_math_log10 : break;
goetz@6458 2814 case Interpreter::java_lang_math_sqrt : break;
goetz@6458 2815 case Interpreter::java_lang_math_pow : break;
goetz@6458 2816 case Interpreter::java_lang_math_exp : break;
goetz@6458 2817 case Interpreter::java_lang_ref_reference_get: entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break;
goetz@6458 2818 default : ShouldNotReachHere(); break;
goetz@6458 2819 }
goetz@6458 2820
goetz@6458 2821 if (entry_point) {
goetz@6458 2822 return entry_point;
goetz@6458 2823 }
goetz@6458 2824 return ((InterpreterGenerator*)this)->generate_normal_entry();
goetz@6458 2825 }
goetz@6458 2826
goetz@6458 2827 InterpreterGenerator::InterpreterGenerator(StubQueue* code)
goetz@6458 2828 : CppInterpreterGenerator(code) {
goetz@6458 2829 generate_all(); // down here so it can be "virtual"
goetz@6458 2830 }
goetz@6458 2831
goetz@6458 2832 // How much stack a topmost interpreter method activation needs in words.
goetz@6458 2833 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
goetz@6458 2834 // Computation is in bytes not words to match layout_activation_impl
goetz@6458 2835 // below, but the return is in words.
goetz@6458 2836
goetz@6458 2837 //
goetz@6458 2838 // 0 [TOP_IJAVA_FRAME_ABI] \
goetz@6458 2839 // alignment (optional) \ |
goetz@6458 2840 // [operand stack / Java parameters] > stack | |
goetz@6458 2841 // [monitors] (optional) > monitors | |
goetz@6458 2842 // [PARENT_IJAVA_FRAME_ABI] \ | |
goetz@6458 2843 // [BytecodeInterpreter object] > interpreter \ | | |
goetz@6458 2844 // alignment (optional) | round | parent | round | top
goetz@6458 2845 // [Java result] (2 slots) > result | | | |
goetz@6458 2846 // [Java non-arg locals] \ locals | | | |
goetz@6458 2847 // [arg locals] / / / / /
goetz@6458 2848 //
goetz@6458 2849
goetz@6458 2850 int locals = method->max_locals() * BytesPerWord;
goetz@6458 2851 int interpreter = frame::interpreter_frame_cinterpreterstate_size_in_bytes();
goetz@6458 2852 int result = 2 * BytesPerWord;
goetz@6458 2853
goetz@6458 2854 int parent = round_to(interpreter + result + locals, 16) + frame::parent_ijava_frame_abi_size;
goetz@6458 2855
goetz@6458 2856 int stack = method->max_stack() * BytesPerWord;
goetz@6458 2857 int monitors = method->is_synchronized() ? frame::interpreter_frame_monitor_size_in_bytes() : 0;
goetz@6458 2858 int top = round_to(parent + monitors + stack, 16) + frame::top_ijava_frame_abi_size;
goetz@6458 2859
goetz@6458 2860 return (top / BytesPerWord);
goetz@6458 2861 }
goetz@6458 2862
goetz@6458 2863 void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
goetz@6458 2864 frame* caller,
goetz@6458 2865 frame* current,
goetz@6458 2866 Method* method,
goetz@6458 2867 intptr_t* locals,
goetz@6458 2868 intptr_t* stack,
goetz@6458 2869 intptr_t* stack_base,
goetz@6458 2870 intptr_t* monitor_base,
goetz@6458 2871 intptr_t* frame_sp,
goetz@6458 2872 bool is_top_frame) {
goetz@6458 2873 // What about any vtable?
goetz@6458 2874 //
goetz@6458 2875 to_fill->_thread = JavaThread::current();
goetz@6458 2876 // This gets filled in later but make it something recognizable for now.
goetz@6458 2877 to_fill->_bcp = method->code_base();
goetz@6458 2878 to_fill->_locals = locals;
goetz@6458 2879 to_fill->_constants = method->constants()->cache();
goetz@6458 2880 to_fill->_method = method;
goetz@6458 2881 to_fill->_mdx = NULL;
goetz@6458 2882 to_fill->_stack = stack;
goetz@6458 2883
goetz@6458 2884 if (is_top_frame && JavaThread::current()->popframe_forcing_deopt_reexecution()) {
goetz@6458 2885 to_fill->_msg = deopt_resume2;
goetz@6458 2886 } else {
goetz@6458 2887 to_fill->_msg = method_resume;
goetz@6458 2888 }
goetz@6458 2889 to_fill->_result._to_call._bcp_advance = 0;
goetz@6458 2890 to_fill->_result._to_call._callee_entry_point = NULL; // doesn't matter to anyone
goetz@6458 2891 to_fill->_result._to_call._callee = NULL; // doesn't matter to anyone
goetz@6458 2892 to_fill->_prev_link = NULL;
goetz@6458 2893
goetz@6458 2894 if (caller->is_interpreted_frame()) {
goetz@6458 2895 interpreterState prev = caller->get_interpreterState();
goetz@6458 2896
goetz@6458 2897 // Support MH calls. Make sure the interpreter will return the right address:
goetz@6458 2898 // 1. Caller did ordinary interpreted->compiled call call: Set a prev_state
goetz@6458 2899 // which makes the CPP interpreter return to frame manager "return_from_interpreted_method"
goetz@6458 2900 // entry after finishing execution.
goetz@6458 2901 // 2. Caller did a MH call: If the caller has a MethodHandleInvoke in it's
goetz@6458 2902 // state (invariant: must be the caller of the bottom vframe) we used the
goetz@6458 2903 // "call_special" entry to do the call, meaning the arguments have not been
goetz@6458 2904 // popped from the stack. Therefore, don't enter a prev state in this case
goetz@6458 2905 // in order to return to "return_from_native" frame manager entry which takes
goetz@6458 2906 // care of popping arguments. Also, don't overwrite the MH.invoke Method in
goetz@6458 2907 // the prev_state in order to be able to figure out the number of arguments to
goetz@6458 2908 // pop.
goetz@6458 2909 // The parameter method can represent MethodHandle.invokeExact(...).
goetz@6458 2910 // The MethodHandleCompiler generates these synthetic Methods,
goetz@6458 2911 // including bytecodes, if an invokedynamic call gets inlined. In
goetz@6458 2912 // this case we want to return like from any other interpreted
goetz@6458 2913 // Java call, so we set _prev_link.
goetz@6458 2914 to_fill->_prev_link = prev;
goetz@6458 2915
goetz@6458 2916 if (*prev->_bcp == Bytecodes::_invokeinterface || *prev->_bcp == Bytecodes::_invokedynamic) {
goetz@6458 2917 prev->_result._to_call._bcp_advance = 5;
goetz@6458 2918 } else {
goetz@6458 2919 prev->_result._to_call._bcp_advance = 3;
goetz@6458 2920 }
goetz@6458 2921 }
goetz@6458 2922 to_fill->_oop_temp = NULL;
goetz@6458 2923 to_fill->_stack_base = stack_base;
goetz@6458 2924 // Need +1 here because stack_base points to the word just above the
goetz@6458 2925 // first expr stack entry and stack_limit is supposed to point to
goetz@6458 2926 // the word just below the last expr stack entry. See
goetz@6458 2927 // generate_compute_interpreter_state.
goetz@6458 2928 to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
goetz@6458 2929 to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
goetz@6458 2930
goetz@6458 2931 to_fill->_frame_bottom = frame_sp;
goetz@6458 2932
goetz@6458 2933 // PPC64 specific
goetz@6458 2934 to_fill->_last_Java_pc = NULL;
goetz@6458 2935 to_fill->_last_Java_fp = NULL;
goetz@6458 2936 to_fill->_last_Java_sp = frame_sp;
goetz@6458 2937 #ifdef ASSERT
goetz@6458 2938 to_fill->_self_link = to_fill;
goetz@6458 2939 to_fill->_native_fresult = 123456.789;
goetz@6458 2940 to_fill->_native_lresult = CONST64(0xdeafcafedeadc0de);
goetz@6458 2941 #endif
goetz@6458 2942 }
goetz@6458 2943
goetz@6458 2944 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate,
goetz@6458 2945 address last_Java_pc,
goetz@6458 2946 intptr_t* last_Java_fp) {
goetz@6458 2947 istate->_last_Java_pc = last_Java_pc;
goetz@6458 2948 istate->_last_Java_fp = last_Java_fp;
goetz@6458 2949 }
goetz@6458 2950
roland@6723 2951 // Computes monitor_size and top_frame_size in bytes.
roland@6723 2952 static void frame_size_helper(int max_stack,
roland@6723 2953 int monitors,
roland@6723 2954 int& monitor_size,
roland@6723 2955 int& top_frame_size) {
roland@6723 2956 monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
roland@6723 2957 top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
roland@6723 2958 + monitor_size
roland@6723 2959 + max_stack * Interpreter::stackElementSize
roland@6723 2960 + 2 * Interpreter::stackElementSize,
roland@6723 2961 frame::alignment_in_bytes)
roland@6723 2962 + frame::top_ijava_frame_abi_size;
roland@6723 2963 }
roland@6723 2964
roland@6723 2965 // Returns number of stackElementWords needed for the interpreter frame with the
roland@6723 2966 // given sections.
roland@6723 2967 int AbstractInterpreter::size_activation(int max_stack,
roland@6723 2968 int temps,
roland@6723 2969 int extra_args,
roland@6723 2970 int monitors,
roland@6723 2971 int callee_params,
roland@6723 2972 int callee_locals,
roland@6723 2973 bool is_top_frame) {
roland@6723 2974 int monitor_size = 0;
roland@6723 2975 int top_frame_size = 0;
roland@6723 2976 frame_size_helper(max_stack, monitors, monitor_size, top_frame_size);
roland@6723 2977
roland@6723 2978 int frame_size;
roland@6723 2979 if (is_top_frame) {
roland@6723 2980 frame_size = top_frame_size;
roland@6723 2981 } else {
roland@6723 2982 frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
roland@6723 2983 + monitor_size
roland@6723 2984 + (temps - callee_params + callee_locals) * Interpreter::stackElementSize
roland@6723 2985 + 2 * Interpreter::stackElementSize,
roland@6723 2986 frame::alignment_in_bytes)
roland@6723 2987 + frame::parent_ijava_frame_abi_size;
roland@6723 2988 assert(extra_args == 0, "non-zero for top_frame only");
roland@6723 2989 }
roland@6723 2990
roland@6723 2991 return frame_size / Interpreter::stackElementSize;
roland@6723 2992 }
roland@6723 2993
roland@6723 2994 void AbstractInterpreter::layout_activation(Method* method,
roland@6723 2995 int temps, // Number of slots on java expression stack in use.
roland@6723 2996 int popframe_args,
roland@6723 2997 int monitors, // Number of active monitors.
roland@6723 2998 int caller_actual_parameters,
roland@6723 2999 int callee_params,// Number of slots for callee parameters.
roland@6723 3000 int callee_locals,// Number of slots for locals.
roland@6723 3001 frame* caller,
roland@6723 3002 frame* interpreter_frame,
roland@6723 3003 bool is_top_frame,
roland@6723 3004 bool is_bottom_frame) {
goetz@6458 3005
goetz@6458 3006 // NOTE this code must exactly mimic what
goetz@6458 3007 // InterpreterGenerator::generate_compute_interpreter_state() does
goetz@6458 3008 // as far as allocating an interpreter frame. However there is an
goetz@6458 3009 // exception. With the C++ based interpreter only the top most frame
goetz@6458 3010 // has a full sized expression stack. The 16 byte slop factor is
goetz@6458 3011 // both the abi scratch area and a place to hold a result from a
goetz@6458 3012 // callee on its way to the callers stack.
goetz@6458 3013
roland@6723 3014 int monitor_size = 0;
roland@6723 3015 int top_frame_size = 0;
roland@6723 3016 frame_size_helper(method->max_stack(), monitors, monitor_size, top_frame_size);
roland@6723 3017
roland@6723 3018 intptr_t sp = (intptr_t)interpreter_frame->sp();
roland@6723 3019 intptr_t fp = *(intptr_t *)sp;
roland@6723 3020 assert(fp == (intptr_t)caller->sp(), "fp must match");
roland@6723 3021 interpreterState cur_state =
roland@6723 3022 (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
roland@6723 3023
roland@6723 3024 // Now fill in the interpreterState object.
roland@6723 3025
roland@6723 3026 intptr_t* locals;
roland@6723 3027 if (caller->is_interpreted_frame()) {
roland@6723 3028 // Locals must agree with the caller because it will be used to set the
roland@6723 3029 // caller's tos when we return.
roland@6723 3030 interpreterState prev = caller->get_interpreterState();
roland@6723 3031 // Calculate start of "locals" for MH calls. For MH calls, the
roland@6723 3032 // current method() (= MH target) and prev->callee() (=
roland@6723 3033 // MH.invoke*()) are different and especially have different
roland@6723 3034 // signatures. To pop the argumentsof the caller, we must use
roland@6723 3035 // the prev->callee()->size_of_arguments() because that's what
roland@6723 3036 // the caller actually pushed. Currently, for synthetic MH
roland@6723 3037 // calls (deoptimized from inlined MH calls), detected by
roland@6723 3038 // is_method_handle_invoke(), we use the callee's arguments
roland@6723 3039 // because here, the caller's and callee's signature match.
roland@6723 3040 if (true /*!caller->is_at_mh_callsite()*/) {
roland@6723 3041 locals = prev->stack() + method->size_of_parameters();
roland@6723 3042 } else {
roland@6723 3043 // Normal MH call.
roland@6723 3044 locals = prev->stack() + prev->callee()->size_of_parameters();
roland@6723 3045 }
goetz@6458 3046 } else {
roland@6723 3047 bool is_deopted;
roland@6723 3048 locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
roland@6723 3049 frame::parent_ijava_frame_abi_size);
goetz@6458 3050 }
goetz@6458 3051
roland@6723 3052 intptr_t* monitor_base = (intptr_t*) cur_state;
roland@6723 3053 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
roland@6723 3054
roland@6723 3055 // Provide pop_frame capability on PPC64, add popframe_args.
roland@6723 3056 // +1 because stack is always prepushed.
roland@6723 3057 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
roland@6723 3058
roland@6723 3059 BytecodeInterpreter::layout_interpreterState(cur_state,
roland@6723 3060 caller,
roland@6723 3061 interpreter_frame,
roland@6723 3062 method,
roland@6723 3063 locals,
roland@6723 3064 stack,
roland@6723 3065 stack_base,
roland@6723 3066 monitor_base,
roland@6723 3067 (intptr_t*)(((intptr_t)fp) - top_frame_size),
roland@6723 3068 is_top_frame);
roland@6723 3069
roland@6723 3070 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
roland@6723 3071 interpreter_frame->fp());
goetz@6458 3072 }
goetz@6458 3073
goetz@6458 3074 #endif // CC_INTERP

mercurial