< prev index next >

src/hotspot/cpu/s390/interp_masm_s390.cpp

Print this page

 950 
 951     should_not_reach_here();
 952 
 953     bind(no_reserved_zone_enabling);
 954   }
 955 
 956   verify_oop(Z_tos, state);
 957   verify_thread();
 958 
 959   pop_interpreter_frame(return_pc, Z_ARG2, Z_ARG3);
 960   BLOCK_COMMENT("} remove_activation");
 961 }
 962 
 963 // lock object
 964 //
 965 // Registers alive
 966 //   monitor - Address of the BasicObjectLock to be used for locking,
 967 //             which must be initialized with the object to lock.
 968 //   object  - Address of the object to be locked.
 969 void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
 970 
 971   if (UseHeavyMonitors) {
 972     call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor);
 973     return;
 974   }
 975 
 976   // template code:
 977   //
 978   // markWord displaced_header = obj->mark().set_unlocked();
 979   // monitor->lock()->set_displaced_header(displaced_header);
 980   // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) {
 981   //   // We stored the monitor address into the object's mark word.
 982   // } else if (THREAD->is_lock_owned((address)displaced_header))
 983   //   // Simple recursive case.
 984   //   monitor->lock()->set_displaced_header(NULL);
 985   // } else {
 986   //   // Slow path.
 987   //   InterpreterRuntime::monitorenter(THREAD, monitor);
 988   // }
 989 
 990   const Register displaced_header = Z_ARG5;
 991   const Register object_mark_addr = Z_ARG4;
 992   const Register current_header   = Z_ARG5;
 993 
 994   NearLabel done;
 995   NearLabel slow_case;
 996 
 997   // markWord displaced_header = obj->mark().set_unlocked();
 998 
 999   // Load markWord from object into displaced_header.
