src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp

Print this page




 987       } else {
 988         // The reference points into a promotion or to-space region
 989         HeapRegion* to = _g1h->heap_region_containing(obj);
 990         to->rem_set()->add_strong_code_root(_nm);
 991       }
 992     }
 993   }
 994 
 995 public:
 996   NMethodMigrationOopClosure(G1CollectedHeap* g1h, HeapRegion* from, nmethod* nm):
 997     _g1h(g1h), _from(from), _nm(nm), _num_self_forwarded(0) {}
 998 
 999   void do_oop(narrowOop* p) { do_oop_work(p); }
1000   void do_oop(oop* p)       { do_oop_work(p); }
1001 
1002   uint retain() { return _num_self_forwarded > 0; }
1003 };
1004 
1005 void HeapRegionRemSet::migrate_strong_code_roots() {
1006   assert(hr()->in_collection_set(), "only collection set regions");
1007   assert(!hr()->isHumongous(), "not humongous regions");
1008 
1009   ResourceMark rm;
1010 
1011   // List of code blobs to retain for this region
1012   GrowableArray<nmethod*> to_be_retained(10);
1013   G1CollectedHeap* g1h = G1CollectedHeap::heap();
1014 
1015   while (_strong_code_roots_list->is_nonempty()) {
1016     nmethod *nm = _strong_code_roots_list->pop();
1017     if (nm != NULL) {
1018       NMethodMigrationOopClosure oop_cl(g1h, hr(), nm);
1019       nm->oops_do(&oop_cl);
1020       if (oop_cl.retain()) {
1021         to_be_retained.push(nm);
1022       }
1023     }
1024   }
1025 
1026   // Now push any code roots we need to retain
1027   assert(to_be_retained.is_empty() || hr()->evacuation_failed(),




 987       } else {
 988         // The reference points into a promotion or to-space region
 989         HeapRegion* to = _g1h->heap_region_containing(obj);
 990         to->rem_set()->add_strong_code_root(_nm);
 991       }
 992     }
 993   }
 994 
 995 public:
 996   NMethodMigrationOopClosure(G1CollectedHeap* g1h, HeapRegion* from, nmethod* nm):
 997     _g1h(g1h), _from(from), _nm(nm), _num_self_forwarded(0) {}
 998 
 999   void do_oop(narrowOop* p) { do_oop_work(p); }
1000   void do_oop(oop* p)       { do_oop_work(p); }
1001 
1002   uint retain() { return _num_self_forwarded > 0; }
1003 };
1004 
1005 void HeapRegionRemSet::migrate_strong_code_roots() {
1006   assert(hr()->in_collection_set(), "only collection set regions");
1007   assert(!hr()->isHumongous(), "humongous region moved?");
1008 
1009   ResourceMark rm;
1010 
1011   // List of code blobs to retain for this region
1012   GrowableArray<nmethod*> to_be_retained(10);
1013   G1CollectedHeap* g1h = G1CollectedHeap::heap();
1014 
1015   while (_strong_code_roots_list->is_nonempty()) {
1016     nmethod *nm = _strong_code_roots_list->pop();
1017     if (nm != NULL) {
1018       NMethodMigrationOopClosure oop_cl(g1h, hr(), nm);
1019       nm->oops_do(&oop_cl);
1020       if (oop_cl.retain()) {
1021         to_be_retained.push(nm);
1022       }
1023     }
1024   }
1025 
1026   // Now push any code roots we need to retain
1027   assert(to_be_retained.is_empty() || hr()->evacuation_failed(),