< prev index next >

src/hotspot/share/opto/library_call.cpp

Print this page

4499 
4500   // If this is a virtual call, we generate a funny guard.  We pull out
4501   // the vtable entry corresponding to hashCode() from the target object.
4502   // If the target method which we are calling happens to be the native
4503   // Object hashCode() method, we pass the guard.  We do not need this
4504   // guard for non-virtual calls -- the caller is known to be the native
4505   // Object hashCode().
4506   if (is_virtual) {
4507     // After null check, get the object's klass.
4508     Node* obj_klass = load_object_klass(obj);
4509     generate_virtual_guard(obj_klass, slow_region);
4510   }
4511 
4512   // Get the header out of the object, use LoadMarkNode when available
4513   Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
4514   // The control of the load must be null. Otherwise, the load can move before
4515   // the null check after castPP removal.
4516   Node* no_ctrl = nullptr;
4517   Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
4518 
4519   // Test the header to see if it is unlocked.
4520   Node *lock_mask      = _gvn.MakeConX(markWord::lock_mask_in_place);
4521   Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask));
4522   Node *unlocked_val   = _gvn.MakeConX(markWord::unlocked_value);
4523   Node *chk_unlocked   = _gvn.transform(new CmpXNode( lmasked_header, unlocked_val));
4524   Node *test_unlocked  = _gvn.transform(new BoolNode( chk_unlocked, BoolTest::ne));

4525 
4526   generate_slow_guard(test_unlocked, slow_region);







4527 
4528   // Get the hash value and check to see that it has been properly assigned.
4529   // We depend on hash_mask being at most 32 bits and avoid the use of
4530   // hash_mask_in_place because it could be larger than 32 bits in a 64-bit
4531   // vm: see markWord.hpp.
4532   Node *hash_mask      = _gvn.intcon(markWord::hash_mask);
4533   Node *hash_shift     = _gvn.intcon(markWord::hash_shift);
4534   Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift));
4535   // This hack lets the hash bits live anywhere in the mark object now, as long
4536   // as the shift drops the relevant bits into the low 32 bits.  Note that
4537   // Java spec says that HashCode is an int so there's no point in capturing
4538   // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
4539   hshifted_header      = ConvX2I(hshifted_header);
4540   Node *hash_val       = _gvn.transform(new AndINode(hshifted_header, hash_mask));
4541 
4542   Node *no_hash_val    = _gvn.intcon(markWord::no_hash);
4543   Node *chk_assigned   = _gvn.transform(new CmpINode( hash_val, no_hash_val));
4544   Node *test_assigned  = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq));
4545 
4546   generate_slow_guard(test_assigned, slow_region);
4547 
4548   Node* init_mem = reset_memory();
4549   // fill in the rest of the null path:
4550   result_io ->init_req(_null_path, i_o());
4551   result_mem->init_req(_null_path, init_mem);
4552 
4553   result_val->init_req(_fast_path, hash_val);

4499 
4500   // If this is a virtual call, we generate a funny guard.  We pull out
4501   // the vtable entry corresponding to hashCode() from the target object.
4502   // If the target method which we are calling happens to be the native
4503   // Object hashCode() method, we pass the guard.  We do not need this
4504   // guard for non-virtual calls -- the caller is known to be the native
4505   // Object hashCode().
4506   if (is_virtual) {
4507     // After null check, get the object's klass.
4508     Node* obj_klass = load_object_klass(obj);
4509     generate_virtual_guard(obj_klass, slow_region);
4510   }
4511 
4512   // Get the header out of the object, use LoadMarkNode when available
4513   Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
4514   // The control of the load must be null. Otherwise, the load can move before
4515   // the null check after castPP removal.
4516   Node* no_ctrl = nullptr;
4517   Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
4518 
4519   // Test the header to see if it is safe to read w.r.t. locking.
4520   Node *lock_mask      = _gvn.MakeConX(markWord::lock_mask_in_place);
4521   Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask));
4522   if (LockingMode == LM_LIGHTWEIGHT) {
4523     Node *monitor_val   = _gvn.MakeConX(markWord::monitor_value);
4524     Node *chk_monitor   = _gvn.transform(new CmpXNode(lmasked_header, monitor_val));
4525     Node *test_monitor  = _gvn.transform(new BoolNode(chk_monitor, BoolTest::eq));
4526 
4527     generate_slow_guard(test_monitor, slow_region);
4528   } else {
4529     Node *unlocked_val      = _gvn.MakeConX(markWord::unlocked_value);
4530     Node *chk_unlocked      = _gvn.transform(new CmpXNode(lmasked_header, unlocked_val));
4531     Node *test_not_unlocked = _gvn.transform(new BoolNode(chk_unlocked, BoolTest::ne));
4532 
4533     generate_slow_guard(test_not_unlocked, slow_region);
4534   }
4535 
4536   // Get the hash value and check to see that it has been properly assigned.
4537   // We depend on hash_mask being at most 32 bits and avoid the use of
4538   // hash_mask_in_place because it could be larger than 32 bits in a 64-bit
4539   // vm: see markWord.hpp.
4540   Node *hash_mask      = _gvn.intcon(UseCompactObjectHeaders ? markWord::hash_mask_compact  : markWord::hash_mask);
4541   Node *hash_shift     = _gvn.intcon(UseCompactObjectHeaders ? markWord::hash_shift_compact : markWord::hash_shift);
4542   Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift));
4543   // This hack lets the hash bits live anywhere in the mark object now, as long
4544   // as the shift drops the relevant bits into the low 32 bits.  Note that
4545   // Java spec says that HashCode is an int so there's no point in capturing
4546   // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
4547   hshifted_header      = ConvX2I(hshifted_header);
4548   Node *hash_val       = _gvn.transform(new AndINode(hshifted_header, hash_mask));
4549 
4550   Node *no_hash_val    = _gvn.intcon(markWord::no_hash);
4551   Node *chk_assigned   = _gvn.transform(new CmpINode( hash_val, no_hash_val));
4552   Node *test_assigned  = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq));
4553 
4554   generate_slow_guard(test_assigned, slow_region);
4555 
4556   Node* init_mem = reset_memory();
4557   // fill in the rest of the null path:
4558   result_io ->init_req(_null_path, i_o());
4559   result_mem->init_req(_null_path, init_mem);
4560 
4561   result_val->init_req(_fast_path, hash_val);
< prev index next >