|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -200,26 +200,29 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj,
|
200 | 200 | const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
|
201 | 201 | const int mark_offset = BasicLock::displaced_header_offset_in_bytes();
|
202 | 202 |
|
203 |
| - if (UseBiasedLocking) { |
204 |
| - // load object |
205 |
| - str(obj, Address(disp_hdr, obj_offset)); |
206 |
| - null_check_offset = biased_locking_enter(obj, hdr/*scratched*/, tmp1, false, tmp2, done, slow_case); |
207 |
| - } |
| 203 | + str(obj, Address(disp_hdr, obj_offset)); |
208 | 204 |
|
209 |
| - assert(oopDesc::mark_offset_in_bytes() == 0, "Required by atomic instructions"); |
| 205 | + null_check_offset = offset(); |
210 | 206 |
|
| 207 | + if (DiagnoseSyncOnPrimitiveWrappers != 0) { |
| 208 | + load_klass(tmp1, obj); |
| 209 | + ldr_u32(tmp1, Address(tmp1, Klass::access_flags_offset())); |
| 210 | + tst(tmp1, JVM_ACC_IS_BOX_CLASS); |
| 211 | + b(slow_case, ne); |
| 212 | + } |
211 | 213 |
|
212 |
| - if (!UseBiasedLocking) { |
213 |
| - null_check_offset = offset(); |
| 214 | + if (UseBiasedLocking) { |
| 215 | + biased_locking_enter(obj, hdr/*scratched*/, tmp1, false, tmp2, done, slow_case); |
214 | 216 | }
|
215 | 217 |
|
| 218 | + assert(oopDesc::mark_offset_in_bytes() == 0, "Required by atomic instructions"); |
| 219 | + |
216 | 220 | // On MP platforms the next load could return a 'stale' value if the memory location has been modified by another thread.
|
217 | 221 | // That would be acceptable as ether CAS or slow case path is taken in that case.
|
218 | 222 |
|
219 | 223 | // Must be the first instruction here, because implicit null check relies on it
|
220 | 224 | ldr(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
|
221 | 225 |
|
222 |
| - str(obj, Address(disp_hdr, obj_offset)); |
223 | 226 | tst(hdr, markWord::unlocked_value);
|
224 | 227 | b(fast_lock, ne);
|
225 | 228 |
|
|
0 commit comments