368 PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id); |
364 PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id); |
369 __ movoop(reg, o); |
365 __ movoop(reg, o); |
370 patching_epilog(patch, lir_patch_normal, reg, info); |
366 patching_epilog(patch, lir_patch_normal, reg, info); |
371 } |
367 } |
372 |
368 |
373 |
|
374 void LIR_Assembler::monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register new_hdr, int monitor_no, Register exception) { |
|
375 if (exception->is_valid()) { |
|
376 // preserve exception |
|
377 // note: the monitor_exit runtime call is a leaf routine |
|
378 // and cannot block => no GC can happen |
|
379 // The slow case (MonitorAccessStub) uses the first two stack slots |
|
380 // ([esp+0] and [esp+4]), therefore we store the exception at [esp+8] |
|
381 __ movptr (Address(rsp, 2*wordSize), exception); |
|
382 } |
|
383 |
|
384 Register obj_reg = obj_opr->as_register(); |
|
385 Register lock_reg = lock_opr->as_register(); |
|
386 |
|
387 // setup registers (lock_reg must be rax, for lock_object) |
|
388 assert(obj_reg != SYNC_header && lock_reg != SYNC_header, "rax, must be available here"); |
|
389 Register hdr = lock_reg; |
|
390 assert(new_hdr == SYNC_header, "wrong register"); |
|
391 lock_reg = new_hdr; |
|
392 // compute pointer to BasicLock |
|
393 Address lock_addr = frame_map()->address_for_monitor_lock(monitor_no); |
|
394 __ lea(lock_reg, lock_addr); |
|
395 // unlock object |
|
396 MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, true, monitor_no); |
|
397 // _slow_case_stubs->append(slow_case); |
|
398 // temporary fix: must be created after exceptionhandler, therefore as call stub |
|
399 _slow_case_stubs->append(slow_case); |
|
400 if (UseFastLocking) { |
|
401 // try inlined fast unlocking first, revert to slow locking if it fails |
|
402 // note: lock_reg points to the displaced header since the displaced header offset is 0! |
|
403 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); |
|
404 __ unlock_object(hdr, obj_reg, lock_reg, *slow_case->entry()); |
|
405 } else { |
|
406 // always do slow unlocking |
|
407 // note: the slow unlocking code could be inlined here, however if we use |
|
408 // slow unlocking, speed doesn't matter anyway and this solution is |
|
409 // simpler and requires less duplicated code - additionally, the |
|
410 // slow unlocking code is the same in either case which simplifies |
|
411 // debugging |
|
412 __ jmp(*slow_case->entry()); |
|
413 } |
|
414 // done |
|
415 __ bind(*slow_case->continuation()); |
|
416 |
|
417 if (exception->is_valid()) { |
|
418 // restore exception |
|
419 __ movptr (exception, Address(rsp, 2 * wordSize)); |
|
420 } |
|
421 } |
|
422 |
369 |
423 // This specifies the rsp decrement needed to build the frame |
370 // This specifies the rsp decrement needed to build the frame |
424 int LIR_Assembler::initial_frame_size_in_bytes() { |
371 int LIR_Assembler::initial_frame_size_in_bytes() { |
425 // if rounding, must let FrameMap know! |
372 // if rounding, must let FrameMap know! |
426 |
373 |