38 #include "gc/shared/cardTableRS.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "gc/shared/collectorCounters.hpp"
41 #include "gc/shared/continuationGCSupport.inline.hpp"
42 #include "gc/shared/gcId.hpp"
43 #include "gc/shared/gcInitLogger.hpp"
44 #include "gc/shared/gcLocker.hpp"
45 #include "gc/shared/gcPolicyCounters.hpp"
46 #include "gc/shared/gcTrace.hpp"
47 #include "gc/shared/gcTraceTime.inline.hpp"
48 #include "gc/shared/gcVMOperations.hpp"
49 #include "gc/shared/genArguments.hpp"
50 #include "gc/shared/genCollectedHeap.hpp"
51 #include "gc/shared/generationSpec.hpp"
52 #include "gc/shared/genOopClosures.inline.hpp"
53 #include "gc/shared/locationPrinter.inline.hpp"
54 #include "gc/shared/oopStorage.inline.hpp"
55 #include "gc/shared/oopStorageParState.inline.hpp"
56 #include "gc/shared/oopStorageSet.inline.hpp"
57 #include "gc/shared/scavengableNMethods.hpp"
58 #include "gc/shared/space.hpp"
59 #include "gc/shared/strongRootsScope.hpp"
60 #include "gc/shared/weakProcessor.hpp"
61 #include "gc/shared/workerThread.hpp"
62 #include "memory/iterator.hpp"
63 #include "memory/metaspaceCounters.hpp"
64 #include "memory/metaspaceUtils.hpp"
65 #include "memory/resourceArea.hpp"
66 #include "memory/universe.hpp"
67 #include "oops/oop.inline.hpp"
68 #include "runtime/handles.hpp"
69 #include "runtime/handles.inline.hpp"
70 #include "runtime/java.hpp"
71 #include "runtime/threads.hpp"
72 #include "runtime/vmThread.hpp"
73 #include "services/memoryService.hpp"
74 #include "utilities/autoRestore.hpp"
75 #include "utilities/debug.hpp"
76 #include "utilities/formatBuffer.hpp"
77 #include "utilities/macros.hpp"
107
108 jint GenCollectedHeap::initialize() {
109 // While there are no constraints in the GC code that HeapWordSize
110 // be any particular value, there are multiple other areas in the
111 // system which believe this to be true (e.g. oop->object_size in some
112 // cases incorrectly returns the size in wordSize units rather than
113 // HeapWordSize).
114 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
115
116 // Allocate space for the heap.
117
118 ReservedHeapSpace heap_rs = allocate(HeapAlignment);
119
120 if (!heap_rs.is_reserved()) {
121 vm_shutdown_during_initialization(
122 "Could not reserve enough space for object heap");
123 return JNI_ENOMEM;
124 }
125
126 initialize_reserved_region(heap_rs);
127
128 _rem_set = create_rem_set(heap_rs.region());
129 _rem_set->initialize();
130 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
131 bs->initialize();
132 BarrierSet::set_barrier_set(bs);
133
134 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
135 _young_gen = _young_gen_spec->init(young_rs, rem_set());
136 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
137
138 old_rs = old_rs.first_part(_old_gen_spec->max_size());
139 _old_gen = _old_gen_spec->init(old_rs, rem_set());
140
141 GCInitLogger::print();
142
143 return JNI_OK;
144 }
145
146 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1026 }
1027
1028 bool GenCollectedHeap::is_maximal_no_gc() const {
1029 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1030 }
1031
1032 void GenCollectedHeap::save_marks() {
1033 _young_gen->save_marks();
1034 _old_gen->save_marks();
1035 }
1036
1037 GenCollectedHeap* GenCollectedHeap::heap() {
1038 // SerialHeap is the only subtype of GenCollectedHeap.
1039 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1040 }
1041
1042 #if INCLUDE_SERIALGC
1043 void GenCollectedHeap::prepare_for_compaction() {
1044 // Start by compacting into same gen.
1045 CompactPoint cp(_old_gen);
1046 _old_gen->prepare_for_compaction(&cp);
1047 _young_gen->prepare_for_compaction(&cp);
1048 }
1049 #endif // INCLUDE_SERIALGC
1050
1051 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1052 log_debug(gc, verify)("%s", _old_gen->name());
1053 _old_gen->verify();
1054
1055 log_debug(gc, verify)("%s", _young_gen->name());
1056 _young_gen->verify();
1057
1058 log_debug(gc, verify)("RemSet");
1059 rem_set()->verify();
1060 }
1061
1062 void GenCollectedHeap::print_on(outputStream* st) const {
1063 if (_young_gen != NULL) {
1064 _young_gen->print_on(st);
1065 }
|
38 #include "gc/shared/cardTableRS.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "gc/shared/collectorCounters.hpp"
41 #include "gc/shared/continuationGCSupport.inline.hpp"
42 #include "gc/shared/gcId.hpp"
43 #include "gc/shared/gcInitLogger.hpp"
44 #include "gc/shared/gcLocker.hpp"
45 #include "gc/shared/gcPolicyCounters.hpp"
46 #include "gc/shared/gcTrace.hpp"
47 #include "gc/shared/gcTraceTime.inline.hpp"
48 #include "gc/shared/gcVMOperations.hpp"
49 #include "gc/shared/genArguments.hpp"
50 #include "gc/shared/genCollectedHeap.hpp"
51 #include "gc/shared/generationSpec.hpp"
52 #include "gc/shared/genOopClosures.inline.hpp"
53 #include "gc/shared/locationPrinter.inline.hpp"
54 #include "gc/shared/oopStorage.inline.hpp"
55 #include "gc/shared/oopStorageParState.inline.hpp"
56 #include "gc/shared/oopStorageSet.inline.hpp"
57 #include "gc/shared/scavengableNMethods.hpp"
58 #include "gc/shared/slidingForwarding.hpp"
59 #include "gc/shared/space.hpp"
60 #include "gc/shared/strongRootsScope.hpp"
61 #include "gc/shared/weakProcessor.hpp"
62 #include "gc/shared/workerThread.hpp"
63 #include "memory/iterator.hpp"
64 #include "memory/metaspaceCounters.hpp"
65 #include "memory/metaspaceUtils.hpp"
66 #include "memory/resourceArea.hpp"
67 #include "memory/universe.hpp"
68 #include "oops/oop.inline.hpp"
69 #include "runtime/handles.hpp"
70 #include "runtime/handles.inline.hpp"
71 #include "runtime/java.hpp"
72 #include "runtime/threads.hpp"
73 #include "runtime/vmThread.hpp"
74 #include "services/memoryService.hpp"
75 #include "utilities/autoRestore.hpp"
76 #include "utilities/debug.hpp"
77 #include "utilities/formatBuffer.hpp"
78 #include "utilities/macros.hpp"
108
109 jint GenCollectedHeap::initialize() {
110 // While there are no constraints in the GC code that HeapWordSize
111 // be any particular value, there are multiple other areas in the
112 // system which believe this to be true (e.g. oop->object_size in some
113 // cases incorrectly returns the size in wordSize units rather than
114 // HeapWordSize).
115 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
116
117 // Allocate space for the heap.
118
119 ReservedHeapSpace heap_rs = allocate(HeapAlignment);
120
121 if (!heap_rs.is_reserved()) {
122 vm_shutdown_during_initialization(
123 "Could not reserve enough space for object heap");
124 return JNI_ENOMEM;
125 }
126
127 initialize_reserved_region(heap_rs);
128 _forwarding = new SlidingForwarding(_reserved);
129
130 _rem_set = create_rem_set(heap_rs.region());
131 _rem_set->initialize();
132 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
133 bs->initialize();
134 BarrierSet::set_barrier_set(bs);
135
136 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
137 _young_gen = _young_gen_spec->init(young_rs, rem_set());
138 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
139
140 old_rs = old_rs.first_part(_old_gen_spec->max_size());
141 _old_gen = _old_gen_spec->init(old_rs, rem_set());
142
143 GCInitLogger::print();
144
145 return JNI_OK;
146 }
147
148 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1028 }
1029
1030 bool GenCollectedHeap::is_maximal_no_gc() const {
1031 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1032 }
1033
1034 void GenCollectedHeap::save_marks() {
1035 _young_gen->save_marks();
1036 _old_gen->save_marks();
1037 }
1038
1039 GenCollectedHeap* GenCollectedHeap::heap() {
1040 // SerialHeap is the only subtype of GenCollectedHeap.
1041 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1042 }
1043
1044 #if INCLUDE_SERIALGC
1045 void GenCollectedHeap::prepare_for_compaction() {
1046 // Start by compacting into same gen.
1047 CompactPoint cp(_old_gen);
1048 _forwarding->clear();
1049 _old_gen->prepare_for_compaction(&cp);
1050 _young_gen->prepare_for_compaction(&cp);
1051 }
1052 #endif // INCLUDE_SERIALGC
1053
1054 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1055 log_debug(gc, verify)("%s", _old_gen->name());
1056 _old_gen->verify();
1057
1058 log_debug(gc, verify)("%s", _young_gen->name());
1059 _young_gen->verify();
1060
1061 log_debug(gc, verify)("RemSet");
1062 rem_set()->verify();
1063 }
1064
1065 void GenCollectedHeap::print_on(outputStream* st) const {
1066 if (_young_gen != NULL) {
1067 _young_gen->print_on(st);
1068 }
|