1 /*
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
105 guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
106 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
107 guarantee(_region_array != NULL, "Could not allocate region_array");
108
109 // Create and register the ParCompactionManager(s) for the worker threads.
110 for(uint i=0; i<parallel_gc_threads; i++) {
111 _manager_array[i] = new ParCompactionManager();
112 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
113 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
114 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
115 region_array()->register_queue(i, region_list(i));
116 }
117
118 // The VMThread gets its own ParCompactionManager, which is not available
119 // for work stealing.
120 _manager_array[parallel_gc_threads] = new ParCompactionManager();
121 guarantee(_manager_array[parallel_gc_threads] != NULL,
122 "Could not create ParCompactionManager");
123 assert(PSParallelCompact::gc_task_manager()->workers() != 0,
124 "Not initialized?");
125 }
126
127 int ParCompactionManager::pop_recycled_stack_index() {
128 assert(_recycled_bottom <= _recycled_top, "list is empty");
129 // Get the next available index
130 if (_recycled_bottom < _recycled_top) {
131 uint cur, next, last;
132 do {
133 cur = _recycled_bottom;
134 next = cur + 1;
135 last = Atomic::cmpxchg(next, &_recycled_bottom, cur);
136 } while (cur != last);
137 return _recycled_stack_index[next];
138 } else {
139 return -1;
140 }
141 }
142
143 void ParCompactionManager::push_recycled_stack_index(uint v) {
144 // Get the next available index
|
1 /*
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
105 guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
106 _region_array = new RegionTaskQueueSet(parallel_gc_threads);
107 guarantee(_region_array != NULL, "Could not allocate region_array");
108
109 // Create and register the ParCompactionManager(s) for the worker threads.
110 for(uint i=0; i<parallel_gc_threads; i++) {
111 _manager_array[i] = new ParCompactionManager();
112 guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
113 stack_array()->register_queue(i, _manager_array[i]->marking_stack());
114 _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
115 region_array()->register_queue(i, region_list(i));
116 }
117
118 // The VMThread gets its own ParCompactionManager, which is not available
119 // for work stealing.
120 _manager_array[parallel_gc_threads] = new ParCompactionManager();
121 guarantee(_manager_array[parallel_gc_threads] != NULL,
122 "Could not create ParCompactionManager");
123 assert(PSParallelCompact::gc_task_manager()->workers() != 0,
124 "Not initialized?");
125 }
126
127 void ParCompactionManager::reset_cache_for_bitmap() {
128 uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
129 for (uint i=0; i<=parallel_gc_threads; i++) {
130 _manager_array[i]->set_last_query_begin(NULL);
131 }
132 }
133
134 int ParCompactionManager::pop_recycled_stack_index() {
135 assert(_recycled_bottom <= _recycled_top, "list is empty");
136 // Get the next available index
137 if (_recycled_bottom < _recycled_top) {
138 uint cur, next, last;
139 do {
140 cur = _recycled_bottom;
141 next = cur + 1;
142 last = Atomic::cmpxchg(next, &_recycled_bottom, cur);
143 } while (cur != last);
144 return _recycled_stack_index[next];
145 } else {
146 return -1;
147 }
148 }
149
150 void ParCompactionManager::push_recycled_stack_index(uint v) {
151 // Get the next available index
|