src/share/vm/code/compiledIC.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8058737 Sdiff src/share/vm/code

src/share/vm/code/compiledIC.cpp

Print this page




 138 
 139 
 140 bool CompiledIC::is_in_transition_state() const {
 141   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 142   return InlineCacheBuffer::contains(_ic_call->destination());
 143 }
 144 
 145 
 146 bool CompiledIC::is_icholder_call() const {
 147   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 148   return !_is_optimized && is_icholder_entry(ic_destination());
 149 }
 150 
 151 // Returns native address of 'call' instruction in inline-cache. Used by
 152 // the InlineCacheBuffer when it needs to find the stub.
 153 address CompiledIC::stub_address() const {
 154   assert(is_in_transition_state(), "should only be called when we are in a transition state");
 155   return _ic_call->destination();
 156 }
 157 








 158 
 159 //-----------------------------------------------------------------------------
 160 // High-level access to an inline cache. Guaranteed to be MT-safe.
 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 
 176 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call)
 177   : _ic_call(call)


 316 void CompiledIC::set_to_clean() {
 317   assert(SafepointSynchronize::is_at_safepoint() || CompiledIC_lock->is_locked() , "MT-unsafe call");
 318   if (TraceInlineCacheClearing || TraceICs) {
 319     tty->print_cr("IC@" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));
 320     print();
 321   }
 322 
 323   address entry;
 324   if (is_optimized()) {
 325     entry = SharedRuntime::get_resolve_opt_virtual_call_stub();
 326   } else {
 327     entry = SharedRuntime::get_resolve_virtual_call_stub();
 328   }
 329 
 330   // A zombie transition will always be safe, since the metadata has already been set to NULL, so
 331   // we only need to patch the destination
 332   bool safe_transition = is_optimized() || SafepointSynchronize::is_at_safepoint();
 333 
 334   if (safe_transition) {
 335     // Kill any leftover stub we might have too
 336     if (is_in_transition_state()) {
 337       ICStub* old_stub = ICStub_from_destination_address(stub_address());
 338       old_stub->clear();
 339     }
 340     if (is_optimized()) {
 341     set_ic_destination(entry);
 342   } else {
 343       set_ic_destination_and_value(entry, (void*)NULL);
 344     }
 345   } else {
 346     // Unsafe transition - create stub.
 347     InlineCacheBuffer::create_transition_stub(this, NULL, entry);
 348   }
 349   // We can't check this anymore. With lazy deopt we could have already
 350   // cleaned this IC entry before we even return. This is possible if
 351   // we ran out of space in the inline cache buffer trying to do the
 352   // set_next and we safepointed to free up space. This is a benign
 353   // race because the IC entry was complete when we safepointed so
 354   // cleaning it immediately is harmless.
 355   // assert(is_clean(), "sanity check");
 356 }
 357 
 358 
 359 bool CompiledIC::is_clean() const {




 138 
 139 
 140 bool CompiledIC::is_in_transition_state() const {
 141   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 142   return InlineCacheBuffer::contains(_ic_call->destination());
 143 }
 144 
 145 
 146 bool CompiledIC::is_icholder_call() const {
 147   assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
 148   return !_is_optimized && is_icholder_entry(ic_destination());
 149 }
 150 
 151 // Returns native address of 'call' instruction in inline-cache. Used by
 152 // the InlineCacheBuffer when it needs to find the stub.
 153 address CompiledIC::stub_address() const {
 154   assert(is_in_transition_state(), "should only be called when we are in a transition state");
 155   return _ic_call->destination();
 156 }
 157 
 158 // Clears the IC stub if the compiled IC is in transition state
 159 void CompiledIC::clear_ic_stub() {
 160   if (is_in_transition_state()) {
 161     ICStub* stub = ICStub_from_destination_address(stub_address());
 162     stub->clear();
 163   }
 164 }
 165 
 166 
 167 //-----------------------------------------------------------------------------
 168 // High-level access to an inline cache. Guaranteed to be MT-safe.
 169 
 170 void CompiledIC::initialize_from_iter(RelocIterator* iter) {
 171   assert(iter->addr() == _ic_call->instruction_address(), "must find ic_call");
 172 
 173   if (iter->type() == relocInfo::virtual_call_type) {
 174     virtual_call_Relocation* r = iter->virtual_call_reloc();
 175     _is_optimized = false;
 176     _value = nativeMovConstReg_at(r->cached_value());
 177   } else {
 178     assert(iter->type() == relocInfo::opt_virtual_call_type, "must be a virtual call");
 179     _is_optimized = true;
 180     _value = NULL;
 181   }
 182 }
 183 
 184 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call)
 185   : _ic_call(call)


 324 void CompiledIC::set_to_clean() {
 325   assert(SafepointSynchronize::is_at_safepoint() || CompiledIC_lock->is_locked() , "MT-unsafe call");
 326   if (TraceInlineCacheClearing || TraceICs) {
 327     tty->print_cr("IC@" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));
 328     print();
 329   }
 330 
 331   address entry;
 332   if (is_optimized()) {
 333     entry = SharedRuntime::get_resolve_opt_virtual_call_stub();
 334   } else {
 335     entry = SharedRuntime::get_resolve_virtual_call_stub();
 336   }
 337 
 338   // A zombie transition will always be safe, since the metadata has already been set to NULL, so
 339   // we only need to patch the destination
 340   bool safe_transition = is_optimized() || SafepointSynchronize::is_at_safepoint();
 341 
 342   if (safe_transition) {
 343     // Kill any leftover stub we might have too
 344     clear_ic_stub();



 345     if (is_optimized()) {
 346     set_ic_destination(entry);
 347   } else {
 348       set_ic_destination_and_value(entry, (void*)NULL);
 349     }
 350   } else {
 351     // Unsafe transition - create stub.
 352     InlineCacheBuffer::create_transition_stub(this, NULL, entry);
 353   }
 354   // We can't check this anymore. With lazy deopt we could have already
 355   // cleaned this IC entry before we even return. This is possible if
 356   // we ran out of space in the inline cache buffer trying to do the
 357   // set_next and we safepointed to free up space. This is a benign
 358   // race because the IC entry was complete when we safepointed so
 359   // cleaning it immediately is harmless.
 360   // assert(is_clean(), "sanity check");
 361 }
 362 
 363 
 364 bool CompiledIC::is_clean() const {


src/share/vm/code/compiledIC.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File