134 _max_heap_byte_size = MaxHeapSize;
135
136 FLAG_SET_ERGO(size_t, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment));
137
138 DEBUG_ONLY(CollectorPolicy::assert_flags();)
139 }
140
141 void CollectorPolicy::initialize_size_info() {
142 log_debug(gc, heap)("Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " Maximum heap " SIZE_FORMAT,
143 _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
144
145 DEBUG_ONLY(CollectorPolicy::assert_size_info();)
146 }
147
148 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
149 bool result = _should_clear_all_soft_refs;
150 set_should_clear_all_soft_refs(false);
151 return result;
152 }
153
154 CardTableRS* CollectorPolicy::create_rem_set(MemRegion whole_heap) {
155 return new CardTableRS(whole_heap);
156 }
157
158 void CollectorPolicy::cleared_all_soft_refs() {
159 // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may
160 // have been cleared in the last collection but if the gc overhear
161 // limit continues to be near, SoftRefs should still be cleared.
162 if (size_policy() != NULL) {
163 _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near();
164 }
165 _all_soft_refs_clear = true;
166 }
167
168 size_t CollectorPolicy::compute_heap_alignment() {
169 // The card marking array and the offset arrays for old generations are
170 // committed in os pages as well. Make sure they are entirely full (to
171 // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1
172 // byte entry and the os page size is 4096, the maximum heap size should
173 // be 512*4096 = 2MB aligned.
174
175 size_t alignment = CardTableRS::ct_max_alignment_constraint();
396 } else {
397 FLAG_SET_ERGO(size_t, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment));
398 _max_heap_byte_size = MaxHeapSize;
399 }
400 }
401
402 // Update NewSize, if possible, to avoid sizing the young gen too small when only
403 // OldSize is set on the command line.
404 if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) {
405 if (OldSize < _initial_heap_byte_size) {
406 size_t new_size = _initial_heap_byte_size - OldSize;
407 // Need to compare against the flag value for max since _max_young_size
408 // might not have been set yet.
409 if (new_size >= _min_young_size && new_size <= MaxNewSize) {
410 FLAG_SET_ERGO(size_t, NewSize, new_size);
411 _initial_young_size = NewSize;
412 }
413 }
414 }
415
416 always_do_update_barrier = UseConcMarkSweepGC;
417
418 DEBUG_ONLY(GenCollectorPolicy::assert_flags();)
419 }
420
421 // Values set on the command line win over any ergonomically
422 // set command line parameters.
423 // Ergonomic choice of parameters are done before this
424 // method is called. Values for command line parameters such as NewSize
425 // and MaxNewSize feed those ergonomic choices into this method.
426 // This method makes the final generation sizings consistent with
427 // themselves and with overall heap sizings.
428 // In the absence of explicitly set command line flags, policies
429 // such as the use of NewRatio are used to size the generation.
430
431 // Minimum sizes of the generations may be different than
432 // the initial sizes. An inconsistency is permitted here
433 // in the total size that can be specified explicitly by
434 // command line specification of OldSize and NewSize and
435 // also a command line specification of -Xms. Issue a warning
436 // but allow the values to pass.
437 void GenCollectorPolicy::initialize_size_info() {
826 JavaThread* jthr = JavaThread::current();
827 if (!jthr->in_critical()) {
828 // Wait for JNI critical section to be exited
829 GCLocker::stall_until_clear();
830 // The GC invoked by the last thread leaving the critical
831 // section will be a young collection and a full collection
832 // is (currently) needed for unloading classes so continue
833 // to the next iteration to get a full GC.
834 continue;
835 } else {
836 if (CheckJNICalls) {
837 fatal("Possible deadlock due to allocating while"
838 " in jni critical section");
839 }
840 return NULL;
841 }
842 }
843
844 { // Need lock to get self consistent gc_count's
845 MutexLocker ml(Heap_lock);
846 gc_count = Universe::heap()->total_collections();
847 full_gc_count = Universe::heap()->total_full_collections();
848 }
849
850 // Generate a VM operation
851 VM_CollectForMetadataAllocation op(loader_data,
852 word_size,
853 mdtype,
854 gc_count,
855 full_gc_count,
856 GCCause::_metadata_GC_threshold);
857 VMThread::execute(&op);
858
859 // If GC was locked out, try again. Check before checking success because the
860 // prologue could have succeeded and the GC still have been locked out.
861 if (op.gc_locked()) {
862 continue;
863 }
864
865 if (op.prologue_succeeded()) {
866 return op.result();
867 }
|
134 _max_heap_byte_size = MaxHeapSize;
135
136 FLAG_SET_ERGO(size_t, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment));
137
138 DEBUG_ONLY(CollectorPolicy::assert_flags();)
139 }
140
141 void CollectorPolicy::initialize_size_info() {
142 log_debug(gc, heap)("Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " Maximum heap " SIZE_FORMAT,
143 _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
144
145 DEBUG_ONLY(CollectorPolicy::assert_size_info();)
146 }
147
148 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
149 bool result = _should_clear_all_soft_refs;
150 set_should_clear_all_soft_refs(false);
151 return result;
152 }
153
154 CardTableRS* CollectorPolicy::create_rem_set(MemRegion whole_heap, CardTableModRefBSForCTRS* ct_bs) {
155 return new CardTableRS(whole_heap, ct_bs);
156 }
157
158 void CollectorPolicy::cleared_all_soft_refs() {
159 // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may
160 // have been cleared in the last collection but if the gc overhear
161 // limit continues to be near, SoftRefs should still be cleared.
162 if (size_policy() != NULL) {
163 _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near();
164 }
165 _all_soft_refs_clear = true;
166 }
167
168 size_t CollectorPolicy::compute_heap_alignment() {
169 // The card marking array and the offset arrays for old generations are
170 // committed in os pages as well. Make sure they are entirely full (to
171 // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1
172 // byte entry and the os page size is 4096, the maximum heap size should
173 // be 512*4096 = 2MB aligned.
174
175 size_t alignment = CardTableRS::ct_max_alignment_constraint();
396 } else {
397 FLAG_SET_ERGO(size_t, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment));
398 _max_heap_byte_size = MaxHeapSize;
399 }
400 }
401
402 // Update NewSize, if possible, to avoid sizing the young gen too small when only
403 // OldSize is set on the command line.
404 if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) {
405 if (OldSize < _initial_heap_byte_size) {
406 size_t new_size = _initial_heap_byte_size - OldSize;
407 // Need to compare against the flag value for max since _max_young_size
408 // might not have been set yet.
409 if (new_size >= _min_young_size && new_size <= MaxNewSize) {
410 FLAG_SET_ERGO(size_t, NewSize, new_size);
411 _initial_young_size = NewSize;
412 }
413 }
414 }
415
416 DEBUG_ONLY(GenCollectorPolicy::assert_flags();)
417 }
418
419 // Values set on the command line win over any ergonomically
420 // set command line parameters.
421 // Ergonomic choice of parameters are done before this
422 // method is called. Values for command line parameters such as NewSize
423 // and MaxNewSize feed those ergonomic choices into this method.
424 // This method makes the final generation sizings consistent with
425 // themselves and with overall heap sizings.
426 // In the absence of explicitly set command line flags, policies
427 // such as the use of NewRatio are used to size the generation.
428
429 // Minimum sizes of the generations may be different than
430 // the initial sizes. An inconsistency is permitted here
431 // in the total size that can be specified explicitly by
432 // command line specification of OldSize and NewSize and
433 // also a command line specification of -Xms. Issue a warning
434 // but allow the values to pass.
435 void GenCollectorPolicy::initialize_size_info() {
824 JavaThread* jthr = JavaThread::current();
825 if (!jthr->in_critical()) {
826 // Wait for JNI critical section to be exited
827 GCLocker::stall_until_clear();
828 // The GC invoked by the last thread leaving the critical
829 // section will be a young collection and a full collection
830 // is (currently) needed for unloading classes so continue
831 // to the next iteration to get a full GC.
832 continue;
833 } else {
834 if (CheckJNICalls) {
835 fatal("Possible deadlock due to allocating while"
836 " in jni critical section");
837 }
838 return NULL;
839 }
840 }
841
842 { // Need lock to get self consistent gc_count's
843 MutexLocker ml(Heap_lock);
844 gc_count = GC::gc()->heap()->total_collections();
845 full_gc_count = GC::gc()->heap()->total_full_collections();
846 }
847
848 // Generate a VM operation
849 VM_CollectForMetadataAllocation op(loader_data,
850 word_size,
851 mdtype,
852 gc_count,
853 full_gc_count,
854 GCCause::_metadata_GC_threshold);
855 VMThread::execute(&op);
856
857 // If GC was locked out, try again. Check before checking success because the
858 // prologue could have succeeded and the GC still have been locked out.
859 if (op.gc_locked()) {
860 continue;
861 }
862
863 if (op.prologue_succeeded()) {
864 return op.result();
865 }
|