0 /*
1 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
|
0 /*
1 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
|
39 #include "gc/parallel/vmPSOperations.hpp"
40 #include "gc/shared/gcHeapSummary.hpp"
41 #include "gc/shared/gcLocker.inline.hpp"
42 #include "gc/shared/gcWhen.hpp"
43 #include "logging/log.hpp"
44 #include "oops/oop.inline.hpp"
45 #include "runtime/handles.inline.hpp"
46 #include "runtime/java.hpp"
47 #include "runtime/vmThread.hpp"
48 #include "services/memoryManager.hpp"
49 #include "services/memTracker.hpp"
50 #include "utilities/vmError.hpp"
51
52 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
53 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
54 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
55 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
56 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
57
58 jint ParallelScavengeHeap::initialize() {
59 CollectedHeap::pre_initialize();
60
61 const size_t heap_size = _collector_policy->max_heap_byte_size();
62
63 ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());
64
65 os::trace_page_sizes("Heap",
66 _collector_policy->min_heap_byte_size(),
67 heap_size,
68 generation_alignment(),
69 heap_rs.base(),
70 heap_rs.size());
71
72 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
73
74 CardTableExtension* const barrier_set = new CardTableExtension(reserved_region());
75 barrier_set->initialize();
76 set_barrier_set(barrier_set);
77
78 // Make up the generations
79 // Calculate the maximum size that a generation can grow. This
|
39 #include "gc/parallel/vmPSOperations.hpp"
40 #include "gc/shared/gcHeapSummary.hpp"
41 #include "gc/shared/gcLocker.inline.hpp"
42 #include "gc/shared/gcWhen.hpp"
43 #include "logging/log.hpp"
44 #include "oops/oop.inline.hpp"
45 #include "runtime/handles.inline.hpp"
46 #include "runtime/java.hpp"
47 #include "runtime/vmThread.hpp"
48 #include "services/memoryManager.hpp"
49 #include "services/memTracker.hpp"
50 #include "utilities/vmError.hpp"
51
52 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
53 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
54 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
55 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
56 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
57
58 jint ParallelScavengeHeap::initialize() {
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
|
472 size_t ParallelScavengeHeap::tlab_used(Thread* thr) const {
473 return young_gen()->eden_space()->tlab_used(thr);
474 }
475
476 size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {
477 return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);
478 }
479
480 HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {
481 return young_gen()->allocate(size);
482 }
483
484 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
485 CollectedHeap::accumulate_statistics_all_tlabs();
486 }
487
488 void ParallelScavengeHeap::resize_all_tlabs() {
489 CollectedHeap::resize_all_tlabs();
490 }
491
492 bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) {
493 // We don't need barriers for stores to objects in the
494 // young gen and, a fortiori, for initializing stores to
495 // objects therein.
496 return is_in_young(new_obj);
497 }
498
499 // This method is used by System.gc() and JVMTI.
500 void ParallelScavengeHeap::collect(GCCause::Cause cause) {
501 assert(!Heap_lock->owned_by_self(),
502 "this thread should not own the Heap_lock");
503
504 uint gc_count = 0;
505 uint full_gc_count = 0;
506 {
507 MutexLocker ml(Heap_lock);
508 // This value is guarded by the Heap_lock
509 gc_count = total_collections();
510 full_gc_count = total_full_collections();
511 }
512
513 VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
514 VMThread::execute(&op);
515 }
516
517 void ParallelScavengeHeap::object_iterate(ObjectClosure* cl) {
|
470 size_t ParallelScavengeHeap::tlab_used(Thread* thr) const {
471 return young_gen()->eden_space()->tlab_used(thr);
472 }
473
474 size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {
475 return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);
476 }
477
478 HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {
479 return young_gen()->allocate(size);
480 }
481
482 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
483 CollectedHeap::accumulate_statistics_all_tlabs();
484 }
485
486 void ParallelScavengeHeap::resize_all_tlabs() {
487 CollectedHeap::resize_all_tlabs();
488 }
489
490 // This method is used by System.gc() and JVMTI.
491 void ParallelScavengeHeap::collect(GCCause::Cause cause) {
492 assert(!Heap_lock->owned_by_self(),
493 "this thread should not own the Heap_lock");
494
495 uint gc_count = 0;
496 uint full_gc_count = 0;
497 {
498 MutexLocker ml(Heap_lock);
499 // This value is guarded by the Heap_lock
500 gc_count = total_collections();
501 full_gc_count = total_full_collections();
502 }
503
504 VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
505 VMThread::execute(&op);
506 }
507
508 void ParallelScavengeHeap::object_iterate(ObjectClosure* cl) {
|
701 }
702
703 void ParallelScavengeHeap::verify_nmethod(nmethod* nm) {
704 CodeCache::verify_scavenge_root_nmethod(nm);
705 }
706
707 GrowableArray<GCMemoryManager*> ParallelScavengeHeap::memory_managers() {
708 GrowableArray<GCMemoryManager*> memory_managers(2);
709 memory_managers.append(_young_manager);
710 memory_managers.append(_old_manager);
711 return memory_managers;
712 }
713
714 GrowableArray<MemoryPool*> ParallelScavengeHeap::memory_pools() {
715 GrowableArray<MemoryPool*> memory_pools(3);
716 memory_pools.append(_eden_pool);
717 memory_pools.append(_survivor_pool);
718 memory_pools.append(_old_pool);
719 return memory_pools;
720 }
721
|
692 }
693
694 void ParallelScavengeHeap::verify_nmethod(nmethod* nm) {
695 CodeCache::verify_scavenge_root_nmethod(nm);
696 }
697
698 GrowableArray<GCMemoryManager*> ParallelScavengeHeap::memory_managers() {
699 GrowableArray<GCMemoryManager*> memory_managers(2);
700 memory_managers.append(_young_manager);
701 memory_managers.append(_old_manager);
702 return memory_managers;
703 }
704
705 GrowableArray<MemoryPool*> ParallelScavengeHeap::memory_pools() {
706 GrowableArray<MemoryPool*> memory_pools(3);
707 memory_pools.append(_eden_pool);
708 memory_pools.append(_survivor_pool);
709 memory_pools.append(_old_pool);
710 return memory_pools;
711 }
|