8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
28 #include "gc/parallel/cardTableExtension.hpp"
29 #include "gc/parallel/gcTaskManager.hpp"
30 #include "gc/parallel/generationSizer.hpp"
31 #include "gc/parallel/objectStartArray.inline.hpp"
32 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
33 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
34 #include "gc/parallel/psMarkSweep.hpp"
35 #include "gc/parallel/psParallelCompact.inline.hpp"
36 #include "gc/parallel/psPromotionManager.hpp"
37 #include "gc/parallel/psScavenge.hpp"
38 #include "gc/parallel/vmPSOperations.hpp"
39 #include "gc/shared/gcHeapSummary.hpp"
40 #include "gc/shared/gcLocker.inline.hpp"
41 #include "gc/shared/gcWhen.hpp"
42 #include "logging/log.hpp"
43 #include "oops/oop.inline.hpp"
44 #include "runtime/handles.inline.hpp"
45 #include "runtime/java.hpp"
46 #include "runtime/vmThread.hpp"
47 #include "services/memTracker.hpp"
48 #include "utilities/vmError.hpp"
52 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
53 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
54 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
55
56 jint ParallelScavengeHeap::initialize() {
57 CollectedHeap::pre_initialize();
58
59 const size_t heap_size = _collector_policy->max_heap_byte_size();
60
61 ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());
62
63 os::trace_page_sizes("Heap",
64 _collector_policy->min_heap_byte_size(),
65 heap_size,
66 generation_alignment(),
67 heap_rs.base(),
68 heap_rs.size());
69
70 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
71
72 CardTableExtension* const barrier_set = new CardTableExtension(reserved_region());
73 barrier_set->initialize();
74 set_barrier_set(barrier_set);
75
76 // Make up the generations
77 // Calculate the maximum size that a generation can grow. This
78 // includes growth into the other generation. Note that the
79 // parameter _max_gen_size is kept as the maximum
80 // size of the generation as the boundaries currently stand.
81 // _max_gen_size is still used as that value.
82 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
83 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
84
85 _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment());
86
87 _old_gen = _gens->old_gen();
88 _young_gen = _gens->young_gen();
89
90 const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();
91 const size_t old_capacity = _old_gen->capacity_in_bytes();
92 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
444 }
445
446 size_t ParallelScavengeHeap::tlab_used(Thread* thr) const {
447 return young_gen()->eden_space()->tlab_used(thr);
448 }
449
450 size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {
451 return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);
452 }
453
454 HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {
455 return young_gen()->allocate(size);
456 }
457
458 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
459 CollectedHeap::accumulate_statistics_all_tlabs();
460 }
461
462 void ParallelScavengeHeap::resize_all_tlabs() {
463 CollectedHeap::resize_all_tlabs();
464 }
465
466 bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) {
467 // We don't need barriers for stores to objects in the
468 // young gen and, a fortiori, for initializing stores to
469 // objects therein.
470 return is_in_young(new_obj);
471 }
472
473 // This method is used by System.gc() and JVMTI.
474 void ParallelScavengeHeap::collect(GCCause::Cause cause) {
475 assert(!Heap_lock->owned_by_self(),
476 "this thread should not own the Heap_lock");
477
478 uint gc_count = 0;
479 uint full_gc_count = 0;
480 {
481 MutexLocker ml(Heap_lock);
482 // This value is guarded by the Heap_lock
483 gc_count = total_collections();
484 full_gc_count = total_full_collections();
485 }
486
487 VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
488 VMThread::execute(&op);
489 }
490
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
28 #include "gc/parallel/gcTaskManager.hpp"
29 #include "gc/parallel/generationSizer.hpp"
30 #include "gc/parallel/objectStartArray.inline.hpp"
31 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
32 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
33 #include "gc/parallel/psMarkSweep.hpp"
34 #include "gc/parallel/psParallelCompact.inline.hpp"
35 #include "gc/parallel/psPromotionManager.hpp"
36 #include "gc/parallel/psScavenge.hpp"
37 #include "gc/parallel/vmPSOperations.hpp"
38 #include "gc/shared/gcHeapSummary.hpp"
39 #include "gc/shared/gcLocker.inline.hpp"
40 #include "gc/shared/gcWhen.hpp"
41 #include "logging/log.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "runtime/handles.inline.hpp"
44 #include "runtime/java.hpp"
45 #include "runtime/vmThread.hpp"
46 #include "services/memTracker.hpp"
47 #include "utilities/vmError.hpp"
51 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
52 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
53 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
54
55 jint ParallelScavengeHeap::initialize() {
56 CollectedHeap::pre_initialize();
57
58 const size_t heap_size = _collector_policy->max_heap_byte_size();
59
60 ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());
61
62 os::trace_page_sizes("Heap",
63 _collector_policy->min_heap_byte_size(),
64 heap_size,
65 generation_alignment(),
66 heap_rs.base(),
67 heap_rs.size());
68
69 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
70
71 PSCardTable* card_table = new PSCardTable(reserved_region());
72 card_table->initialize();
73 CardTableModRefBS* const barrier_set = new CardTableModRefBS(card_table);
74 barrier_set->initialize();
75 set_barrier_set(barrier_set);
76
77 // Make up the generations
78 // Calculate the maximum size that a generation can grow. This
79 // includes growth into the other generation. Note that the
80 // parameter _max_gen_size is kept as the maximum
81 // size of the generation as the boundaries currently stand.
82 // _max_gen_size is still used as that value.
83 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
84 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
85
86 _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment());
87
88 _old_gen = _gens->old_gen();
89 _young_gen = _gens->young_gen();
90
91 const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();
92 const size_t old_capacity = _old_gen->capacity_in_bytes();
93 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
445 }
446
447 size_t ParallelScavengeHeap::tlab_used(Thread* thr) const {
448 return young_gen()->eden_space()->tlab_used(thr);
449 }
450
451 size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {
452 return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);
453 }
454
455 HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {
456 return young_gen()->allocate(size);
457 }
458
459 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
460 CollectedHeap::accumulate_statistics_all_tlabs();
461 }
462
463 void ParallelScavengeHeap::resize_all_tlabs() {
464 CollectedHeap::resize_all_tlabs();
465 }
466
467 // This method is used by System.gc() and JVMTI.
468 void ParallelScavengeHeap::collect(GCCause::Cause cause) {
469 assert(!Heap_lock->owned_by_self(),
470 "this thread should not own the Heap_lock");
471
472 uint gc_count = 0;
473 uint full_gc_count = 0;
474 {
475 MutexLocker ml(Heap_lock);
476 // This value is guarded by the Heap_lock
477 gc_count = total_collections();
478 full_gc_count = total_full_collections();
479 }
480
481 VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
482 VMThread::execute(&op);
483 }
484
|