comparison src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 4ca6dc0799b6 8e20ef014b08
children 7848fc12602b
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
54 #include "runtime/vmThread.hpp" 54 #include "runtime/vmThread.hpp"
55 #include "runtime/vm_operations.hpp" 55 #include "runtime/vm_operations.hpp"
56 #include "services/memoryService.hpp" 56 #include "services/memoryService.hpp"
57 #include "utilities/stack.inline.hpp" 57 #include "utilities/stack.inline.hpp"
58 58
59 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
59 60
60 HeapWord* PSScavenge::_to_space_top_before_gc = NULL; 61 HeapWord* PSScavenge::_to_space_top_before_gc = NULL;
61 int PSScavenge::_consecutive_skipped_scavenges = 0; 62 int PSScavenge::_consecutive_skipped_scavenges = 0;
62 ReferenceProcessor* PSScavenge::_ref_processor = NULL; 63 ReferenceProcessor* PSScavenge::_ref_processor = NULL;
63 CardTableExtension* PSScavenge::_card_table = NULL; 64 CardTableExtension* PSScavenge::_card_table = NULL;
464 } else { 465 } else {
465 reference_processor()->enqueue_discovered_references(NULL); 466 reference_processor()->enqueue_discovered_references(NULL);
466 } 467 }
467 } 468 }
468 469
469 GCTraceTime tm("StringTable", false, false, &_gc_timer); 470 {
470 // Unlink any dead interned Strings and process the remaining live ones. 471 GCTraceTime tm("StringTable", false, false, &_gc_timer);
471 PSScavengeRootsClosure root_closure(promotion_manager); 472 // Unlink any dead interned Strings and process the remaining live ones.
472 StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); 473 PSScavengeRootsClosure root_closure(promotion_manager);
474 StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure);
475 }
473 476
474 // Finally, flush the promotion_manager's labs, and deallocate its stacks. 477 // Finally, flush the promotion_manager's labs, and deallocate its stacks.
475 promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer); 478 promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer);
476 if (promotion_failure_occurred) { 479 if (promotion_failure_occurred) {
477 clean_up_failed_promotion(); 480 clean_up_failed_promotion();
525 counters->update_survived(survived); 528 counters->update_survived(survived);
526 counters->update_promoted(promoted); 529 counters->update_promoted(promoted);
527 counters->update_survivor_overflowed(_survivor_overflow); 530 counters->update_survivor_overflowed(_survivor_overflow);
528 } 531 }
529 532
533 size_t max_young_size = young_gen->max_size();
534
535 // Deciding a free ratio in the young generation is tricky, so if
536 // MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating
537 // that the old generation size may have been limited because of them) we
538 // should then limit our young generation size using NewRatio to have it
539 // follow the old generation size.
540 if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) {
541 max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size());
542 }
543
530 size_t survivor_limit = 544 size_t survivor_limit =
531 size_policy->max_survivor_size(young_gen->max_size()); 545 size_policy->max_survivor_size(max_young_size);
532 _tenuring_threshold = 546 _tenuring_threshold =
533 size_policy->compute_survivor_space_size_and_threshold( 547 size_policy->compute_survivor_space_size_and_threshold(
534 _survivor_overflow, 548 _survivor_overflow,
535 _tenuring_threshold, 549 _tenuring_threshold,
536 survivor_limit); 550 survivor_limit);
549 } 563 }
550 564
551 // Do call at minor collections? 565 // Do call at minor collections?
552 // Don't check if the size_policy is ready at this 566 // Don't check if the size_policy is ready at this
553 // level. Let the size_policy check that internally. 567 // level. Let the size_policy check that internally.
554 if (UseAdaptiveSizePolicy && 568 if (UseAdaptiveGenerationSizePolicyAtMinorCollection &&
555 UseAdaptiveGenerationSizePolicyAtMinorCollection &&
556 ((gc_cause != GCCause::_java_lang_system_gc) || 569 ((gc_cause != GCCause::_java_lang_system_gc) ||
557 UseAdaptiveSizePolicyWithSystemGC)) { 570 UseAdaptiveSizePolicyWithSystemGC)) {
558 571
559 // Calculate optimial free space amounts 572 // Calculate optimial free space amounts
560 assert(young_gen->max_size() > 573 assert(young_gen->max_size() >
564 577
565 size_t young_live = young_gen->used_in_bytes(); 578 size_t young_live = young_gen->used_in_bytes();
566 size_t eden_live = young_gen->eden_space()->used_in_bytes(); 579 size_t eden_live = young_gen->eden_space()->used_in_bytes();
567 size_t cur_eden = young_gen->eden_space()->capacity_in_bytes(); 580 size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
568 size_t max_old_gen_size = old_gen->max_gen_size(); 581 size_t max_old_gen_size = old_gen->max_gen_size();
569 size_t max_eden_size = young_gen->max_size() - 582 size_t max_eden_size = max_young_size -
570 young_gen->from_space()->capacity_in_bytes() - 583 young_gen->from_space()->capacity_in_bytes() -
571 young_gen->to_space()->capacity_in_bytes(); 584 young_gen->to_space()->capacity_in_bytes();
572 585
573 // Used for diagnostics 586 // Used for diagnostics
574 size_policy->clear_generation_free_space_flags(); 587 size_policy->clear_generation_free_space_flags();
846 ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing 859 ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
847 (int) ParallelGCThreads, // mt processing degree 860 (int) ParallelGCThreads, // mt processing degree
848 true, // mt discovery 861 true, // mt discovery
849 (int) ParallelGCThreads, // mt discovery degree 862 (int) ParallelGCThreads, // mt discovery degree
850 true, // atomic_discovery 863 true, // atomic_discovery
851 NULL, // header provides liveness info 864 NULL); // header provides liveness info
852 false); // next field updates do not need write barrier
853 865
854 // Cache the cardtable 866 // Cache the cardtable
855 BarrierSet* bs = Universe::heap()->barrier_set(); 867 BarrierSet* bs = Universe::heap()->barrier_set();
856 assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind"); 868 assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
857 _card_table = (CardTableExtension*)bs; 869 _card_table = (CardTableExtension*)bs;