< prev index next >

src/hotspot/cpu/x86/interp_masm_x86.cpp

Print this page




1174 
1175     // Load object pointer into obj_reg
1176     movptr(obj_reg, Address(lock_reg, obj_offset));
1177 
1178     if (UseBiasedLocking) {
1179       biased_locking_enter(lock_reg, obj_reg, swap_reg, tmp_reg, false, done, &slow_case);
1180     }
1181 
1182     // Load immediate 1 into swap_reg %rax
1183     movl(swap_reg, (int32_t)1);
1184 
1185     // Load (object->mark() | 1) into swap_reg %rax
1186     orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1187 
1188     // Save (object->mark() | 1) into BasicLock's displaced header
1189     movptr(Address(lock_reg, mark_offset), swap_reg);
1190 
1191     assert(lock_offset == 0,
1192            "displaced header must be first word in BasicObjectLock");
1193 
1194     if (os::is_MP()) lock();
1195     cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1196     if (PrintBiasedLockingStatistics) {
1197       cond_inc32(Assembler::zero,
1198                  ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));
1199     }
1200     jcc(Assembler::zero, done);
1201 
1202     const int zero_bits = LP64_ONLY(7) NOT_LP64(3);
1203 
1204     // Test if the oopMark is an obvious stack pointer, i.e.,
1205     //  1) (mark & zero_bits) == 0, and
1206     //  2) rsp <= mark < mark + os::pagesize()
1207     //
1208     // These 3 tests can be done by evaluating the following
1209     // expression: ((mark - rsp) & (zero_bits - os::vm_page_size())),
1210     // assuming both stack pointer and pagesize have their
1211     // least significant bits clear.
1212     // NOTE: the oopMark is in swap_reg %rax as the result of cmpxchg
1213     subptr(swap_reg, rsp);
1214     andptr(swap_reg, zero_bits - os::vm_page_size());


1271     movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()));
1272 
1273     // Free entry
1274     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);
1275 
1276     if (UseBiasedLocking) {
1277       biased_locking_exit(obj_reg, header_reg, done);
1278     }
1279 
1280     // Load the old header from BasicLock structure
1281     movptr(header_reg, Address(swap_reg,
1282                                BasicLock::displaced_header_offset_in_bytes()));
1283 
1284     // Test for recursion
1285     testptr(header_reg, header_reg);
1286 
1287     // zero for recursive case
1288     jcc(Assembler::zero, done);
1289 
1290     // Atomic swap back the old header
1291     if (os::is_MP()) lock();
1292     cmpxchgptr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1293 
1294     // zero for simple unlock of a stack-lock case
1295     jcc(Assembler::zero, done);
1296 
1297     // Call the runtime routine for slow case.
1298     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()),
1299          obj_reg); // restore obj
1300     call_VM(noreg,
1301             CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
1302             lock_reg);
1303 
1304     bind(done);
1305 
1306     restore_bcp();
1307   }
1308 }
1309 
1310 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp,
1311                                                          Label& zero_continue) {




1174 
1175     // Load object pointer into obj_reg
1176     movptr(obj_reg, Address(lock_reg, obj_offset));
1177 
1178     if (UseBiasedLocking) {
1179       biased_locking_enter(lock_reg, obj_reg, swap_reg, tmp_reg, false, done, &slow_case);
1180     }
1181 
1182     // Load immediate 1 into swap_reg %rax
1183     movl(swap_reg, (int32_t)1);
1184 
1185     // Load (object->mark() | 1) into swap_reg %rax
1186     orptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1187 
1188     // Save (object->mark() | 1) into BasicLock's displaced header
1189     movptr(Address(lock_reg, mark_offset), swap_reg);
1190 
1191     assert(lock_offset == 0,
1192            "displaced header must be first word in BasicObjectLock");
1193 
1194     lock();
1195     cmpxchgptr(lock_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1196     if (PrintBiasedLockingStatistics) {
1197       cond_inc32(Assembler::zero,
1198                  ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr()));
1199     }
1200     jcc(Assembler::zero, done);
1201 
1202     const int zero_bits = LP64_ONLY(7) NOT_LP64(3);
1203 
1204     // Test if the oopMark is an obvious stack pointer, i.e.,
1205     //  1) (mark & zero_bits) == 0, and
1206     //  2) rsp <= mark < mark + os::pagesize()
1207     //
1208     // These 3 tests can be done by evaluating the following
1209     // expression: ((mark - rsp) & (zero_bits - os::vm_page_size())),
1210     // assuming both stack pointer and pagesize have their
1211     // least significant bits clear.
1212     // NOTE: the oopMark is in swap_reg %rax as the result of cmpxchg
1213     subptr(swap_reg, rsp);
1214     andptr(swap_reg, zero_bits - os::vm_page_size());


1271     movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()));
1272 
1273     // Free entry
1274     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);
1275 
1276     if (UseBiasedLocking) {
1277       biased_locking_exit(obj_reg, header_reg, done);
1278     }
1279 
1280     // Load the old header from BasicLock structure
1281     movptr(header_reg, Address(swap_reg,
1282                                BasicLock::displaced_header_offset_in_bytes()));
1283 
1284     // Test for recursion
1285     testptr(header_reg, header_reg);
1286 
1287     // zero for recursive case
1288     jcc(Assembler::zero, done);
1289 
1290     // Atomic swap back the old header
1291     lock();
1292     cmpxchgptr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1293 
1294     // zero for simple unlock of a stack-lock case
1295     jcc(Assembler::zero, done);
1296 
1297     // Call the runtime routine for slow case.
1298     movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()),
1299          obj_reg); // restore obj
1300     call_VM(noreg,
1301             CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
1302             lock_reg);
1303 
1304     bind(done);
1305 
1306     restore_bcp();
1307   }
1308 }
1309 
1310 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp,
1311                                                          Label& zero_continue) {


< prev index next >