109 // HeapWordSize).
110 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
111
112 // Allocate space for the heap.
113
114 char* heap_address;
115 ReservedSpace heap_rs;
116
117 size_t heap_alignment = collector_policy()->heap_alignment();
118
119 heap_address = allocate(heap_alignment, &heap_rs);
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((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
128
129 _rem_set = collector_policy()->create_rem_set(reserved_region());
130 set_barrier_set(rem_set()->bs());
131
132 ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false);
133 _young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set());
134 heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size());
135
136 ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false);
137 _old_gen = gen_policy()->old_gen_spec()->init(old_rs, rem_set());
138 clear_incremental_collection_failed();
139
140 #if INCLUDE_ALL_GCS
141 // If we are running CMS, create the collector responsible
142 // for collecting the CMS generations.
143 if (collector_policy()->is_concurrent_mark_sweep_policy()) {
144 bool success = create_cms_collector();
145 if (!success) return JNI_ENOMEM;
146 }
147 #endif // INCLUDE_ALL_GCS
148
149 return JNI_OK;
150 }
1293 // back a time later than 'now'.
1294 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
1295 GenTimeOfLastGCClosure tolgc_cl(now);
1296 // iterate over generations getting the oldest
1297 // time that a generation was collected
1298 generation_iterate(&tolgc_cl, false);
1299
1300 jlong retVal = now - tolgc_cl.time();
1301 if (retVal < 0) {
1302 log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
1303 ". returning zero instead.", retVal);
1304 return 0;
1305 }
1306 return retVal;
1307 }
1308
1309 void GenCollectedHeap::stop() {
1310 #if INCLUDE_ALL_GCS
1311 if (UseConcMarkSweepGC) {
1312 ConcurrentMarkSweepThread::cmst()->stop();
1313 }
1314 #endif
1315 }
|
109 // HeapWordSize).
110 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
111
112 // Allocate space for the heap.
113
114 char* heap_address;
115 ReservedSpace heap_rs;
116
117 size_t heap_alignment = collector_policy()->heap_alignment();
118
119 heap_address = allocate(heap_alignment, &heap_rs);
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((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
128
129 _rem_set = new CardTableRS(reserved_region());
130 _rem_set->initialize();
131 CardTableModRefBS *bs = new CardTableModRefBS(_rem_set);
132 bs->initialize();
133 set_barrier_set(bs);
134
135 ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false);
136 _young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set());
137 heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size());
138
139 ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false);
140 _old_gen = gen_policy()->old_gen_spec()->init(old_rs, rem_set());
141 clear_incremental_collection_failed();
142
143 #if INCLUDE_ALL_GCS
144 // If we are running CMS, create the collector responsible
145 // for collecting the CMS generations.
146 if (collector_policy()->is_concurrent_mark_sweep_policy()) {
147 bool success = create_cms_collector();
148 if (!success) return JNI_ENOMEM;
149 }
150 #endif // INCLUDE_ALL_GCS
151
152 return JNI_OK;
153 }
1296 // back a time later than 'now'.
1297 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
1298 GenTimeOfLastGCClosure tolgc_cl(now);
1299 // iterate over generations getting the oldest
1300 // time that a generation was collected
1301 generation_iterate(&tolgc_cl, false);
1302
1303 jlong retVal = now - tolgc_cl.time();
1304 if (retVal < 0) {
1305 log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
1306 ". returning zero instead.", retVal);
1307 return 0;
1308 }
1309 return retVal;
1310 }
1311
1312 void GenCollectedHeap::stop() {
1313 #if INCLUDE_ALL_GCS
1314 if (UseConcMarkSweepGC) {
1315 ConcurrentMarkSweepThread::cmst()->stop();
1316 }
1317 #endif
1318 }
1319
1320 void GenCollectedHeap::safepoint_synchronize_begin() {
1321 #if INCLUDE_ALL_GCS
1322 if (UseConcMarkSweepGC) {
1323 ConcurrentMarkSweepThread::synchronize(false);
1324 }
1325 #endif
1326 }
1327
1328 void GenCollectedHeap::safepoint_synchronize_end() {
1329 #if INCLUDE_ALL_GCS
1330 if (UseConcMarkSweepGC) {
1331 ConcurrentMarkSweepThread::desynchronize(false);
1332 }
1333 #endif
1334 }
|