src/hotspot/share/gc/g1/g1CollectionSet.cpp
changeset 49333 489f1dd40582
parent 48969 7eb296a8ce2c
child 49643 a3453bbd5418
equal deleted inserted replaced
49332:cd21aff24069 49333:489f1dd40582
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2018, 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.
    78   delete _cset_chooser;
    78   delete _cset_chooser;
    79 }
    79 }
    80 
    80 
    81 void G1CollectionSet::init_region_lengths(uint eden_cset_region_length,
    81 void G1CollectionSet::init_region_lengths(uint eden_cset_region_length,
    82                                           uint survivor_cset_region_length) {
    82                                           uint survivor_cset_region_length) {
    83   assert_at_safepoint(true);
    83   assert_at_safepoint_on_vm_thread();
    84 
    84 
    85   _eden_region_length     = eden_cset_region_length;
    85   _eden_region_length     = eden_cset_region_length;
    86   _survivor_region_length = survivor_cset_region_length;
    86   _survivor_region_length = survivor_cset_region_length;
    87 
    87 
    88   assert((size_t) young_region_length() == _collection_set_cur_length,
    88   assert((size_t) young_region_length() == _collection_set_cur_length,
   101   _recorded_rs_lengths = rs_lengths;
   101   _recorded_rs_lengths = rs_lengths;
   102 }
   102 }
   103 
   103 
   104 // Add the heap region at the head of the non-incremental collection set
   104 // Add the heap region at the head of the non-incremental collection set
   105 void G1CollectionSet::add_old_region(HeapRegion* hr) {
   105 void G1CollectionSet::add_old_region(HeapRegion* hr) {
   106   assert_at_safepoint(true);
   106   assert_at_safepoint_on_vm_thread();
   107 
   107 
   108   assert(_inc_build_state == Active, "Precondition");
   108   assert(_inc_build_state == Active, "Precondition");
   109   assert(hr->is_old(), "the region should be old");
   109   assert(hr->is_old(), "the region should be old");
   110 
   110 
   111   assert(!hr->in_collection_set(), "should not already be in the CSet");
   111   assert(!hr->in_collection_set(), "should not already be in the CSet");
   165   _inc_recorded_rs_lengths_diffs = 0;
   165   _inc_recorded_rs_lengths_diffs = 0;
   166   _inc_predicted_elapsed_time_ms_diffs = 0.0;
   166   _inc_predicted_elapsed_time_ms_diffs = 0.0;
   167 }
   167 }
   168 
   168 
   169 void G1CollectionSet::clear() {
   169 void G1CollectionSet::clear() {
   170   assert_at_safepoint(true);
   170   assert_at_safepoint_on_vm_thread();
   171   _collection_set_cur_length = 0;
   171   _collection_set_cur_length = 0;
   172 }
   172 }
   173 
   173 
   174 void G1CollectionSet::iterate(HeapRegionClosure* cl) const {
   174 void G1CollectionSet::iterate(HeapRegionClosure* cl) const {
   175   iterate_from(cl, 0, 1);
   175   iterate_from(cl, 0, 1);
   312 
   312 
   313   bool valid() const { return _valid; }
   313   bool valid() const { return _valid; }
   314 };
   314 };
   315 
   315 
   316 bool G1CollectionSet::verify_young_ages() {
   316 bool G1CollectionSet::verify_young_ages() {
   317   assert_at_safepoint(true);
   317   assert_at_safepoint_on_vm_thread();
   318 
   318 
   319   G1VerifyYoungAgesClosure cl;
   319   G1VerifyYoungAgesClosure cl;
   320   iterate(&cl);
   320   iterate(&cl);
   321 
   321 
   322   if (!cl.valid()) {
   322   if (!cl.valid()) {
   539     return false;
   539     return false;
   540   }
   540   }
   541 };
   541 };
   542 
   542 
   543 void G1CollectionSet::verify_young_cset_indices() const {
   543 void G1CollectionSet::verify_young_cset_indices() const {
   544   assert_at_safepoint(true);
   544   assert_at_safepoint_on_vm_thread();
   545 
   545 
   546   G1VerifyYoungCSetIndicesClosure cl(_collection_set_cur_length);
   546   G1VerifyYoungCSetIndicesClosure cl(_collection_set_cur_length);
   547   iterate(&cl);
   547   iterate(&cl);
   548 }
   548 }
   549 #endif
   549 #endif