1000   z_lg(displaced_header, oopDesc::mark_offset_in_bytes(), object);
1001 
1002   if (DiagnoseSyncOnValueBasedClasses != 0) {
1003     load_klass(Z_R1_scratch, object);
1004     testbit(Address(Z_R1_scratch, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
1005     z_btrue(slow_case);
1006   }
1007 
1008   // Set displaced_header to be (markWord of object | UNLOCK_VALUE).
1009   z_oill(displaced_header, markWord::unlocked_value);
1010 
1011   // monitor->lock()->set_displaced_header(displaced_header);
1012 
1013   // Initialize the box (Must happen before we update the object mark!).
1014   z_stg(displaced_header, BasicObjectLock::lock_offset_in_bytes() +
1015                           BasicLock::displaced_header_offset_in_bytes(), monitor);
1016 
1017   // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) {
1018 
1019   // Store stack address of the BasicObjectLock (this is monitor) into object.
1020   add2reg(object_mark_addr, oopDesc::mark_offset_in_bytes(), object);
1021 
1022   z_csg(displaced_header, monitor, 0, object_mark_addr);
1023   assert(current_header==displaced_header, "must be same register"); // Identified two registers from z/Architecture.
1024 
1025   z_bre(done);
1026 
1027   // } else if (THREAD->is_lock_owned((address)displaced_header))
1028   //   // Simple recursive case.
1029   //   monitor->lock()->set_displaced_header(NULL);
1030 
1031   // We did not see an unlocked object so try the fast recursive case.
1032 
1033   // Check if owner is self by comparing the value in the markWord of object
1034   // (current_header) with the stack pointer.
1035   z_sgr(current_header, Z_SP);
1036 
1037   assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
1038 
1039   // The prior sequence "LGR, NGR, LTGR" can be done better
1040   // (Z_R1 is temp and not used after here).
1041   load_const_optimized(Z_R0, (~(os::vm_page_size()-1) | markWord::lock_mask_in_place));
1042   z_ngr(Z_R0, current_header); // AND sets CC (result eq/ne 0)
1043 
1044   // If condition is true we are done and hence we can store 0 in the displaced
1045   // header indicating it is a recursive lock and be done.
1046   z_brne(slow_case);
1047   z_release();  // Membar unnecessary on zarch AND because the above csg does a sync before and after.
1048   z_stg(Z_R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() +
1049                       BasicLock::displaced_header_offset_in_bytes(), monitor);
1050   z_bru(done);
1051 
1052   // } else {
1053   //   // Slow path.
1054   //   InterpreterRuntime::monitorenter(THREAD, monitor);
1055 
1056   // None of the above fast optimizations worked so we have to get into the
1057   // slow case of monitor enter.
1058   bind(slow_case);
1059   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor);
1060 
1061   // }
1062 
1063   bind(done);
1064 }
1065 
1066 // Unlocks an object. Used in monitorexit bytecode and remove_activation.
1067 //
1068 // Registers alive
1069 //   monitor - address of the BasicObjectLock to be used for locking,
1070 //             which must be initialized with the object to lock.
1071 //
1072 // Throw IllegalMonitorException if object is not locked by current thread.
1073 void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) {
1074 
1075   if (UseHeavyMonitors) {
1076     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
1077     return;
1078   }
1079 
1080 // else {
1081   // template code:
1082   //
1083   // if ((displaced_header = monitor->displaced_header()) == NULL) {
1084   //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
1085   //   monitor->set_obj(NULL);
1086   // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
1087   //   // We swapped the unlocked mark in displaced_header into the object's mark word.
1088   //   monitor->set_obj(NULL);
1089   // } else {
1090   //   // Slow path.
1091   //   InterpreterRuntime::monitorexit(monitor);
1092   // }
1093 
1094   const Register displaced_header = Z_ARG4;
1095   const Register current_header   = Z_R1;
1096   Address obj_entry(monitor, BasicObjectLock::obj_offset_in_bytes());
1097   Label done;
1098 
1099   if (object == noreg) {
1100     // In the template interpreter, we must assure that the object
1101     // entry in the monitor is cleared on all paths. Thus we move
1102     // loading up to here, and clear the entry afterwards.
1103     object = Z_ARG3; // Use Z_ARG3 if caller didn't pass object.
1104     z_lg(object, obj_entry);
1105   }
1106 
1107   assert_different_registers(monitor, object, displaced_header, current_header);
1108 
1109   // if ((displaced_header = monitor->displaced_header()) == NULL) {
1110   //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
1111   //   monitor->set_obj(NULL);
1112 
1113   clear_mem(obj_entry, sizeof(oop));
1114 
1115   // Test first if we are in the fast recursive case.
1116   MacroAssembler::load_and_test_long(displaced_header,
1117                                      Address(monitor, BasicObjectLock::lock_offset_in_bytes() +
1118                                                       BasicLock::displaced_header_offset_in_bytes()));
1119   z_bre(done); // displaced_header == 0 -> goto done
1120 
1121   // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
1122   //   // We swapped the unlocked mark in displaced_header into the object's mark word.
1123   //   monitor->set_obj(NULL);
1124 
1125   // If we still have a lightweight lock, unlock the object and be done.
1126 
1127   // The markword is expected to be at offset 0.
1128   assert(oopDesc::mark_offset_in_bytes() == 0, "unlock_object: review code below");
1129 
1130   // We have the displaced header in displaced_header. If the lock is still
1131   // lightweight, it will contain the monitor address and we'll store the
1132   // displaced header back into the object's mark word.
1133   z_lgr(current_header, monitor);
1134   z_csg(current_header, displaced_header, 0, object);
1135   z_bre(done);
1136 
1137   // } else {
1138   //   // Slow path.
1139   //   InterpreterRuntime::monitorexit(monitor);
1140 
1141   // The lock has been converted into a heavy lock and hence
1142   // we need to get into the slow case.
1143   z_stg(object, obj_entry);   // Restore object entry, has been cleared above.
1144   call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);
1145 
1146   // }
1147 
1148   bind(done);
1149 }
1150 
1151 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {
1152   assert(ProfileInterpreter, "must be profiling interpreter");
1153   load_and_test_long(mdp, Address(Z_fp, _z_ijava_state_neg(mdx)));
1154   z_brz(zero_continue);
1155 }
1156 
1157 // Set the method data pointer for the current bcp.
1158 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
1159   assert(ProfileInterpreter, "must be profiling interpreter");
1160   Label    set_mdp;
1161   Register mdp    = Z_ARG4;
1162   Register method = Z_ARG5;
1163 
1164   get_method(method);
1165   // Test MDO to avoid the call if it is NULL.
1166   load_and_test_long(mdp, method2_(method, method_data));
1167   z_brz(set_mdp);
1168 

 950 
 951     should_not_reach_here();
 952 
 953     bind(no_reserved_zone_enabling);
 954   }
 955 
 956   verify_oop(Z_tos, state);
 957   verify_thread();
 958 
 959   pop_interpreter_frame(return_pc, Z_ARG2, Z_ARG3);
 960   BLOCK_COMMENT("} remove_activation");
 961 }
 962 
 963 // lock object
 964 //
 965 // Registers alive
 966 //   monitor - Address of the BasicObjectLock to be used for locking,
 967 //             which must be initialized with the object to lock.
 968 //   object  - Address of the object to be locked.
 969 void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {

























































































 970   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor);




 971 }
 972 
 973 // Unlocks an object. Used in monitorexit bytecode and remove_activation.
 974 //
 975 // Registers alive
 976 //   monitor - address of the BasicObjectLock to be used for locking,
 977 //             which must be initialized with the object to lock.
 978 //
 979 // Throw IllegalMonitorException if object is not locked by current thread.
 980 void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) {






































































 981   call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor);




 982 }
 983 
 984 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {
 985   assert(ProfileInterpreter, "must be profiling interpreter");
 986   load_and_test_long(mdp, Address(Z_fp, _z_ijava_state_neg(mdx)));
 987   z_brz(zero_continue);
 988 }
 989 
 990 // Set the method data pointer for the current bcp.
 991 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
 992   assert(ProfileInterpreter, "must be profiling interpreter");
 993   Label    set_mdp;
 994   Register mdp    = Z_ARG4;
 995   Register method = Z_ARG5;
 996 
 997   get_method(method);
 998   // Test MDO to avoid the call if it is NULL.
 999   load_and_test_long(mdp, method2_(method, method_data));
1000   z_brz(set_mdp);
1001 
< prev index next >