src/cpu/x86/vm/interp_masm_x86_64.cpp

Sat, 29 Sep 2012 06:40:00 -0400

author
coleenp
date
Sat, 29 Sep 2012 06:40:00 -0400
changeset 4142
d8ce2825b193
parent 4037
da91efe96a93
child 4299
f34d701e952e
permissions
-rw-r--r--

8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
Summary: Capitalize these metadata types (and objArrayKlass)
Reviewed-by: stefank, twisti, kvn

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

mercurial