src/cpu/x86/vm/interp_masm_x86_32.cpp

Mon, 02 May 2011 18:53:37 -0700

author
never
date
Mon, 02 May 2011 18:53:37 -0700
changeset 2868
2e038ad0c1d0
parent 2698
38fea01eb669
child 3005
341a57af9b0a
permissions
-rw-r--r--

7009361: JSR 292 Invalid value on stack on solaris-sparc with -Xcomp
Reviewed-by: kvn, twisti

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

mercurial