hotspot/src/share/vm/code/compiledIC.cpp
changeset 25486 be44827be5e7
parent 25359 8a19ff205f89
child 25490 59f226da8d81
equal deleted inserted replaced
25485:9c3d427eed01 25486:be44827be5e7
   157 
   157 
   158 
   158 
   159 //-----------------------------------------------------------------------------
   159 //-----------------------------------------------------------------------------
   160 // High-level access to an inline cache. Guaranteed to be MT-safe.
   160 // High-level access to an inline cache. Guaranteed to be MT-safe.
   161 
   161 
       
   162 void CompiledIC::initialize_from_iter(RelocIterator* iter) {
       
   163   assert(iter->addr() == _ic_call->instruction_address(), "must find ic_call");
       
   164 
       
   165   if (iter->type() == relocInfo::virtual_call_type) {
       
   166     virtual_call_Relocation* r = iter->virtual_call_reloc();
       
   167     _is_optimized = false;
       
   168     _value = nativeMovConstReg_at(r->cached_value());
       
   169   } else {
       
   170     assert(iter->type() == relocInfo::opt_virtual_call_type, "must be a virtual call");
       
   171     _is_optimized = true;
       
   172     _value = NULL;
       
   173   }
       
   174 }
       
   175 
   162 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call)
   176 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call)
   163   : _ic_call(call)
   177   : _ic_call(call)
   164 {
   178 {
   165   address ic_call = call->instruction_address();
   179   address ic_call = _ic_call->instruction_address();
   166 
   180 
   167   assert(ic_call != NULL, "ic_call address must be set");
   181   assert(ic_call != NULL, "ic_call address must be set");
   168   assert(nm != NULL, "must pass nmethod");
   182   assert(nm != NULL, "must pass nmethod");
   169   assert(nm->contains(ic_call), "must be in nmethod");
   183   assert(nm->contains(ic_call), "must be in nmethod");
   170 
   184 
   171   // Search for the ic_call at the given address.
   185   // Search for the ic_call at the given address.
   172   RelocIterator iter(nm, ic_call, ic_call+1);
   186   RelocIterator iter(nm, ic_call, ic_call+1);
   173   bool ret = iter.next();
   187   bool ret = iter.next();
   174   assert(ret == true, "relocInfo must exist at this address");
   188   assert(ret == true, "relocInfo must exist at this address");
   175   assert(iter.addr() == ic_call, "must find ic_call");
   189   assert(iter.addr() == ic_call, "must find ic_call");
   176   if (iter.type() == relocInfo::virtual_call_type) {
   190 
   177     virtual_call_Relocation* r = iter.virtual_call_reloc();
   191   initialize_from_iter(&iter);
   178     _is_optimized = false;
   192 }
   179     _value = nativeMovConstReg_at(r->cached_value());
   193 
   180   } else {
   194 CompiledIC::CompiledIC(RelocIterator* iter)
   181     assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call");
   195   : _ic_call(nativeCall_at(iter->addr()))
   182     _is_optimized = true;
   196 {
   183     _value = NULL;
   197   address ic_call = _ic_call->instruction_address();
   184   }
   198 
       
   199   nmethod* nm = iter->code();
       
   200   assert(ic_call != NULL, "ic_call address must be set");
       
   201   assert(nm != NULL, "must pass nmethod");
       
   202   assert(nm->contains(ic_call), "must be in nmethod");
       
   203 
       
   204   initialize_from_iter(iter);
   185 }
   205 }
   186 
   206 
   187 bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) {
   207 bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) {
   188   assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
   208   assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
   189   assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic");
   209   assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic");