< prev index next > src/hotspot/share/opto/library_call.cpp
Print this page
// The control of the load must be null. Otherwise, the load can move before
// the null check after castPP removal.
Node* no_ctrl = nullptr;
Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
- // Test the header to see if it is unlocked.
+ // Test the header to see if it is safe to read w.r.t. locking.
Node *lock_mask = _gvn.MakeConX(markWord::biased_lock_mask_in_place);
Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask));
- Node *unlocked_val = _gvn.MakeConX(markWord::unlocked_value);
- Node *chk_unlocked = _gvn.transform(new CmpXNode( lmasked_header, unlocked_val));
- Node *test_unlocked = _gvn.transform(new BoolNode( chk_unlocked, BoolTest::ne));
+ if (LockingMode == LM_LIGHTWEIGHT) {
+ Node *monitor_val = _gvn.MakeConX(markWord::monitor_value);
+ Node *chk_monitor = _gvn.transform(new CmpXNode(lmasked_header, monitor_val));
+ Node *test_monitor = _gvn.transform(new BoolNode(chk_monitor, BoolTest::eq));
- generate_slow_guard(test_unlocked, slow_region);
+ generate_slow_guard(test_monitor, slow_region);
+ } else {
+ Node *unlocked_val = _gvn.MakeConX(markWord::unlocked_value);
+ Node *chk_unlocked = _gvn.transform(new CmpXNode(lmasked_header, unlocked_val));
+ Node *test_not_unlocked = _gvn.transform(new BoolNode(chk_unlocked, BoolTest::ne));
+
+ generate_slow_guard(test_not_unlocked, slow_region);
+ }
// Get the hash value and check to see that it has been properly assigned.
// We depend on hash_mask being at most 32 bits and avoid the use of
// hash_mask_in_place because it could be larger than 32 bits in a 64-bit
// vm: see markWord.hpp.
- Node *hash_mask = _gvn.intcon(markWord::hash_mask);
- Node *hash_shift = _gvn.intcon(markWord::hash_shift);
+ Node *hash_mask = _gvn.intcon(UseCompactObjectHeaders ? markWord::hash_mask_compact : markWord::hash_mask);
+ Node *hash_shift = _gvn.intcon(UseCompactObjectHeaders ? markWord::hash_shift_compact : markWord::hash_shift);
Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift));
// This hack lets the hash bits live anywhere in the mark object now, as long
// as the shift drops the relevant bits into the low 32 bits. Note that
// Java spec says that HashCode is an int so there's no point in capturing
// an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
< prev index next >