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

Print this page
rev 6872 : imported patch nm-hashtable

*** 4591,4600 **** --- 4591,4650 ---- } _count++; } }; + class G1CodeBlobClosure : public CodeBlobClosure { + class HeapRegionGatheringOopClosure : public OopClosure { + G1CollectedHeap* _g1h; + OopClosure* _work; + nmethod* _nm; + + template <typename T> + void do_oop_work(T* p) { + _work->do_oop(p); + T oop_or_narrowoop = oopDesc::load_heap_oop(p); + if (!oopDesc::is_null(oop_or_narrowoop)) { + oop o = oopDesc::decode_heap_oop_not_null(oop_or_narrowoop); + HeapRegion* hr = _g1h->heap_region_containing_raw(o); + assert(!_g1h->obj_in_cs(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in CS then evacuation failed and nm must already be in the remset"); + hr->lock_add_strong_code_root(_nm); + } + } + + public: + HeapRegionGatheringOopClosure(OopClosure* oc) : _g1h(G1CollectedHeap::heap()), _work(oc), _nm(NULL) {} + + void do_oop(oop* o) { + do_oop_work(o); + } + + void do_oop(narrowOop* o) { + do_oop_work(o); + } + + void set_nm(nmethod* nm) { + _nm = nm; + } + }; + + HeapRegionGatheringOopClosure _oc; + public: + G1CodeBlobClosure(OopClosure* oc) : _oc(oc) {} + + void do_code_blob(CodeBlob* cb) { + nmethod* that = cb->as_nmethod_or_null(); + if (that != NULL) { + if (!that->test_set_oops_do_mark()) { + _oc.set_nm(that); + that->oops_do(&_oc); + that->fix_oop_relocations(); + } + } + } + }; + class G1ParTask : public AbstractGangTask { protected: G1CollectedHeap* _g1h; RefToScanQueueSet *_queues; ParallelTaskTerminator _terminator;
*** 4659,4684 **** void do_cld(ClassLoaderData* cld) { cld->oops_do(_oop_closure, &_klass_in_cld_closure, _claim); } }; - class G1CodeBlobClosure: public CodeBlobClosure { - OopClosure* _f; - - public: - G1CodeBlobClosure(OopClosure* f) : _f(f) {} - void do_code_blob(CodeBlob* blob) { - nmethod* that = blob->as_nmethod_or_null(); - if (that != NULL) { - if (!that->test_set_oops_do_mark()) { - that->oops_do(_f); - that->fix_oop_relocations(); - } - } - } - }; - void work(uint worker_id) { if (worker_id >= _n_workers) return; // no work needed this round double start_time_ms = os::elapsedTime() * 1000.0; _g1h->g1_policy()->phase_times()->record_gc_worker_start_time(worker_id, start_time_ms); --- 4709,4718 ----
*** 4865,4875 **** } } g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms); // Now scan the complement of the collection set. ! MarkingCodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots, CodeBlobToOopClosure::FixRelocations); g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i); _process_strong_tasks->all_tasks_completed(); } --- 4899,4909 ---- } } g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms); // Now scan the complement of the collection set. ! G1CodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots); g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i); _process_strong_tasks->all_tasks_completed(); }
*** 5912,5927 **** // Note the counts for the cards in the regions in the // collection set are reset when the collection set is freed. hot_card_cache->reset_hot_cache(); hot_card_cache->set_use_cache(true); - // Migrate the strong code roots attached to each region in - // the collection set. Ideally we would like to do this - // after we have finished the scanning/evacuation of the - // strong code roots for a particular heap region. - migrate_strong_code_roots(); - purge_code_root_memory(); if (g1_policy()->during_initial_mark_pause()) { // Reset the claim values set during marking the strong code roots reset_heap_region_claim_values(); --- 5946,5955 ----
*** 6971,6986 **** err_msg("trying to add code root "PTR_FORMAT" in continuation of humongous region "HR_FORMAT " starting at "HR_FORMAT, _nm, HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()))); // HeapRegion::add_strong_code_root() avoids adding duplicate ! // entries but having duplicates is OK since we "mark" nmethods ! // as visited when we scan the strong code root lists during the GC. hr->add_strong_code_root(_nm); - assert(hr->rem_set()->strong_code_roots_list_contains(_nm), - err_msg("failed to add code root "PTR_FORMAT" to remembered set of region "HR_FORMAT, - _nm, HR_FORMAT_PARAMS(hr))); } } public: RegisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) : --- 6999,7010 ---- err_msg("trying to add code root "PTR_FORMAT" in continuation of humongous region "HR_FORMAT " starting at "HR_FORMAT, _nm, HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()))); // HeapRegion::add_strong_code_root() avoids adding duplicate ! // entries. hr->add_strong_code_root(_nm); } } public: RegisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) :
*** 7003,7015 **** err_msg("trying to remove code root "PTR_FORMAT" in continuation of humongous region "HR_FORMAT " starting at "HR_FORMAT, _nm, HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()))); hr->remove_strong_code_root(_nm); - assert(!hr->rem_set()->strong_code_roots_list_contains(_nm), - err_msg("failed to remove code root "PTR_FORMAT" of region "HR_FORMAT, - _nm, HR_FORMAT_PARAMS(hr))); } } public: UnregisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) : --- 7027,7036 ----
*** 7033,7064 **** guarantee(nm != NULL, "sanity"); UnregisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(&reg_cl, true); } - class MigrateCodeRootsHeapRegionClosure: public HeapRegionClosure { - public: - bool doHeapRegion(HeapRegion *hr) { - assert(!hr->isHumongous(), - err_msg("humongous region "HR_FORMAT" should not have been added to collection set", - HR_FORMAT_PARAMS(hr))); - hr->migrate_strong_code_roots(); - return false; - } - }; - - void G1CollectedHeap::migrate_strong_code_roots() { - MigrateCodeRootsHeapRegionClosure cl; - double migrate_start = os::elapsedTime(); - collection_set_iterate(&cl); - double migration_time_ms = (os::elapsedTime() - migrate_start) * 1000.0; - g1_policy()->phase_times()->record_strong_code_root_migration_time(migration_time_ms); - } - void G1CollectedHeap::purge_code_root_memory() { double purge_start = os::elapsedTime(); ! G1CodeRootSet::purge_chunks(G1CodeRootsChunkCacheKeepPercent); double purge_time_ms = (os::elapsedTime() - purge_start) * 1000.0; g1_policy()->phase_times()->record_strong_code_root_purge_time(purge_time_ms); } class RebuildStrongCodeRootClosure: public CodeBlobClosure { --- 7054,7066 ---- guarantee(nm != NULL, "sanity"); UnregisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(&reg_cl, true); } void G1CollectedHeap::purge_code_root_memory() { double purge_start = os::elapsedTime(); ! G1CodeRootSet::purge(); double purge_time_ms = (os::elapsedTime() - purge_start) * 1000.0; g1_policy()->phase_times()->record_strong_code_root_purge_time(purge_time_ms); } class RebuildStrongCodeRootClosure: public CodeBlobClosure {