annotate src/cpu/x86/vm/interp_masm_x86_32.cpp @ 1041:cd9ae3736d40

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