45 if (status != JNI_OK) return status; |
45 if (status != JNI_OK) return status; |
46 |
46 |
47 // If we are running CMS, create the collector responsible |
47 // If we are running CMS, create the collector responsible |
48 // for collecting the CMS generations. |
48 // for collecting the CMS generations. |
49 assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy"); |
49 assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy"); |
50 create_cms_collector(); |
50 if (!create_cms_collector()) { |
|
51 return JNI_ENOMEM; |
|
52 } |
51 |
53 |
52 return JNI_OK; |
54 return JNI_OK; |
53 } |
55 } |
54 |
56 |
55 void CMSHeap::check_gen_kinds() { |
57 void CMSHeap::check_gen_kinds() { |
82 GenCollectedHeap::print_on_error(st); |
84 GenCollectedHeap::print_on_error(st); |
83 st->cr(); |
85 st->cr(); |
84 CMSCollector::print_on_error(st); |
86 CMSCollector::print_on_error(st); |
85 } |
87 } |
86 |
88 |
87 void CMSHeap::create_cms_collector() { |
89 bool CMSHeap::create_cms_collector() { |
88 assert(old_gen()->kind() == Generation::ConcurrentMarkSweep, |
90 assert(old_gen()->kind() == Generation::ConcurrentMarkSweep, |
89 "Unexpected generation kinds"); |
91 "Unexpected generation kinds"); |
90 assert(gen_policy()->is_concurrent_mark_sweep_policy(), "Unexpected policy type"); |
92 assert(gen_policy()->is_concurrent_mark_sweep_policy(), "Unexpected policy type"); |
91 CMSCollector* collector = |
93 CMSCollector* collector = |
92 new CMSCollector((ConcurrentMarkSweepGeneration*) old_gen(), |
94 new CMSCollector((ConcurrentMarkSweepGeneration*) old_gen(), |
93 rem_set(), |
95 rem_set(), |
94 gen_policy()->as_concurrent_mark_sweep_policy()); |
96 gen_policy()->as_concurrent_mark_sweep_policy()); |
95 |
97 |
96 if (!collector->completed_initialization()) { |
98 if (collector == NULL || !collector->completed_initialization()) { |
|
99 if (collector) { |
|
100 delete collector; // Be nice in embedded situation |
|
101 } |
97 vm_shutdown_during_initialization("Could not create CMS collector"); |
102 vm_shutdown_during_initialization("Could not create CMS collector"); |
|
103 return false; |
98 } |
104 } |
|
105 return true; // success |
99 } |
106 } |
100 |
107 |
101 void CMSHeap::collect(GCCause::Cause cause) { |
108 void CMSHeap::collect(GCCause::Cause cause) { |
102 if (should_do_concurrent_full_gc(cause)) { |
109 if (should_do_concurrent_full_gc(cause)) { |
103 // Mostly concurrent full collection. |
110 // Mostly concurrent full collection. |