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