Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.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 | ab4422d0ed59 |
children | aed758eda82a |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
36 | 36 |
37 class ParallelScavengeHeap; | 37 class ParallelScavengeHeap; |
38 class PSAdaptiveSizePolicy; | 38 class PSAdaptiveSizePolicy; |
39 class PSYoungGen; | 39 class PSYoungGen; |
40 class PSOldGen; | 40 class PSOldGen; |
41 class PSPermGen; | |
42 class ParCompactionManager; | 41 class ParCompactionManager; |
43 class ParallelTaskTerminator; | 42 class ParallelTaskTerminator; |
44 class PSParallelCompact; | 43 class PSParallelCompact; |
45 class GCTaskManager; | 44 class GCTaskManager; |
46 class GCTaskQueue; | 45 class GCTaskQueue; |
403 | 402 |
404 HeapWord* calc_new_pointer(oop p) { | 403 HeapWord* calc_new_pointer(oop p) { |
405 return calc_new_pointer((HeapWord*) p); | 404 return calc_new_pointer((HeapWord*) p); |
406 } | 405 } |
407 | 406 |
408 // Return the updated address for the given klass | |
409 klassOop calc_new_klass(klassOop); | |
410 | |
411 #ifdef ASSERT | 407 #ifdef ASSERT |
412 void verify_clear(const PSVirtualSpace* vspace); | 408 void verify_clear(const PSVirtualSpace* vspace); |
413 void verify_clear(); | 409 void verify_clear(); |
414 #endif // #ifdef ASSERT | 410 #endif // #ifdef ASSERT |
415 | 411 |
777 // Convenient access to type names. | 773 // Convenient access to type names. |
778 typedef ParMarkBitMap::idx_t idx_t; | 774 typedef ParMarkBitMap::idx_t idx_t; |
779 typedef ParallelCompactData::RegionData RegionData; | 775 typedef ParallelCompactData::RegionData RegionData; |
780 | 776 |
781 typedef enum { | 777 typedef enum { |
782 perm_space_id, old_space_id, eden_space_id, | 778 old_space_id, eden_space_id, |
783 from_space_id, to_space_id, last_space_id | 779 from_space_id, to_space_id, last_space_id |
784 } SpaceId; | 780 } SpaceId; |
785 | 781 |
786 public: | 782 public: |
787 // Inline closure decls | 783 // Inline closure decls |
819 public: | 815 public: |
820 FollowStackClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } | 816 FollowStackClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } |
821 virtual void do_void(); | 817 virtual void do_void(); |
822 }; | 818 }; |
823 | 819 |
824 class AdjustPointerClosure: public OopsInGenClosure { | 820 class AdjustPointerClosure: public OopClosure { |
825 private: | 821 private: |
826 bool _is_root; | 822 bool _is_root; |
827 public: | 823 public: |
828 AdjustPointerClosure(bool is_root) : _is_root(is_root) { } | 824 AdjustPointerClosure(bool is_root) : _is_root(is_root) { } |
829 virtual void do_oop(oop* p); | 825 virtual void do_oop(oop* p); |
830 virtual void do_oop(narrowOop* p); | 826 virtual void do_oop(narrowOop* p); |
831 // do not walk from thread stacks to the code cache on this phase | 827 // do not walk from thread stacks to the code cache on this phase |
832 virtual void do_code_blob(CodeBlob* cb) const { } | 828 virtual void do_code_blob(CodeBlob* cb) const { } |
833 }; | 829 }; |
834 | 830 |
831 class AdjustKlassClosure : public KlassClosure { | |
832 public: | |
833 void do_klass(Klass* klass); | |
834 }; | |
835 | |
835 friend class KeepAliveClosure; | 836 friend class KeepAliveClosure; |
836 friend class FollowStackClosure; | 837 friend class FollowStackClosure; |
837 friend class AdjustPointerClosure; | 838 friend class AdjustPointerClosure; |
839 friend class AdjustKlassClosure; | |
840 friend class FollowKlassClosure; | |
838 friend class FollowRootClosure; | 841 friend class FollowRootClosure; |
839 friend class instanceKlassKlass; | 842 friend class instanceClassLoaderKlass; |
840 friend class RefProcTaskProxy; | 843 friend class RefProcTaskProxy; |
841 | 844 |
842 private: | 845 private: |
843 static elapsedTimer _accumulated_time; | 846 static elapsedTimer _accumulated_time; |
844 static unsigned int _total_invocations; | 847 static unsigned int _total_invocations; |
850 static IsAliveClosure _is_alive_closure; | 853 static IsAliveClosure _is_alive_closure; |
851 static SpaceInfo _space_info[last_space_id]; | 854 static SpaceInfo _space_info[last_space_id]; |
852 static bool _print_phases; | 855 static bool _print_phases; |
853 static AdjustPointerClosure _adjust_root_pointer_closure; | 856 static AdjustPointerClosure _adjust_root_pointer_closure; |
854 static AdjustPointerClosure _adjust_pointer_closure; | 857 static AdjustPointerClosure _adjust_pointer_closure; |
858 static AdjustKlassClosure _adjust_klass_closure; | |
855 | 859 |
856 // Reference processing (used in ...follow_contents) | 860 // Reference processing (used in ...follow_contents) |
857 static ReferenceProcessor* _ref_processor; | 861 static ReferenceProcessor* _ref_processor; |
858 | 862 |
859 // Updated location of intArrayKlassObj. | 863 // Updated location of intArrayKlassObj. |
860 static klassOop _updated_int_array_klass_obj; | 864 static Klass* _updated_int_array_klass_obj; |
861 | 865 |
862 // Values computed at initialization and used by dead_wood_limiter(). | 866 // Values computed at initialization and used by dead_wood_limiter(). |
863 static double _dwl_mean; | 867 static double _dwl_mean; |
864 static double _dwl_std_dev; | 868 static double _dwl_std_dev; |
865 static double _dwl_first_term; | 869 static double _dwl_first_term; |
867 #ifdef ASSERT | 871 #ifdef ASSERT |
868 static bool _dwl_initialized; | 872 static bool _dwl_initialized; |
869 #endif // #ifdef ASSERT | 873 #endif // #ifdef ASSERT |
870 | 874 |
871 private: | 875 private: |
872 // Closure accessors | |
873 static OopClosure* adjust_pointer_closure() { return (OopClosure*)&_adjust_pointer_closure; } | |
874 static OopClosure* adjust_root_pointer_closure() { return (OopClosure*)&_adjust_root_pointer_closure; } | |
875 static BoolObjectClosure* is_alive_closure() { return (BoolObjectClosure*)&_is_alive_closure; } | |
876 | 876 |
877 static void initialize_space_info(); | 877 static void initialize_space_info(); |
878 | 878 |
879 // Return true if details about individual phases should be printed. | 879 // Return true if details about individual phases should be printed. |
880 static inline bool print_phases(); | 880 static inline bool print_phases(); |
886 static void post_compact(); | 886 static void post_compact(); |
887 | 887 |
888 // Mark live objects | 888 // Mark live objects |
889 static void marking_phase(ParCompactionManager* cm, | 889 static void marking_phase(ParCompactionManager* cm, |
890 bool maximum_heap_compaction); | 890 bool maximum_heap_compaction); |
891 static void follow_weak_klass_links(); | |
892 static void follow_mdo_weak_refs(); | |
893 | 891 |
894 template <class T> static inline void adjust_pointer(T* p, bool is_root); | 892 template <class T> static inline void adjust_pointer(T* p, bool is_root); |
895 static void adjust_root_pointer(oop* p) { adjust_pointer(p, true); } | 893 static void adjust_root_pointer(oop* p) { adjust_pointer(p, true); } |
896 | 894 |
897 template <class T> | 895 template <class T> |
978 static void summarize_space(SpaceId id, bool maximum_compaction); | 976 static void summarize_space(SpaceId id, bool maximum_compaction); |
979 static void summary_phase(ParCompactionManager* cm, bool maximum_compaction); | 977 static void summary_phase(ParCompactionManager* cm, bool maximum_compaction); |
980 | 978 |
981 // Adjust addresses in roots. Does not adjust addresses in heap. | 979 // Adjust addresses in roots. Does not adjust addresses in heap. |
982 static void adjust_roots(); | 980 static void adjust_roots(); |
983 | |
984 // Serial code executed in preparation for the compaction phase. | |
985 static void compact_prologue(); | |
986 | 981 |
987 // Move objects to new locations. | 982 // Move objects to new locations. |
988 static void compact_perm(ParCompactionManager* cm); | 983 static void compact_perm(ParCompactionManager* cm); |
989 static void compact(); | 984 static void compact(); |
990 | 985 |
1047 MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } | 1042 MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } |
1048 virtual void do_oop(oop* p); | 1043 virtual void do_oop(oop* p); |
1049 virtual void do_oop(narrowOop* p); | 1044 virtual void do_oop(narrowOop* p); |
1050 }; | 1045 }; |
1051 | 1046 |
1047 // The one and only place to start following the classes. | |
1048 // Should only be applied to the ClassLoaderData klasses list. | |
1049 class FollowKlassClosure : public KlassClosure { | |
1050 private: | |
1051 MarkAndPushClosure* _mark_and_push_closure; | |
1052 public: | |
1053 FollowKlassClosure(MarkAndPushClosure* mark_and_push_closure) : | |
1054 _mark_and_push_closure(mark_and_push_closure) { } | |
1055 void do_klass(Klass* klass); | |
1056 }; | |
1057 | |
1052 PSParallelCompact(); | 1058 PSParallelCompact(); |
1053 | 1059 |
1054 // Convenient accessor for Universe::heap(). | 1060 // Convenient accessor for Universe::heap(). |
1055 static ParallelScavengeHeap* gc_heap() { | 1061 static ParallelScavengeHeap* gc_heap() { |
1056 return (ParallelScavengeHeap*)Universe::heap(); | 1062 return (ParallelScavengeHeap*)Universe::heap(); |
1064 // allocations. This should be called during the VM initialization | 1070 // allocations. This should be called during the VM initialization |
1065 // at a pointer where it would be appropriate to return a JNI_ENOMEM | 1071 // at a pointer where it would be appropriate to return a JNI_ENOMEM |
1066 // in the event of a failure. | 1072 // in the event of a failure. |
1067 static bool initialize(); | 1073 static bool initialize(); |
1068 | 1074 |
1075 // Closure accessors | |
1076 static OopClosure* adjust_pointer_closure() { return (OopClosure*)&_adjust_pointer_closure; } | |
1077 static OopClosure* adjust_root_pointer_closure() { return (OopClosure*)&_adjust_root_pointer_closure; } | |
1078 static KlassClosure* adjust_klass_closure() { return (KlassClosure*)&_adjust_klass_closure; } | |
1079 static BoolObjectClosure* is_alive_closure() { return (BoolObjectClosure*)&_is_alive_closure; } | |
1080 | |
1069 // Public accessors | 1081 // Public accessors |
1070 static elapsedTimer* accumulated_time() { return &_accumulated_time; } | 1082 static elapsedTimer* accumulated_time() { return &_accumulated_time; } |
1071 static unsigned int total_invocations() { return _total_invocations; } | 1083 static unsigned int total_invocations() { return _total_invocations; } |
1072 static CollectorCounters* counters() { return _counters; } | 1084 static CollectorCounters* counters() { return _counters; } |
1073 | 1085 |
1074 // Used to add tasks | 1086 // Used to add tasks |
1075 static GCTaskManager* const gc_task_manager(); | 1087 static GCTaskManager* const gc_task_manager(); |
1076 static klassOop updated_int_array_klass_obj() { | 1088 static Klass* updated_int_array_klass_obj() { |
1077 return _updated_int_array_klass_obj; | 1089 return _updated_int_array_klass_obj; |
1078 } | 1090 } |
1079 | 1091 |
1080 // Marking support | 1092 // Marking support |
1081 static inline bool mark_obj(oop obj); | 1093 static inline bool mark_obj(oop obj); |
1094 static inline bool is_marked(oop obj); | |
1082 // Check mark and maybe push on marking stack | 1095 // Check mark and maybe push on marking stack |
1083 template <class T> static inline void mark_and_push(ParCompactionManager* cm, | 1096 template <class T> static inline void mark_and_push(ParCompactionManager* cm, |
1084 T* p); | 1097 T* p); |
1098 | |
1099 static void follow_klass(ParCompactionManager* cm, Klass* klass); | |
1100 static void adjust_klass(ParCompactionManager* cm, Klass* klass); | |
1101 | |
1102 static void follow_class_loader(ParCompactionManager* cm, | |
1103 ClassLoaderData* klass); | |
1104 static void adjust_class_loader(ParCompactionManager* cm, | |
1105 ClassLoaderData* klass); | |
1085 | 1106 |
1086 // Compaction support. | 1107 // Compaction support. |
1087 // Return true if p is in the range [beg_addr, end_addr). | 1108 // Return true if p is in the range [beg_addr, end_addr). |
1088 static inline bool is_in(HeapWord* p, HeapWord* beg_addr, HeapWord* end_addr); | 1109 static inline bool is_in(HeapWord* p, HeapWord* beg_addr, HeapWord* end_addr); |
1089 static inline bool is_in(oop* p, HeapWord* beg_addr, HeapWord* end_addr); | 1110 static inline bool is_in(oop* p, HeapWord* beg_addr, HeapWord* end_addr); |
1091 // Convenience wrappers for per-space data kept in _space_info. | 1112 // Convenience wrappers for per-space data kept in _space_info. |
1092 static inline MutableSpace* space(SpaceId space_id); | 1113 static inline MutableSpace* space(SpaceId space_id); |
1093 static inline HeapWord* new_top(SpaceId space_id); | 1114 static inline HeapWord* new_top(SpaceId space_id); |
1094 static inline HeapWord* dense_prefix(SpaceId space_id); | 1115 static inline HeapWord* dense_prefix(SpaceId space_id); |
1095 static inline ObjectStartArray* start_array(SpaceId space_id); | 1116 static inline ObjectStartArray* start_array(SpaceId space_id); |
1096 | |
1097 // Return true if the klass should be updated. | |
1098 static inline bool should_update_klass(klassOop k); | |
1099 | 1117 |
1100 // Move and update the live objects in the specified space. | 1118 // Move and update the live objects in the specified space. |
1101 static void move_and_update(ParCompactionManager* cm, SpaceId space_id); | 1119 static void move_and_update(ParCompactionManager* cm, SpaceId space_id); |
1102 | 1120 |
1103 // Process the end of the given region range in the dense prefix. | 1121 // Process the end of the given region range in the dense prefix. |
1177 static void track_adjusted_pointer(void* p, bool isroot); | 1195 static void track_adjusted_pointer(void* p, bool isroot); |
1178 static void check_adjust_pointer(void* p); | 1196 static void check_adjust_pointer(void* p); |
1179 static void track_interior_pointers(oop obj); | 1197 static void track_interior_pointers(oop obj); |
1180 static void check_interior_pointers(); | 1198 static void check_interior_pointers(); |
1181 | 1199 |
1182 static void reset_live_oop_tracking(bool at_perm); | 1200 static void reset_live_oop_tracking(); |
1183 static void register_live_oop(oop p, size_t size); | 1201 static void register_live_oop(oop p, size_t size); |
1184 static void validate_live_oop(oop p, size_t size); | 1202 static void validate_live_oop(oop p, size_t size); |
1185 static void live_oop_moved_to(HeapWord* q, size_t size, HeapWord* compaction_top); | 1203 static void live_oop_moved_to(HeapWord* q, size_t size, HeapWord* compaction_top); |
1186 static void compaction_complete(); | 1204 static void compaction_complete(); |
1187 | 1205 |
1189 // Finds and prints the current base oop and offset for a word | 1207 // Finds and prints the current base oop and offset for a word |
1190 // within an oop that was live during the last GC. Helpful for | 1208 // within an oop that was live during the last GC. Helpful for |
1191 // tracking down heap stomps. | 1209 // tracking down heap stomps. |
1192 static void print_new_location_of_heap_address(HeapWord* q); | 1210 static void print_new_location_of_heap_address(HeapWord* q); |
1193 #endif // #ifdef VALIDATE_MARK_SWEEP | 1211 #endif // #ifdef VALIDATE_MARK_SWEEP |
1194 | |
1195 // Call backs for class unloading | |
1196 // Update subklass/sibling/implementor links at end of marking. | |
1197 static void revisit_weak_klass_link(ParCompactionManager* cm, Klass* k); | |
1198 | |
1199 // Clear unmarked oops in MDOs at the end of marking. | |
1200 static void revisit_mdo(ParCompactionManager* cm, DataLayout* p); | |
1201 | 1212 |
1202 #ifndef PRODUCT | 1213 #ifndef PRODUCT |
1203 // Debugging support. | 1214 // Debugging support. |
1204 static const char* space_names[last_space_id]; | 1215 static const char* space_names[last_space_id]; |
1205 static void print_region_ranges(); | 1216 static void print_region_ranges(); |
1227 _summary_data.add_obj(obj, obj_size); | 1238 _summary_data.add_obj(obj, obj_size); |
1228 return true; | 1239 return true; |
1229 } else { | 1240 } else { |
1230 return false; | 1241 return false; |
1231 } | 1242 } |
1243 } | |
1244 | |
1245 inline bool PSParallelCompact::is_marked(oop obj) { | |
1246 return mark_bitmap()->is_marked(obj); | |
1232 } | 1247 } |
1233 | 1248 |
1234 template <class T> | 1249 template <class T> |
1235 inline void PSParallelCompact::follow_root(ParCompactionManager* cm, T* p) { | 1250 inline void PSParallelCompact::follow_root(ParCompactionManager* cm, T* p) { |
1236 assert(!Universe::heap()->is_in_reserved(p), | 1251 assert(!Universe::heap()->is_in_reserved(p), |
1268 inline void PSParallelCompact::adjust_pointer(T* p, bool isroot) { | 1283 inline void PSParallelCompact::adjust_pointer(T* p, bool isroot) { |
1269 T heap_oop = oopDesc::load_heap_oop(p); | 1284 T heap_oop = oopDesc::load_heap_oop(p); |
1270 if (!oopDesc::is_null(heap_oop)) { | 1285 if (!oopDesc::is_null(heap_oop)) { |
1271 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); | 1286 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
1272 oop new_obj = (oop)summary_data().calc_new_pointer(obj); | 1287 oop new_obj = (oop)summary_data().calc_new_pointer(obj); |
1273 assert(new_obj != NULL || // is forwarding ptr? | 1288 assert(new_obj != NULL, // is forwarding ptr? |
1274 obj->is_shared(), // never forwarded? | |
1275 "should be forwarded"); | 1289 "should be forwarded"); |
1276 // Just always do the update unconditionally? | 1290 // Just always do the update unconditionally? |
1277 if (new_obj != NULL) { | 1291 if (new_obj != NULL) { |
1278 assert(Universe::heap()->is_in_reserved(new_obj), | 1292 assert(Universe::heap()->is_in_reserved(new_obj), |
1279 "should be in object space"); | 1293 "should be in object space"); |
1351 inline ObjectStartArray* PSParallelCompact::start_array(SpaceId id) { | 1365 inline ObjectStartArray* PSParallelCompact::start_array(SpaceId id) { |
1352 assert(id < last_space_id, "id out of range"); | 1366 assert(id < last_space_id, "id out of range"); |
1353 return _space_info[id].start_array(); | 1367 return _space_info[id].start_array(); |
1354 } | 1368 } |
1355 | 1369 |
1356 inline bool PSParallelCompact::should_update_klass(klassOop k) { | |
1357 return ((HeapWord*) k) >= dense_prefix(perm_space_id); | |
1358 } | |
1359 | |
1360 #ifdef ASSERT | 1370 #ifdef ASSERT |
1361 inline void | 1371 inline void |
1362 PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) | 1372 PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) |
1363 { | 1373 { |
1364 assert(old_addr >= new_addr || space_id(old_addr) != space_id(new_addr), | 1374 assert(old_addr >= new_addr || space_id(old_addr) != space_id(new_addr), |
1446 public: | 1456 public: |
1447 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) : | 1457 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) : |
1448 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm), | 1458 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm), |
1449 _start_array(PSParallelCompact::start_array(space_id)) | 1459 _start_array(PSParallelCompact::start_array(space_id)) |
1450 { | 1460 { |
1451 assert(space_id == PSParallelCompact::perm_space_id || | 1461 assert(space_id == PSParallelCompact::old_space_id, |
1452 space_id == PSParallelCompact::old_space_id, | |
1453 "cannot use FillClosure in the young gen"); | 1462 "cannot use FillClosure in the young gen"); |
1454 } | 1463 } |
1455 | 1464 |
1456 virtual IterationStatus do_addr(HeapWord* addr, size_t size) { | 1465 virtual IterationStatus do_addr(HeapWord* addr, size_t size) { |
1457 CollectedHeap::fill_with_objects(addr, size); | 1466 CollectedHeap::fill_with_objects(addr, size); |