27 #include "interp_masm_sparc.hpp" |
27 #include "interp_masm_sparc.hpp" |
28 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreter.hpp" |
29 #include "interpreter/interpreterRuntime.hpp" |
29 #include "interpreter/interpreterRuntime.hpp" |
30 #include "logging/log.hpp" |
30 #include "logging/log.hpp" |
31 #include "oops/arrayOop.hpp" |
31 #include "oops/arrayOop.hpp" |
32 #include "oops/markOop.hpp" |
32 #include "oops/markWord.hpp" |
33 #include "oops/methodData.hpp" |
33 #include "oops/methodData.hpp" |
34 #include "oops/method.hpp" |
34 #include "oops/method.hpp" |
35 #include "oops/methodCounters.hpp" |
35 #include "oops/methodCounters.hpp" |
36 #include "prims/jvmtiExport.hpp" |
36 #include "prims/jvmtiExport.hpp" |
37 #include "prims/jvmtiThreadState.hpp" |
37 #include "prims/jvmtiThreadState.hpp" |
1198 |
1198 |
1199 Label slow_case; |
1199 Label slow_case; |
1200 |
1200 |
1201 assert_different_registers(lock_reg, obj_reg, mark_reg, temp_reg); |
1201 assert_different_registers(lock_reg, obj_reg, mark_reg, temp_reg); |
1202 |
1202 |
1203 // load markOop from object into mark_reg |
1203 // load markWord from object into mark_reg |
1204 ld_ptr(mark_addr, mark_reg); |
1204 ld_ptr(mark_addr, mark_reg); |
1205 |
1205 |
1206 if (UseBiasedLocking) { |
1206 if (UseBiasedLocking) { |
1207 biased_locking_enter(obj_reg, mark_reg, temp_reg, done, &slow_case); |
1207 biased_locking_enter(obj_reg, mark_reg, temp_reg, done, &slow_case); |
1208 } |
1208 } |
1209 |
1209 |
1210 // get the address of basicLock on stack that will be stored in the object |
1210 // get the address of basicLock on stack that will be stored in the object |
1211 // we need a temporary register here as we do not want to clobber lock_reg |
1211 // we need a temporary register here as we do not want to clobber lock_reg |
1212 // (cas clobbers the destination register) |
1212 // (cas clobbers the destination register) |
1213 mov(lock_reg, temp_reg); |
1213 mov(lock_reg, temp_reg); |
1214 // set mark reg to be (markOop of object | UNLOCK_VALUE) |
1214 // set mark reg to be (markWord of object | UNLOCK_VALUE) |
1215 or3(mark_reg, markOopDesc::unlocked_value, mark_reg); |
1215 or3(mark_reg, markWord::unlocked_value, mark_reg); |
1216 // initialize the box (Must happen before we update the object mark!) |
1216 // initialize the box (Must happen before we update the object mark!) |
1217 st_ptr(mark_reg, lock_addr, BasicLock::displaced_header_offset_in_bytes()); |
1217 st_ptr(mark_reg, lock_addr, BasicLock::displaced_header_offset_in_bytes()); |
1218 // compare and exchange object_addr, markOop | 1, stack address of basicLock |
1218 // compare and exchange object_addr, markWord | 1, stack address of basicLock |
1219 assert(mark_addr.disp() == 0, "cas must take a zero displacement"); |
1219 assert(mark_addr.disp() == 0, "cas must take a zero displacement"); |
1220 cas_ptr(mark_addr.base(), mark_reg, temp_reg); |
1220 cas_ptr(mark_addr.base(), mark_reg, temp_reg); |
1221 |
1221 |
1222 // if the compare and exchange succeeded we are done (we saw an unlocked object) |
1222 // if the compare and exchange succeeded we are done (we saw an unlocked object) |
1223 cmp_and_brx_short(mark_reg, temp_reg, Assembler::equal, Assembler::pt, done); |
1223 cmp_and_brx_short(mark_reg, temp_reg, Assembler::equal, Assembler::pt, done); |
1224 |
1224 |
1225 // We did not see an unlocked object so try the fast recursive case |
1225 // We did not see an unlocked object so try the fast recursive case |
1226 |
1226 |
1227 // Check if owner is self by comparing the value in the markOop of object |
1227 // Check if owner is self by comparing the value in the markWord of object |
1228 // with the stack pointer |
1228 // with the stack pointer |
1229 sub(temp_reg, SP, temp_reg); |
1229 sub(temp_reg, SP, temp_reg); |
1230 sub(temp_reg, STACK_BIAS, temp_reg); |
1230 sub(temp_reg, STACK_BIAS, temp_reg); |
1231 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant"); |
1231 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant"); |
1232 |
1232 |
1233 // Composite "andcc" test: |
1233 // Composite "andcc" test: |
1234 // (a) %sp -vs- markword proximity check, and, |
1234 // (a) %sp -vs- markword proximity check, and, |
1235 // (b) verify mark word LSBs == 0 (Stack-locked). |
1235 // (b) verify mark word LSBs == 0 (Stack-locked). |
1236 // |
1236 // |
1237 // FFFFF003/FFFFFFFFFFFF003 is (markOopDesc::lock_mask_in_place | -os::vm_page_size()) |
1237 // FFFFF003/FFFFFFFFFFFF003 is (markWord::lock_mask_in_place | -os::vm_page_size()) |
1238 // Note that the page size used for %sp proximity testing is arbitrary and is |
1238 // Note that the page size used for %sp proximity testing is arbitrary and is |
1239 // unrelated to the actual MMU page size. We use a 'logical' page size of |
1239 // unrelated to the actual MMU page size. We use a 'logical' page size of |
1240 // 4096 bytes. F..FFF003 is designed to fit conveniently in the SIMM13 immediate |
1240 // 4096 bytes. F..FFF003 is designed to fit conveniently in the SIMM13 immediate |
1241 // field of the andcc instruction. |
1241 // field of the andcc instruction. |
1242 andcc (temp_reg, 0xFFFFF003, G0) ; |
1242 andcc (temp_reg, 0xFFFFF003, G0) ; |