225 } else {
226 const Register t1_hash = t1;
227 Label monitor_found;
228
229 // Save the mark, we might need it to extract the hash.
230 mov(t3, t1_mark);
231
232 // Look for the monitor in the om_cache.
233
234 ByteSize cache_offset = JavaThread::om_cache_oops_offset();
235 ByteSize monitor_offset = OMCache::oop_to_monitor_difference();
236 const int num_unrolled = OMCache::CAPACITY;
237 for (int i = 0; i < num_unrolled; i++) {
238 ldr(t1_monitor, Address(rthread, cache_offset + monitor_offset));
239 ldr(t2, Address(rthread, cache_offset));
240 cmp(obj, t2);
241 br(Assembler::EQ, monitor_found);
242 cache_offset = cache_offset + OMCache::oop_to_oop_difference();
243 }
244
245 // Look for the monitor in the table.
246
247 // Get the hash code.
248 ubfx(t1_hash, t3, markWord::hash_shift, markWord::hash_bits);
249
250 // Get the table and calculate the bucket's address
251 lea(t3, ExternalAddress(ObjectMonitorTable::current_table_address()));
252 ldr(t3, Address(t3));
253 ldr(t2, Address(t3, ObjectMonitorTable::table_capacity_mask_offset()));
254 ands(t1_hash, t1_hash, t2);
255 ldr(t3, Address(t3, ObjectMonitorTable::table_buckets_offset()));
256
257 // Read the monitor from the bucket.
258 ldr(t1_monitor, Address(t3, t1_hash, Address::lsl(LogBytesPerWord)));
259
260 // Check if the monitor in the bucket is special (empty, tombstone or removed).
261 cmp(t1_monitor, (unsigned char)ObjectMonitorTable::SpecialPointerValues::below_is_special);
262 br(Assembler::LO, slow_path);
263
264 // Check if object matches.
265 ldr(t3, Address(t1_monitor, ObjectMonitor::object_offset()));
266 BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
267 bs_asm->try_resolve_weak_handle_in_c2(this, t3, t2, slow_path);
268 cmp(t3, obj);
269 br(Assembler::NE, slow_path);
270
271 bind(monitor_found);
272 }
273
274 const Register t2_owner_addr = t2;
275 const Register t3_owner = t3;
276 const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast<int>(markWord::monitor_value));
277 const Address owner_address(t1_monitor, ObjectMonitor::owner_offset() - monitor_tag);
278 const Address recursions_address(t1_monitor, ObjectMonitor::recursions_offset() - monitor_tag);
279
280 Label monitor_locked;
281
282 // Compute owner address.
283 lea(t2_owner_addr, owner_address);
284
285 // Try to CAS owner (no owner => current thread's _monitor_owner_id).
286 ldr(rscratch2, Address(rthread, JavaThread::monitor_owner_id_offset()));
287 cmpxchg(t2_owner_addr, zr, rscratch2, Assembler::xword, /*acquire*/ true,
288 /*release*/ false, /*weak*/ false, t3_owner);
289 br(Assembler::EQ, monitor_locked);
290
|
225 } else {
226 const Register t1_hash = t1;
227 Label monitor_found;
228
229 // Save the mark, we might need it to extract the hash.
230 mov(t3, t1_mark);
231
232 // Look for the monitor in the om_cache.
233
234 ByteSize cache_offset = JavaThread::om_cache_oops_offset();
235 ByteSize monitor_offset = OMCache::oop_to_monitor_difference();
236 const int num_unrolled = OMCache::CAPACITY;
237 for (int i = 0; i < num_unrolled; i++) {
238 ldr(t1_monitor, Address(rthread, cache_offset + monitor_offset));
239 ldr(t2, Address(rthread, cache_offset));
240 cmp(obj, t2);
241 br(Assembler::EQ, monitor_found);
242 cache_offset = cache_offset + OMCache::oop_to_oop_difference();
243 }
244
245 if (UseCompactObjectHeaders) {
246 // TODO: The fast-path table lookup currently doesn't work with Lilliput's
247 // compact identity-hashcode implementation.
248 // See: https://bugs.openjdk.org/browse/JDK-8380981
249 b(slow_path);
250 } else {
251 // Look for the monitor in the table.
252
253 // Get the hash code.
254 ubfx(t1_hash, t3, markWord::hash_shift, markWord::hash_bits);
255
256 // Get the table and calculate the bucket's address
257 lea(t3, ExternalAddress(ObjectMonitorTable::current_table_address()));
258 ldr(t3, Address(t3));
259 ldr(t2, Address(t3, ObjectMonitorTable::table_capacity_mask_offset()));
260 ands(t1_hash, t1_hash, t2);
261 ldr(t3, Address(t3, ObjectMonitorTable::table_buckets_offset()));
262
263 // Read the monitor from the bucket.
264 ldr(t1_monitor, Address(t3, t1_hash, Address::lsl(LogBytesPerWord)));
265
266 // Check if the monitor in the bucket is special (empty, tombstone or removed).
267 cmp(t1_monitor, (unsigned char)ObjectMonitorTable::SpecialPointerValues::below_is_special);
268 br(Assembler::LO, slow_path);
269
270 // Check if object matches.
271 ldr(t3, Address(t1_monitor, ObjectMonitor::object_offset()));
272 BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
273 bs_asm->try_resolve_weak_handle_in_c2(this, t3, t2, slow_path);
274 cmp(t3, obj);
275 br(Assembler::NE, slow_path);
276 }
277 bind(monitor_found);
278 }
279
280 const Register t2_owner_addr = t2;
281 const Register t3_owner = t3;
282 const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast<int>(markWord::monitor_value));
283 const Address owner_address(t1_monitor, ObjectMonitor::owner_offset() - monitor_tag);
284 const Address recursions_address(t1_monitor, ObjectMonitor::recursions_offset() - monitor_tag);
285
286 Label monitor_locked;
287
288 // Compute owner address.
289 lea(t2_owner_addr, owner_address);
290
291 // Try to CAS owner (no owner => current thread's _monitor_owner_id).
292 ldr(rscratch2, Address(rthread, JavaThread::monitor_owner_id_offset()));
293 cmpxchg(t2_owner_addr, zr, rscratch2, Assembler::xword, /*acquire*/ true,
294 /*release*/ false, /*weak*/ false, t3_owner);
295 br(Assembler::EQ, monitor_locked);
296
|