< prev index next >

src/hotspot/share/ci/ciMethodData.cpp

Print this page

 52   _saw_free_extra_data(false),
 53   // Initialize the escape information (to "don't know.");
 54   _eflags(0), _arg_local(0), _arg_stack(0), _arg_returned(0),
 55   _invocation_counter(0),
 56   _orig() {}
 57 
 58 // Check for entries that reference an unloaded method
 59 class PrepareExtraDataClosure : public CleanExtraDataClosure {
 60   MethodData*            _mdo;
 61   SafepointStateTracker  _safepoint_tracker;
 62   GrowableArray<Method*> _uncached_methods;
 63 
 64 public:
 65   PrepareExtraDataClosure(MethodData* mdo)
 66     : _mdo(mdo),
 67       _safepoint_tracker(SafepointSynchronize::safepoint_state_tracker()),
 68       _uncached_methods()
 69   { }
 70 
 71   bool is_live(Method* m) {
 72     if (!m->method_holder()->is_loader_alive()) {




 73       return false;
 74     }
 75     if (CURRENT_ENV->cached_metadata(m) == nullptr) {
 76       // Uncached entries need to be pre-populated.
 77       _uncached_methods.append(m);
 78     }
 79     return true;
 80   }
 81 
 82   bool has_safepointed() {
 83     return _safepoint_tracker.safepoint_state_changed();
 84   }
 85 
 86   bool finish() {
 87     if (_uncached_methods.length() == 0) {
 88       // Preparation finished iff all Methods* were already cached.
 89       return true;
 90     }
 91     // We are currently holding the extra_data_lock and ensuring
 92     // no safepoint breaks the lock.

287     _invocation_counter = 1;
288   }
289 
290   _state = mdo->is_mature() ? mature_state : immature_state;
291   _eflags = mdo->eflags();
292   _arg_local = mdo->arg_local();
293   _arg_stack = mdo->arg_stack();
294   _arg_returned  = mdo->arg_returned();
295   if (ReplayCompiles) {
296     ciReplay::initialize(this);
297     if (is_empty()) {
298       return false;
299     }
300   }
301   return true;
302 }
303 
304 void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) {
305   for (uint row = 0; row < row_limit(); row++) {
306     Klass* k = data->as_ReceiverTypeData()->receiver(row);
307     if (k != nullptr) {

308       if (k->is_loader_alive()) {
309         ciKlass* klass = CURRENT_ENV->get_klass(k);
310         set_receiver(row, klass);
311       } else {
312         // With concurrent class unloading, the MDO could have stale metadata; override it
313         clear_row(row);
314       }
315     } else {
316       set_receiver(row, nullptr);
317     }
318   }
319 }
320 
321 void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries* entries) {
322   for (int i = 0; i < number_of_entries(); i++) {
323     intptr_t k = entries->type(i);
324     Klass* klass = (Klass*)klass_part(k);
325     if (klass != nullptr && !klass->is_loader_alive()) {


326       // With concurrent class unloading, the MDO could have stale metadata; override it
327       TypeStackSlotEntries::set_type(i, TypeStackSlotEntries::with_status((Klass*)nullptr, k));
328     } else {
329       TypeStackSlotEntries::set_type(i, translate_klass(k));
330     }
331   }
332 }
333 
334 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) {
335   intptr_t k = ret->type();
336   Klass* klass = (Klass*)klass_part(k);
337   if (klass != nullptr && !klass->is_loader_alive()) {


338     // With concurrent class unloading, the MDO could have stale metadata; override it
339     set_type(ReturnTypeEntry::with_status((Klass*)nullptr, k));
340   } else {
341     set_type(translate_klass(k));
342   }
343 }
344 
345 void ciSpeculativeTrapData::translate_from(const ProfileData* data) {
346   Method* m = data->as_SpeculativeTrapData()->method();
347   ciMethod* ci_m = CURRENT_ENV->get_method(m);
348   set_method(ci_m);
349 }
350 
351 // Get the data at an arbitrary (sort of) data index.
352 ciProfileData* ciMethodData::data_at(int data_index) {
353   if (out_of_bounds(data_index)) {
354     return nullptr;
355   }
356   DataLayout* data_layout = data_layout_at(data_index);
357   return data_from(data_layout);

 52   _saw_free_extra_data(false),
 53   // Initialize the escape information (to "don't know.");
 54   _eflags(0), _arg_local(0), _arg_stack(0), _arg_returned(0),
 55   _invocation_counter(0),
 56   _orig() {}
 57 
 58 // Check for entries that reference an unloaded method
 59 class PrepareExtraDataClosure : public CleanExtraDataClosure {
 60   MethodData*            _mdo;
 61   SafepointStateTracker  _safepoint_tracker;
 62   GrowableArray<Method*> _uncached_methods;
 63 
 64 public:
 65   PrepareExtraDataClosure(MethodData* mdo)
 66     : _mdo(mdo),
 67       _safepoint_tracker(SafepointSynchronize::safepoint_state_tracker()),
 68       _uncached_methods()
 69   { }
 70 
 71   bool is_live(Method* m) {
 72     Klass* holder = m->method_holder();
 73     if (holder == nullptr || // premain: not yet loaded
 74         holder->class_loader_data() == nullptr ||
 75         !holder->is_loader_alive() ||
 76         (holder->is_instance_klass() && !InstanceKlass::cast(holder)->is_loaded())) {
 77       return false;
 78     }
 79     if (CURRENT_ENV->cached_metadata(m) == nullptr) {
 80       // Uncached entries need to be pre-populated.
 81       _uncached_methods.append(m);
 82     }
 83     return true;
 84   }
 85 
 86   bool has_safepointed() {
 87     return _safepoint_tracker.safepoint_state_changed();
 88   }
 89 
 90   bool finish() {
 91     if (_uncached_methods.length() == 0) {
 92       // Preparation finished iff all Methods* were already cached.
 93       return true;
 94     }
 95     // We are currently holding the extra_data_lock and ensuring
 96     // no safepoint breaks the lock.

291     _invocation_counter = 1;
292   }
293 
294   _state = mdo->is_mature() ? mature_state : immature_state;
295   _eflags = mdo->eflags();
296   _arg_local = mdo->arg_local();
297   _arg_stack = mdo->arg_stack();
298   _arg_returned  = mdo->arg_returned();
299   if (ReplayCompiles) {
300     ciReplay::initialize(this);
301     if (is_empty()) {
302       return false;
303     }
304   }
305   return true;
306 }
307 
308 void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) {
309   for (uint row = 0; row < row_limit(); row++) {
310     Klass* k = data->as_ReceiverTypeData()->receiver(row);
311     if (k != nullptr && k->class_loader_data() != nullptr &&
312         (!k->is_instance_klass() || InstanceKlass::cast(k)->is_loaded())) {
313       if (k->is_loader_alive()) {
314         ciKlass* klass = CURRENT_ENV->get_klass(k);
315         set_receiver(row, klass);
316       } else {
317         // With concurrent class unloading, the MDO could have stale metadata; override it
318         clear_row(row);
319       }
320     } else {
321       set_receiver(row, nullptr);
322     }
323   }
324 }
325 
326 void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries* entries) {
327   for (int i = 0; i < number_of_entries(); i++) {
328     intptr_t k = entries->type(i);
329     Klass* klass = (Klass*)klass_part(k);
330     if (klass != nullptr &&
331         ((klass->is_instance_klass() && !InstanceKlass::cast(klass)->is_loaded()) ||
332          (klass->class_loader_data() == nullptr || !klass->is_loader_alive()))) {
333       // With concurrent class unloading, the MDO could have stale metadata; override it
334       TypeStackSlotEntries::set_type(i, TypeStackSlotEntries::with_status((Klass*)nullptr, k));
335     } else {
336       TypeStackSlotEntries::set_type(i, translate_klass(k));
337     }
338   }
339 }
340 
341 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) {
342   intptr_t k = ret->type();
343   Klass* klass = (Klass*)klass_part(k);
344   if (klass != nullptr &&
345       ((klass->is_instance_klass() && !InstanceKlass::cast(klass)->is_loaded()) ||
346        (klass->class_loader_data() == nullptr || !klass->is_loader_alive()))) {
347     // With concurrent class unloading, the MDO could have stale metadata; override it
348     set_type(ReturnTypeEntry::with_status((Klass*)nullptr, k));
349   } else {
350     set_type(translate_klass(k));
351   }
352 }
353 
354 void ciSpeculativeTrapData::translate_from(const ProfileData* data) {
355   Method* m = data->as_SpeculativeTrapData()->method();
356   ciMethod* ci_m = CURRENT_ENV->get_method(m);
357   set_method(ci_m);
358 }
359 
360 // Get the data at an arbitrary (sort of) data index.
361 ciProfileData* ciMethodData::data_at(int data_index) {
362   if (out_of_bounds(data_index)) {
363     return nullptr;
364   }
365   DataLayout* data_layout = data_layout_at(data_index);
366   return data_from(data_layout);
< prev index next >