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/workerThread.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/handles.hpp"
66 #include "runtime/handles.inline.hpp"
67 #include "runtime/java.hpp"
68 #include "runtime/vmThread.hpp"
69 #include "services/memoryService.hpp"
70 #include "utilities/autoRestore.hpp"
71 #include "utilities/debug.hpp"
72 #include "utilities/formatBuffer.hpp"
73 #include "utilities/macros.hpp"
74 #include "utilities/stack.inline.hpp"
103
104 jint GenCollectedHeap::initialize() {
105 // While there are no constraints in the GC code that HeapWordSize
106 // be any particular value, there are multiple other areas in the
107 // system which believe this to be true (e.g. oop->object_size in some
108 // cases incorrectly returns the size in wordSize units rather than
109 // HeapWordSize).
110 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
111
112 // Allocate space for the heap.
113
114 ReservedHeapSpace heap_rs = allocate(HeapAlignment);
115
116 if (!heap_rs.is_reserved()) {
117 vm_shutdown_during_initialization(
118 "Could not reserve enough space for object heap");
119 return JNI_ENOMEM;
120 }
121
122 initialize_reserved_region(heap_rs);
123
124 _rem_set = create_rem_set(heap_rs.region());
125 _rem_set->initialize();
126 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
127 bs->initialize();
128 BarrierSet::set_barrier_set(bs);
129
130 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
131 _young_gen = _young_gen_spec->init(young_rs, rem_set());
132 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
133
134 old_rs = old_rs.first_part(_old_gen_spec->max_size());
135 _old_gen = _old_gen_spec->init(old_rs, rem_set());
136
137 GCInitLogger::print();
138
139 return JNI_OK;
140 }
141
142 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1051 }
1052
1053 bool GenCollectedHeap::is_maximal_no_gc() const {
1054 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1055 }
1056
1057 void GenCollectedHeap::save_marks() {
1058 _young_gen->save_marks();
1059 _old_gen->save_marks();
1060 }
1061
1062 GenCollectedHeap* GenCollectedHeap::heap() {
1063 // SerialHeap is the only subtype of GenCollectedHeap.
1064 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1065 }
1066
1067 #if INCLUDE_SERIALGC
1068 void GenCollectedHeap::prepare_for_compaction() {
1069 // Start by compacting into same gen.
1070 CompactPoint cp(_old_gen);
1071 _old_gen->prepare_for_compaction(&cp);
1072 _young_gen->prepare_for_compaction(&cp);
1073 }
1074 #endif // INCLUDE_SERIALGC
1075
1076 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1077 log_debug(gc, verify)("%s", _old_gen->name());
1078 _old_gen->verify();
1079
1080 log_debug(gc, verify)("%s", _old_gen->name());
1081 _young_gen->verify();
1082
1083 log_debug(gc, verify)("RemSet");
1084 rem_set()->verify();
1085 }
1086
1087 void GenCollectedHeap::print_on(outputStream* st) const {
1088 if (_young_gen != NULL) {
1089 _young_gen->print_on(st);
1090 }
|
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/workerThread.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/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"
75 #include "utilities/stack.inline.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 _forwarding = new SlidingForwarding(_reserved);
125
126 _rem_set = create_rem_set(heap_rs.region());
127 _rem_set->initialize();
128 CardTableBarrierSet *bs = new CardTableBarrierSet(_rem_set);
129 bs->initialize();
130 BarrierSet::set_barrier_set(bs);
131
132 ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
133 _young_gen = _young_gen_spec->init(young_rs, rem_set());
134 ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
135
136 old_rs = old_rs.first_part(_old_gen_spec->max_size());
137 _old_gen = _old_gen_spec->init(old_rs, rem_set());
138
139 GCInitLogger::print();
140
141 return JNI_OK;
142 }
143
144 CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) {
1053 }
1054
1055 bool GenCollectedHeap::is_maximal_no_gc() const {
1056 return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc();
1057 }
1058
1059 void GenCollectedHeap::save_marks() {
1060 _young_gen->save_marks();
1061 _old_gen->save_marks();
1062 }
1063
1064 GenCollectedHeap* GenCollectedHeap::heap() {
1065 // SerialHeap is the only subtype of GenCollectedHeap.
1066 return named_heap<GenCollectedHeap>(CollectedHeap::Serial);
1067 }
1068
1069 #if INCLUDE_SERIALGC
1070 void GenCollectedHeap::prepare_for_compaction() {
1071 // Start by compacting into same gen.
1072 CompactPoint cp(_old_gen);
1073 _forwarding->clear();
1074 _old_gen->prepare_for_compaction(&cp);
1075 _young_gen->prepare_for_compaction(&cp);
1076 }
1077 #endif // INCLUDE_SERIALGC
1078
1079 void GenCollectedHeap::verify(VerifyOption option /* ignored */) {
1080 log_debug(gc, verify)("%s", _old_gen->name());
1081 _old_gen->verify();
1082
1083 log_debug(gc, verify)("%s", _old_gen->name());
1084 _young_gen->verify();
1085
1086 log_debug(gc, verify)("RemSet");
1087 rem_set()->verify();
1088 }
1089
1090 void GenCollectedHeap::print_on(outputStream* st) const {
1091 if (_young_gen != NULL) {
1092 _young_gen->print_on(st);
1093 }
|