0 /*
1 * Copyright (c) 2005, 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.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "classfile/systemDictionary.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
27 #include "gc/parallel/objectStartArray.hpp"
28 #include "gc/parallel/parMarkBitMap.inline.hpp"
29 #include "gc/parallel/parallelScavengeHeap.hpp"
30 #include "gc/parallel/psCompactionManager.inline.hpp"
31 #include "gc/parallel/psOldGen.hpp"
32 #include "gc/parallel/psParallelCompact.inline.hpp"
33 #include "gc/shared/taskqueue.inline.hpp"
34 #include "logging/log.hpp"
35 #include "memory/iterator.inline.hpp"
36 #include "oops/access.inline.hpp"
37 #include "oops/compressedOops.inline.hpp"
38 #include "oops/instanceKlass.inline.hpp"
39 #include "oops/instanceMirrorKlass.inline.hpp"
40 #include "oops/objArrayKlass.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "runtime/atomic.hpp"
43
44 PSOldGen* ParCompactionManager::_old_gen = NULL;
45 ParCompactionManager** ParCompactionManager::_manager_array = NULL;
|
0 /*
1 * Copyright (c) 2005, 2019, 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.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "classfile/systemDictionary.hpp"
26 #include "gc/parallel/objectStartArray.hpp"
27 #include "gc/parallel/parMarkBitMap.inline.hpp"
28 #include "gc/parallel/parallelScavengeHeap.hpp"
29 #include "gc/parallel/psCompactionManager.inline.hpp"
30 #include "gc/parallel/psOldGen.hpp"
31 #include "gc/parallel/psParallelCompact.inline.hpp"
32 #include "gc/shared/taskqueue.inline.hpp"
33 #include "logging/log.hpp"
34 #include "memory/iterator.inline.hpp"
35 #include "oops/access.inline.hpp"
36 #include "oops/compressedOops.inline.hpp"
37 #include "oops/instanceKlass.inline.hpp"
38 #include "oops/instanceMirrorKlass.inline.hpp"
39 #include "oops/objArrayKlass.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 #include "runtime/atomic.hpp"
42
43 PSOldGen* ParCompactionManager::_old_gen = NULL;
44 ParCompactionManager** ParCompactionManager::_manager_array = NULL;
|
50 ObjectStartArray* ParCompactionManager::_start_array = NULL;
51 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
52 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
53
54 ParCompactionManager::ParCompactionManager() :
55 _action(CopyAndUpdate) {
56
57 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
58
59 _old_gen = heap->old_gen();
60 _start_array = old_gen()->start_array();
61
62 marking_stack()->initialize();
63 _objarray_stack.initialize();
64 _region_stack.initialize();
65
66 reset_bitmap_query_cache();
67 }
68
69 void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
70 assert(PSParallelCompact::gc_task_manager() != NULL,
71 "Needed for initialization");
72
73 _mark_bitmap = mbm;
74
75 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
76
77 assert(_manager_array == NULL, "Attempt to initialize twice");
78 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC);
79 guarantee(_manager_array != NULL, "Could not allocate manager_array");
80
81 _stack_array = new OopTaskQueueSet(parallel_gc_threads);
82 guarantee(_stack_array != NULL, "Could not allocate stack_array");
83 _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads);
84 guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
85 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
86 guarantee(_region_array != NULL, "Could not allocate region_array");
87
88 // Create and register the ParCompactionManager(s) for the worker threads.
89 for(uint i=0; i<parallel_gc_threads; i++) {
90 _manager_array[i] = new ParCompactionManager();
91 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
92 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
93 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
94 region_array()->register_queue(i, _manager_array[i]->region_stack());
95 }
96
97 // The VMThread gets its own ParCompactionManager, which is not available
98 // for work stealing.
99 _manager_array[parallel_gc_threads] = new ParCompactionManager();
100 guarantee(_manager_array[parallel_gc_threads] != NULL,
101 "Could not create ParCompactionManager");
102 assert(PSParallelCompact::gc_task_manager()->workers() != 0,
103 "Not initialized?");
104 }
105
106 void ParCompactionManager::reset_all_bitmap_query_caches() {
107 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
108 for (uint i=0; i<=parallel_gc_threads; i++) {
109 _manager_array[i]->reset_bitmap_query_cache();
110 }
111 }
112
113 bool ParCompactionManager::should_update() {
114 assert(action() != NotValid, "Action is not set");
115 return (action() == ParCompactionManager::Update) ||
116 (action() == ParCompactionManager::CopyAndUpdate) ||
117 (action() == ParCompactionManager::UpdateAndCopy);
118 }
119
120 bool ParCompactionManager::should_copy() {
121 assert(action() != NotValid, "Action is not set");
122 return (action() == ParCompactionManager::Copy) ||
123 (action() == ParCompactionManager::CopyAndUpdate) ||
124 (action() == ParCompactionManager::UpdateAndCopy);
125 }
126
|
49 ObjectStartArray* ParCompactionManager::_start_array = NULL;
50 ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL;
51 RegionTaskQueueSet* ParCompactionManager::_region_array = NULL;
52
53 ParCompactionManager::ParCompactionManager() :
54 _action(CopyAndUpdate) {
55
56 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
57
58 _old_gen = heap->old_gen();
59 _start_array = old_gen()->start_array();
60
61 marking_stack()->initialize();
62 _objarray_stack.initialize();
63 _region_stack.initialize();
64
65 reset_bitmap_query_cache();
66 }
67
68 void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
69 assert(ParallelScavengeHeap::heap() != NULL,
70 "Needed for initialization");
71
72 _mark_bitmap = mbm;
73
74 uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().total_workers();
75
76 assert(_manager_array == NULL, "Attempt to initialize twice");
77 _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC);
78 guarantee(_manager_array != NULL, "Could not allocate manager_array");
79
80 _stack_array = new OopTaskQueueSet(parallel_gc_threads);
81 guarantee(_stack_array != NULL, "Could not allocate stack_array");
82 _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads);
83 guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
84 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
85 guarantee(_region_array != NULL, "Could not allocate region_array");
86
87 // Create and register the ParCompactionManager(s) for the worker threads.
88 for(uint i=0; i<parallel_gc_threads; i++) {
89 _manager_array[i] = new ParCompactionManager();
90 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
91 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
92 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
93 region_array()->register_queue(i, _manager_array[i]->region_stack());
94 }
95
96 // The VMThread gets its own ParCompactionManager, which is not available
97 // for work stealing.
98 _manager_array[parallel_gc_threads] = new ParCompactionManager();
99 guarantee(_manager_array[parallel_gc_threads] != NULL,
100 "Could not create ParCompactionManager");
101 assert(ParallelScavengeHeap::heap()->workers().total_workers() != 0,
102 "Not initialized?");
103 }
104
105 void ParCompactionManager::reset_all_bitmap_query_caches() {
106 uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().total_workers();
107 for (uint i=0; i<=parallel_gc_threads; i++) {
108 _manager_array[i]->reset_bitmap_query_cache();
109 }
110 }
111
112 bool ParCompactionManager::should_update() {
113 assert(action() != NotValid, "Action is not set");
114 return (action() == ParCompactionManager::Update) ||
115 (action() == ParCompactionManager::CopyAndUpdate) ||
116 (action() == ParCompactionManager::UpdateAndCopy);
117 }
118
119 bool ParCompactionManager::should_copy() {
120 assert(action() != NotValid, "Action is not set");
121 return (action() == ParCompactionManager::Copy) ||
122 (action() == ParCompactionManager::CopyAndUpdate) ||
123 (action() == ParCompactionManager::UpdateAndCopy);
124 }
125
|