1 /* 2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2016, 2017 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 // Major contributions by AHa, AS, JL, ML. 27 28 #include "precompiled.hpp" 29 #include "asm/macroAssembler.inline.hpp" 30 #include "interp_masm_s390.hpp" 31 #include "interpreter/interpreter.hpp" 32 #include "interpreter/interpreterRuntime.hpp" 33 #include "oops/arrayOop.hpp" 34 #include "oops/markOop.hpp" 35 #include "prims/jvmtiExport.hpp" 36 #include "prims/jvmtiThreadState.hpp" 37 #include "runtime/basicLock.hpp" 38 #include "runtime/biasedLocking.hpp" 39 #include "runtime/sharedRuntime.hpp" 40 #include "runtime/thread.inline.hpp" 41 42 // Implementation of InterpreterMacroAssembler. 43 // This file specializes the assember with interpreter-specific macros. 44 45 #ifdef PRODUCT 46 #define BLOCK_COMMENT(str) 47 #define BIND(label) bind(label); 48 #else 49 #define BLOCK_COMMENT(str) block_comment(str) 50 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") 51 #endif 52 53 void InterpreterMacroAssembler::jump_to_entry(address entry, Register Rscratch) { 54 assert(entry != NULL, "Entry must have been generated by now"); 55 assert(Rscratch != Z_R0, "Can't use R0 for addressing"); 56 branch_optimized(Assembler::bcondAlways, entry); 57 } 58 59 void InterpreterMacroAssembler::empty_expression_stack(void) { 60 get_monitors(Z_R1_scratch); 61 add2reg(Z_esp, -Interpreter::stackElementSize, Z_R1_scratch); 62 } 63 64 // Dispatch code executed in the prolog of a bytecode which does not do it's 65 // own dispatch. 66 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int bcp_incr) { 67 // On z/Architecture we are short on registers, therefore we do not preload the 68 // dispatch address of the next bytecode. 69 } 70 71 // Dispatch code executed in the epilog of a bytecode which does not do it's 72 // own dispatch. 73 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) { 74 dispatch_next(state, step); 75 } 76 77 void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) { 78 z_llgc(Z_bytecode, bcp_incr, Z_R0, Z_bcp); // Load next bytecode. 79 add2reg(Z_bcp, bcp_incr); // Advance bcp. Add2reg produces optimal code. 80 dispatch_base(state, Interpreter::dispatch_table(state)); 81 } 82 83 // Common code to dispatch and dispatch_only. 84 // Dispatch value in Lbyte_code and increment Lbcp. 85 86 void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) { 87 verify_FPU(1, state); 88 89 #ifdef ASSERT 90 address reentry = NULL; 91 { Label OK; 92 // Check if the frame pointer in Z_fp is correct. 93 z_cg(Z_fp, 0, Z_SP); 94 z_bre(OK); 95 reentry = stop_chain_static(reentry, "invalid frame pointer Z_fp: " FILE_AND_LINE); 96 bind(OK); 97 } 98 { Label OK; 99 // check if the locals pointer in Z_locals is correct 100 z_cg(Z_locals, _z_ijava_state_neg(locals), Z_fp); 101 z_bre(OK); 102 reentry = stop_chain_static(reentry, "invalid locals pointer Z_locals: " FILE_AND_LINE); 103 bind(OK); 104 } 105 #endif 106 107 // TODO: Maybe implement +VerifyActivationFrameSize here. 108 // verify_thread(); // Too slow. We will just verify on method entry & exit. 109 verify_oop(Z_tos, state); 110 111 // Dispatch table to use. 112 load_absolute_address(Z_tmp_1, (address) table); // Z_tmp_1 = table; 113 114 // 0 <= Z_bytecode < 256 => Use a 32 bit shift, because it is shorter than sllg. 115 // Z_bytecode must have been loaded zero-extended for this approach to be correct. 116 z_sll(Z_bytecode, LogBytesPerWord, Z_R0); // Multiply by wordSize. 117 z_lg(Z_tmp_1, 0, Z_bytecode, Z_tmp_1); // Get entry addr. 118 119 z_br(Z_tmp_1); 120 } 121 122 void InterpreterMacroAssembler::dispatch_only(TosState state) { 123 dispatch_base(state, Interpreter::dispatch_table(state)); 124 } 125 126 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) { 127 dispatch_base(state, Interpreter::normal_table(state)); 128 } 129 130 void InterpreterMacroAssembler::dispatch_via(TosState state, address *table) { 131 // Load current bytecode. 132 z_llgc(Z_bytecode, Address(Z_bcp, (intptr_t)0)); 133 dispatch_base(state, table); 134 } 135 136 // The following call_VM*_base() methods overload and mask the respective 137 // declarations/definitions in class MacroAssembler. They are meant as a "detour" 138 // to perform additional, template interpreter specific tasks before actually 139 // calling their MacroAssembler counterparts. 140 141 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point) { 142 bool allow_relocation = true; // Fenerally valid variant. Assume code is relocated. 143 // interpreter specific 144 // Note: No need to save/restore bcp (Z_R13) pointer since these are callee 145 // saved registers and no blocking/ GC can happen in leaf calls. 146 147 // super call 148 MacroAssembler::call_VM_leaf_base(entry_point, allow_relocation); 149 } 150 151 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point, bool allow_relocation) { 152 // interpreter specific 153 // Note: No need to save/restore bcp (Z_R13) pointer since these are callee 154 // saved registers and no blocking/ GC can happen in leaf calls. 155 156 // super call 157 MacroAssembler::call_VM_leaf_base(entry_point, allow_relocation); 158 } 159 160 void InterpreterMacroAssembler::call_VM_base(Register oop_result, Register last_java_sp, 161 address entry_point, bool check_exceptions) { 162 bool allow_relocation = true; // Fenerally valid variant. Assume code is relocated. 163 // interpreter specific 164 165 save_bcp(); 166 save_esp(); 167 // super call 168 MacroAssembler::call_VM_base(oop_result, last_java_sp, 169 entry_point, allow_relocation, check_exceptions); 170 restore_bcp(); 171 } 172 173 void InterpreterMacroAssembler::call_VM_base(Register oop_result, Register last_java_sp, 174 address entry_point, bool allow_relocation, 175 bool check_exceptions) { 176 // interpreter specific 177 178 save_bcp(); 179 save_esp(); 180 // super call 181 MacroAssembler::call_VM_base(oop_result, last_java_sp, 182 entry_point, allow_relocation, check_exceptions); 183 restore_bcp(); 184 } 185 186 void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) { 187 if (JvmtiExport::can_pop_frame()) { 188 BLOCK_COMMENT("check_and_handle_popframe {"); 189 Label L; 190 // Initiate popframe handling only if it is not already being 191 // processed. If the flag has the popframe_processing bit set, it 192 // means that this code is called *during* popframe handling - we 193 // don't want to reenter. 194 // TODO: Check if all four state combinations could be visible. 195 // If (processing and !pending) is an invisible/impossible state, 196 // there is optimization potential by testing both bits at once. 197 // Then, All_Zeroes and All_Ones means skip, Mixed means doit. 198 testbit(Address(Z_thread, JavaThread::popframe_condition_offset()), 199 exact_log2(JavaThread::popframe_pending_bit)); 200 z_bfalse(L); 201 testbit(Address(Z_thread, JavaThread::popframe_condition_offset()), 202 exact_log2(JavaThread::popframe_processing_bit)); 203 z_btrue(L); 204 205 // Call Interpreter::remove_activation_preserving_args_entry() to get the 206 // address of the same-named entrypoint in the generated interpreter code. 207 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); 208 // The above call should (as its only effect) return the contents of the field 209 // _remove_activation_preserving_args_entry in Z_RET. 210 // We just jump there to have the work done. 211 z_br(Z_RET); 212 // There is no way for control to fall thru here. 213 214 bind(L); 215 BLOCK_COMMENT("} check_and_handle_popframe"); 216 } 217 } 218 219 220 void InterpreterMacroAssembler::load_earlyret_value(TosState state) { 221 Register RjvmtiState = Z_R1_scratch; 222 int tos_off = in_bytes(JvmtiThreadState::earlyret_tos_offset()); 223 int oop_off = in_bytes(JvmtiThreadState::earlyret_oop_offset()); 224 int val_off = in_bytes(JvmtiThreadState::earlyret_value_offset()); 225 int state_off = in_bytes(JavaThread::jvmti_thread_state_offset()); 226 227 z_lg(RjvmtiState, state_off, Z_thread); 228 229 switch (state) { 230 case atos: z_lg(Z_tos, oop_off, RjvmtiState); 231 store_const(Address(RjvmtiState, oop_off), 0L, 8, 8, Z_R0_scratch); 232 break; 233 case ltos: z_lg(Z_tos, val_off, RjvmtiState); break; 234 case btos: // fall through 235 case ztos: // fall through 236 case ctos: // fall through 237 case stos: // fall through 238 case itos: z_llgf(Z_tos, val_off, RjvmtiState); break; 239 case ftos: z_le(Z_ftos, val_off, RjvmtiState); break; 240 case dtos: z_ld(Z_ftos, val_off, RjvmtiState); break; 241 case vtos: /* nothing to do */ break; 242 default : ShouldNotReachHere(); 243 } 244 245 // Clean up tos value in the jvmti thread state. 246 store_const(Address(RjvmtiState, val_off), 0L, 8, 8, Z_R0_scratch); 247 // Set tos state field to illegal value. 248 store_const(Address(RjvmtiState, tos_off), ilgl, 4, 1, Z_R0_scratch); 249 } 250 251 void InterpreterMacroAssembler::check_and_handle_earlyret(Register scratch_reg) { 252 if (JvmtiExport::can_force_early_return()) { 253 BLOCK_COMMENT("check_and_handle_earlyret {"); 254 Label L; 255 // arg regs are save, because we are just behind the call in call_VM_base 256 Register jvmti_thread_state = Z_ARG2; 257 Register tmp = Z_ARG3; 258 load_and_test_long(jvmti_thread_state, Address(Z_thread, JavaThread::jvmti_thread_state_offset())); 259 z_bre(L); // if (thread->jvmti_thread_state() == NULL) exit; 260 261 // Initiate earlyret handling only if it is not already being processed. 262 // If the flag has the earlyret_processing bit set, it means that this code 263 // is called *during* earlyret handling - we don't want to reenter. 264 265 assert((JvmtiThreadState::earlyret_pending != 0) && (JvmtiThreadState::earlyret_inactive == 0), 266 "must fix this check, when changing the values of the earlyret enum"); 267 assert(JvmtiThreadState::earlyret_pending == 1, "must fix this check, when changing the values of the earlyret enum"); 268 269 load_and_test_int(tmp, Address(jvmti_thread_state, JvmtiThreadState::earlyret_state_offset())); 270 z_brz(L); // if (thread->jvmti_thread_state()->_earlyret_state != JvmtiThreadState::earlyret_pending) exit; 271 272 // Call Interpreter::remove_activation_early_entry() to get the address of the 273 // same-named entrypoint in the generated interpreter code. 274 assert(sizeof(TosState) == 4, "unexpected size"); 275 z_l(Z_ARG1, Address(jvmti_thread_state, JvmtiThreadState::earlyret_tos_offset())); 276 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), Z_ARG1); 277 // The above call should (as its only effect) return the contents of the field 278 // _remove_activation_preserving_args_entry in Z_RET. 279 // We just jump there to have the work done. 280 z_br(Z_RET); 281 // There is no way for control to fall thru here. 282 283 bind(L); 284 BLOCK_COMMENT("} check_and_handle_earlyret"); 285 } 286 } 287 288 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2) { 289 lgr_if_needed(Z_ARG1, arg_1); 290 assert(arg_2 != Z_ARG1, "smashed argument"); 291 lgr_if_needed(Z_ARG2, arg_2); 292 MacroAssembler::call_VM_leaf_base(entry_point, true); 293 } 294 295 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size) { 296 Address param(Z_bcp, bcp_offset); 297 298 BLOCK_COMMENT("get_cache_index_at_bcp {"); 299 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); 300 if (index_size == sizeof(u2)) { 301 load_sized_value(index, param, 2, false /*signed*/); 302 } else if (index_size == sizeof(u4)) { 303 304 load_sized_value(index, param, 4, false); 305 306 // Check if the secondary index definition is still ~x, otherwise 307 // we have to change the following assembler code to calculate the 308 // plain index. 309 assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); 310 not_(index); // Convert to plain index. 311 } else if (index_size == sizeof(u1)) { 312 z_llgc(index, param); 313 } else { 314 ShouldNotReachHere(); 315 } 316 BLOCK_COMMENT("}"); 317 } 318 319 320 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, Register cpe_offset, 321 int bcp_offset, size_t index_size) { 322 BLOCK_COMMENT("get_cache_and_index_at_bcp {"); 323 assert_different_registers(cache, cpe_offset); 324 get_cache_index_at_bcp(cpe_offset, bcp_offset, index_size); 325 z_lg(cache, Address(Z_fp, _z_ijava_state_neg(cpoolCache))); 326 // Convert from field index to ConstantPoolCache offset in bytes. 327 z_sllg(cpe_offset, cpe_offset, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord)); 328 BLOCK_COMMENT("}"); 329 } 330 331 // Kills Z_R0_scratch. 332 void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache, 333 Register cpe_offset, 334 Register bytecode, 335 int byte_no, 336 int bcp_offset, 337 size_t index_size) { 338 BLOCK_COMMENT("get_cache_and_index_and_bytecode_at_bcp {"); 339 get_cache_and_index_at_bcp(cache, cpe_offset, bcp_offset, index_size); 340 341 // We want to load (from CP cache) the bytecode that corresponds to the passed-in byte_no. 342 // It is located at (cache + cpe_offset + base_offset + indices_offset + (8-1) (last byte in DW) - (byte_no+1). 343 // Instead of loading, shifting and masking a DW, we just load that one byte of interest with z_llgc (unsigned). 344 const int base_ix_off = in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()); 345 const int off_in_DW = (8-1) - (1+byte_no); 346 assert(ConstantPoolCacheEntry::bytecode_1_mask == ConstantPoolCacheEntry::bytecode_2_mask, "common mask"); 347 assert(ConstantPoolCacheEntry::bytecode_1_mask == 0xff, ""); 348 load_sized_value(bytecode, Address(cache, cpe_offset, base_ix_off+off_in_DW), 1, false /*signed*/); 349 350 BLOCK_COMMENT("}"); 351 } 352 353 // Load object from cpool->resolved_references(index). 354 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) { 355 assert_different_registers(result, index); 356 get_constant_pool(result); 357 358 // Convert 359 // - from field index to resolved_references() index and 360 // - from word index to byte offset. 361 // Since this is a java object, it is potentially compressed. 362 Register tmp = index; // reuse 363 z_sllg(index, index, LogBytesPerHeapOop); // Offset into resolved references array. 364 // Load pointer for resolved_references[] objArray. 365 z_lg(result, ConstantPool::cache_offset_in_bytes(), result); 366 z_lg(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); 367 resolve_oop_handle(result); // Load resolved references array itself. 368 #ifdef ASSERT 369 NearLabel index_ok; 370 z_lgf(Z_R0, Address(result, arrayOopDesc::length_offset_in_bytes())); 371 z_sllg(Z_R0, Z_R0, LogBytesPerHeapOop); 372 compare64_and_branch(tmp, Z_R0, Assembler::bcondLow, index_ok); 373 stop("resolved reference index out of bounds", 0x09256); 374 bind(index_ok); 375 #endif 376 z_agr(result, index); // Address of indexed array element. 377 load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result); 378 } 379 380 // load cpool->resolved_klass_at(index) 381 void InterpreterMacroAssembler::load_resolved_klass_at_offset(Register cpool, Register offset, Register iklass) { 382 // int value = *(Rcpool->int_at_addr(which)); 383 // int resolved_klass_index = extract_low_short_from_int(value); 384 z_llgh(offset, Address(cpool, offset, sizeof(ConstantPool) + 2)); // offset = resolved_klass_index (s390 is big-endian) 385 z_sllg(offset, offset, LogBytesPerWord); // Convert 'index' to 'offset' 386 z_lg(iklass, Address(cpool, ConstantPool::resolved_klasses_offset_in_bytes())); // iklass = cpool->_resolved_klasses 387 z_lg(iklass, Address(iklass, offset, Array<Klass*>::base_offset_in_bytes())); 388 } 389 390 void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, 391 Register tmp, 392 int bcp_offset, 393 size_t index_size) { 394 BLOCK_COMMENT("get_cache_entry_pointer_at_bcp {"); 395 get_cache_and_index_at_bcp(cache, tmp, bcp_offset, index_size); 396 add2reg_with_index(cache, in_bytes(ConstantPoolCache::base_offset()), tmp, cache); 397 BLOCK_COMMENT("}"); 398 } 399 400 // Generate a subtype check: branch to ok_is_subtype if sub_klass is 401 // a subtype of super_klass. Blows registers Rsuper_klass, Rsub_klass, tmp1, tmp2. 402 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, 403 Register Rsuper_klass, 404 Register Rtmp1, 405 Register Rtmp2, 406 Label &ok_is_subtype) { 407 // Profile the not-null value's klass. 408 profile_typecheck(Rtmp1, Rsub_klass, Rtmp2); 409 410 // Do the check. 411 check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype); 412 413 // Profile the failure of the check. 414 profile_typecheck_failed(Rtmp1, Rtmp2); 415 } 416 417 // Pop topmost element from stack. It just disappears. 418 // Useful if consumed previously by access via stackTop(). 419 void InterpreterMacroAssembler::popx(int len) { 420 add2reg(Z_esp, len*Interpreter::stackElementSize); 421 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 422 } 423 424 // Get Address object of stack top. No checks. No pop. 425 // Purpose: - Provide address of stack operand to exploit reg-mem operations. 426 // - Avoid RISC-like mem2reg - reg-reg-op sequence. 427 Address InterpreterMacroAssembler::stackTop() { 428 return Address(Z_esp, Interpreter::expr_offset_in_bytes(0)); 429 } 430 431 void InterpreterMacroAssembler::pop_i(Register r) { 432 z_l(r, Interpreter::expr_offset_in_bytes(0), Z_esp); 433 add2reg(Z_esp, Interpreter::stackElementSize); 434 assert_different_registers(r, Z_R1_scratch); 435 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 436 } 437 438 void InterpreterMacroAssembler::pop_ptr(Register r) { 439 z_lg(r, Interpreter::expr_offset_in_bytes(0), Z_esp); 440 add2reg(Z_esp, Interpreter::stackElementSize); 441 assert_different_registers(r, Z_R1_scratch); 442 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 443 } 444 445 void InterpreterMacroAssembler::pop_l(Register r) { 446 z_lg(r, Interpreter::expr_offset_in_bytes(0), Z_esp); 447 add2reg(Z_esp, 2*Interpreter::stackElementSize); 448 assert_different_registers(r, Z_R1_scratch); 449 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 450 } 451 452 void InterpreterMacroAssembler::pop_f(FloatRegister f) { 453 mem2freg_opt(f, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)), false); 454 add2reg(Z_esp, Interpreter::stackElementSize); 455 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 456 } 457 458 void InterpreterMacroAssembler::pop_d(FloatRegister f) { 459 mem2freg_opt(f, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)), true); 460 add2reg(Z_esp, 2*Interpreter::stackElementSize); 461 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 462 } 463 464 void InterpreterMacroAssembler::push_i(Register r) { 465 assert_different_registers(r, Z_R1_scratch); 466 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 467 z_st(r, Address(Z_esp)); 468 add2reg(Z_esp, -Interpreter::stackElementSize); 469 } 470 471 void InterpreterMacroAssembler::push_ptr(Register r) { 472 z_stg(r, Address(Z_esp)); 473 add2reg(Z_esp, -Interpreter::stackElementSize); 474 } 475 476 void InterpreterMacroAssembler::push_l(Register r) { 477 assert_different_registers(r, Z_R1_scratch); 478 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 479 int offset = -Interpreter::stackElementSize; 480 z_stg(r, Address(Z_esp, offset)); 481 clear_mem(Address(Z_esp), Interpreter::stackElementSize); 482 add2reg(Z_esp, 2 * offset); 483 } 484 485 void InterpreterMacroAssembler::push_f(FloatRegister f) { 486 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 487 freg2mem_opt(f, Address(Z_esp), false); 488 add2reg(Z_esp, -Interpreter::stackElementSize); 489 } 490 491 void InterpreterMacroAssembler::push_d(FloatRegister d) { 492 debug_only(verify_esp(Z_esp, Z_R1_scratch)); 493 int offset = -Interpreter::stackElementSize; 494 freg2mem_opt(d, Address(Z_esp, offset)); 495 add2reg(Z_esp, 2 * offset); 496 } 497 498 void InterpreterMacroAssembler::push(TosState state) { 499 verify_oop(Z_tos, state); 500 switch (state) { 501 case atos: push_ptr(); break; 502 case btos: push_i(); break; 503 case ztos: 504 case ctos: 505 case stos: push_i(); break; 506 case itos: push_i(); break; 507 case ltos: push_l(); break; 508 case ftos: push_f(); break; 509 case dtos: push_d(); break; 510 case vtos: /* nothing to do */ break; 511 default : ShouldNotReachHere(); 512 } 513 } 514 515 void InterpreterMacroAssembler::pop(TosState state) { 516 switch (state) { 517 case atos: pop_ptr(Z_tos); break; 518 case btos: pop_i(Z_tos); break; 519 case ztos: 520 case ctos: 521 case stos: pop_i(Z_tos); break; 522 case itos: pop_i(Z_tos); break; 523 case ltos: pop_l(Z_tos); break; 524 case ftos: pop_f(Z_ftos); break; 525 case dtos: pop_d(Z_ftos); break; 526 case vtos: /* nothing to do */ break; 527 default : ShouldNotReachHere(); 528 } 529 verify_oop(Z_tos, state); 530 } 531 532 // Helpers for swap and dup. 533 void InterpreterMacroAssembler::load_ptr(int n, Register val) { 534 z_lg(val, Address(Z_esp, Interpreter::expr_offset_in_bytes(n))); 535 } 536 537 void InterpreterMacroAssembler::store_ptr(int n, Register val) { 538 z_stg(val, Address(Z_esp, Interpreter::expr_offset_in_bytes(n))); 539 } 540 541 void InterpreterMacroAssembler::prepare_to_jump_from_interpreted(Register method) { 542 // Satisfy interpreter calling convention (see generate_normal_entry()). 543 z_lgr(Z_R10, Z_SP); // Set sender sp (aka initial caller sp, aka unextended sp). 544 // Record top_frame_sp, because the callee might modify it, if it's compiled. 545 z_stg(Z_SP, _z_ijava_state_neg(top_frame_sp), Z_fp); 546 save_bcp(); 547 save_esp(); 548 z_lgr(Z_method, method); // Set Z_method (kills Z_fp!). 549 } 550 551 // Jump to from_interpreted entry of a call unless single stepping is possible 552 // in this thread in which case we must call the i2i entry. 553 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) { 554 assert_different_registers(method, Z_R10 /*used for initial_caller_sp*/, temp); 555 prepare_to_jump_from_interpreted(method); 556 557 if (JvmtiExport::can_post_interpreter_events()) { 558 // JVMTI events, such as single-stepping, are implemented partly by avoiding running 559 // compiled code in threads for which the event is enabled. Check here for 560 // interp_only_mode if these events CAN be enabled. 561 z_lg(Z_R1_scratch, Address(method, Method::from_interpreted_offset())); 562 MacroAssembler::load_and_test_int(Z_R0_scratch, Address(Z_thread, JavaThread::interp_only_mode_offset())); 563 z_bcr(bcondEqual, Z_R1_scratch); // Run compiled code if zero. 564 // Run interpreted. 565 z_lg(Z_R1_scratch, Address(method, Method::interpreter_entry_offset())); 566 z_br(Z_R1_scratch); 567 } else { 568 // Run compiled code. 569 z_lg(Z_R1_scratch, Address(method, Method::from_interpreted_offset())); 570 z_br(Z_R1_scratch); 571 } 572 } 573 574 #ifdef ASSERT 575 void InterpreterMacroAssembler::verify_esp(Register Resp, Register Rtemp) { 576 // About to read or write Resp[0]. 577 // Make sure it is not in the monitors or the TOP_IJAVA_FRAME_ABI. 578 address reentry = NULL; 579 580 { 581 // Check if the frame pointer in Z_fp is correct. 582 NearLabel OK; 583 z_cg(Z_fp, 0, Z_SP); 584 z_bre(OK); 585 reentry = stop_chain_static(reentry, "invalid frame pointer Z_fp"); 586 bind(OK); 587 } 588 { 589 // Resp must not point into or below the operand stack, 590 // i.e. IJAVA_STATE.monitors > Resp. 591 NearLabel OK; 592 Register Rmonitors = Rtemp; 593 z_lg(Rmonitors, _z_ijava_state_neg(monitors), Z_fp); 594 compareU64_and_branch(Rmonitors, Resp, bcondHigh, OK); 595 reentry = stop_chain_static(reentry, "too many pops: Z_esp points into monitor area"); 596 bind(OK); 597 } 598 { 599 // Resp may point to the last word of TOP_IJAVA_FRAME_ABI, but not below 600 // i.e. !(Z_SP + frame::z_top_ijava_frame_abi_size - Interpreter::stackElementSize > Resp). 601 NearLabel OK; 602 Register Rabi_bottom = Rtemp; 603 add2reg(Rabi_bottom, frame::z_top_ijava_frame_abi_size - Interpreter::stackElementSize, Z_SP); 604 compareU64_and_branch(Rabi_bottom, Resp, bcondNotHigh, OK); 605 reentry = stop_chain_static(reentry, "too many pushes: Z_esp points into TOP_IJAVA_FRAME_ABI"); 606 bind(OK); 607 } 608 } 609 610 void InterpreterMacroAssembler::asm_assert_ijava_state_magic(Register tmp) { 611 Label magic_ok; 612 load_const_optimized(tmp, frame::z_istate_magic_number); 613 z_cg(tmp, Address(Z_fp, _z_ijava_state_neg(magic))); 614 z_bre(magic_ok); 615 stop_static("error: wrong magic number in ijava_state access"); 616 bind(magic_ok); 617 } 618 #endif // ASSERT 619 620 void InterpreterMacroAssembler::save_bcp() { 621 z_stg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp))); 622 asm_assert_ijava_state_magic(Z_bcp); 623 NOT_PRODUCT(z_lg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp)))); 624 } 625 626 void InterpreterMacroAssembler::restore_bcp() { 627 asm_assert_ijava_state_magic(Z_bcp); 628 z_lg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp))); 629 } 630 631 void InterpreterMacroAssembler::save_esp() { 632 z_stg(Z_esp, Address(Z_fp, _z_ijava_state_neg(esp))); 633 } 634 635 void InterpreterMacroAssembler::restore_esp() { 636 asm_assert_ijava_state_magic(Z_esp); 637 z_lg(Z_esp, Address(Z_fp, _z_ijava_state_neg(esp))); 638 } 639 640 void InterpreterMacroAssembler::get_monitors(Register reg) { 641 asm_assert_ijava_state_magic(reg); 642 mem2reg_opt(reg, Address(Z_fp, _z_ijava_state_neg(monitors))); 643 } 644 645 void InterpreterMacroAssembler::save_monitors(Register reg) { 646 reg2mem_opt(reg, Address(Z_fp, _z_ijava_state_neg(monitors))); 647 } 648 649 void InterpreterMacroAssembler::get_mdp(Register mdp) { 650 z_lg(mdp, _z_ijava_state_neg(mdx), Z_fp); 651 } 652 653 void InterpreterMacroAssembler::save_mdp(Register mdp) { 654 z_stg(mdp, _z_ijava_state_neg(mdx), Z_fp); 655 } 656 657 // Values that are only read (besides initialization). 658 void InterpreterMacroAssembler::restore_locals() { 659 asm_assert_ijava_state_magic(Z_locals); 660 z_lg(Z_locals, Address(Z_fp, _z_ijava_state_neg(locals))); 661 } 662 663 void InterpreterMacroAssembler::get_method(Register reg) { 664 asm_assert_ijava_state_magic(reg); 665 z_lg(reg, Address(Z_fp, _z_ijava_state_neg(method))); 666 } 667 668 void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(Register Rdst, int bcp_offset, 669 signedOrNot is_signed) { 670 // Rdst is an 8-byte return value!!! 671 672 // Unaligned loads incur only a small penalty on z/Architecture. The penalty 673 // is a few (2..3) ticks, even when the load crosses a cache line 674 // boundary. In case of a cache miss, the stall could, of course, be 675 // much longer. 676 677 switch (is_signed) { 678 case Signed: 679 z_lgh(Rdst, bcp_offset, Z_R0, Z_bcp); 680 break; 681 case Unsigned: 682 z_llgh(Rdst, bcp_offset, Z_R0, Z_bcp); 683 break; 684 default: 685 ShouldNotReachHere(); 686 } 687 } 688 689 690 void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(Register Rdst, int bcp_offset, 691 setCCOrNot set_cc) { 692 // Rdst is an 8-byte return value!!! 693 694 // Unaligned loads incur only a small penalty on z/Architecture. The penalty 695 // is a few (2..3) ticks, even when the load crosses a cache line 696 // boundary. In case of a cache miss, the stall could, of course, be 697 // much longer. 698 699 // Both variants implement a sign-extending int2long load. 700 if (set_cc == set_CC) { 701 load_and_test_int2long(Rdst, Address(Z_bcp, (intptr_t)bcp_offset)); 702 } else { 703 mem2reg_signed_opt( Rdst, Address(Z_bcp, (intptr_t)bcp_offset)); 704 } 705 } 706 707 void InterpreterMacroAssembler::get_constant_pool(Register Rdst) { 708 get_method(Rdst); 709 mem2reg_opt(Rdst, Address(Rdst, Method::const_offset())); 710 mem2reg_opt(Rdst, Address(Rdst, ConstMethod::constants_offset())); 711 } 712 713 void InterpreterMacroAssembler::get_cpool_and_tags(Register Rcpool, Register Rtags) { 714 get_constant_pool(Rcpool); 715 mem2reg_opt(Rtags, Address(Rcpool, ConstantPool::tags_offset_in_bytes())); 716 } 717 718 // Unlock if synchronized method. 719 // 720 // Unlock the receiver if this is a synchronized method. 721 // Unlock any Java monitors from syncronized blocks. 722 // 723 // If there are locked Java monitors 724 // If throw_monitor_exception 725 // throws IllegalMonitorStateException 726 // Else if install_monitor_exception 727 // installs IllegalMonitorStateException 728 // Else 729 // no error processing 730 void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state, 731 bool throw_monitor_exception, 732 bool install_monitor_exception) { 733 NearLabel unlocked, unlock, no_unlock; 734 735 { 736 Register R_method = Z_ARG2; 737 Register R_do_not_unlock_if_synchronized = Z_ARG3; 738 739 // Get the value of _do_not_unlock_if_synchronized into G1_scratch. 740 const Address do_not_unlock_if_synchronized(Z_thread, 741 JavaThread::do_not_unlock_if_synchronized_offset()); 742 load_sized_value(R_do_not_unlock_if_synchronized, do_not_unlock_if_synchronized, 1, false /*unsigned*/); 743 z_mvi(do_not_unlock_if_synchronized, false); // Reset the flag. 744 745 // Check if synchronized method. 746 get_method(R_method); 747 verify_oop(Z_tos, state); 748 push(state); // Save tos/result. 749 testbit(method2_(R_method, access_flags), JVM_ACC_SYNCHRONIZED_BIT); 750 z_bfalse(unlocked); 751 752 // Don't unlock anything if the _do_not_unlock_if_synchronized flag 753 // is set. 754 compareU64_and_branch(R_do_not_unlock_if_synchronized, (intptr_t)0L, bcondNotEqual, no_unlock); 755 } 756 757 // unlock monitor 758 759 // BasicObjectLock will be first in list, since this is a 760 // synchronized method. However, need to check that the object has 761 // not been unlocked by an explicit monitorexit bytecode. 762 const Address monitor(Z_fp, -(frame::z_ijava_state_size + (int) sizeof(BasicObjectLock))); 763 // We use Z_ARG2 so that if we go slow path it will be the correct 764 // register for unlock_object to pass to VM directly. 765 load_address(Z_ARG2, monitor); // Address of first monitor. 766 z_lg(Z_ARG3, Address(Z_ARG2, BasicObjectLock::obj_offset_in_bytes())); 767 compareU64_and_branch(Z_ARG3, (intptr_t)0L, bcondNotEqual, unlock); 768 769 if (throw_monitor_exception) { 770 // Entry already unlocked need to throw an exception. 771 MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); 772 should_not_reach_here(); 773 } else { 774 // Monitor already unlocked during a stack unroll. 775 // If requested, install an illegal_monitor_state_exception. 776 // Continue with stack unrolling. 777 if (install_monitor_exception) { 778 MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception)); 779 } 780 z_bru(unlocked); 781 } 782 783 bind(unlock); 784 785 unlock_object(Z_ARG2); 786 787 bind(unlocked); 788 789 // I0, I1: Might contain return value 790 791 // Check that all monitors are unlocked. 792 { 793 NearLabel loop, exception, entry, restart; 794 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; 795 // We use Z_ARG2 so that if we go slow path it will be the correct 796 // register for unlock_object to pass to VM directly. 797 Register R_current_monitor = Z_ARG2; 798 Register R_monitor_block_bot = Z_ARG1; 799 const Address monitor_block_top(Z_fp, _z_ijava_state_neg(monitors)); 800 const Address monitor_block_bot(Z_fp, -frame::z_ijava_state_size); 801 802 bind(restart); 803 // Starting with top-most entry. 804 z_lg(R_current_monitor, monitor_block_top); 805 // Points to word before bottom of monitor block. 806 load_address(R_monitor_block_bot, monitor_block_bot); 807 z_bru(entry); 808 809 // Entry already locked, need to throw exception. 810 bind(exception); 811 812 if (throw_monitor_exception) { 813 // Throw exception. 814 MacroAssembler::call_VM(noreg, 815 CAST_FROM_FN_PTR(address, InterpreterRuntime:: 816 throw_illegal_monitor_state_exception)); 817 should_not_reach_here(); 818 } else { 819 // Stack unrolling. Unlock object and install illegal_monitor_exception. 820 // Unlock does not block, so don't have to worry about the frame. 821 // We don't have to preserve c_rarg1 since we are going to throw an exception. 822 unlock_object(R_current_monitor); 823 if (install_monitor_exception) { 824 call_VM(noreg, CAST_FROM_FN_PTR(address, 825 InterpreterRuntime:: 826 new_illegal_monitor_state_exception)); 827 } 828 z_bru(restart); 829 } 830 831 bind(loop); 832 // Check if current entry is used. 833 load_and_test_long(Z_R0_scratch, Address(R_current_monitor, BasicObjectLock::obj_offset_in_bytes())); 834 z_brne(exception); 835 836 add2reg(R_current_monitor, entry_size); // Otherwise advance to next entry. 837 bind(entry); 838 compareU64_and_branch(R_current_monitor, R_monitor_block_bot, bcondNotEqual, loop); 839 } 840 841 bind(no_unlock); 842 pop(state); 843 verify_oop(Z_tos, state); 844 } 845 846 void InterpreterMacroAssembler::narrow(Register result, Register ret_type) { 847 get_method(ret_type); 848 z_lg(ret_type, Address(ret_type, in_bytes(Method::const_offset()))); 849 z_lb(ret_type, Address(ret_type, in_bytes(ConstMethod::result_type_offset()))); 850 851 Label notBool, notByte, notChar, done; 852 853 // common case first 854 compareU32_and_branch(ret_type, T_INT, bcondEqual, done); 855 856 compareU32_and_branch(ret_type, T_BOOLEAN, bcondNotEqual, notBool); 857 z_nilf(result, 0x1); 858 z_bru(done); 859 860 bind(notBool); 861 compareU32_and_branch(ret_type, T_BYTE, bcondNotEqual, notByte); 862 z_lbr(result, result); 863 z_bru(done); 864 865 bind(notByte); 866 compareU32_and_branch(ret_type, T_CHAR, bcondNotEqual, notChar); 867 z_nilf(result, 0xffff); 868 z_bru(done); 869 870 bind(notChar); 871 // compareU32_and_branch(ret_type, T_SHORT, bcondNotEqual, notShort); 872 z_lhr(result, result); 873 874 // Nothing to do for T_INT 875 bind(done); 876 } 877 878 // remove activation 879 // 880 // Unlock the receiver if this is a synchronized method. 881 // Unlock any Java monitors from syncronized blocks. 882 // Remove the activation from the stack. 883 // 884 // If there are locked Java monitors 885 // If throw_monitor_exception 886 // throws IllegalMonitorStateException 887 // Else if install_monitor_exception 888 // installs IllegalMonitorStateException 889 // Else 890 // no error processing 891 void InterpreterMacroAssembler::remove_activation(TosState state, 892 Register return_pc, 893 bool throw_monitor_exception, 894 bool install_monitor_exception, 895 bool notify_jvmti) { 896 BLOCK_COMMENT("remove_activation {"); 897 unlock_if_synchronized_method(state, throw_monitor_exception, install_monitor_exception); 898 899 // Save result (push state before jvmti call and pop it afterwards) and notify jvmti. 900 notify_method_exit(false, state, notify_jvmti ? NotifyJVMTI : SkipNotifyJVMTI); 901 902 if (StackReservedPages > 0) { 903 BLOCK_COMMENT("reserved_stack_check:"); 904 // Test if reserved zone needs to be enabled. 905 Label no_reserved_zone_enabling; 906 907 // Compare frame pointers. There is no good stack pointer, as with stack 908 // frame compression we can get different SPs when we do calls. A subsequent 909 // call could have a smaller SP, so that this compare succeeds for an 910 // inner call of the method annotated with ReservedStack. 911 z_lg(Z_R0, Address(Z_SP, (intptr_t)_z_abi(callers_sp))); 912 z_clg(Z_R0, Address(Z_thread, JavaThread::reserved_stack_activation_offset())); // Compare with frame pointer in memory. 913 z_brl(no_reserved_zone_enabling); 914 915 // Enable reserved zone again, throw stack overflow exception. 916 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), Z_thread); 917 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_delayed_StackOverflowError)); 918 919 should_not_reach_here(); 920 921 bind(no_reserved_zone_enabling); 922 } 923 924 verify_oop(Z_tos, state); 925 verify_thread(); 926 927 pop_interpreter_frame(return_pc, Z_ARG2, Z_ARG3); 928 BLOCK_COMMENT("} remove_activation"); 929 } 930 931 // lock object 932 // 933 // Registers alive 934 // monitor - Address of the BasicObjectLock to be used for locking, 935 // which must be initialized with the object to lock. 936 // object - Address of the object to be locked. 937 void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { 938 939 if (UseHeavyMonitors) { 940 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), 941 monitor, /*check_for_exceptions=*/false); 942 return; 943 } 944 945 // template code: 946 // 947 // markOop displaced_header = obj->mark().set_unlocked(); 948 // monitor->lock()->set_displaced_header(displaced_header); 949 // if (Atomic::cmpxchg(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) { 950 // // We stored the monitor address into the object's mark word. 951 // } else if (THREAD->is_lock_owned((address)displaced_header)) 952 // // Simple recursive case. 953 // monitor->lock()->set_displaced_header(NULL); 954 // } else { 955 // // Slow path. 956 // InterpreterRuntime::monitorenter(THREAD, monitor); 957 // } 958 959 const Register displaced_header = Z_ARG5; 960 const Register object_mark_addr = Z_ARG4; 961 const Register current_header = Z_ARG5; 962 963 NearLabel done; 964 NearLabel slow_case; 965 966 // markOop displaced_header = obj->mark().set_unlocked(); 967 968 // Load markOop from object into displaced_header. 969 z_lg(displaced_header, oopDesc::mark_offset_in_bytes(), object); 970 971 if (UseBiasedLocking) { 972 biased_locking_enter(object, displaced_header, Z_R1, Z_R0, done, &slow_case); 973 } 974 975 // Set displaced_header to be (markOop of object | UNLOCK_VALUE). 976 z_oill(displaced_header, markOopDesc::unlocked_value); 977 978 // monitor->lock()->set_displaced_header(displaced_header); 979 980 // Initialize the box (Must happen before we update the object mark!). 981 z_stg(displaced_header, BasicObjectLock::lock_offset_in_bytes() + 982 BasicLock::displaced_header_offset_in_bytes(), monitor); 983 984 // if (Atomic::cmpxchg(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) { 985 986 // Store stack address of the BasicObjectLock (this is monitor) into object. 987 add2reg(object_mark_addr, oopDesc::mark_offset_in_bytes(), object); 988 989 z_csg(displaced_header, monitor, 0, object_mark_addr); 990 assert(current_header==displaced_header, "must be same register"); // Identified two registers from z/Architecture. 991 992 z_bre(done); 993 994 // } else if (THREAD->is_lock_owned((address)displaced_header)) 995 // // Simple recursive case. 996 // monitor->lock()->set_displaced_header(NULL); 997 998 // We did not see an unlocked object so try the fast recursive case. 999 1000 // Check if owner is self by comparing the value in the markOop of object 1001 // (current_header) with the stack pointer. 1002 z_sgr(current_header, Z_SP); 1003 1004 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant"); 1005 1006 // The prior sequence "LGR, NGR, LTGR" can be done better 1007 // (Z_R1 is temp and not used after here). 1008 load_const_optimized(Z_R0, (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place)); 1009 z_ngr(Z_R0, current_header); // AND sets CC (result eq/ne 0) 1010 1011 // If condition is true we are done and hence we can store 0 in the displaced 1012 // header indicating it is a recursive lock and be done. 1013 z_brne(slow_case); 1014 z_release(); // Membar unnecessary on zarch AND because the above csg does a sync before and after. 1015 z_stg(Z_R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() + 1016 BasicLock::displaced_header_offset_in_bytes(), monitor); 1017 z_bru(done); 1018 1019 // } else { 1020 // // Slow path. 1021 // InterpreterRuntime::monitorenter(THREAD, monitor); 1022 1023 // None of the above fast optimizations worked so we have to get into the 1024 // slow case of monitor enter. 1025 bind(slow_case); 1026 1027 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), 1028 monitor, /*check_for_exceptions=*/false); 1029 1030 // } 1031 1032 bind(done); 1033 } 1034 1035 // Unlocks an object. Used in monitorexit bytecode and remove_activation. 1036 // 1037 // Registers alive 1038 // monitor - address of the BasicObjectLock to be used for locking, 1039 // which must be initialized with the object to lock. 1040 // 1041 // Throw IllegalMonitorException if object is not locked by current thread. 1042 void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) { 1043 1044 if (UseHeavyMonitors) { 1045 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 1046 monitor, /*check_for_exceptions=*/ true); 1047 return; 1048 } 1049 1050 // else { 1051 // template code: 1052 // 1053 // if ((displaced_header = monitor->displaced_header()) == NULL) { 1054 // // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL. 1055 // monitor->set_obj(NULL); 1056 // } else if (Atomic::cmpxchg(displaced_header, obj->mark_addr(), monitor) == monitor) { 1057 // // We swapped the unlocked mark in displaced_header into the object's mark word. 1058 // monitor->set_obj(NULL); 1059 // } else { 1060 // // Slow path. 1061 // InterpreterRuntime::monitorexit(THREAD, monitor); 1062 // } 1063 1064 const Register displaced_header = Z_ARG4; 1065 const Register current_header = Z_R1; 1066 Address obj_entry(monitor, BasicObjectLock::obj_offset_in_bytes()); 1067 Label done; 1068 1069 if (object == noreg) { 1070 // In the template interpreter, we must assure that the object 1071 // entry in the monitor is cleared on all paths. Thus we move 1072 // loading up to here, and clear the entry afterwards. 1073 object = Z_ARG3; // Use Z_ARG3 if caller didn't pass object. 1074 z_lg(object, obj_entry); 1075 } 1076 1077 assert_different_registers(monitor, object, displaced_header, current_header); 1078 1079 // if ((displaced_header = monitor->displaced_header()) == NULL) { 1080 // // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL. 1081 // monitor->set_obj(NULL); 1082 1083 clear_mem(obj_entry, sizeof(oop)); 1084 1085 if (UseBiasedLocking) { 1086 // The object address from the monitor is in object. 1087 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); 1088 biased_locking_exit(object, displaced_header, done); 1089 } 1090 1091 // Test first if we are in the fast recursive case. 1092 MacroAssembler::load_and_test_long(displaced_header, 1093 Address(monitor, BasicObjectLock::lock_offset_in_bytes() + 1094 BasicLock::displaced_header_offset_in_bytes())); 1095 z_bre(done); // displaced_header == 0 -> goto done 1096 1097 // } else if (Atomic::cmpxchg(displaced_header, obj->mark_addr(), monitor) == monitor) { 1098 // // We swapped the unlocked mark in displaced_header into the object's mark word. 1099 // monitor->set_obj(NULL); 1100 1101 // If we still have a lightweight lock, unlock the object and be done. 1102 1103 // The markword is expected to be at offset 0. 1104 assert(oopDesc::mark_offset_in_bytes() == 0, "unlock_object: review code below"); 1105 1106 // We have the displaced header in displaced_header. If the lock is still 1107 // lightweight, it will contain the monitor address and we'll store the 1108 // displaced header back into the object's mark word. 1109 z_lgr(current_header, monitor); 1110 z_csg(current_header, displaced_header, 0, object); 1111 z_bre(done); 1112 1113 // } else { 1114 // // Slow path. 1115 // InterpreterRuntime::monitorexit(THREAD, monitor); 1116 1117 // The lock has been converted into a heavy lock and hence 1118 // we need to get into the slow case. 1119 z_stg(object, obj_entry); // Restore object entry, has been cleared above. 1120 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 1121 monitor, /*check_for_exceptions=*/false); 1122 1123 // } 1124 1125 bind(done); 1126 } 1127 1128 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) { 1129 assert(ProfileInterpreter, "must be profiling interpreter"); 1130 load_and_test_long(mdp, Address(Z_fp, _z_ijava_state_neg(mdx))); 1131 z_brz(zero_continue); 1132 } 1133 1134 // Set the method data pointer for the current bcp. 1135 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { 1136 assert(ProfileInterpreter, "must be profiling interpreter"); 1137 Label set_mdp; 1138 Register mdp = Z_ARG4; 1139 Register method = Z_ARG5; 1140 1141 get_method(method); 1142 // Test MDO to avoid the call if it is NULL. 1143 load_and_test_long(mdp, method2_(method, method_data)); 1144 z_brz(set_mdp); 1145 1146 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), method, Z_bcp); 1147 // Z_RET: mdi 1148 // Mdo is guaranteed to be non-zero here, we checked for it before the call. 1149 assert(method->is_nonvolatile(), "choose nonvolatile reg or reload from frame"); 1150 z_lg(mdp, method2_(method, method_data)); // Must reload, mdp is volatile reg. 1151 add2reg_with_index(mdp, in_bytes(MethodData::data_offset()), Z_RET, mdp); 1152 1153 bind(set_mdp); 1154 save_mdp(mdp); 1155 } 1156 1157 void InterpreterMacroAssembler::verify_method_data_pointer() { 1158 assert(ProfileInterpreter, "must be profiling interpreter"); 1159 #ifdef ASSERT 1160 NearLabel verify_continue; 1161 Register bcp_expected = Z_ARG3; 1162 Register mdp = Z_ARG4; 1163 Register method = Z_ARG5; 1164 1165 test_method_data_pointer(mdp, verify_continue); // If mdp is zero, continue 1166 get_method(method); 1167 1168 // If the mdp is valid, it will point to a DataLayout header which is 1169 // consistent with the bcp. The converse is highly probable also. 1170 load_sized_value(bcp_expected, Address(mdp, DataLayout::bci_offset()), 2, false /*signed*/); 1171 z_ag(bcp_expected, Address(method, Method::const_offset())); 1172 load_address(bcp_expected, Address(bcp_expected, ConstMethod::codes_offset())); 1173 compareU64_and_branch(bcp_expected, Z_bcp, bcondEqual, verify_continue); 1174 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), method, Z_bcp, mdp); 1175 bind(verify_continue); 1176 #endif // ASSERT 1177 } 1178 1179 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, int constant, Register value) { 1180 assert(ProfileInterpreter, "must be profiling interpreter"); 1181 z_stg(value, constant, mdp_in); 1182 } 1183 1184 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, 1185 int constant, 1186 Register tmp, 1187 bool decrement) { 1188 assert_different_registers(mdp_in, tmp); 1189 // counter address 1190 Address data(mdp_in, constant); 1191 const int delta = decrement ? -DataLayout::counter_increment : DataLayout::counter_increment; 1192 add2mem_64(Address(mdp_in, constant), delta, tmp); 1193 } 1194 1195 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, 1196 int flag_byte_constant) { 1197 assert(ProfileInterpreter, "must be profiling interpreter"); 1198 // Set the flag. 1199 z_oi(Address(mdp_in, DataLayout::flags_offset()), flag_byte_constant); 1200 } 1201 1202 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in, 1203 int offset, 1204 Register value, 1205 Register test_value_out, 1206 Label& not_equal_continue) { 1207 assert(ProfileInterpreter, "must be profiling interpreter"); 1208 if (test_value_out == noreg) { 1209 z_cg(value, Address(mdp_in, offset)); 1210 z_brne(not_equal_continue); 1211 } else { 1212 // Put the test value into a register, so caller can use it: 1213 z_lg(test_value_out, Address(mdp_in, offset)); 1214 compareU64_and_branch(test_value_out, value, bcondNotEqual, not_equal_continue); 1215 } 1216 } 1217 1218 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, int offset_of_disp) { 1219 update_mdp_by_offset(mdp_in, noreg, offset_of_disp); 1220 } 1221 1222 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 1223 Register dataidx, 1224 int offset_of_disp) { 1225 assert(ProfileInterpreter, "must be profiling interpreter"); 1226 Address disp_address(mdp_in, dataidx, offset_of_disp); 1227 Assembler::z_ag(mdp_in, disp_address); 1228 save_mdp(mdp_in); 1229 } 1230 1231 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, int constant) { 1232 assert(ProfileInterpreter, "must be profiling interpreter"); 1233 add2reg(mdp_in, constant); 1234 save_mdp(mdp_in); 1235 } 1236 1237 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { 1238 assert(ProfileInterpreter, "must be profiling interpreter"); 1239 assert(return_bci->is_nonvolatile(), "choose nonvolatile reg or save/restore"); 1240 call_VM(noreg, 1241 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), 1242 return_bci); 1243 } 1244 1245 void InterpreterMacroAssembler::profile_taken_branch(Register mdp, Register bumped_count) { 1246 if (ProfileInterpreter) { 1247 Label profile_continue; 1248 1249 // If no method data exists, go to profile_continue. 1250 // Otherwise, assign to mdp. 1251 test_method_data_pointer(mdp, profile_continue); 1252 1253 // We are taking a branch. Increment the taken count. 1254 // We inline increment_mdp_data_at to return bumped_count in a register 1255 //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset())); 1256 Address data(mdp, JumpData::taken_offset()); 1257 z_lg(bumped_count, data); 1258 // 64-bit overflow is very unlikely. Saturation to 32-bit values is 1259 // performed when reading the counts. 1260 add2reg(bumped_count, DataLayout::counter_increment); 1261 z_stg(bumped_count, data); // Store back out 1262 1263 // The method data pointer needs to be updated to reflect the new target. 1264 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset())); 1265 bind(profile_continue); 1266 } 1267 } 1268 1269 // Kills Z_R1_scratch. 1270 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { 1271 if (ProfileInterpreter) { 1272 Label profile_continue; 1273 1274 // If no method data exists, go to profile_continue. 1275 test_method_data_pointer(mdp, profile_continue); 1276 1277 // We are taking a branch. Increment the not taken count. 1278 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()), Z_R1_scratch); 1279 1280 // The method data pointer needs to be updated to correspond to 1281 // the next bytecode. 1282 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); 1283 bind(profile_continue); 1284 } 1285 } 1286 1287 // Kills: Z_R1_scratch. 1288 void InterpreterMacroAssembler::profile_call(Register mdp) { 1289 if (ProfileInterpreter) { 1290 Label profile_continue; 1291 1292 // If no method data exists, go to profile_continue. 1293 test_method_data_pointer(mdp, profile_continue); 1294 1295 // We are making a call. Increment the count. 1296 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1297 1298 // The method data pointer needs to be updated to reflect the new target. 1299 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size())); 1300 bind(profile_continue); 1301 } 1302 } 1303 1304 void InterpreterMacroAssembler::profile_final_call(Register mdp) { 1305 if (ProfileInterpreter) { 1306 Label profile_continue; 1307 1308 // If no method data exists, go to profile_continue. 1309 test_method_data_pointer(mdp, profile_continue); 1310 1311 // We are making a call. Increment the count. 1312 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1313 1314 // The method data pointer needs to be updated to reflect the new target. 1315 update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); 1316 bind(profile_continue); 1317 } 1318 } 1319 1320 void InterpreterMacroAssembler::profile_virtual_call(Register receiver, 1321 Register mdp, 1322 Register reg2, 1323 bool receiver_can_be_null) { 1324 if (ProfileInterpreter) { 1325 NearLabel profile_continue; 1326 1327 // If no method data exists, go to profile_continue. 1328 test_method_data_pointer(mdp, profile_continue); 1329 1330 NearLabel skip_receiver_profile; 1331 if (receiver_can_be_null) { 1332 NearLabel not_null; 1333 compareU64_and_branch(receiver, (intptr_t)0L, bcondNotEqual, not_null); 1334 // We are making a call. Increment the count for null receiver. 1335 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1336 z_bru(skip_receiver_profile); 1337 bind(not_null); 1338 } 1339 1340 // Record the receiver type. 1341 record_klass_in_profile(receiver, mdp, reg2, true); 1342 bind(skip_receiver_profile); 1343 1344 // The method data pointer needs to be updated to reflect the new target. 1345 update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); 1346 bind(profile_continue); 1347 } 1348 } 1349 1350 // This routine creates a state machine for updating the multi-row 1351 // type profile at a virtual call site (or other type-sensitive bytecode). 1352 // The machine visits each row (of receiver/count) until the receiver type 1353 // is found, or until it runs out of rows. At the same time, it remembers 1354 // the location of the first empty row. (An empty row records null for its 1355 // receiver, and can be allocated for a newly-observed receiver type.) 1356 // Because there are two degrees of freedom in the state, a simple linear 1357 // search will not work; it must be a decision tree. Hence this helper 1358 // function is recursive, to generate the required tree structured code. 1359 // It's the interpreter, so we are trading off code space for speed. 1360 // See below for example code. 1361 void InterpreterMacroAssembler::record_klass_in_profile_helper( 1362 Register receiver, Register mdp, 1363 Register reg2, int start_row, 1364 Label& done, bool is_virtual_call) { 1365 if (TypeProfileWidth == 0) { 1366 if (is_virtual_call) { 1367 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1368 } 1369 return; 1370 } 1371 1372 int last_row = VirtualCallData::row_limit() - 1; 1373 assert(start_row <= last_row, "must be work left to do"); 1374 // Test this row for both the receiver and for null. 1375 // Take any of three different outcomes: 1376 // 1. found receiver => increment count and goto done 1377 // 2. found null => keep looking for case 1, maybe allocate this cell 1378 // 3. found something else => keep looking for cases 1 and 2 1379 // Case 3 is handled by a recursive call. 1380 for (int row = start_row; row <= last_row; row++) { 1381 NearLabel next_test; 1382 bool test_for_null_also = (row == start_row); 1383 1384 // See if the receiver is receiver[n]. 1385 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row)); 1386 test_mdp_data_at(mdp, recvr_offset, receiver, 1387 (test_for_null_also ? reg2 : noreg), 1388 next_test); 1389 // (Reg2 now contains the receiver from the CallData.) 1390 1391 // The receiver is receiver[n]. Increment count[n]. 1392 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row)); 1393 increment_mdp_data_at(mdp, count_offset); 1394 z_bru(done); 1395 bind(next_test); 1396 1397 if (test_for_null_also) { 1398 Label found_null; 1399 // Failed the equality check on receiver[n]... Test for null. 1400 z_ltgr(reg2, reg2); 1401 if (start_row == last_row) { 1402 // The only thing left to do is handle the null case. 1403 if (is_virtual_call) { 1404 z_brz(found_null); 1405 // Receiver did not match any saved receiver and there is no empty row for it. 1406 // Increment total counter to indicate polymorphic case. 1407 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1408 z_bru(done); 1409 bind(found_null); 1410 } else { 1411 z_brnz(done); 1412 } 1413 break; 1414 } 1415 // Since null is rare, make it be the branch-taken case. 1416 z_brz(found_null); 1417 1418 // Put all the "Case 3" tests here. 1419 record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done, is_virtual_call); 1420 1421 // Found a null. Keep searching for a matching receiver, 1422 // but remember that this is an empty (unused) slot. 1423 bind(found_null); 1424 } 1425 } 1426 1427 // In the fall-through case, we found no matching receiver, but we 1428 // observed the receiver[start_row] is NULL. 1429 1430 // Fill in the receiver field and increment the count. 1431 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row)); 1432 set_mdp_data_at(mdp, recvr_offset, receiver); 1433 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row)); 1434 load_const_optimized(reg2, DataLayout::counter_increment); 1435 set_mdp_data_at(mdp, count_offset, reg2); 1436 if (start_row > 0) { 1437 z_bru(done); 1438 } 1439 } 1440 1441 // Example state machine code for three profile rows: 1442 // // main copy of decision tree, rooted at row[1] 1443 // if (row[0].rec == rec) { row[0].incr(); goto done; } 1444 // if (row[0].rec != NULL) { 1445 // // inner copy of decision tree, rooted at row[1] 1446 // if (row[1].rec == rec) { row[1].incr(); goto done; } 1447 // if (row[1].rec != NULL) { 1448 // // degenerate decision tree, rooted at row[2] 1449 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1450 // if (row[2].rec != NULL) { count.incr(); goto done; } // overflow 1451 // row[2].init(rec); goto done; 1452 // } else { 1453 // // remember row[1] is empty 1454 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1455 // row[1].init(rec); goto done; 1456 // } 1457 // } else { 1458 // // remember row[0] is empty 1459 // if (row[1].rec == rec) { row[1].incr(); goto done; } 1460 // if (row[2].rec == rec) { row[2].incr(); goto done; } 1461 // row[0].init(rec); goto done; 1462 // } 1463 // done: 1464 1465 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, 1466 Register mdp, Register reg2, 1467 bool is_virtual_call) { 1468 assert(ProfileInterpreter, "must be profiling"); 1469 Label done; 1470 1471 record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call); 1472 1473 bind (done); 1474 } 1475 1476 void InterpreterMacroAssembler::profile_ret(Register return_bci, Register mdp) { 1477 if (ProfileInterpreter) { 1478 NearLabel profile_continue; 1479 uint row; 1480 1481 // If no method data exists, go to profile_continue. 1482 test_method_data_pointer(mdp, profile_continue); 1483 1484 // Update the total ret count. 1485 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); 1486 1487 for (row = 0; row < RetData::row_limit(); row++) { 1488 NearLabel next_test; 1489 1490 // See if return_bci is equal to bci[n]: 1491 test_mdp_data_at(mdp, 1492 in_bytes(RetData::bci_offset(row)), 1493 return_bci, noreg, 1494 next_test); 1495 1496 // Return_bci is equal to bci[n]. Increment the count. 1497 increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row))); 1498 1499 // The method data pointer needs to be updated to reflect the new target. 1500 update_mdp_by_offset(mdp, in_bytes(RetData::bci_displacement_offset(row))); 1501 z_bru(profile_continue); 1502 bind(next_test); 1503 } 1504 1505 update_mdp_for_ret(return_bci); 1506 1507 bind(profile_continue); 1508 } 1509 } 1510 1511 void InterpreterMacroAssembler::profile_null_seen(Register mdp) { 1512 if (ProfileInterpreter) { 1513 Label profile_continue; 1514 1515 // If no method data exists, go to profile_continue. 1516 test_method_data_pointer(mdp, profile_continue); 1517 1518 set_mdp_flag_at(mdp, BitData::null_seen_byte_constant()); 1519 1520 // The method data pointer needs to be updated. 1521 int mdp_delta = in_bytes(BitData::bit_data_size()); 1522 if (TypeProfileCasts) { 1523 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1524 } 1525 update_mdp_by_constant(mdp, mdp_delta); 1526 1527 bind(profile_continue); 1528 } 1529 } 1530 1531 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp, Register tmp) { 1532 if (ProfileInterpreter && TypeProfileCasts) { 1533 Label profile_continue; 1534 1535 // If no method data exists, go to profile_continue. 1536 test_method_data_pointer(mdp, profile_continue); 1537 1538 int count_offset = in_bytes(CounterData::count_offset()); 1539 // Back up the address, since we have already bumped the mdp. 1540 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); 1541 1542 // *Decrement* the counter. We expect to see zero or small negatives. 1543 increment_mdp_data_at(mdp, count_offset, tmp, true); 1544 1545 bind (profile_continue); 1546 } 1547 } 1548 1549 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) { 1550 if (ProfileInterpreter) { 1551 Label profile_continue; 1552 1553 // If no method data exists, go to profile_continue. 1554 test_method_data_pointer(mdp, profile_continue); 1555 1556 // The method data pointer needs to be updated. 1557 int mdp_delta = in_bytes(BitData::bit_data_size()); 1558 if (TypeProfileCasts) { 1559 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1560 1561 // Record the object type. 1562 record_klass_in_profile(klass, mdp, reg2, false); 1563 } 1564 update_mdp_by_constant(mdp, mdp_delta); 1565 1566 bind(profile_continue); 1567 } 1568 } 1569 1570 void InterpreterMacroAssembler::profile_switch_default(Register mdp) { 1571 if (ProfileInterpreter) { 1572 Label profile_continue; 1573 1574 // If no method data exists, go to profile_continue. 1575 test_method_data_pointer(mdp, profile_continue); 1576 1577 // Update the default case count. 1578 increment_mdp_data_at(mdp, in_bytes(MultiBranchData::default_count_offset())); 1579 1580 // The method data pointer needs to be updated. 1581 update_mdp_by_offset(mdp, in_bytes(MultiBranchData::default_displacement_offset())); 1582 1583 bind(profile_continue); 1584 } 1585 } 1586 1587 // Kills: index, scratch1, scratch2. 1588 void InterpreterMacroAssembler::profile_switch_case(Register index, 1589 Register mdp, 1590 Register scratch1, 1591 Register scratch2) { 1592 if (ProfileInterpreter) { 1593 Label profile_continue; 1594 assert_different_registers(index, mdp, scratch1, scratch2); 1595 1596 // If no method data exists, go to profile_continue. 1597 test_method_data_pointer(mdp, profile_continue); 1598 1599 // Build the base (index * per_case_size_in_bytes()) + 1600 // case_array_offset_in_bytes(). 1601 z_sllg(index, index, exact_log2(in_bytes(MultiBranchData::per_case_size()))); 1602 add2reg(index, in_bytes(MultiBranchData::case_array_offset())); 1603 1604 // Add the calculated base to the mdp -> address of the case' data. 1605 Address case_data_addr(mdp, index); 1606 Register case_data = scratch1; 1607 load_address(case_data, case_data_addr); 1608 1609 // Update the case count. 1610 increment_mdp_data_at(case_data, 1611 in_bytes(MultiBranchData::relative_count_offset()), 1612 scratch2); 1613 1614 // The method data pointer needs to be updated. 1615 update_mdp_by_offset(mdp, 1616 index, 1617 in_bytes(MultiBranchData::relative_displacement_offset())); 1618 1619 bind(profile_continue); 1620 } 1621 } 1622 1623 // kills: R0, R1, flags, loads klass from obj (if not null) 1624 void InterpreterMacroAssembler::profile_obj_type(Register obj, Address mdo_addr, Register klass, bool cmp_done) { 1625 NearLabel null_seen, init_klass, do_nothing, do_update; 1626 1627 // Klass = obj is allowed. 1628 const Register tmp = Z_R1; 1629 assert_different_registers(obj, mdo_addr.base(), tmp, Z_R0); 1630 assert_different_registers(klass, mdo_addr.base(), tmp, Z_R0); 1631 1632 z_lg(tmp, mdo_addr); 1633 if (cmp_done) { 1634 z_brz(null_seen); 1635 } else { 1636 compareU64_and_branch(obj, (intptr_t)0, Assembler::bcondEqual, null_seen); 1637 } 1638 1639 verify_oop(obj); 1640 load_klass(klass, obj); 1641 1642 // Klass seen before, nothing to do (regardless of unknown bit). 1643 z_lgr(Z_R0, tmp); 1644 assert(Immediate::is_uimm(~TypeEntries::type_klass_mask, 16), "or change following instruction"); 1645 z_nill(Z_R0, TypeEntries::type_klass_mask & 0xFFFF); 1646 compareU64_and_branch(Z_R0, klass, Assembler::bcondEqual, do_nothing); 1647 1648 // Already unknown. Nothing to do anymore. 1649 z_tmll(tmp, TypeEntries::type_unknown); 1650 z_brc(Assembler::bcondAllOne, do_nothing); 1651 1652 z_lgr(Z_R0, tmp); 1653 assert(Immediate::is_uimm(~TypeEntries::type_mask, 16), "or change following instruction"); 1654 z_nill(Z_R0, TypeEntries::type_mask & 0xFFFF); 1655 compareU64_and_branch(Z_R0, (intptr_t)0, Assembler::bcondEqual, init_klass); 1656 1657 // Different than before. Cannot keep accurate profile. 1658 z_oill(tmp, TypeEntries::type_unknown); 1659 z_bru(do_update); 1660 1661 bind(init_klass); 1662 // Combine klass and null_seen bit (only used if (tmp & type_mask)==0). 1663 z_ogr(tmp, klass); 1664 z_bru(do_update); 1665 1666 bind(null_seen); 1667 // Set null_seen if obj is 0. 1668 z_oill(tmp, TypeEntries::null_seen); 1669 // fallthru: z_bru(do_update); 1670 1671 bind(do_update); 1672 z_stg(tmp, mdo_addr); 1673 1674 bind(do_nothing); 1675 } 1676 1677 void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { 1678 if (!ProfileInterpreter) { 1679 return; 1680 } 1681 1682 assert_different_registers(mdp, callee, tmp); 1683 1684 if (MethodData::profile_arguments() || MethodData::profile_return()) { 1685 Label profile_continue; 1686 1687 test_method_data_pointer(mdp, profile_continue); 1688 1689 int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); 1690 1691 z_cliy(in_bytes(DataLayout::tag_offset()) - off_to_start, mdp, 1692 is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); 1693 z_brne(profile_continue); 1694 1695 if (MethodData::profile_arguments()) { 1696 NearLabel done; 1697 int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); 1698 add2reg(mdp, off_to_args); 1699 1700 for (int i = 0; i < TypeProfileArgsLimit; i++) { 1701 if (i > 0 || MethodData::profile_return()) { 1702 // If return value type is profiled we may have no argument to profile. 1703 z_lg(tmp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, mdp); 1704 add2reg(tmp, -i*TypeStackSlotEntries::per_arg_count()); 1705 compare64_and_branch(tmp, TypeStackSlotEntries::per_arg_count(), Assembler::bcondLow, done); 1706 } 1707 z_lg(tmp, Address(callee, Method::const_offset())); 1708 z_lgh(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); 1709 // Stack offset o (zero based) from the start of the argument 1710 // list. For n arguments translates into offset n - o - 1 from 1711 // the end of the argument list. But there is an extra slot at 1712 // the top of the stack. So the offset is n - o from Lesp. 1713 z_sg(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); 1714 z_sllg(tmp, tmp, Interpreter::logStackElementSize); 1715 Address stack_slot_addr(tmp, Z_esp); 1716 z_ltg(tmp, stack_slot_addr); 1717 1718 Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); 1719 profile_obj_type(tmp, mdo_arg_addr, tmp, /*ltg did compare to 0*/ true); 1720 1721 int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); 1722 add2reg(mdp, to_add); 1723 off_to_args += to_add; 1724 } 1725 1726 if (MethodData::profile_return()) { 1727 z_lg(tmp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, mdp); 1728 add2reg(tmp, -TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); 1729 } 1730 1731 bind(done); 1732 1733 if (MethodData::profile_return()) { 1734 // We're right after the type profile for the last 1735 // argument. Tmp is the number of cells left in the 1736 // CallTypeData/VirtualCallTypeData to reach its end. Non null 1737 // if there's a return to profile. 1738 assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); 1739 z_sllg(tmp, tmp, exact_log2(DataLayout::cell_size)); 1740 z_agr(mdp, tmp); 1741 } 1742 z_stg(mdp, _z_ijava_state_neg(mdx), Z_fp); 1743 } else { 1744 assert(MethodData::profile_return(), "either profile call args or call ret"); 1745 update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size())); 1746 } 1747 1748 // Mdp points right after the end of the 1749 // CallTypeData/VirtualCallTypeData, right after the cells for the 1750 // return value type if there's one. 1751 bind(profile_continue); 1752 } 1753 } 1754 1755 void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { 1756 assert_different_registers(mdp, ret, tmp); 1757 if (ProfileInterpreter && MethodData::profile_return()) { 1758 Label profile_continue; 1759 1760 test_method_data_pointer(mdp, profile_continue); 1761 1762 if (MethodData::profile_return_jsr292_only()) { 1763 // If we don't profile all invoke bytecodes we must make sure 1764 // it's a bytecode we indeed profile. We can't go back to the 1765 // beginning of the ProfileData we intend to update to check its 1766 // type because we're right after it and we don't known its 1767 // length. 1768 NearLabel do_profile; 1769 Address bc(Z_bcp); 1770 z_lb(tmp, bc); 1771 compare32_and_branch(tmp, Bytecodes::_invokedynamic, Assembler::bcondEqual, do_profile); 1772 compare32_and_branch(tmp, Bytecodes::_invokehandle, Assembler::bcondEqual, do_profile); 1773 get_method(tmp); 1774 // Supplement to 8139891: _intrinsic_id exceeded 1-byte size limit. 1775 if (Method::intrinsic_id_size_in_bytes() == 1) { 1776 z_cli(Method::intrinsic_id_offset_in_bytes(), tmp, vmIntrinsics::_compiledLambdaForm); 1777 } else { 1778 assert(Method::intrinsic_id_size_in_bytes() == 2, "size error: check Method::_intrinsic_id"); 1779 z_lh(tmp, Method::intrinsic_id_offset_in_bytes(), Z_R0, tmp); 1780 z_chi(tmp, vmIntrinsics::_compiledLambdaForm); 1781 } 1782 z_brne(profile_continue); 1783 1784 bind(do_profile); 1785 } 1786 1787 Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); 1788 profile_obj_type(ret, mdo_ret_addr, tmp); 1789 1790 bind(profile_continue); 1791 } 1792 } 1793 1794 void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) { 1795 if (ProfileInterpreter && MethodData::profile_parameters()) { 1796 Label profile_continue, done; 1797 1798 test_method_data_pointer(mdp, profile_continue); 1799 1800 // Load the offset of the area within the MDO used for 1801 // parameters. If it's negative we're not profiling any parameters. 1802 Address parm_di_addr(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset())); 1803 load_and_test_int2long(tmp1, parm_di_addr); 1804 z_brl(profile_continue); 1805 1806 // Compute a pointer to the area for parameters from the offset 1807 // and move the pointer to the slot for the last 1808 // parameters. Collect profiling from last parameter down. 1809 // mdo start + parameters offset + array length - 1 1810 1811 // Pointer to the parameter area in the MDO. 1812 z_agr(mdp, tmp1); 1813 1814 // Offset of the current profile entry to update. 1815 const Register entry_offset = tmp1; 1816 // entry_offset = array len in number of cells. 1817 z_lg(entry_offset, Address(mdp, ArrayData::array_len_offset())); 1818 // entry_offset (number of cells) = array len - size of 1 entry 1819 add2reg(entry_offset, -TypeStackSlotEntries::per_arg_count()); 1820 // entry_offset in bytes 1821 z_sllg(entry_offset, entry_offset, exact_log2(DataLayout::cell_size)); 1822 1823 Label loop; 1824 bind(loop); 1825 1826 Address arg_off(mdp, entry_offset, ParametersTypeData::stack_slot_offset(0)); 1827 Address arg_type(mdp, entry_offset, ParametersTypeData::type_offset(0)); 1828 1829 // Load offset on the stack from the slot for this parameter. 1830 z_lg(tmp2, arg_off); 1831 z_sllg(tmp2, tmp2, Interpreter::logStackElementSize); 1832 z_lcgr(tmp2); // Negate. 1833 1834 // Profile the parameter. 1835 z_ltg(tmp2, Address(Z_locals, tmp2)); 1836 profile_obj_type(tmp2, arg_type, tmp2, /*ltg did compare to 0*/ true); 1837 1838 // Go to next parameter. 1839 z_aghi(entry_offset, -TypeStackSlotEntries::per_arg_count() * DataLayout::cell_size); 1840 z_brnl(loop); 1841 1842 bind(profile_continue); 1843 } 1844 } 1845 1846 // Jump if ((*counter_addr += increment) & mask) satisfies the condition. 1847 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, 1848 int increment, 1849 Address mask, 1850 Register scratch, 1851 bool preloaded, 1852 branch_condition cond, 1853 Label *where) { 1854 assert_different_registers(counter_addr.base(), scratch); 1855 if (preloaded) { 1856 add2reg(scratch, increment); 1857 reg2mem_opt(scratch, counter_addr, false); 1858 } else { 1859 if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment) && counter_addr.is_RSYform()) { 1860 z_alsi(counter_addr.disp20(), counter_addr.base(), increment); 1861 mem2reg_signed_opt(scratch, counter_addr); 1862 } else { 1863 mem2reg_signed_opt(scratch, counter_addr); 1864 add2reg(scratch, increment); 1865 reg2mem_opt(scratch, counter_addr, false); 1866 } 1867 } 1868 z_n(scratch, mask); 1869 if (where) { z_brc(cond, *where); } 1870 } 1871 1872 // Get MethodCounters object for given method. Lazily allocated if necessary. 1873 // method - Ptr to Method object. 1874 // Rcounters - Ptr to MethodCounters object associated with Method object. 1875 // skip - Exit point if MethodCounters object can't be created (OOM condition). 1876 void InterpreterMacroAssembler::get_method_counters(Register Rmethod, 1877 Register Rcounters, 1878 Label& skip) { 1879 assert_different_registers(Rmethod, Rcounters); 1880 1881 BLOCK_COMMENT("get MethodCounters object {"); 1882 1883 Label has_counters; 1884 load_and_test_long(Rcounters, Address(Rmethod, Method::method_counters_offset())); 1885 z_brnz(has_counters); 1886 1887 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), Rmethod, false); 1888 z_ltgr(Rcounters, Z_RET); // Runtime call returns MethodCounters object. 1889 z_brz(skip); // No MethodCounters, out of memory. 1890 1891 bind(has_counters); 1892 1893 BLOCK_COMMENT("} get MethodCounters object"); 1894 } 1895 1896 // Increment invocation counter in MethodCounters object. 1897 // Return (invocation_counter+backedge_counter) as "result" in RctrSum. 1898 // Counter values are all unsigned. 1899 void InterpreterMacroAssembler::increment_invocation_counter(Register Rcounters, Register RctrSum) { 1900 assert(UseCompiler || LogTouchedMethods, "incrementing must be useful"); 1901 assert_different_registers(Rcounters, RctrSum); 1902 1903 int increment = InvocationCounter::count_increment; 1904 int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset()); 1905 int be_counter_offset = in_bytes(MethodCounters::backedge_counter_offset() + InvocationCounter::counter_offset()); 1906 1907 BLOCK_COMMENT("Increment invocation counter {"); 1908 1909 if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment)) { 1910 // Increment the invocation counter in place, 1911 // then add the incremented value to the backedge counter. 1912 z_l(RctrSum, be_counter_offset, Rcounters); 1913 z_alsi(inv_counter_offset, Rcounters, increment); // Atomic increment @no extra cost! 1914 z_nilf(RctrSum, InvocationCounter::count_mask_value); // Mask off state bits. 1915 z_al(RctrSum, inv_counter_offset, Z_R0, Rcounters); 1916 } else { 1917 // This path is optimized for low register consumption 1918 // at the cost of somewhat higher operand delays. 1919 // It does not need an extra temp register. 1920 1921 // Update the invocation counter. 1922 z_l(RctrSum, inv_counter_offset, Rcounters); 1923 if (RctrSum == Z_R0) { 1924 z_ahi(RctrSum, increment); 1925 } else { 1926 add2reg(RctrSum, increment); 1927 } 1928 z_st(RctrSum, inv_counter_offset, Rcounters); 1929 1930 // Mask off the state bits. 1931 z_nilf(RctrSum, InvocationCounter::count_mask_value); 1932 1933 // Add the backedge counter to the updated invocation counter to 1934 // form the result. 1935 z_al(RctrSum, be_counter_offset, Z_R0, Rcounters); 1936 } 1937 1938 BLOCK_COMMENT("} Increment invocation counter"); 1939 1940 // Note that this macro must leave the backedge_count + invocation_count in Rtmp! 1941 } 1942 1943 1944 // increment backedge counter in MethodCounters object. 1945 // return (invocation_counter+backedge_counter) as "result" in RctrSum 1946 // counter values are all unsigned! 1947 void InterpreterMacroAssembler::increment_backedge_counter(Register Rcounters, Register RctrSum) { 1948 assert(UseCompiler, "incrementing must be useful"); 1949 assert_different_registers(Rcounters, RctrSum); 1950 1951 int increment = InvocationCounter::count_increment; 1952 int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset()); 1953 int be_counter_offset = in_bytes(MethodCounters::backedge_counter_offset() + InvocationCounter::counter_offset()); 1954 1955 BLOCK_COMMENT("Increment backedge counter {"); 1956 1957 if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment)) { 1958 // Increment the invocation counter in place, 1959 // then add the incremented value to the backedge counter. 1960 z_l(RctrSum, inv_counter_offset, Rcounters); 1961 z_alsi(be_counter_offset, Rcounters, increment); // Atomic increment @no extra cost! 1962 z_nilf(RctrSum, InvocationCounter::count_mask_value); // Mask off state bits. 1963 z_al(RctrSum, be_counter_offset, Z_R0, Rcounters); 1964 } else { 1965 // This path is optimized for low register consumption 1966 // at the cost of somewhat higher operand delays. 1967 // It does not need an extra temp register. 1968 1969 // Update the invocation counter. 1970 z_l(RctrSum, be_counter_offset, Rcounters); 1971 if (RctrSum == Z_R0) { 1972 z_ahi(RctrSum, increment); 1973 } else { 1974 add2reg(RctrSum, increment); 1975 } 1976 z_st(RctrSum, be_counter_offset, Rcounters); 1977 1978 // Mask off the state bits. 1979 z_nilf(RctrSum, InvocationCounter::count_mask_value); 1980 1981 // Add the backedge counter to the updated invocation counter to 1982 // form the result. 1983 z_al(RctrSum, inv_counter_offset, Z_R0, Rcounters); 1984 } 1985 1986 BLOCK_COMMENT("} Increment backedge counter"); 1987 1988 // Note that this macro must leave the backedge_count + invocation_count in Rtmp! 1989 } 1990 1991 // Add an InterpMonitorElem to stack (see frame_s390.hpp). 1992 void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, 1993 Register Rtemp1, 1994 Register Rtemp2, 1995 Register Rtemp3) { 1996 1997 const Register Rcurr_slot = Rtemp1; 1998 const Register Rlimit = Rtemp2; 1999 const jint delta = -frame::interpreter_frame_monitor_size() * wordSize; 2000 2001 assert((delta & LongAlignmentMask) == 0, 2002 "sizeof BasicObjectLock must be even number of doublewords"); 2003 assert(2 * wordSize == -delta, "this works only as long as delta == -2*wordSize"); 2004 assert(Rcurr_slot != Z_R0, "Register must be usable as base register"); 2005 assert_different_registers(Rlimit, Rcurr_slot, Rtemp3); 2006 2007 get_monitors(Rlimit); 2008 2009 // Adjust stack pointer for additional monitor entry. 2010 resize_frame(RegisterOrConstant((intptr_t) delta), Z_fp, false); 2011 2012 if (!stack_is_empty) { 2013 // Must copy stack contents down. 2014 NearLabel next, done; 2015 2016 // Rtemp := addr(Tos), Z_esp is pointing below it! 2017 add2reg(Rcurr_slot, wordSize, Z_esp); 2018 2019 // Nothing to do, if already at monitor area. 2020 compareU64_and_branch(Rcurr_slot, Rlimit, bcondNotLow, done); 2021 2022 bind(next); 2023 2024 // Move one stack slot. 2025 mem2reg_opt(Rtemp3, Address(Rcurr_slot)); 2026 reg2mem_opt(Rtemp3, Address(Rcurr_slot, delta)); 2027 add2reg(Rcurr_slot, wordSize); 2028 compareU64_and_branch(Rcurr_slot, Rlimit, bcondLow, next); // Are we done? 2029 2030 bind(done); 2031 // Done copying stack. 2032 } 2033 2034 // Adjust expression stack and monitor pointers. 2035 add2reg(Z_esp, delta); 2036 add2reg(Rlimit, delta); 2037 save_monitors(Rlimit); 2038 } 2039 2040 // Note: Index holds the offset in bytes afterwards. 2041 // You can use this to store a new value (with Llocals as the base). 2042 void InterpreterMacroAssembler::access_local_int(Register index, Register dst) { 2043 z_sllg(index, index, LogBytesPerWord); 2044 mem2reg_opt(dst, Address(Z_locals, index), false); 2045 } 2046 2047 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { 2048 if (state == atos) { MacroAssembler::verify_oop(reg); } 2049 } 2050 2051 // Inline assembly for: 2052 // 2053 // if (thread is in interp_only_mode) { 2054 // InterpreterRuntime::post_method_entry(); 2055 // } 2056 2057 void InterpreterMacroAssembler::notify_method_entry() { 2058 2059 // JVMTI 2060 // Whenever JVMTI puts a thread in interp_only_mode, method 2061 // entry/exit events are sent for that thread to track stack 2062 // depth. If it is possible to enter interp_only_mode we add 2063 // the code to check if the event should be sent. 2064 if (JvmtiExport::can_post_interpreter_events()) { 2065 Label jvmti_post_done; 2066 MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset())); 2067 z_bre(jvmti_post_done); 2068 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry), /*check_exceptions=*/false); 2069 bind(jvmti_post_done); 2070 } 2071 } 2072 2073 // Inline assembly for: 2074 // 2075 // if (thread is in interp_only_mode) { 2076 // if (!native_method) save result 2077 // InterpreterRuntime::post_method_exit(); 2078 // if (!native_method) restore result 2079 // } 2080 // if (DTraceMethodProbes) { 2081 // SharedRuntime::dtrace_method_exit(thread, method); 2082 // } 2083 // 2084 // For native methods their result is stored in z_ijava_state.lresult 2085 // and z_ijava_state.fresult before coming here. 2086 // Java methods have their result stored in the expression stack. 2087 // 2088 // Notice the dependency to frame::interpreter_frame_result(). 2089 void InterpreterMacroAssembler::notify_method_exit(bool native_method, 2090 TosState state, 2091 NotifyMethodExitMode mode) { 2092 // JVMTI 2093 // Whenever JVMTI puts a thread in interp_only_mode, method 2094 // entry/exit events are sent for that thread to track stack 2095 // depth. If it is possible to enter interp_only_mode we add 2096 // the code to check if the event should be sent. 2097 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { 2098 Label jvmti_post_done; 2099 MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset())); 2100 z_bre(jvmti_post_done); 2101 if (!native_method) push(state); // see frame::interpreter_frame_result() 2102 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit), /*check_exceptions=*/false); 2103 if (!native_method) pop(state); 2104 bind(jvmti_post_done); 2105 } 2106 2107 #if 0 2108 // Dtrace currently not supported on z/Architecture. 2109 { 2110 SkipIfEqual skip(this, &DTraceMethodProbes, false); 2111 push(state); 2112 get_method(c_rarg1); 2113 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), 2114 r15_thread, c_rarg1); 2115 pop(state); 2116 } 2117 #endif 2118 } 2119 2120 void InterpreterMacroAssembler::skip_if_jvmti_mode(Label &Lskip, Register Rscratch) { 2121 if (!JvmtiExport::can_post_interpreter_events()) { 2122 return; 2123 } 2124 2125 load_and_test_int(Rscratch, Address(Z_thread, JavaThread::interp_only_mode_offset())); 2126 z_brnz(Lskip); 2127 2128 } 2129 2130 // Pop the topmost TOP_IJAVA_FRAME and set it's sender_sp as new Z_SP. 2131 // The return pc is loaded into the register return_pc. 2132 // 2133 // Registers updated: 2134 // return_pc - The return pc of the calling frame. 2135 // tmp1, tmp2 - scratch 2136 void InterpreterMacroAssembler::pop_interpreter_frame(Register return_pc, Register tmp1, Register tmp2) { 2137 // F0 Z_SP -> caller_sp (F1's) 2138 // ... 2139 // sender_sp (F1's) 2140 // ... 2141 // F1 Z_fp -> caller_sp (F2's) 2142 // return_pc (Continuation after return from F0.) 2143 // ... 2144 // F2 caller_sp 2145 2146 // Remove F0's activation. Restoring Z_SP to sender_sp reverts modifications 2147 // (a) by a c2i adapter and (b) by generate_fixed_frame(). 2148 // In case (a) the new top frame F1 is an unextended compiled frame. 2149 // In case (b) F1 is converted from PARENT_IJAVA_FRAME to TOP_IJAVA_FRAME. 2150 2151 // Case (b) seems to be redundant when returning to a interpreted caller, 2152 // because then the caller's top_frame_sp is installed as sp (see 2153 // TemplateInterpreterGenerator::generate_return_entry_for ()). But 2154 // pop_interpreter_frame() is also used in exception handling and there the 2155 // frame type of the caller is unknown, therefore top_frame_sp cannot be used, 2156 // so it is important that sender_sp is the caller's sp as TOP_IJAVA_FRAME. 2157 2158 Register R_f1_sender_sp = tmp1; 2159 Register R_f2_sp = tmp2; 2160 2161 // Tirst check the for the interpreter frame's magic. 2162 asm_assert_ijava_state_magic(R_f2_sp/*tmp*/); 2163 z_lg(R_f2_sp, _z_parent_ijava_frame_abi(callers_sp), Z_fp); 2164 z_lg(R_f1_sender_sp, _z_ijava_state_neg(sender_sp), Z_fp); 2165 if (return_pc->is_valid()) 2166 z_lg(return_pc, _z_parent_ijava_frame_abi(return_pc), Z_fp); 2167 // Pop F0 by resizing to R_f1_sender_sp and using R_f2_sp as fp. 2168 resize_frame_absolute(R_f1_sender_sp, R_f2_sp, false/*load fp*/); 2169 2170 #ifdef ASSERT 2171 // The return_pc in the new top frame is dead... at least that's my 2172 // current understanding; to assert this I overwrite it. 2173 load_const_optimized(Z_ARG3, 0xb00b1); 2174 z_stg(Z_ARG3, _z_parent_ijava_frame_abi(return_pc), Z_SP); 2175 #endif 2176 } 2177 2178 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { 2179 if (VerifyFPU) { 2180 unimplemented("verfiyFPU"); 2181 } 2182 } 2183