35 #include "gc/shared/cardTableBarrierSet.hpp"
36 #include "gc/shared/cardTableRS.hpp"
37 #include "gc/shared/collectedHeap.inline.hpp"
38 #include "gc/shared/collectorCounters.hpp"
39 #include "gc/shared/gcId.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "gc/shared/gcPolicyCounters.hpp"
42 #include "gc/shared/gcTrace.hpp"
43 #include "gc/shared/gcTraceTime.inline.hpp"
44 #include "gc/shared/genArguments.hpp"
45 #include "gc/shared/gcVMOperations.hpp"
46 #include "gc/shared/genCollectedHeap.hpp"
47 #include "gc/shared/genOopClosures.inline.hpp"
48 #include "gc/shared/generationSpec.hpp"
49 #include "gc/shared/gcInitLogger.hpp"
50 #include "gc/shared/locationPrinter.inline.hpp"
51 #include "gc/shared/oopStorage.inline.hpp"
52 #include "gc/shared/oopStorageSet.inline.hpp"
53 #include "gc/shared/oopStorageParState.inline.hpp"
54 #include "gc/shared/scavengableNMethods.hpp"
55 #include "gc/shared/space.hpp"
56 #include "gc/shared/strongRootsScope.hpp"
57 #include "gc/shared/weakProcessor.hpp"
58 #include "gc/shared/workgroup.hpp"
59 #include "memory/iterator.hpp"
60 #include "memory/metaspaceCounters.hpp"
61 #include "memory/metaspaceUtils.hpp"
62 #include "memory/resourceArea.hpp"
63 #include "memory/universe.hpp"
64 #include "oops/oop.inline.hpp"
65 #include "runtime/biasedLocking.hpp"
66 #include "runtime/handles.hpp"
67 #include "runtime/handles.inline.hpp"
68 #include "runtime/java.hpp"
69 #include "runtime/vmThread.hpp"
70 #include "services/memoryService.hpp"
71 #include "utilities/autoRestore.hpp"
72 #include "utilities/debug.hpp"
73 #include "utilities/formatBuffer.hpp"
74 #include "utilities/macros.hpp"
104
105 jint GenCollectedHeap::initialize() {
106 // While there are no constraints in the GC code that HeapWordSize
107 // be any particular value, there are multiple other areas in the
108 // system which believe this to be true (e.g. oop->object_size in some
109 // cases incorrectly returns the size in wordSize units rather than
110 // HeapWordSize).
111 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
112
113 // Allocate space for the heap.
114
115 ReservedHeapSpace heap_rs = allocate(HeapAlignment);
116
117 if (!heap_rs.is_reserved()) {
118 vm_shutdown_during_initialization(
119 "Could not reserve enough space for object heap");
120 return JNI_ENOMEM;
121 }
122
123 initialize_reserved_region(heap_rs);
124
125 _rem_set = create_rem_set(heap_rs.region());
126 _rem_set->initialize();
127 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
128 bs->initialize();
129 BarrierSet::set_barrier_set(bs);
130
131 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
132 _young_gen = _young_gen_spec->init(young_rs, rem_set());
133 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
134
135 old_rs = old_rs.first_part(_old_gen_spec->max_size());
136 _old_gen = _old_gen_spec->init(old_rs, rem_set());
137
138 GCInitLogger::print();
139
140 return JNI_OK;
141 }
142
143 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1095 }
1096
1097 bool GenCollectedHeap::is_maximal_no_gc() const {
1098 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1099 }
1100
1101 void GenCollectedHeap::save_marks() {
1102 _young_gen->save_marks();
1103 _old_gen->save_marks();
1104 }
1105
1106 GenCollectedHeap* GenCollectedHeap::heap() {
1107 // SerialHeap is the only subtype of GenCollectedHeap.
1108 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1109 }
1110
1111 #if INCLUDE_SERIALGC
1112 void GenCollectedHeap::prepare_for_compaction() {
1113 // Start by compacting into same gen.
1114 CompactPoint cp(_old_gen);
1115 _old_gen->prepare_for_compaction(&cp);
1116 _young_gen->prepare_for_compaction(&cp);
1117 }
1118 #endif // INCLUDE_SERIALGC
1119
1120 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1121 log_debug(gc, verify)("%s", _old_gen->name());
1122 _old_gen->verify();
1123
1124 log_debug(gc, verify)("%s", _old_gen->name());
1125 _young_gen->verify();
1126
1127 log_debug(gc, verify)("RemSet");
1128 rem_set()->verify();
1129 }
1130
1131 void GenCollectedHeap::print_on(outputStream* st) const {
1132 if (_young_gen != NULL) {
1133 _young_gen->print_on(st);
1134 }
|
35 #include "gc/shared/cardTableBarrierSet.hpp"
36 #include "gc/shared/cardTableRS.hpp"
37 #include "gc/shared/collectedHeap.inline.hpp"
38 #include "gc/shared/collectorCounters.hpp"
39 #include "gc/shared/gcId.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "gc/shared/gcPolicyCounters.hpp"
42 #include "gc/shared/gcTrace.hpp"
43 #include "gc/shared/gcTraceTime.inline.hpp"
44 #include "gc/shared/genArguments.hpp"
45 #include "gc/shared/gcVMOperations.hpp"
46 #include "gc/shared/genCollectedHeap.hpp"
47 #include "gc/shared/genOopClosures.inline.hpp"
48 #include "gc/shared/generationSpec.hpp"
49 #include "gc/shared/gcInitLogger.hpp"
50 #include "gc/shared/locationPrinter.inline.hpp"
51 #include "gc/shared/oopStorage.inline.hpp"
52 #include "gc/shared/oopStorageSet.inline.hpp"
53 #include "gc/shared/oopStorageParState.inline.hpp"
54 #include "gc/shared/scavengableNMethods.hpp"
55 #include "gc/shared/slidingForwarding.hpp"
56 #include "gc/shared/space.hpp"
57 #include "gc/shared/strongRootsScope.hpp"
58 #include "gc/shared/weakProcessor.hpp"
59 #include "gc/shared/workgroup.hpp"
60 #include "memory/iterator.hpp"
61 #include "memory/metaspaceCounters.hpp"
62 #include "memory/metaspaceUtils.hpp"
63 #include "memory/resourceArea.hpp"
64 #include "memory/universe.hpp"
65 #include "oops/oop.inline.hpp"
66 #include "runtime/biasedLocking.hpp"
67 #include "runtime/handles.hpp"
68 #include "runtime/handles.inline.hpp"
69 #include "runtime/java.hpp"
70 #include "runtime/vmThread.hpp"
71 #include "services/memoryService.hpp"
72 #include "utilities/autoRestore.hpp"
73 #include "utilities/debug.hpp"
74 #include "utilities/formatBuffer.hpp"
75 #include "utilities/macros.hpp"
105
106 jint GenCollectedHeap::initialize() {
107 // While there are no constraints in the GC code that HeapWordSize
108 // be any particular value, there are multiple other areas in the
109 // system which believe this to be true (e.g. oop->object_size in some
110 // cases incorrectly returns the size in wordSize units rather than
111 // HeapWordSize).
112 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
113
114 // Allocate space for the heap.
115
116 ReservedHeapSpace heap_rs = allocate(HeapAlignment);
117
118 if (!heap_rs.is_reserved()) {
119 vm_shutdown_during_initialization(
120 "Could not reserve enough space for object heap");
121 return JNI_ENOMEM;
122 }
123
124 initialize_reserved_region(heap_rs);
125 _forwarding = new SlidingForwarding(_reserved);
126
127 _rem_set = create_rem_set(heap_rs.region());
128 _rem_set->initialize();
129 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
130 bs->initialize();
131 BarrierSet::set_barrier_set(bs);
132
133 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
134 _young_gen = _young_gen_spec->init(young_rs, rem_set());
135 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
136
137 old_rs = old_rs.first_part(_old_gen_spec->max_size());
138 _old_gen = _old_gen_spec->init(old_rs, rem_set());
139
140 GCInitLogger::print();
141
142 return JNI_OK;
143 }
144
145 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1097 }
1098
1099 bool GenCollectedHeap::is_maximal_no_gc() const {
1100 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1101 }
1102
1103 void GenCollectedHeap::save_marks() {
1104 _young_gen->save_marks();
1105 _old_gen->save_marks();
1106 }
1107
1108 GenCollectedHeap* GenCollectedHeap::heap() {
1109 // SerialHeap is the only subtype of GenCollectedHeap.
1110 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1111 }
1112
1113 #if INCLUDE_SERIALGC
1114 void GenCollectedHeap::prepare_for_compaction() {
1115 // Start by compacting into same gen.
1116 CompactPoint cp(_old_gen);
1117 _forwarding->clear();
1118 _old_gen->prepare_for_compaction(&cp);
1119 _young_gen->prepare_for_compaction(&cp);
1120 }
1121 #endif // INCLUDE_SERIALGC
1122
1123 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1124 log_debug(gc, verify)("%s", _old_gen->name());
1125 _old_gen->verify();
1126
1127 log_debug(gc, verify)("%s", _old_gen->name());
1128 _young_gen->verify();
1129
1130 log_debug(gc, verify)("RemSet");
1131 rem_set()->verify();
1132 }
1133
1134 void GenCollectedHeap::print_on(outputStream* st) const {
1135 if (_young_gen != NULL) {
1136 _young_gen->print_on(st);
1137 }
|