< prev index next >

src/hotspot/cpu/s390/interp_masm_s390.cpp

Print this page
@@ -965,189 +965,22 @@
  // Registers alive
  //   monitor - Address of the BasicObjectLock to be used for locking,
  //             which must be initialized with the object to lock.
  //   object  - Address of the object to be locked.
  void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
- 
-   if (UseHeavyMonitors) {
-     call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor);
-     return;
-   }
- 
-   // template code:
-   //
-   // markWord displaced_header = obj->mark().set_unlocked();
-   // monitor->lock()->set_displaced_header(displaced_header);
-   // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) {
-   //   // We stored the monitor address into the object's mark word.
-   // } else if (THREAD->is_lock_owned((address)displaced_header))
-   //   // Simple recursive case.
-   //   monitor->lock()->set_displaced_header(NULL);
-   // } else {
-   //   // Slow path.
-   //   InterpreterRuntime::monitorenter(THREAD, monitor);
-   // }
- 
-   const Register displaced_header = Z_ARG5;
-   const Register object_mark_addr = Z_ARG4;
-   const Register current_header   = Z_ARG5;
- 
-   NearLabel done;
-   NearLabel slow_case;
- 
-   // markWord displaced_header = obj->mark().set_unlocked();
- 
-   // Load markWord from object into displaced_header.
-   z_lg(displaced_header, oopDesc::mark_offset_in_bytes(), object);
- 
-   if (DiagnoseSyncOnValueBasedClasses != 0) {
-     load_klass(Z_R1_scratch, object);
-     testbit(Address(Z_R1_scratch, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
-     z_btrue(slow_case);
-   }
- 
-   // Set displaced_header to be (markWord of object | UNLOCK_VALUE).
-   z_oill(displaced_header, markWord::unlocked_value);
- 
-   // monitor->lock()->set_displaced_header(displaced_header);
- 
-   // Initialize the box (Must happen before we update the object mark!).
-   z_stg(displaced_header, BasicObjectLock::lock_offset_in_bytes() +
-                           BasicLock::displaced_header_offset_in_bytes(), monitor);
- 
-   // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) {
- 
-   // Store stack address of the BasicObjectLock (this is monitor) into object.
-   add2reg(object_mark_addr, oopDesc::mark_offset_in_bytes(), object);
- 
-   z_csg(displaced_header, monitor, 0, object_mark_addr);
-   assert(current_header==displaced_header, "must be same register"); // Identified two registers from z/Architecture.
- 
-   z_bre(done);
- 
-   // } else if (THREAD->is_lock_owned((address)displaced_header))
-   //   // Simple recursive case.
-   //   monitor->lock()->set_displaced_header(NULL);
- 
-   // We did not see an unlocked object so try the fast recursive case.
- 
-   // Check if owner is self by comparing the value in the markWord of object
-   // (current_header) with the stack pointer.
-   z_sgr(current_header, Z_SP);
- 
-   assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
- 
-   // The prior sequence "LGR, NGR, LTGR" can be done better
-   // (Z_R1 is temp and not used after here).
-   load_const_optimized(Z_R0, (~(os::vm_page_size()-1) | markWord::lock_mask_in_place));
-   z_ngr(Z_R0, current_header); // AND sets CC (result eq/ne 0)
- 
-   // If condition is true we are done and hence we can store 0 in the displaced
-   // header indicating it is a recursive lock and be done.
-   z_brne(slow_case);
-   z_release();  // Membar unnecessary on zarch AND because the above csg does a sync before and after.
-   z_stg(Z_R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() +
-                       BasicLock::displaced_header_offset_in_bytes(), monitor);
-   z_bru(done);
- 
-   // } else {
-   //   // Slow path.
-   //   InterpreterRuntime::monitorenter(THREAD, monitor);
- 
-   // None of the above fast optimizations worked so we have to get into the
-   // slow case of monitor enter.
-   bind(slow_case);
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor);
- 
-   // }
- 
-   bind(done);
  }
  
  // Unlocks an object. Used in monitorexit bytecode and remove_activation.
  //
  // Registers alive
  //   monitor - address of the BasicObjectLock to be used for locking,
  //             which must be initialized with the object to lock.
  //
  // Throw IllegalMonitorException if object is not locked by current thread.
  void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) {
- 
-   if (UseHeavyMonitors) {
-     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
-     return;
-   }
- 
- // else {
-   // template code:
-   //
-   // if ((displaced_header = monitor->displaced_header()) == NULL) {
-   //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
-   //   monitor->set_obj(NULL);
-   // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
-   //   // We swapped the unlocked mark in displaced_header into the object's mark word.
-   //   monitor->set_obj(NULL);
-   // } else {
-   //   // Slow path.
-   //   InterpreterRuntime::monitorexit(monitor);
-   // }
- 
-   const Register displaced_header = Z_ARG4;
-   const Register current_header   = Z_R1;
-   Address obj_entry(monitor, BasicObjectLock::obj_offset_in_bytes());
-   Label done;
- 
-   if (object == noreg) {
-     // In the template interpreter, we must assure that the object
-     // entry in the monitor is cleared on all paths. Thus we move
-     // loading up to here, and clear the entry afterwards.
-     object = Z_ARG3; // Use Z_ARG3 if caller didn't pass object.
-     z_lg(object, obj_entry);
-   }
- 
-   assert_different_registers(monitor, object, displaced_header, current_header);
- 
-   // if ((displaced_header = monitor->displaced_header()) == NULL) {
-   //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
-   //   monitor->set_obj(NULL);
- 
-   clear_mem(obj_entry, sizeof(oop));
- 
-   // Test first if we are in the fast recursive case.
-   MacroAssembler::load_and_test_long(displaced_header,
-                                      Address(monitor, BasicObjectLock::lock_offset_in_bytes() +
-                                                       BasicLock::displaced_header_offset_in_bytes()));
-   z_bre(done); // displaced_header == 0 -> goto done
- 
-   // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
-   //   // We swapped the unlocked mark in displaced_header into the object's mark word.
-   //   monitor->set_obj(NULL);
- 
-   // If we still have a lightweight lock, unlock the object and be done.
- 
-   // The markword is expected to be at offset 0.
-   assert(oopDesc::mark_offset_in_bytes() == 0, "unlock_object: review code below");
- 
-   // We have the displaced header in displaced_header. If the lock is still
-   // lightweight, it will contain the monitor address and we'll store the
-   // displaced header back into the object's mark word.
-   z_lgr(current_header, monitor);
-   z_csg(current_header, displaced_header, 0, object);
-   z_bre(done);
- 
-   // } else {
-   //   // Slow path.
-   //   InterpreterRuntime::monitorexit(monitor);
- 
-   // The lock has been converted into a heavy lock and hence
-   // we need to get into the slow case.
-   z_stg(object, obj_entry);   // Restore object entry, has been cleared above.
    call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
- 
-   // }
- 
-   bind(done);
  }
  
  void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {
    assert(ProfileInterpreter, "must be profiling interpreter");
    load_and_test_long(mdp, Address(Z_fp, _z_ijava_state_neg(mdx)));
< prev index next >