src/cpu/ppc/vm/cppInterpreter_ppc.cpp

Thu, 06 Mar 2014 10:55:28 -0800

author
goetz
date
Thu, 06 Mar 2014 10:55:28 -0800
changeset 6511
31e80afe3fed
parent 6501
c668f307a4c0
child 6512
fd1b9f02cc91
permissions
-rw-r--r--

8035647: PPC64: Support for elf v2 abi.
Summary: ELFv2 ABI used by the little endian PowerPC64 on Linux.
Reviewed-by: kvn
Contributed-by: asmundak@google.com

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

mercurial