Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | c9814fadeb38 |
children | 9646b7ff4d14 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
43 // may combine concurrent marking with parallel, incremental compaction of | 43 // may combine concurrent marking with parallel, incremental compaction of |
44 // heap subsets that will yield large amounts of garbage. | 44 // heap subsets that will yield large amounts of garbage. |
45 | 45 |
46 class HeapRegion; | 46 class HeapRegion; |
47 class HRRSCleanupTask; | 47 class HRRSCleanupTask; |
48 class PermanentGenerationSpec; | |
49 class GenerationSpec; | 48 class GenerationSpec; |
50 class OopsInHeapRegionClosure; | 49 class OopsInHeapRegionClosure; |
50 class G1KlassScanClosure; | |
51 class G1ScanHeapEvacClosure; | 51 class G1ScanHeapEvacClosure; |
52 class ObjectClosure; | 52 class ObjectClosure; |
53 class SpaceClosure; | 53 class SpaceClosure; |
54 class CompactibleSpaceClosure; | 54 class CompactibleSpaceClosure; |
55 class Space; | 55 class Space; |
188 | 188 |
189 class RefineCardTableEntryClosure; | 189 class RefineCardTableEntryClosure; |
190 | 190 |
191 class G1CollectedHeap : public SharedHeap { | 191 class G1CollectedHeap : public SharedHeap { |
192 friend class VM_G1CollectForAllocation; | 192 friend class VM_G1CollectForAllocation; |
193 friend class VM_GenCollectForPermanentAllocation; | |
194 friend class VM_G1CollectFull; | 193 friend class VM_G1CollectFull; |
195 friend class VM_G1IncCollectionPause; | 194 friend class VM_G1IncCollectionPause; |
196 friend class VMStructs; | 195 friend class VMStructs; |
197 friend class MutatorAllocRegion; | 196 friend class MutatorAllocRegion; |
198 friend class SurvivorGCAllocRegion; | 197 friend class SurvivorGCAllocRegion; |
223 // The one and only G1CollectedHeap, so static functions can find it. | 222 // The one and only G1CollectedHeap, so static functions can find it. |
224 static G1CollectedHeap* _g1h; | 223 static G1CollectedHeap* _g1h; |
225 | 224 |
226 static size_t _humongous_object_threshold_in_words; | 225 static size_t _humongous_object_threshold_in_words; |
227 | 226 |
228 // Storage for the G1 heap (excludes the permanent generation). | 227 // Storage for the G1 heap. |
229 VirtualSpace _g1_storage; | 228 VirtualSpace _g1_storage; |
230 MemRegion _g1_reserved; | 229 MemRegion _g1_reserved; |
231 | 230 |
232 // The part of _g1_storage that is currently committed. | 231 // The part of _g1_storage that is currently committed. |
233 MemRegion _g1_committed; | 232 MemRegion _g1_committed; |
628 bool clear_all_soft_refs, | 627 bool clear_all_soft_refs, |
629 size_t word_size); | 628 size_t word_size); |
630 | 629 |
631 // Callback from VM_G1CollectFull operation. | 630 // Callback from VM_G1CollectFull operation. |
632 // Perform a full collection. | 631 // Perform a full collection. |
633 void do_full_collection(bool clear_all_soft_refs); | 632 virtual void do_full_collection(bool clear_all_soft_refs); |
634 | 633 |
635 // Resize the heap if necessary after a full collection. If this is | 634 // Resize the heap if necessary after a full collection. If this is |
636 // after a collect-for allocation, "word_size" is the allocation size, | 635 // after a collect-for allocation, "word_size" is the allocation size, |
637 // and will be considered part of the used portion of the heap. | 636 // and will be considered part of the used portion of the heap. |
638 void resize_if_necessary_after_full_collection(size_t word_size); | 637 void resize_if_necessary_after_full_collection(size_t word_size); |
803 // statistics or updating free lists. | 802 // statistics or updating free lists. |
804 void abandon_collection_set(HeapRegion* cs_head); | 803 void abandon_collection_set(HeapRegion* cs_head); |
805 | 804 |
806 // Applies "scan_non_heap_roots" to roots outside the heap, | 805 // Applies "scan_non_heap_roots" to roots outside the heap, |
807 // "scan_rs" to roots inside the heap (having done "set_region" to | 806 // "scan_rs" to roots inside the heap (having done "set_region" to |
808 // indicate the region in which the root resides), and does "scan_perm" | 807 // indicate the region in which the root resides), |
809 // (setting the generation to the perm generation.) If "scan_rs" is | 808 // and does "scan_metadata" If "scan_rs" is |
810 // NULL, then this step is skipped. The "worker_i" | 809 // NULL, then this step is skipped. The "worker_i" |
811 // param is for use with parallel roots processing, and should be | 810 // param is for use with parallel roots processing, and should be |
812 // the "i" of the calling parallel worker thread's work(i) function. | 811 // the "i" of the calling parallel worker thread's work(i) function. |
813 // In the sequential case this param will be ignored. | 812 // In the sequential case this param will be ignored. |
814 void g1_process_strong_roots(bool collecting_perm_gen, | 813 void g1_process_strong_roots(bool is_scavenging, |
815 ScanningOption so, | 814 ScanningOption so, |
816 OopClosure* scan_non_heap_roots, | 815 OopClosure* scan_non_heap_roots, |
817 OopsInHeapRegionClosure* scan_rs, | 816 OopsInHeapRegionClosure* scan_rs, |
818 OopsInGenClosure* scan_perm, | 817 G1KlassScanClosure* scan_klasses, |
819 int worker_i); | 818 int worker_i); |
820 | 819 |
821 // Apply "blk" to all the weak roots of the system. These include | 820 // Apply "blk" to all the weak roots of the system. These include |
822 // JNI weak roots, the code cache, system dictionary, symbol table, | 821 // JNI weak roots, the code cache, system dictionary, symbol table, |
823 // string table, and referents of reachable weak refs. | 822 // string table, and referents of reachable weak refs. |
1069 // Must call the initialize method afterwards. | 1068 // Must call the initialize method afterwards. |
1070 // May not return if something goes wrong. | 1069 // May not return if something goes wrong. |
1071 G1CollectedHeap(G1CollectorPolicy* policy); | 1070 G1CollectedHeap(G1CollectorPolicy* policy); |
1072 | 1071 |
1073 // Initialize the G1CollectedHeap to have the initial and | 1072 // Initialize the G1CollectedHeap to have the initial and |
1074 // maximum sizes, permanent generation, and remembered and barrier sets | 1073 // maximum sizes and remembered and barrier sets |
1075 // specified by the policy object. | 1074 // specified by the policy object. |
1076 jint initialize(); | 1075 jint initialize(); |
1077 | 1076 |
1078 // Initialize weak reference processing. | 1077 // Initialize weak reference processing. |
1079 virtual void ref_processing_init(); | 1078 virtual void ref_processing_init(); |
1097 return CollectedHeap::G1CollectedHeap; | 1096 return CollectedHeap::G1CollectedHeap; |
1098 } | 1097 } |
1099 | 1098 |
1100 // The current policy object for the collector. | 1099 // The current policy object for the collector. |
1101 G1CollectorPolicy* g1_policy() const { return _g1_policy; } | 1100 G1CollectorPolicy* g1_policy() const { return _g1_policy; } |
1101 | |
1102 virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) g1_policy(); } | |
1102 | 1103 |
1103 // Adaptive size policy. No such thing for g1. | 1104 // Adaptive size policy. No such thing for g1. |
1104 virtual AdaptiveSizePolicy* size_policy() { return NULL; } | 1105 virtual AdaptiveSizePolicy* size_policy() { return NULL; } |
1105 | 1106 |
1106 // The rem set and barrier set. | 1107 // The rem set and barrier set. |
1275 // "CollectedHeap" supports. | 1276 // "CollectedHeap" supports. |
1276 virtual void collect(GCCause::Cause cause); | 1277 virtual void collect(GCCause::Cause cause); |
1277 | 1278 |
1278 // The same as above but assume that the caller holds the Heap_lock. | 1279 // The same as above but assume that the caller holds the Heap_lock. |
1279 void collect_locked(GCCause::Cause cause); | 1280 void collect_locked(GCCause::Cause cause); |
1280 | |
1281 // This interface assumes that it's being called by the | |
1282 // vm thread. It collects the heap assuming that the | |
1283 // heap lock is already held and that we are executing in | |
1284 // the context of the vm thread. | |
1285 virtual void collect_as_vm_thread(GCCause::Cause cause); | |
1286 | 1281 |
1287 // True iff a evacuation has failed in the most-recent collection. | 1282 // True iff a evacuation has failed in the most-recent collection. |
1288 bool evacuation_failed() { return _evacuation_failed; } | 1283 bool evacuation_failed() { return _evacuation_failed; } |
1289 | 1284 |
1290 // It will free a region if it has allocated objects in it that are | 1285 // It will free a region if it has allocated objects in it that are |
1315 // Return "TRUE" iff the given object address is within the collection | 1310 // Return "TRUE" iff the given object address is within the collection |
1316 // set. | 1311 // set. |
1317 inline bool obj_in_cs(oop obj); | 1312 inline bool obj_in_cs(oop obj); |
1318 | 1313 |
1319 // Return "TRUE" iff the given object address is in the reserved | 1314 // Return "TRUE" iff the given object address is in the reserved |
1320 // region of g1 (excluding the permanent generation). | 1315 // region of g1. |
1321 bool is_in_g1_reserved(const void* p) const { | 1316 bool is_in_g1_reserved(const void* p) const { |
1322 return _g1_reserved.contains(p); | 1317 return _g1_reserved.contains(p); |
1323 } | 1318 } |
1324 | 1319 |
1325 // Returns a MemRegion that corresponds to the space that has been | 1320 // Returns a MemRegion that corresponds to the space that has been |
1342 | 1337 |
1343 // Iteration functions. | 1338 // Iteration functions. |
1344 | 1339 |
1345 // Iterate over all the ref-containing fields of all objects, calling | 1340 // Iterate over all the ref-containing fields of all objects, calling |
1346 // "cl.do_oop" on each. | 1341 // "cl.do_oop" on each. |
1347 virtual void oop_iterate(OopClosure* cl) { | 1342 virtual void oop_iterate(ExtendedOopClosure* cl); |
1348 oop_iterate(cl, true); | |
1349 } | |
1350 void oop_iterate(OopClosure* cl, bool do_perm); | |
1351 | 1343 |
1352 // Same as above, restricted to a memory region. | 1344 // Same as above, restricted to a memory region. |
1353 virtual void oop_iterate(MemRegion mr, OopClosure* cl) { | 1345 void oop_iterate(MemRegion mr, ExtendedOopClosure* cl); |
1354 oop_iterate(mr, cl, true); | |
1355 } | |
1356 void oop_iterate(MemRegion mr, OopClosure* cl, bool do_perm); | |
1357 | 1346 |
1358 // Iterate over all objects, calling "cl.do_object" on each. | 1347 // Iterate over all objects, calling "cl.do_object" on each. |
1359 virtual void object_iterate(ObjectClosure* cl) { | 1348 virtual void object_iterate(ObjectClosure* cl); |
1360 object_iterate(cl, true); | 1349 |
1361 } | |
1362 virtual void safe_object_iterate(ObjectClosure* cl) { | 1350 virtual void safe_object_iterate(ObjectClosure* cl) { |
1363 object_iterate(cl, true); | 1351 object_iterate(cl); |
1364 } | 1352 } |
1365 void object_iterate(ObjectClosure* cl, bool do_perm); | |
1366 | 1353 |
1367 // Iterate over all objects allocated since the last collection, calling | 1354 // Iterate over all objects allocated since the last collection, calling |
1368 // "cl.do_object" on each. The heap must have been initialized properly | 1355 // "cl.do_object" on each. The heap must have been initialized properly |
1369 // to support this function, or else this call will fail. | 1356 // to support this function, or else this call will fail. |
1370 virtual void object_iterate_since_last_GC(ObjectClosure* cl); | 1357 virtual void object_iterate_since_last_GC(ObjectClosure* cl); |
1522 // information for young gen objects. | 1509 // information for young gen objects. |
1523 virtual bool can_elide_initializing_store_barrier(oop new_obj) { | 1510 virtual bool can_elide_initializing_store_barrier(oop new_obj) { |
1524 return is_in_young(new_obj); | 1511 return is_in_young(new_obj); |
1525 } | 1512 } |
1526 | 1513 |
1527 // Can a compiler elide a store barrier when it writes | |
1528 // a permanent oop into the heap? Applies when the compiler | |
1529 // is storing x to the heap, where x->is_perm() is true. | |
1530 virtual bool can_elide_permanent_oop_store_barriers() const { | |
1531 // At least until perm gen collection is also G1-ified, at | |
1532 // which point this should return false. | |
1533 return true; | |
1534 } | |
1535 | |
1536 // Returns "true" iff the given word_size is "very large". | 1514 // Returns "true" iff the given word_size is "very large". |
1537 static bool isHumongous(size_t word_size) { | 1515 static bool isHumongous(size_t word_size) { |
1538 // Note this has to be strictly greater-than as the TLABs | 1516 // Note this has to be strictly greater-than as the TLABs |
1539 // are capped at the humongous thresold and we want to | 1517 // are capped at the humongous thresold and we want to |
1540 // ensure that we don't try to allocate a TLAB as | 1518 // ensure that we don't try to allocate a TLAB as |
1655 | 1633 |
1656 // Determine if an object is dead, given only the object itself. | 1634 // Determine if an object is dead, given only the object itself. |
1657 // This will find the region to which the object belongs and | 1635 // This will find the region to which the object belongs and |
1658 // then call the region version of the same function. | 1636 // then call the region version of the same function. |
1659 | 1637 |
1660 // Added if it is in permanent gen it isn't dead. | |
1661 // Added if it is NULL it isn't dead. | 1638 // Added if it is NULL it isn't dead. |
1662 | 1639 |
1663 bool is_obj_dead(const oop obj) const { | 1640 bool is_obj_dead(const oop obj) const { |
1664 const HeapRegion* hr = heap_region_containing(obj); | 1641 const HeapRegion* hr = heap_region_containing(obj); |
1665 if (hr == NULL) { | 1642 if (hr == NULL) { |
1666 if (Universe::heap()->is_in_permanent(obj)) | 1643 if (obj == NULL) return false; |
1667 return false; | |
1668 else if (obj == NULL) return false; | |
1669 else return true; | 1644 else return true; |
1670 } | 1645 } |
1671 else return is_obj_dead(obj, hr); | 1646 else return is_obj_dead(obj, hr); |
1672 } | 1647 } |
1673 | 1648 |
1674 bool is_obj_ill(const oop obj) const { | 1649 bool is_obj_ill(const oop obj) const { |
1675 const HeapRegion* hr = heap_region_containing(obj); | 1650 const HeapRegion* hr = heap_region_containing(obj); |
1676 if (hr == NULL) { | 1651 if (hr == NULL) { |
1677 if (Universe::heap()->is_in_permanent(obj)) | 1652 if (obj == NULL) return false; |
1678 return false; | |
1679 else if (obj == NULL) return false; | |
1680 else return true; | 1653 else return true; |
1681 } | 1654 } |
1682 else return is_obj_ill(obj, hr); | 1655 else return is_obj_ill(obj, hr); |
1683 } | 1656 } |
1684 | 1657 |