src/cpu/x86/vm/interp_masm_x86_64.cpp

Wed, 02 Jun 2010 22:45:42 -0700

author
jrose
date
Wed, 02 Jun 2010 22:45:42 -0700
changeset 1934
e9ff18c4ace7
parent 1907
c18cbe5936b8
parent 1920
ab102d5d923e
child 2138
d5d065957597
permissions
-rw-r--r--

Merge

duke@435 1 /*
trims@1907 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_interp_masm_x86_64.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 // Implementation of InterpreterMacroAssembler
duke@435 30
never@739 31 #ifdef CC_INTERP
never@739 32 void InterpreterMacroAssembler::get_method(Register reg) {
coleenp@955 33 movptr(reg, Address(rbp, -((int)sizeof(BytecodeInterpreter) + 2 * wordSize)));
never@739 34 movptr(reg, Address(reg, byte_offset_of(BytecodeInterpreter, _method)));
never@739 35 }
never@739 36 #endif // CC_INTERP
never@739 37
never@739 38 #ifndef CC_INTERP
never@739 39
duke@435 40 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point,
duke@435 41 int number_of_arguments) {
duke@435 42 // interpreter specific
duke@435 43 //
duke@435 44 // Note: No need to save/restore bcp & locals (r13 & r14) pointer
duke@435 45 // since these are callee saved registers and no blocking/
duke@435 46 // GC can happen in leaf calls.
ysr@777 47 // Further Note: DO NOT save/restore bcp/locals. If a caller has
ysr@777 48 // already saved them so that it can use esi/edi as temporaries
ysr@777 49 // then a save/restore here will DESTROY the copy the caller
ysr@777 50 // saved! There used to be a save_bcp() that only happened in
ysr@777 51 // the ASSERT path (no restore_bcp). Which caused bizarre failures
ysr@777 52 // when jvm built with ASSERTs.
duke@435 53 #ifdef ASSERT
duke@435 54 {
duke@435 55 Label L;
never@739 56 cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
duke@435 57 jcc(Assembler::equal, L);
duke@435 58 stop("InterpreterMacroAssembler::call_VM_leaf_base:"
duke@435 59 " last_sp != NULL");
duke@435 60 bind(L);
duke@435 61 }
duke@435 62 #endif
duke@435 63 // super call
duke@435 64 MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);
duke@435 65 // interpreter specific
ysr@777 66 // Used to ASSERT that r13/r14 were equal to frame's bcp/locals
ysr@777 67 // but since they may not have been saved (and we don't want to
ysr@777 68 // save thme here (see note above) the assert is invalid.
duke@435 69 }
duke@435 70
duke@435 71 void InterpreterMacroAssembler::call_VM_base(Register oop_result,
duke@435 72 Register java_thread,
duke@435 73 Register last_java_sp,
duke@435 74 address entry_point,
duke@435 75 int number_of_arguments,
duke@435 76 bool check_exceptions) {
duke@435 77 // interpreter specific
duke@435 78 //
duke@435 79 // Note: Could avoid restoring locals ptr (callee saved) - however doesn't
duke@435 80 // really make a difference for these runtime calls, since they are
duke@435 81 // slow anyway. Btw., bcp must be saved/restored since it may change
duke@435 82 // due to GC.
duke@435 83 // assert(java_thread == noreg , "not expecting a precomputed java thread");
duke@435 84 save_bcp();
duke@435 85 #ifdef ASSERT
duke@435 86 {
duke@435 87 Label L;
never@739 88 cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
duke@435 89 jcc(Assembler::equal, L);
duke@435 90 stop("InterpreterMacroAssembler::call_VM_leaf_base:"
duke@435 91 " last_sp != NULL");
duke@435 92 bind(L);
duke@435 93 }
duke@435 94 #endif /* ASSERT */
duke@435 95 // super call
duke@435 96 MacroAssembler::call_VM_base(oop_result, noreg, last_java_sp,
duke@435 97 entry_point, number_of_arguments,
duke@435 98 check_exceptions);
duke@435 99 // interpreter specific
duke@435 100 restore_bcp();
duke@435 101 restore_locals();
duke@435 102 }
duke@435 103
duke@435 104
duke@435 105 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) {
duke@435 106 if (JvmtiExport::can_pop_frame()) {
duke@435 107 Label L;
duke@435 108 // Initiate popframe handling only if it is not already being
duke@435 109 // processed. If the flag has the popframe_processing bit set, it
duke@435 110 // means that this code is called *during* popframe handling - we
duke@435 111 // don't want to reenter.
duke@435 112 // This method is only called just after the call into the vm in
duke@435 113 // call_VM_base, so the arg registers are available.
duke@435 114 movl(c_rarg0, Address(r15_thread, JavaThread::popframe_condition_offset()));
duke@435 115 testl(c_rarg0, JavaThread::popframe_pending_bit);
duke@435 116 jcc(Assembler::zero, L);
duke@435 117 testl(c_rarg0, JavaThread::popframe_processing_bit);
duke@435 118 jcc(Assembler::notZero, L);
duke@435 119 // Call Interpreter::remove_activation_preserving_args_entry() to get the
duke@435 120 // address of the same-named entrypoint in the generated interpreter code.
duke@435 121 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
duke@435 122 jmp(rax);
duke@435 123 bind(L);
duke@435 124 }
duke@435 125 }
duke@435 126
duke@435 127
duke@435 128 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
never@739 129 movptr(rcx, Address(r15_thread, JavaThread::jvmti_thread_state_offset()));
duke@435 130 const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset());
duke@435 131 const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset());
duke@435 132 const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset());
duke@435 133 switch (state) {
never@739 134 case atos: movptr(rax, oop_addr);
never@739 135 movptr(oop_addr, (int32_t)NULL_WORD);
duke@435 136 verify_oop(rax, state); break;
never@739 137 case ltos: movptr(rax, val_addr); break;
duke@435 138 case btos: // fall through
duke@435 139 case ctos: // fall through
duke@435 140 case stos: // fall through
duke@435 141 case itos: movl(rax, val_addr); break;
duke@435 142 case ftos: movflt(xmm0, val_addr); break;
duke@435 143 case dtos: movdbl(xmm0, val_addr); break;
duke@435 144 case vtos: /* nothing to do */ break;
duke@435 145 default : ShouldNotReachHere();
duke@435 146 }
duke@435 147 // Clean up tos value in the thread object
duke@435 148 movl(tos_addr, (int) ilgl);
never@739 149 movl(val_addr, (int32_t) NULL_WORD);
duke@435 150 }
duke@435 151
duke@435 152
duke@435 153 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) {
duke@435 154 if (JvmtiExport::can_force_early_return()) {
duke@435 155 Label L;
never@739 156 movptr(c_rarg0, Address(r15_thread, JavaThread::jvmti_thread_state_offset()));
never@739 157 testptr(c_rarg0, c_rarg0);
duke@435 158 jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == NULL) exit;
duke@435 159
duke@435 160 // Initiate earlyret handling only if it is not already being processed.
duke@435 161 // If the flag has the earlyret_processing bit set, it means that this code
duke@435 162 // is called *during* earlyret handling - we don't want to reenter.
duke@435 163 movl(c_rarg0, Address(c_rarg0, JvmtiThreadState::earlyret_state_offset()));
duke@435 164 cmpl(c_rarg0, JvmtiThreadState::earlyret_pending);
duke@435 165 jcc(Assembler::notEqual, L);
duke@435 166
duke@435 167 // Call Interpreter::remove_activation_early_entry() to get the address of the
duke@435 168 // same-named entrypoint in the generated interpreter code.
never@739 169 movptr(c_rarg0, Address(r15_thread, JavaThread::jvmti_thread_state_offset()));
duke@435 170 movl(c_rarg0, Address(c_rarg0, JvmtiThreadState::earlyret_tos_offset()));
duke@435 171 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), c_rarg0);
duke@435 172 jmp(rax);
duke@435 173 bind(L);
duke@435 174 }
duke@435 175 }
duke@435 176
duke@435 177
duke@435 178 void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(
duke@435 179 Register reg,
duke@435 180 int bcp_offset) {
duke@435 181 assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
duke@435 182 movl(reg, Address(r13, bcp_offset));
duke@435 183 bswapl(reg);
duke@435 184 shrl(reg, 16);
duke@435 185 }
duke@435 186
duke@435 187
twisti@1543 188 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
twisti@1543 189 int bcp_offset,
jrose@1920 190 size_t index_size) {
twisti@1543 191 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
jrose@1920 192 if (index_size == sizeof(u2)) {
twisti@1543 193 load_unsigned_short(index, Address(r13, bcp_offset));
jrose@1920 194 } else if (index_size == sizeof(u4)) {
twisti@1543 195 assert(EnableInvokeDynamic, "giant index used only for EnableInvokeDynamic");
twisti@1543 196 movl(index, Address(r13, bcp_offset));
twisti@1543 197 // Check if the secondary index definition is still ~x, otherwise
twisti@1543 198 // we have to change the following assembler code to calculate the
twisti@1543 199 // plain index.
twisti@1543 200 assert(constantPoolCacheOopDesc::decode_secondary_index(~123) == 123, "else change next line");
twisti@1543 201 notl(index); // convert to plain index
jrose@1920 202 } else if (index_size == sizeof(u1)) {
jrose@1920 203 assert(EnableMethodHandles, "tiny index used only for EnableMethodHandles");
jrose@1920 204 load_unsigned_byte(index, Address(r13, bcp_offset));
jrose@1920 205 } else {
jrose@1920 206 ShouldNotReachHere();
twisti@1543 207 }
twisti@1543 208 }
twisti@1543 209
twisti@1543 210
duke@435 211 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache,
duke@435 212 Register index,
twisti@1543 213 int bcp_offset,
jrose@1920 214 size_t index_size) {
duke@435 215 assert(cache != index, "must use different registers");
jrose@1920 216 get_cache_index_at_bcp(index, bcp_offset, index_size);
never@739 217 movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
duke@435 218 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below");
duke@435 219 // convert from field index to ConstantPoolCacheEntry index
duke@435 220 shll(index, 2);
duke@435 221 }
duke@435 222
duke@435 223
duke@435 224 void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache,
duke@435 225 Register tmp,
twisti@1543 226 int bcp_offset,
jrose@1920 227 size_t index_size) {
duke@435 228 assert(cache != tmp, "must use different register");
jrose@1920 229 get_cache_index_at_bcp(tmp, bcp_offset, index_size);
duke@435 230 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below");
duke@435 231 // convert from field index to ConstantPoolCacheEntry index
duke@435 232 // and from word offset to byte offset
duke@435 233 shll(tmp, 2 + LogBytesPerWord);
never@739 234 movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize));
duke@435 235 // skip past the header
never@739 236 addptr(cache, in_bytes(constantPoolCacheOopDesc::base_offset()));
never@739 237 addptr(cache, tmp); // construct pointer to cache entry
duke@435 238 }
duke@435 239
duke@435 240
duke@435 241 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a
duke@435 242 // subtype of super_klass.
duke@435 243 //
duke@435 244 // Args:
duke@435 245 // rax: superklass
duke@435 246 // Rsub_klass: subklass
duke@435 247 //
duke@435 248 // Kills:
duke@435 249 // rcx, rdi
duke@435 250 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
duke@435 251 Label& ok_is_subtype) {
duke@435 252 assert(Rsub_klass != rax, "rax holds superklass");
duke@435 253 assert(Rsub_klass != r14, "r14 holds locals");
duke@435 254 assert(Rsub_klass != r13, "r13 holds bcp");
duke@435 255 assert(Rsub_klass != rcx, "rcx holds 2ndary super array length");
duke@435 256 assert(Rsub_klass != rdi, "rdi holds 2ndary super array scan ptr");
duke@435 257
jrose@1079 258 // Profile the not-null value's klass.
jrose@1079 259 profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi
duke@435 260
jrose@1079 261 // Do the check.
jrose@1079 262 check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx
duke@435 263
jrose@1079 264 // Profile the failure of the check.
duke@435 265 profile_typecheck_failed(rcx); // blows rcx
duke@435 266 }
duke@435 267
duke@435 268
never@739 269
duke@435 270 // Java Expression Stack
duke@435 271
duke@435 272 void InterpreterMacroAssembler::pop_ptr(Register r) {
never@739 273 pop(r);
duke@435 274 }
duke@435 275
duke@435 276 void InterpreterMacroAssembler::pop_i(Register r) {
never@739 277 // XXX can't use pop currently, upper half non clean
duke@435 278 movl(r, Address(rsp, 0));
never@739 279 addptr(rsp, wordSize);
duke@435 280 }
duke@435 281
duke@435 282 void InterpreterMacroAssembler::pop_l(Register r) {
duke@435 283 movq(r, Address(rsp, 0));
twisti@1861 284 addptr(rsp, 2 * Interpreter::stackElementSize);
duke@435 285 }
duke@435 286
duke@435 287 void InterpreterMacroAssembler::pop_f(XMMRegister r) {
duke@435 288 movflt(r, Address(rsp, 0));
never@739 289 addptr(rsp, wordSize);
duke@435 290 }
duke@435 291
duke@435 292 void InterpreterMacroAssembler::pop_d(XMMRegister r) {
duke@435 293 movdbl(r, Address(rsp, 0));
twisti@1861 294 addptr(rsp, 2 * Interpreter::stackElementSize);
duke@435 295 }
duke@435 296
duke@435 297 void InterpreterMacroAssembler::push_ptr(Register r) {
never@739 298 push(r);
duke@435 299 }
duke@435 300
duke@435 301 void InterpreterMacroAssembler::push_i(Register r) {
never@739 302 push(r);
duke@435 303 }
duke@435 304
duke@435 305 void InterpreterMacroAssembler::push_l(Register r) {
twisti@1861 306 subptr(rsp, 2 * wordSize);
duke@435 307 movq(Address(rsp, 0), r);
duke@435 308 }
duke@435 309
duke@435 310 void InterpreterMacroAssembler::push_f(XMMRegister r) {
never@739 311 subptr(rsp, wordSize);
duke@435 312 movflt(Address(rsp, 0), r);
duke@435 313 }
duke@435 314
duke@435 315 void InterpreterMacroAssembler::push_d(XMMRegister r) {
twisti@1861 316 subptr(rsp, 2 * wordSize);
duke@435 317 movdbl(Address(rsp, 0), r);
duke@435 318 }
duke@435 319
duke@435 320 void InterpreterMacroAssembler::pop(TosState state) {
duke@435 321 switch (state) {
duke@435 322 case atos: pop_ptr(); break;
duke@435 323 case btos:
duke@435 324 case ctos:
duke@435 325 case stos:
duke@435 326 case itos: pop_i(); break;
duke@435 327 case ltos: pop_l(); break;
duke@435 328 case ftos: pop_f(); break;
duke@435 329 case dtos: pop_d(); break;
duke@435 330 case vtos: /* nothing to do */ break;
duke@435 331 default: ShouldNotReachHere();
duke@435 332 }
duke@435 333 verify_oop(rax, state);
duke@435 334 }
duke@435 335
duke@435 336 void InterpreterMacroAssembler::push(TosState state) {
duke@435 337 verify_oop(rax, state);
duke@435 338 switch (state) {
duke@435 339 case atos: push_ptr(); break;
duke@435 340 case btos:
duke@435 341 case ctos:
duke@435 342 case stos:
duke@435 343 case itos: push_i(); break;
duke@435 344 case ltos: push_l(); break;
duke@435 345 case ftos: push_f(); break;
duke@435 346 case dtos: push_d(); break;
duke@435 347 case vtos: /* nothing to do */ break;
duke@435 348 default : ShouldNotReachHere();
duke@435 349 }
duke@435 350 }
duke@435 351
duke@435 352
twisti@1861 353 // Helpers for swap and dup
twisti@1861 354 void InterpreterMacroAssembler::load_ptr(int n, Register val) {
never@739 355 movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n)));
duke@435 356 }
duke@435 357
twisti@1861 358 void InterpreterMacroAssembler::store_ptr(int n, Register val) {
never@739 359 movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val);
duke@435 360 }
duke@435 361
duke@435 362
duke@435 363 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point) {
duke@435 364 MacroAssembler::call_VM_leaf_base(entry_point, 0);
duke@435 365 }
duke@435 366
duke@435 367
duke@435 368 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point,
duke@435 369 Register arg_1) {
duke@435 370 if (c_rarg0 != arg_1) {
never@739 371 mov(c_rarg0, arg_1);
duke@435 372 }
duke@435 373 MacroAssembler::call_VM_leaf_base(entry_point, 1);
duke@435 374 }
duke@435 375
duke@435 376
duke@435 377 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point,
duke@435 378 Register arg_1,
duke@435 379 Register arg_2) {
duke@435 380 assert(c_rarg0 != arg_2, "smashed argument");
duke@435 381 assert(c_rarg1 != arg_1, "smashed argument");
duke@435 382 if (c_rarg0 != arg_1) {
never@739 383 mov(c_rarg0, arg_1);
duke@435 384 }
duke@435 385 if (c_rarg1 != arg_2) {
never@739 386 mov(c_rarg1, arg_2);
duke@435 387 }
duke@435 388 MacroAssembler::call_VM_leaf_base(entry_point, 2);
duke@435 389 }
duke@435 390
duke@435 391 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point,
duke@435 392 Register arg_1,
duke@435 393 Register arg_2,
duke@435 394 Register arg_3) {
duke@435 395 assert(c_rarg0 != arg_2, "smashed argument");
duke@435 396 assert(c_rarg0 != arg_3, "smashed argument");
duke@435 397 assert(c_rarg1 != arg_1, "smashed argument");
duke@435 398 assert(c_rarg1 != arg_3, "smashed argument");
duke@435 399 assert(c_rarg2 != arg_1, "smashed argument");
duke@435 400 assert(c_rarg2 != arg_2, "smashed argument");
duke@435 401 if (c_rarg0 != arg_1) {
never@739 402 mov(c_rarg0, arg_1);
duke@435 403 }
duke@435 404 if (c_rarg1 != arg_2) {
never@739 405 mov(c_rarg1, arg_2);
duke@435 406 }
duke@435 407 if (c_rarg2 != arg_3) {
never@739 408 mov(c_rarg2, arg_3);
duke@435 409 }
duke@435 410 MacroAssembler::call_VM_leaf_base(entry_point, 3);
duke@435 411 }
duke@435 412
jrose@1145 413 void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() {
duke@435 414 // set sender sp
never@739 415 lea(r13, Address(rsp, wordSize));
duke@435 416 // record last_sp
never@739 417 movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), r13);
jrose@1145 418 }
jrose@1145 419
jrose@1145 420
jrose@1145 421 // Jump to from_interpreted entry of a call unless single stepping is possible
jrose@1145 422 // in this thread in which case we must call the i2i entry
jrose@1145 423 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) {
jrose@1145 424 prepare_to_jump_from_interpreted();
duke@435 425
duke@435 426 if (JvmtiExport::can_post_interpreter_events()) {
duke@435 427 Label run_compiled_code;
duke@435 428 // JVMTI events, such as single-stepping, are implemented partly by avoiding running
duke@435 429 // compiled code in threads for which the event is enabled. Check here for
duke@435 430 // interp_only_mode if these events CAN be enabled.
duke@435 431 get_thread(temp);
duke@435 432 // interp_only is an int, on little endian it is sufficient to test the byte only
duke@435 433 // Is a cmpl faster (ce
duke@435 434 cmpb(Address(temp, JavaThread::interp_only_mode_offset()), 0);
duke@435 435 jcc(Assembler::zero, run_compiled_code);
duke@435 436 jmp(Address(method, methodOopDesc::interpreter_entry_offset()));
duke@435 437 bind(run_compiled_code);
duke@435 438 }
duke@435 439
duke@435 440 jmp(Address(method, methodOopDesc::from_interpreted_offset()));
duke@435 441
duke@435 442 }
duke@435 443
duke@435 444
duke@435 445 // The following two routines provide a hook so that an implementation
duke@435 446 // can schedule the dispatch in two parts. amd64 does not do this.
duke@435 447 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) {
duke@435 448 // Nothing amd64 specific to be done here
duke@435 449 }
duke@435 450
duke@435 451 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
duke@435 452 dispatch_next(state, step);
duke@435 453 }
duke@435 454
duke@435 455 void InterpreterMacroAssembler::dispatch_base(TosState state,
duke@435 456 address* table,
duke@435 457 bool verifyoop) {
duke@435 458 verify_FPU(1, state);
duke@435 459 if (VerifyActivationFrameSize) {
duke@435 460 Label L;
never@739 461 mov(rcx, rbp);
never@739 462 subptr(rcx, rsp);
never@739 463 int32_t min_frame_size =
duke@435 464 (frame::link_offset - frame::interpreter_frame_initial_sp_offset) *
duke@435 465 wordSize;
never@739 466 cmpptr(rcx, (int32_t)min_frame_size);
duke@435 467 jcc(Assembler::greaterEqual, L);
duke@435 468 stop("broken stack frame");
duke@435 469 bind(L);
duke@435 470 }
duke@435 471 if (verifyoop) {
duke@435 472 verify_oop(rax, state);
duke@435 473 }
duke@435 474 lea(rscratch1, ExternalAddress((address)table));
duke@435 475 jmp(Address(rscratch1, rbx, Address::times_8));
duke@435 476 }
duke@435 477
duke@435 478 void InterpreterMacroAssembler::dispatch_only(TosState state) {
duke@435 479 dispatch_base(state, Interpreter::dispatch_table(state));
duke@435 480 }
duke@435 481
duke@435 482 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
duke@435 483 dispatch_base(state, Interpreter::normal_table(state));
duke@435 484 }
duke@435 485
duke@435 486 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
duke@435 487 dispatch_base(state, Interpreter::normal_table(state), false);
duke@435 488 }
duke@435 489
duke@435 490
duke@435 491 void InterpreterMacroAssembler::dispatch_next(TosState state, int step) {
duke@435 492 // load next bytecode (load before advancing r13 to prevent AGI)
duke@435 493 load_unsigned_byte(rbx, Address(r13, step));
duke@435 494 // advance r13
never@739 495 increment(r13, step);
duke@435 496 dispatch_base(state, Interpreter::dispatch_table(state));
duke@435 497 }
duke@435 498
duke@435 499 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
duke@435 500 // load current bytecode
duke@435 501 load_unsigned_byte(rbx, Address(r13, 0));
duke@435 502 dispatch_base(state, table);
duke@435 503 }
duke@435 504
duke@435 505 // remove activation
duke@435 506 //
duke@435 507 // Unlock the receiver if this is a synchronized method.
duke@435 508 // Unlock any Java monitors from syncronized blocks.
duke@435 509 // Remove the activation from the stack.
duke@435 510 //
duke@435 511 // If there are locked Java monitors
duke@435 512 // If throw_monitor_exception
duke@435 513 // throws IllegalMonitorStateException
duke@435 514 // Else if install_monitor_exception
duke@435 515 // installs IllegalMonitorStateException
duke@435 516 // Else
duke@435 517 // no error processing
duke@435 518 void InterpreterMacroAssembler::remove_activation(
duke@435 519 TosState state,
duke@435 520 Register ret_addr,
duke@435 521 bool throw_monitor_exception,
duke@435 522 bool install_monitor_exception,
duke@435 523 bool notify_jvmdi) {
duke@435 524 // Note: Registers rdx xmm0 may be in use for the
duke@435 525 // result check if synchronized method
duke@435 526 Label unlocked, unlock, no_unlock;
duke@435 527
duke@435 528 // get the value of _do_not_unlock_if_synchronized into rdx
duke@435 529 const Address do_not_unlock_if_synchronized(r15_thread,
duke@435 530 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
duke@435 531 movbool(rdx, do_not_unlock_if_synchronized);
duke@435 532 movbool(do_not_unlock_if_synchronized, false); // reset the flag
duke@435 533
duke@435 534 // get method access flags
never@739 535 movptr(rbx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
duke@435 536 movl(rcx, Address(rbx, methodOopDesc::access_flags_offset()));
duke@435 537 testl(rcx, JVM_ACC_SYNCHRONIZED);
duke@435 538 jcc(Assembler::zero, unlocked);
duke@435 539
duke@435 540 // Don't unlock anything if the _do_not_unlock_if_synchronized flag
duke@435 541 // is set.
duke@435 542 testbool(rdx);
duke@435 543 jcc(Assembler::notZero, no_unlock);
duke@435 544
duke@435 545 // unlock monitor
duke@435 546 push(state); // save result
duke@435 547
duke@435 548 // BasicObjectLock will be first in list, since this is a
duke@435 549 // synchronized method. However, need to check that the object has
duke@435 550 // not been unlocked by an explicit monitorexit bytecode.
duke@435 551 const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset *
duke@435 552 wordSize - (int) sizeof(BasicObjectLock));
duke@435 553 // We use c_rarg1 so that if we go slow path it will be the correct
duke@435 554 // register for unlock_object to pass to VM directly
never@739 555 lea(c_rarg1, monitor); // address of first monitor
duke@435 556
never@739 557 movptr(rax, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()));
never@739 558 testptr(rax, rax);
duke@435 559 jcc(Assembler::notZero, unlock);
duke@435 560
duke@435 561 pop(state);
duke@435 562 if (throw_monitor_exception) {
duke@435 563 // Entry already unlocked, need to throw exception
duke@435 564 call_VM(noreg, CAST_FROM_FN_PTR(address,
duke@435 565 InterpreterRuntime::throw_illegal_monitor_state_exception));
duke@435 566 should_not_reach_here();
duke@435 567 } else {
duke@435 568 // Monitor already unlocked during a stack unroll. If requested,
duke@435 569 // install an illegal_monitor_state_exception. Continue with
duke@435 570 // stack unrolling.
duke@435 571 if (install_monitor_exception) {
duke@435 572 call_VM(noreg, CAST_FROM_FN_PTR(address,
duke@435 573 InterpreterRuntime::new_illegal_monitor_state_exception));
duke@435 574 }
duke@435 575 jmp(unlocked);
duke@435 576 }
duke@435 577
duke@435 578 bind(unlock);
duke@435 579 unlock_object(c_rarg1);
duke@435 580 pop(state);
duke@435 581
duke@435 582 // Check that for block-structured locking (i.e., that all locked
duke@435 583 // objects has been unlocked)
duke@435 584 bind(unlocked);
duke@435 585
duke@435 586 // rax: Might contain return value
duke@435 587
duke@435 588 // Check that all monitors are unlocked
duke@435 589 {
duke@435 590 Label loop, exception, entry, restart;
duke@435 591 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
duke@435 592 const Address monitor_block_top(
duke@435 593 rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
duke@435 594 const Address monitor_block_bot(
duke@435 595 rbp, frame::interpreter_frame_initial_sp_offset * wordSize);
duke@435 596
duke@435 597 bind(restart);
duke@435 598 // We use c_rarg1 so that if we go slow path it will be the correct
duke@435 599 // register for unlock_object to pass to VM directly
never@739 600 movptr(c_rarg1, monitor_block_top); // points to current entry, starting
duke@435 601 // with top-most entry
never@739 602 lea(rbx, monitor_block_bot); // points to word before bottom of
duke@435 603 // monitor block
duke@435 604 jmp(entry);
duke@435 605
duke@435 606 // Entry already locked, need to throw exception
duke@435 607 bind(exception);
duke@435 608
duke@435 609 if (throw_monitor_exception) {
duke@435 610 // Throw exception
duke@435 611 MacroAssembler::call_VM(noreg,
duke@435 612 CAST_FROM_FN_PTR(address, InterpreterRuntime::
duke@435 613 throw_illegal_monitor_state_exception));
duke@435 614 should_not_reach_here();
duke@435 615 } else {
duke@435 616 // Stack unrolling. Unlock object and install illegal_monitor_exception.
duke@435 617 // Unlock does not block, so don't have to worry about the frame.
duke@435 618 // We don't have to preserve c_rarg1 since we are going to throw an exception.
duke@435 619
duke@435 620 push(state);
duke@435 621 unlock_object(c_rarg1);
duke@435 622 pop(state);
duke@435 623
duke@435 624 if (install_monitor_exception) {
duke@435 625 call_VM(noreg, CAST_FROM_FN_PTR(address,
duke@435 626 InterpreterRuntime::
duke@435 627 new_illegal_monitor_state_exception));
duke@435 628 }
duke@435 629
duke@435 630 jmp(restart);
duke@435 631 }
duke@435 632
duke@435 633 bind(loop);
duke@435 634 // check if current entry is used
never@739 635 cmpptr(Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL);
duke@435 636 jcc(Assembler::notEqual, exception);
duke@435 637
never@739 638 addptr(c_rarg1, entry_size); // otherwise advance to next entry
duke@435 639 bind(entry);
never@739 640 cmpptr(c_rarg1, rbx); // check if bottom reached
duke@435 641 jcc(Assembler::notEqual, loop); // if not at bottom then check this entry
duke@435 642 }
duke@435 643
duke@435 644 bind(no_unlock);
duke@435 645
duke@435 646 // jvmti support
duke@435 647 if (notify_jvmdi) {
duke@435 648 notify_method_exit(state, NotifyJVMTI); // preserve TOSCA
duke@435 649 } else {
duke@435 650 notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA
duke@435 651 }
duke@435 652
duke@435 653 // remove activation
duke@435 654 // get sender sp
never@739 655 movptr(rbx,
never@739 656 Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize));
duke@435 657 leave(); // remove frame anchor
never@739 658 pop(ret_addr); // get return address
never@739 659 mov(rsp, rbx); // set sp to sender sp
duke@435 660 }
duke@435 661
never@739 662 #endif // C_INTERP
never@739 663
duke@435 664 // Lock object
duke@435 665 //
duke@435 666 // Args:
duke@435 667 // c_rarg1: BasicObjectLock to be used for locking
duke@435 668 //
duke@435 669 // Kills:
duke@435 670 // rax
duke@435 671 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, .. (param regs)
duke@435 672 // rscratch1, rscratch2 (scratch regs)
duke@435 673 void InterpreterMacroAssembler::lock_object(Register lock_reg) {
duke@435 674 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1");
duke@435 675
duke@435 676 if (UseHeavyMonitors) {
duke@435 677 call_VM(noreg,
duke@435 678 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
duke@435 679 lock_reg);
duke@435 680 } else {
duke@435 681 Label done;
duke@435 682
duke@435 683 const Register swap_reg = rax; // Must use rax for cmpxchg instruction
duke@435 684 const Register obj_reg = c_rarg3; // Will contain the oop
duke@435 685
duke@435 686 const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
duke@435 687 const int lock_offset = BasicObjectLock::lock_offset_in_bytes ();
duke@435 688 const int mark_offset = lock_offset +
duke@435 689 BasicLock::displaced_header_offset_in_bytes();
duke@435 690
duke@435 691 Label slow_case;
duke@435 692
duke@435 693 // Load object pointer into obj_reg %c_rarg3
never@739 694 movptr(obj_reg, Address(lock_reg, obj_offset));
duke@435 695
duke@435 696 if (UseBiasedLocking) {
duke@435 697 biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, done, &slow_case);
duke@435 698 }
duke@435 699
duke@435 700 // Load immediate 1 into swap_reg %rax
duke@435 701 movl(swap_reg, 1);
duke@435 702
duke@435 703 // Load (object->mark() | 1) into swap_reg %rax
never@739 704 orptr(swap_reg, Address(obj_reg, 0));
duke@435 705
duke@435 706 // Save (object->mark() | 1) into BasicLock's displaced header
never@739 707 movptr(Address(lock_reg, mark_offset), swap_reg);
duke@435 708
duke@435 709 assert(lock_offset == 0,
duke@435 710 "displached header must be first word in BasicObjectLock");
duke@435 711
duke@435 712 if (os::is_MP()) lock();
never@739 713 cmpxchgptr(lock_reg, Address(obj_reg, 0));
duke@435 714 if (PrintBiasedLockingStatistics) {
duke@435 715 cond_inc32(Assembler::zero,
duke@435 716 ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));
duke@435 717 }
duke@435 718 jcc(Assembler::zero, done);
duke@435 719
duke@435 720 // Test if the oopMark is an obvious stack pointer, i.e.,
duke@435 721 // 1) (mark & 7) == 0, and
duke@435 722 // 2) rsp <= mark < mark + os::pagesize()
duke@435 723 //
duke@435 724 // These 3 tests can be done by evaluating the following
duke@435 725 // expression: ((mark - rsp) & (7 - os::vm_page_size())),
duke@435 726 // assuming both stack pointer and pagesize have their
duke@435 727 // least significant 3 bits clear.
duke@435 728 // NOTE: the oopMark is in swap_reg %rax as the result of cmpxchg
never@739 729 subptr(swap_reg, rsp);
never@739 730 andptr(swap_reg, 7 - os::vm_page_size());
duke@435 731
duke@435 732 // Save the test result, for recursive case, the result is zero
never@739 733 movptr(Address(lock_reg, mark_offset), swap_reg);
duke@435 734
duke@435 735 if (PrintBiasedLockingStatistics) {
duke@435 736 cond_inc32(Assembler::zero,
duke@435 737 ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));
duke@435 738 }
duke@435 739 jcc(Assembler::zero, done);
duke@435 740
duke@435 741 bind(slow_case);
duke@435 742
duke@435 743 // Call the runtime routine for slow case
duke@435 744 call_VM(noreg,
duke@435 745 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
duke@435 746 lock_reg);
duke@435 747
duke@435 748 bind(done);
duke@435 749 }
duke@435 750 }
duke@435 751
duke@435 752
duke@435 753 // Unlocks an object. Used in monitorexit bytecode and
duke@435 754 // remove_activation. Throws an IllegalMonitorException if object is
duke@435 755 // not locked by current thread.
duke@435 756 //
duke@435 757 // Args:
duke@435 758 // c_rarg1: BasicObjectLock for lock
duke@435 759 //
duke@435 760 // Kills:
duke@435 761 // rax
duke@435 762 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs)
duke@435 763 // rscratch1, rscratch2 (scratch regs)
duke@435 764 void InterpreterMacroAssembler::unlock_object(Register lock_reg) {
duke@435 765 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be rarg1");
duke@435 766
duke@435 767 if (UseHeavyMonitors) {
duke@435 768 call_VM(noreg,
duke@435 769 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
duke@435 770 lock_reg);
duke@435 771 } else {
duke@435 772 Label done;
duke@435 773
duke@435 774 const Register swap_reg = rax; // Must use rax for cmpxchg instruction
duke@435 775 const Register header_reg = c_rarg2; // Will contain the old oopMark
duke@435 776 const Register obj_reg = c_rarg3; // Will contain the oop
duke@435 777
duke@435 778 save_bcp(); // Save in case of exception
duke@435 779
duke@435 780 // Convert from BasicObjectLock structure to object and BasicLock
duke@435 781 // structure Store the BasicLock address into %rax
never@739 782 lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes()));
duke@435 783
duke@435 784 // Load oop into obj_reg(%c_rarg3)
never@739 785 movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()));
duke@435 786
duke@435 787 // Free entry
never@739 788 movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);
duke@435 789
duke@435 790 if (UseBiasedLocking) {
duke@435 791 biased_locking_exit(obj_reg, header_reg, done);
duke@435 792 }
duke@435 793
duke@435 794 // Load the old header from BasicLock structure
never@739 795 movptr(header_reg, Address(swap_reg,
never@739 796 BasicLock::displaced_header_offset_in_bytes()));
duke@435 797
duke@435 798 // Test for recursion
never@739 799 testptr(header_reg, header_reg);
duke@435 800
duke@435 801 // zero for recursive case
duke@435 802 jcc(Assembler::zero, done);
duke@435 803
duke@435 804 // Atomic swap back the old header
duke@435 805 if (os::is_MP()) lock();
never@739 806 cmpxchgptr(header_reg, Address(obj_reg, 0));
duke@435 807
duke@435 808 // zero for recursive case
duke@435 809 jcc(Assembler::zero, done);
duke@435 810
duke@435 811 // Call the runtime routine for slow case.
never@739 812 movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()),
duke@435 813 obj_reg); // restore obj
duke@435 814 call_VM(noreg,
duke@435 815 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
duke@435 816 lock_reg);
duke@435 817
duke@435 818 bind(done);
duke@435 819
duke@435 820 restore_bcp();
duke@435 821 }
duke@435 822 }
duke@435 823
never@739 824 #ifndef CC_INTERP
duke@435 825
duke@435 826 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp,
duke@435 827 Label& zero_continue) {
duke@435 828 assert(ProfileInterpreter, "must be profiling interpreter");
never@739 829 movptr(mdp, Address(rbp, frame::interpreter_frame_mdx_offset * wordSize));
never@739 830 testptr(mdp, mdp);
duke@435 831 jcc(Assembler::zero, zero_continue);
duke@435 832 }
duke@435 833
duke@435 834
duke@435 835 // Set the method data pointer for the current bcp.
duke@435 836 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
duke@435 837 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 838 Label zero_continue;
never@739 839 push(rax);
never@739 840 push(rbx);
duke@435 841
duke@435 842 get_method(rbx);
duke@435 843 // Test MDO to avoid the call if it is NULL.
never@739 844 movptr(rax, Address(rbx, in_bytes(methodOopDesc::method_data_offset())));
never@739 845 testptr(rax, rax);
duke@435 846 jcc(Assembler::zero, zero_continue);
duke@435 847
duke@435 848 // rbx: method
duke@435 849 // r13: bcp
duke@435 850 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, r13);
duke@435 851 // rax: mdi
duke@435 852
never@739 853 movptr(rbx, Address(rbx, in_bytes(methodOopDesc::method_data_offset())));
never@739 854 testptr(rbx, rbx);
duke@435 855 jcc(Assembler::zero, zero_continue);
never@739 856 addptr(rbx, in_bytes(methodDataOopDesc::data_offset()));
never@739 857 addptr(rbx, rax);
never@739 858 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rbx);
duke@435 859
duke@435 860 bind(zero_continue);
never@739 861 pop(rbx);
never@739 862 pop(rax);
duke@435 863 }
duke@435 864
duke@435 865 void InterpreterMacroAssembler::verify_method_data_pointer() {
duke@435 866 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 867 #ifdef ASSERT
duke@435 868 Label verify_continue;
never@739 869 push(rax);
never@739 870 push(rbx);
never@739 871 push(c_rarg3);
never@739 872 push(c_rarg2);
duke@435 873 test_method_data_pointer(c_rarg3, verify_continue); // If mdp is zero, continue
duke@435 874 get_method(rbx);
duke@435 875
duke@435 876 // If the mdp is valid, it will point to a DataLayout header which is
duke@435 877 // consistent with the bcp. The converse is highly probable also.
jrose@1057 878 load_unsigned_short(c_rarg2,
jrose@1057 879 Address(c_rarg3, in_bytes(DataLayout::bci_offset())));
never@739 880 addptr(c_rarg2, Address(rbx, methodOopDesc::const_offset()));
never@739 881 lea(c_rarg2, Address(c_rarg2, constMethodOopDesc::codes_offset()));
never@739 882 cmpptr(c_rarg2, r13);
duke@435 883 jcc(Assembler::equal, verify_continue);
duke@435 884 // rbx: method
duke@435 885 // r13: bcp
duke@435 886 // c_rarg3: mdp
duke@435 887 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp),
duke@435 888 rbx, r13, c_rarg3);
duke@435 889 bind(verify_continue);
never@739 890 pop(c_rarg2);
never@739 891 pop(c_rarg3);
never@739 892 pop(rbx);
never@739 893 pop(rax);
duke@435 894 #endif // ASSERT
duke@435 895 }
duke@435 896
duke@435 897
duke@435 898 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in,
duke@435 899 int constant,
duke@435 900 Register value) {
duke@435 901 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 902 Address data(mdp_in, constant);
never@739 903 movptr(data, value);
duke@435 904 }
duke@435 905
duke@435 906
duke@435 907 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
duke@435 908 int constant,
duke@435 909 bool decrement) {
duke@435 910 // Counter address
duke@435 911 Address data(mdp_in, constant);
duke@435 912
duke@435 913 increment_mdp_data_at(data, decrement);
duke@435 914 }
duke@435 915
duke@435 916 void InterpreterMacroAssembler::increment_mdp_data_at(Address data,
duke@435 917 bool decrement) {
duke@435 918 assert(ProfileInterpreter, "must be profiling interpreter");
never@739 919 // %%% this does 64bit counters at best it is wasting space
never@739 920 // at worst it is a rare bug when counters overflow
duke@435 921
duke@435 922 if (decrement) {
duke@435 923 // Decrement the register. Set condition codes.
never@739 924 addptr(data, (int32_t) -DataLayout::counter_increment);
duke@435 925 // If the decrement causes the counter to overflow, stay negative
duke@435 926 Label L;
duke@435 927 jcc(Assembler::negative, L);
never@739 928 addptr(data, (int32_t) DataLayout::counter_increment);
duke@435 929 bind(L);
duke@435 930 } else {
duke@435 931 assert(DataLayout::counter_increment == 1,
duke@435 932 "flow-free idiom only works with 1");
duke@435 933 // Increment the register. Set carry flag.
never@739 934 addptr(data, DataLayout::counter_increment);
duke@435 935 // If the increment causes the counter to overflow, pull back by 1.
never@739 936 sbbptr(data, (int32_t)0);
duke@435 937 }
duke@435 938 }
duke@435 939
duke@435 940
duke@435 941 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
duke@435 942 Register reg,
duke@435 943 int constant,
duke@435 944 bool decrement) {
duke@435 945 Address data(mdp_in, reg, Address::times_1, constant);
duke@435 946
duke@435 947 increment_mdp_data_at(data, decrement);
duke@435 948 }
duke@435 949
duke@435 950 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,
duke@435 951 int flag_byte_constant) {
duke@435 952 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 953 int header_offset = in_bytes(DataLayout::header_offset());
duke@435 954 int header_bits = DataLayout::flag_mask_to_header_mask(flag_byte_constant);
duke@435 955 // Set the flag
duke@435 956 orl(Address(mdp_in, header_offset), header_bits);
duke@435 957 }
duke@435 958
duke@435 959
duke@435 960
duke@435 961 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,
duke@435 962 int offset,
duke@435 963 Register value,
duke@435 964 Register test_value_out,
duke@435 965 Label& not_equal_continue) {
duke@435 966 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 967 if (test_value_out == noreg) {
never@739 968 cmpptr(value, Address(mdp_in, offset));
duke@435 969 } else {
duke@435 970 // Put the test value into a register, so caller can use it:
never@739 971 movptr(test_value_out, Address(mdp_in, offset));
never@739 972 cmpptr(test_value_out, value);
duke@435 973 }
duke@435 974 jcc(Assembler::notEqual, not_equal_continue);
duke@435 975 }
duke@435 976
duke@435 977
duke@435 978 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
duke@435 979 int offset_of_disp) {
duke@435 980 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 981 Address disp_address(mdp_in, offset_of_disp);
never@739 982 addptr(mdp_in, disp_address);
never@739 983 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);
duke@435 984 }
duke@435 985
duke@435 986
duke@435 987 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
duke@435 988 Register reg,
duke@435 989 int offset_of_disp) {
duke@435 990 assert(ProfileInterpreter, "must be profiling interpreter");
duke@435 991 Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp);
never@739 992 addptr(mdp_in, disp_address);
never@739 993 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);
duke@435 994 }
duke@435 995
duke@435 996
duke@435 997 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in,
duke@435 998 int constant) {
duke@435 999 assert(ProfileInterpreter, "must be profiling interpreter");
never@739 1000 addptr(mdp_in, constant);
never@739 1001 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in);
duke@435 1002 }
duke@435 1003
duke@435 1004
duke@435 1005 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
duke@435 1006 assert(ProfileInterpreter, "must be profiling interpreter");
never@739 1007 push(return_bci); // save/restore across call_VM
duke@435 1008 call_VM(noreg,
duke@435 1009 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret),
duke@435 1010 return_bci);
never@739 1011 pop(return_bci);
duke@435 1012 }
duke@435 1013
duke@435 1014
duke@435 1015 void InterpreterMacroAssembler::profile_taken_branch(Register mdp,
duke@435 1016 Register bumped_count) {
duke@435 1017 if (ProfileInterpreter) {
duke@435 1018 Label profile_continue;
duke@435 1019
duke@435 1020 // If no method data exists, go to profile_continue.
duke@435 1021 // Otherwise, assign to mdp
duke@435 1022 test_method_data_pointer(mdp, profile_continue);
duke@435 1023
duke@435 1024 // We are taking a branch. Increment the taken count.
duke@435 1025 // We inline increment_mdp_data_at to return bumped_count in a register
duke@435 1026 //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
duke@435 1027 Address data(mdp, in_bytes(JumpData::taken_offset()));
never@739 1028 movptr(bumped_count, data);
duke@435 1029 assert(DataLayout::counter_increment == 1,
duke@435 1030 "flow-free idiom only works with 1");
never@739 1031 addptr(bumped_count, DataLayout::counter_increment);
never@739 1032 sbbptr(bumped_count, 0);
never@739 1033 movptr(data, bumped_count); // Store back out
duke@435 1034
duke@435 1035 // The method data pointer needs to be updated to reflect the new target.
duke@435 1036 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
duke@435 1037 bind(profile_continue);
duke@435 1038 }
duke@435 1039 }
duke@435 1040
duke@435 1041
duke@435 1042 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
duke@435 1043 if (ProfileInterpreter) {
duke@435 1044 Label profile_continue;
duke@435 1045
duke@435 1046 // If no method data exists, go to profile_continue.
duke@435 1047 test_method_data_pointer(mdp, profile_continue);
duke@435 1048
duke@435 1049 // We are taking a branch. Increment the not taken count.
duke@435 1050 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
duke@435 1051
duke@435 1052 // The method data pointer needs to be updated to correspond to
duke@435 1053 // the next bytecode
duke@435 1054 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
duke@435 1055 bind(profile_continue);
duke@435 1056 }
duke@435 1057 }
duke@435 1058
duke@435 1059
duke@435 1060 void InterpreterMacroAssembler::profile_call(Register mdp) {
duke@435 1061 if (ProfileInterpreter) {
duke@435 1062 Label profile_continue;
duke@435 1063
duke@435 1064 // If no method data exists, go to profile_continue.
duke@435 1065 test_method_data_pointer(mdp, profile_continue);
duke@435 1066
duke@435 1067 // We are making a call. Increment the count.
duke@435 1068 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
duke@435 1069
duke@435 1070 // The method data pointer needs to be updated to reflect the new target.
duke@435 1071 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
duke@435 1072 bind(profile_continue);
duke@435 1073 }
duke@435 1074 }
duke@435 1075
duke@435 1076
duke@435 1077 void InterpreterMacroAssembler::profile_final_call(Register mdp) {
duke@435 1078 if (ProfileInterpreter) {
duke@435 1079 Label profile_continue;
duke@435 1080
duke@435 1081 // If no method data exists, go to profile_continue.
duke@435 1082 test_method_data_pointer(mdp, profile_continue);
duke@435 1083
duke@435 1084 // We are making a call. Increment the count.
duke@435 1085 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
duke@435 1086
duke@435 1087 // The method data pointer needs to be updated to reflect the new target.
duke@435 1088 update_mdp_by_constant(mdp,
duke@435 1089 in_bytes(VirtualCallData::
duke@435 1090 virtual_call_data_size()));
duke@435 1091 bind(profile_continue);
duke@435 1092 }
duke@435 1093 }
duke@435 1094
duke@435 1095
duke@435 1096 void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
duke@435 1097 Register mdp,
twisti@1543 1098 Register reg2,
twisti@1543 1099 bool receiver_can_be_null) {
duke@435 1100 if (ProfileInterpreter) {
duke@435 1101 Label profile_continue;
duke@435 1102
duke@435 1103 // If no method data exists, go to profile_continue.
duke@435 1104 test_method_data_pointer(mdp, profile_continue);
duke@435 1105
twisti@1543 1106 Label skip_receiver_profile;
twisti@1543 1107 if (receiver_can_be_null) {
kvn@1641 1108 Label not_null;
twisti@1543 1109 testptr(receiver, receiver);
kvn@1641 1110 jccb(Assembler::notZero, not_null);
kvn@1641 1111 // We are making a call. Increment the count for null receiver.
kvn@1641 1112 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
kvn@1641 1113 jmp(skip_receiver_profile);
kvn@1641 1114 bind(not_null);
twisti@1543 1115 }
twisti@1543 1116
duke@435 1117 // Record the receiver type.
kvn@1641 1118 record_klass_in_profile(receiver, mdp, reg2, true);
twisti@1543 1119 bind(skip_receiver_profile);
duke@435 1120
duke@435 1121 // The method data pointer needs to be updated to reflect the new target.
duke@435 1122 update_mdp_by_constant(mdp,
duke@435 1123 in_bytes(VirtualCallData::
duke@435 1124 virtual_call_data_size()));
duke@435 1125 bind(profile_continue);
duke@435 1126 }
duke@435 1127 }
duke@435 1128
duke@435 1129 // This routine creates a state machine for updating the multi-row
duke@435 1130 // type profile at a virtual call site (or other type-sensitive bytecode).
duke@435 1131 // The machine visits each row (of receiver/count) until the receiver type
duke@435 1132 // is found, or until it runs out of rows. At the same time, it remembers
duke@435 1133 // the location of the first empty row. (An empty row records null for its
duke@435 1134 // receiver, and can be allocated for a newly-observed receiver type.)
duke@435 1135 // Because there are two degrees of freedom in the state, a simple linear
duke@435 1136 // search will not work; it must be a decision tree. Hence this helper
duke@435 1137 // function is recursive, to generate the required tree structured code.
duke@435 1138 // It's the interpreter, so we are trading off code space for speed.
duke@435 1139 // See below for example code.
duke@435 1140 void InterpreterMacroAssembler::record_klass_in_profile_helper(
duke@435 1141 Register receiver, Register mdp,
kvn@1641 1142 Register reg2, int start_row,
kvn@1641 1143 Label& done, bool is_virtual_call) {
kvn@1641 1144 if (TypeProfileWidth == 0) {
kvn@1641 1145 if (is_virtual_call) {
kvn@1641 1146 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
kvn@1641 1147 }
poonam@1402 1148 return;
kvn@1641 1149 }
poonam@1402 1150
duke@435 1151 int last_row = VirtualCallData::row_limit() - 1;
duke@435 1152 assert(start_row <= last_row, "must be work left to do");
duke@435 1153 // Test this row for both the receiver and for null.
duke@435 1154 // Take any of three different outcomes:
duke@435 1155 // 1. found receiver => increment count and goto done
duke@435 1156 // 2. found null => keep looking for case 1, maybe allocate this cell
duke@435 1157 // 3. found something else => keep looking for cases 1 and 2
duke@435 1158 // Case 3 is handled by a recursive call.
duke@435 1159 for (int row = start_row; row <= last_row; row++) {
duke@435 1160 Label next_test;
duke@435 1161 bool test_for_null_also = (row == start_row);
duke@435 1162
duke@435 1163 // See if the receiver is receiver[n].
duke@435 1164 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
duke@435 1165 test_mdp_data_at(mdp, recvr_offset, receiver,
duke@435 1166 (test_for_null_also ? reg2 : noreg),
duke@435 1167 next_test);
duke@435 1168 // (Reg2 now contains the receiver from the CallData.)
duke@435 1169
duke@435 1170 // The receiver is receiver[n]. Increment count[n].
duke@435 1171 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
duke@435 1172 increment_mdp_data_at(mdp, count_offset);
duke@435 1173 jmp(done);
duke@435 1174 bind(next_test);
duke@435 1175
duke@435 1176 if (test_for_null_also) {
kvn@1641 1177 Label found_null;
duke@435 1178 // Failed the equality check on receiver[n]... Test for null.
never@739 1179 testptr(reg2, reg2);
duke@435 1180 if (start_row == last_row) {
duke@435 1181 // The only thing left to do is handle the null case.
kvn@1641 1182 if (is_virtual_call) {
kvn@1641 1183 jccb(Assembler::zero, found_null);
kvn@1641 1184 // Receiver did not match any saved receiver and there is no empty row for it.
kvn@1686 1185 // Increment total counter to indicate polymorphic case.
kvn@1641 1186 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
kvn@1641 1187 jmp(done);
kvn@1641 1188 bind(found_null);
kvn@1641 1189 } else {
kvn@1641 1190 jcc(Assembler::notZero, done);
kvn@1641 1191 }
duke@435 1192 break;
duke@435 1193 }
duke@435 1194 // Since null is rare, make it be the branch-taken case.
duke@435 1195 jcc(Assembler::zero, found_null);
duke@435 1196
duke@435 1197 // Put all the "Case 3" tests here.
kvn@1641 1198 record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done, is_virtual_call);
duke@435 1199
duke@435 1200 // Found a null. Keep searching for a matching receiver,
duke@435 1201 // but remember that this is an empty (unused) slot.
duke@435 1202 bind(found_null);
duke@435 1203 }
duke@435 1204 }
duke@435 1205
duke@435 1206 // In the fall-through case, we found no matching receiver, but we
duke@435 1207 // observed the receiver[start_row] is NULL.
duke@435 1208
duke@435 1209 // Fill in the receiver field and increment the count.
duke@435 1210 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
duke@435 1211 set_mdp_data_at(mdp, recvr_offset, receiver);
duke@435 1212 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
duke@435 1213 movl(reg2, DataLayout::counter_increment);
duke@435 1214 set_mdp_data_at(mdp, count_offset, reg2);
kvn@1641 1215 if (start_row > 0) {
kvn@1641 1216 jmp(done);
kvn@1641 1217 }
duke@435 1218 }
duke@435 1219
duke@435 1220 // Example state machine code for three profile rows:
duke@435 1221 // // main copy of decision tree, rooted at row[1]
duke@435 1222 // if (row[0].rec == rec) { row[0].incr(); goto done; }
duke@435 1223 // if (row[0].rec != NULL) {
duke@435 1224 // // inner copy of decision tree, rooted at row[1]
duke@435 1225 // if (row[1].rec == rec) { row[1].incr(); goto done; }
duke@435 1226 // if (row[1].rec != NULL) {
duke@435 1227 // // degenerate decision tree, rooted at row[2]
duke@435 1228 // if (row[2].rec == rec) { row[2].incr(); goto done; }
kvn@1641 1229 // if (row[2].rec != NULL) { count.incr(); goto done; } // overflow
duke@435 1230 // row[2].init(rec); goto done;
duke@435 1231 // } else {
duke@435 1232 // // remember row[1] is empty
duke@435 1233 // if (row[2].rec == rec) { row[2].incr(); goto done; }
duke@435 1234 // row[1].init(rec); goto done;
duke@435 1235 // }
duke@435 1236 // } else {
duke@435 1237 // // remember row[0] is empty
duke@435 1238 // if (row[1].rec == rec) { row[1].incr(); goto done; }
duke@435 1239 // if (row[2].rec == rec) { row[2].incr(); goto done; }
duke@435 1240 // row[0].init(rec); goto done;
duke@435 1241 // }
kvn@1641 1242 // done:
duke@435 1243
duke@435 1244 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
kvn@1641 1245 Register mdp, Register reg2,
kvn@1641 1246 bool is_virtual_call) {
duke@435 1247 assert(ProfileInterpreter, "must be profiling");
duke@435 1248 Label done;
duke@435 1249
kvn@1641 1250 record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call);
duke@435 1251
duke@435 1252 bind (done);
duke@435 1253 }
duke@435 1254
duke@435 1255 void InterpreterMacroAssembler::profile_ret(Register return_bci,
duke@435 1256 Register mdp) {
duke@435 1257 if (ProfileInterpreter) {
duke@435 1258 Label profile_continue;
duke@435 1259 uint row;
duke@435 1260
duke@435 1261 // If no method data exists, go to profile_continue.
duke@435 1262 test_method_data_pointer(mdp, profile_continue);
duke@435 1263
duke@435 1264 // Update the total ret count.
duke@435 1265 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
duke@435 1266
duke@435 1267 for (row = 0; row < RetData::row_limit(); row++) {
duke@435 1268 Label next_test;
duke@435 1269
duke@435 1270 // See if return_bci is equal to bci[n]:
duke@435 1271 test_mdp_data_at(mdp,
duke@435 1272 in_bytes(RetData::bci_offset(row)),
duke@435 1273 return_bci, noreg,
duke@435 1274 next_test);
duke@435 1275
duke@435 1276 // return_bci is equal to bci[n]. Increment the count.
duke@435 1277 increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)));
duke@435 1278
duke@435 1279 // The method data pointer needs to be updated to reflect the new target.
duke@435 1280 update_mdp_by_offset(mdp,
duke@435 1281 in_bytes(RetData::bci_displacement_offset(row)));
duke@435 1282 jmp(profile_continue);
duke@435 1283 bind(next_test);
duke@435 1284 }
duke@435 1285
duke@435 1286 update_mdp_for_ret(return_bci);
duke@435 1287
duke@435 1288 bind(profile_continue);
duke@435 1289 }
duke@435 1290 }
duke@435 1291
duke@435 1292
duke@435 1293 void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
duke@435 1294 if (ProfileInterpreter) {
duke@435 1295 Label profile_continue;
duke@435 1296
duke@435 1297 // If no method data exists, go to profile_continue.
duke@435 1298 test_method_data_pointer(mdp, profile_continue);
duke@435 1299
never@1261 1300 set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
never@1261 1301
duke@435 1302 // The method data pointer needs to be updated.
duke@435 1303 int mdp_delta = in_bytes(BitData::bit_data_size());
duke@435 1304 if (TypeProfileCasts) {
duke@435 1305 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
duke@435 1306 }
duke@435 1307 update_mdp_by_constant(mdp, mdp_delta);
duke@435 1308
duke@435 1309 bind(profile_continue);
duke@435 1310 }
duke@435 1311 }
duke@435 1312
duke@435 1313
duke@435 1314 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {
duke@435 1315 if (ProfileInterpreter && TypeProfileCasts) {
duke@435 1316 Label profile_continue;
duke@435 1317
duke@435 1318 // If no method data exists, go to profile_continue.
duke@435 1319 test_method_data_pointer(mdp, profile_continue);
duke@435 1320
duke@435 1321 int count_offset = in_bytes(CounterData::count_offset());
duke@435 1322 // Back up the address, since we have already bumped the mdp.
duke@435 1323 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
duke@435 1324
duke@435 1325 // *Decrement* the counter. We expect to see zero or small negatives.
duke@435 1326 increment_mdp_data_at(mdp, count_offset, true);
duke@435 1327
duke@435 1328 bind (profile_continue);
duke@435 1329 }
duke@435 1330 }
duke@435 1331
duke@435 1332
duke@435 1333 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) {
duke@435 1334 if (ProfileInterpreter) {
duke@435 1335 Label profile_continue;
duke@435 1336
duke@435 1337 // If no method data exists, go to profile_continue.
duke@435 1338 test_method_data_pointer(mdp, profile_continue);
duke@435 1339
duke@435 1340 // The method data pointer needs to be updated.
duke@435 1341 int mdp_delta = in_bytes(BitData::bit_data_size());
duke@435 1342 if (TypeProfileCasts) {
duke@435 1343 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
duke@435 1344
duke@435 1345 // Record the object type.
kvn@1641 1346 record_klass_in_profile(klass, mdp, reg2, false);
duke@435 1347 }
duke@435 1348 update_mdp_by_constant(mdp, mdp_delta);
duke@435 1349
duke@435 1350 bind(profile_continue);
duke@435 1351 }
duke@435 1352 }
duke@435 1353
duke@435 1354
duke@435 1355 void InterpreterMacroAssembler::profile_switch_default(Register mdp) {
duke@435 1356 if (ProfileInterpreter) {
duke@435 1357 Label profile_continue;
duke@435 1358
duke@435 1359 // If no method data exists, go to profile_continue.
duke@435 1360 test_method_data_pointer(mdp, profile_continue);
duke@435 1361
duke@435 1362 // Update the default case count
duke@435 1363 increment_mdp_data_at(mdp,
duke@435 1364 in_bytes(MultiBranchData::default_count_offset()));
duke@435 1365
duke@435 1366 // The method data pointer needs to be updated.
duke@435 1367 update_mdp_by_offset(mdp,
duke@435 1368 in_bytes(MultiBranchData::
duke@435 1369 default_displacement_offset()));
duke@435 1370
duke@435 1371 bind(profile_continue);
duke@435 1372 }
duke@435 1373 }
duke@435 1374
duke@435 1375
duke@435 1376 void InterpreterMacroAssembler::profile_switch_case(Register index,
duke@435 1377 Register mdp,
duke@435 1378 Register reg2) {
duke@435 1379 if (ProfileInterpreter) {
duke@435 1380 Label profile_continue;
duke@435 1381
duke@435 1382 // If no method data exists, go to profile_continue.
duke@435 1383 test_method_data_pointer(mdp, profile_continue);
duke@435 1384
duke@435 1385 // Build the base (index * per_case_size_in_bytes()) +
duke@435 1386 // case_array_offset_in_bytes()
duke@435 1387 movl(reg2, in_bytes(MultiBranchData::per_case_size()));
never@739 1388 imulptr(index, reg2); // XXX l ?
never@739 1389 addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ?
duke@435 1390
duke@435 1391 // Update the case count
duke@435 1392 increment_mdp_data_at(mdp,
duke@435 1393 index,
duke@435 1394 in_bytes(MultiBranchData::relative_count_offset()));
duke@435 1395
duke@435 1396 // The method data pointer needs to be updated.
duke@435 1397 update_mdp_by_offset(mdp,
duke@435 1398 index,
duke@435 1399 in_bytes(MultiBranchData::
duke@435 1400 relative_displacement_offset()));
duke@435 1401
duke@435 1402 bind(profile_continue);
duke@435 1403 }
duke@435 1404 }
duke@435 1405
duke@435 1406
never@739 1407
duke@435 1408 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) {
duke@435 1409 if (state == atos) {
duke@435 1410 MacroAssembler::verify_oop(reg);
duke@435 1411 }
duke@435 1412 }
duke@435 1413
duke@435 1414 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
duke@435 1415 }
never@739 1416 #endif // !CC_INTERP
duke@435 1417
duke@435 1418
duke@435 1419 void InterpreterMacroAssembler::notify_method_entry() {
duke@435 1420 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
duke@435 1421 // track stack depth. If it is possible to enter interp_only_mode we add
duke@435 1422 // the code to check if the event should be sent.
duke@435 1423 if (JvmtiExport::can_post_interpreter_events()) {
duke@435 1424 Label L;
duke@435 1425 movl(rdx, Address(r15_thread, JavaThread::interp_only_mode_offset()));
duke@435 1426 testl(rdx, rdx);
duke@435 1427 jcc(Assembler::zero, L);
duke@435 1428 call_VM(noreg, CAST_FROM_FN_PTR(address,
duke@435 1429 InterpreterRuntime::post_method_entry));
duke@435 1430 bind(L);
duke@435 1431 }
duke@435 1432
duke@435 1433 {
duke@435 1434 SkipIfEqual skip(this, &DTraceMethodProbes, false);
duke@435 1435 get_method(c_rarg1);
duke@435 1436 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
duke@435 1437 r15_thread, c_rarg1);
duke@435 1438 }
dcubed@1045 1439
dcubed@1045 1440 // RedefineClasses() tracing support for obsolete method entry
dcubed@1045 1441 if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
dcubed@1045 1442 get_method(c_rarg1);
dcubed@1045 1443 call_VM_leaf(
dcubed@1045 1444 CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
dcubed@1045 1445 r15_thread, c_rarg1);
dcubed@1045 1446 }
duke@435 1447 }
duke@435 1448
duke@435 1449
duke@435 1450 void InterpreterMacroAssembler::notify_method_exit(
duke@435 1451 TosState state, NotifyMethodExitMode mode) {
duke@435 1452 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to
duke@435 1453 // track stack depth. If it is possible to enter interp_only_mode we add
duke@435 1454 // the code to check if the event should be sent.
duke@435 1455 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {
duke@435 1456 Label L;
duke@435 1457 // Note: frame::interpreter_frame_result has a dependency on how the
duke@435 1458 // method result is saved across the call to post_method_exit. If this
duke@435 1459 // is changed then the interpreter_frame_result implementation will
duke@435 1460 // need to be updated too.
never@739 1461
never@739 1462 // For c++ interpreter the result is always stored at a known location in the frame
never@739 1463 // template interpreter will leave it on the top of the stack.
never@739 1464 NOT_CC_INTERP(push(state);)
duke@435 1465 movl(rdx, Address(r15_thread, JavaThread::interp_only_mode_offset()));
duke@435 1466 testl(rdx, rdx);
duke@435 1467 jcc(Assembler::zero, L);
duke@435 1468 call_VM(noreg,
duke@435 1469 CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit));
duke@435 1470 bind(L);
never@739 1471 NOT_CC_INTERP(pop(state));
duke@435 1472 }
duke@435 1473
duke@435 1474 {
duke@435 1475 SkipIfEqual skip(this, &DTraceMethodProbes, false);
never@739 1476 NOT_CC_INTERP(push(state));
duke@435 1477 get_method(c_rarg1);
duke@435 1478 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
duke@435 1479 r15_thread, c_rarg1);
never@739 1480 NOT_CC_INTERP(pop(state));
duke@435 1481 }
duke@435 1482 }

mercurial