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 #include "precompiled.hpp"
25 #include "gc/shared/gcArguments.hpp"
26 #include "gc/shared/oopStorage.hpp"
27 #include "gc/z/zAddress.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "gc/z/zHeap.inline.hpp"
30 #include "gc/z/zHeapIterator.hpp"
31 #include "gc/z/zList.inline.hpp"
32 #include "gc/z/zLock.inline.hpp"
33 #include "gc/z/zMark.inline.hpp"
34 #include "gc/z/zOopClosures.inline.hpp"
35 #include "gc/z/zPage.inline.hpp"
36 #include "gc/z/zPageTable.inline.hpp"
37 #include "gc/z/zRelocationSet.inline.hpp"
38 #include "gc/z/zResurrection.hpp"
39 #include "gc/z/zRootsIterator.hpp"
40 #include "gc/z/zStat.hpp"
41 #include "gc/z/zTask.hpp"
42 #include "gc/z/zThread.hpp"
43 #include "gc/z/zTracer.inline.hpp"
44 #include "gc/z/zVerify.hpp"
45 #include "gc/z/zVirtualMemory.inline.hpp"
46 #include "gc/z/zWorkers.inline.hpp"
47 #include "logging/log.hpp"
369 _reference_processor.process_references();
370
371 // Process concurrent weak roots
372 _weak_roots_processor.process_concurrent_weak_roots();
373
374 // Unload unused classes and code
375 _unload.unload();
376
377 // Unblock resurrection of weak/phantom references
378 ZResurrection::unblock();
379
380 // Enqueue Soft/Weak/Final/PhantomReferences. Note that this
381 // must be done after unblocking resurrection. Otherwise the
382 // Finalizer thread could call Reference.get() on the Finalizers
383 // that were just enqueued, which would incorrectly return null
384 // during the resurrection block window, since such referents
385 // are only Finalizable marked.
386 _reference_processor.enqueue_references();
387 }
388
389 void ZHeap::select_relocation_set() {
390 // Do not allow pages to be deleted
391 _page_allocator.enable_deferred_delete();
392
393 // Register relocatable pages with selector
394 ZRelocationSetSelector selector;
395 ZPageTableIterator pt_iter(&_page_table);
396 for (ZPage* page; pt_iter.next(&page);) {
397 if (!page->is_relocatable()) {
398 // Not relocatable, don't register
399 continue;
400 }
401
402 if (page->is_marked()) {
403 // Register live page
404 selector.register_live_page(page);
405 } else {
406 // Register garbage page
407 selector.register_garbage_page(page);
408
409 // Reclaim page immediately
410 free_page(page, true /* reclaimed */);
411 }
412 }
413
414 // Allow pages to be deleted
415 _page_allocator.disable_deferred_delete();
416
417 // Select pages to relocate
418 selector.select(&_relocation_set);
419
420 // Setup forwarding table
421 ZRelocationSetIterator rs_iter(&_relocation_set);
422 for (ZForwarding* forwarding; rs_iter.next(&forwarding);) {
423 _forwarding_table.insert(forwarding);
424 }
425
426 // Update statistics
427 ZStatRelocation::set_at_select_relocation_set(selector.relocating());
428 ZStatHeap::set_at_select_relocation_set(selector.live(),
429 selector.garbage(),
430 reclaimed());
431 }
432
433 void ZHeap::reset_relocation_set() {
434 // Reset forwarding table
435 ZRelocationSetIterator iter(&_relocation_set);
|
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 #include "precompiled.hpp"
25 #include "gc/shared/gcArguments.hpp"
26 #include "gc/shared/oopStorage.hpp"
27 #include "gc/z/zAddress.hpp"
28 #include "gc/z/zArray.inline.hpp"
29 #include "gc/z/zGlobals.hpp"
30 #include "gc/z/zHeap.inline.hpp"
31 #include "gc/z/zHeapIterator.hpp"
32 #include "gc/z/zList.inline.hpp"
33 #include "gc/z/zLock.inline.hpp"
34 #include "gc/z/zMark.inline.hpp"
35 #include "gc/z/zOopClosures.inline.hpp"
36 #include "gc/z/zPage.inline.hpp"
37 #include "gc/z/zPageTable.inline.hpp"
38 #include "gc/z/zRelocationSet.inline.hpp"
39 #include "gc/z/zResurrection.hpp"
40 #include "gc/z/zRootsIterator.hpp"
41 #include "gc/z/zStat.hpp"
42 #include "gc/z/zTask.hpp"
43 #include "gc/z/zThread.hpp"
44 #include "gc/z/zTracer.inline.hpp"
45 #include "gc/z/zVerify.hpp"
46 #include "gc/z/zVirtualMemory.inline.hpp"
47 #include "gc/z/zWorkers.inline.hpp"
48 #include "logging/log.hpp"
370 _reference_processor.process_references();
371
372 // Process concurrent weak roots
373 _weak_roots_processor.process_concurrent_weak_roots();
374
375 // Unload unused classes and code
376 _unload.unload();
377
378 // Unblock resurrection of weak/phantom references
379 ZResurrection::unblock();
380
381 // Enqueue Soft/Weak/Final/PhantomReferences. Note that this
382 // must be done after unblocking resurrection. Otherwise the
383 // Finalizer thread could call Reference.get() on the Finalizers
384 // that were just enqueued, which would incorrectly return null
385 // during the resurrection block window, since such referents
386 // are only Finalizable marked.
387 _reference_processor.enqueue_references();
388 }
389
390 class ZHeapReclaimPagesTask : public ZTask {
391 private:
392 ZArrayParallelIterator<ZPage*> _iter;
393
394 public:
395 ZHeapReclaimPagesTask(ZArray<ZPage*>* pages) :
396 ZTask("ZHeapReclaimPagesTask"),
397 _iter(pages) {}
398
399 virtual void work() {
400 for (ZPage* page; _iter.next(&page);) {
401 ZHeap::heap()->free_page(page, true /* reclaimed */);
402 }
403 }
404 };
405
406 void ZHeap::select_relocation_set() {
407 // Do not allow pages to be deleted
408 _page_allocator.enable_deferred_delete();
409
410 // Register relocatable pages with selector
411 ZRelocationSetSelector selector;
412 ZPageTableIterator pt_iter(&_page_table);
413 for (ZPage* page; pt_iter.next(&page);) {
414 if (!page->is_relocatable()) {
415 // Not relocatable, don't register
416 continue;
417 }
418
419 if (page->is_marked()) {
420 // Register live page
421 selector.register_live_page(page);
422 } else {
423 // Register reclaimable page
424 selector.register_reclaimable_page(page);
425 }
426 }
427
428 // Allow pages to be deleted
429 _page_allocator.disable_deferred_delete();
430
431 // Free reclaimable page
432 ZHeapReclaimPagesTask task(selector.reclaimable());
433 _workers.run_concurrent(&task);
434
435 // Select pages to relocate
436 selector.select(&_relocation_set);
437
438 // Setup forwarding table
439 ZRelocationSetIterator rs_iter(&_relocation_set);
440 for (ZForwarding* forwarding; rs_iter.next(&forwarding);) {
441 _forwarding_table.insert(forwarding);
442 }
443
444 // Update statistics
445 ZStatRelocation::set_at_select_relocation_set(selector.relocating());
446 ZStatHeap::set_at_select_relocation_set(selector.live(),
447 selector.garbage(),
448 reclaimed());
449 }
450
451 void ZHeap::reset_relocation_set() {
452 // Reset forwarding table
453 ZRelocationSetIterator iter(&_relocation_set);
|