< prev index next >

src/share/vm/gc/g1/heapRegionManager.cpp

Print this page
rev 11970 : imported patch heap_region_manager_volatiles
   1 /*
   2  * Copyright (c) 2001, 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  *


 464     prev_committed = true;
 465     prev_end = hr->end();
 466   }
 467   for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
 468     guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
 469   }
 470 
 471   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
 472   _free_list.verify();
 473 }
 474 
 475 #ifndef PRODUCT
 476 void HeapRegionManager::verify_optional() {
 477   verify();
 478 }
 479 #endif // PRODUCT
 480 
 481 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
 482     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
 483   assert(n_workers > 0, "Need at least one worker.");
 484   _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
 485   memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);

 486 }
 487 
 488 HeapRegionClaimer::~HeapRegionClaimer() {
 489   if (_claims != NULL) {
 490     FREE_C_HEAP_ARRAY(uint, _claims);
 491   }
 492 }
 493 
 494 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 495   assert(worker_id < _n_workers, "Invalid worker_id.");
 496   return _n_regions * worker_id / _n_workers;
 497 }
 498 
 499 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 500   assert(region_index < _n_regions, "Invalid index.");
 501   return _claims[region_index] == Claimed;
 502 }
 503 
 504 bool HeapRegionClaimer::claim_region(uint region_index) {
 505   assert(region_index < _n_regions, "Invalid index.");
   1 /*
   2  * Copyright (c) 2001, 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  *


 464     prev_committed = true;
 465     prev_end = hr->end();
 466   }
 467   for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
 468     guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
 469   }
 470 
 471   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
 472   _free_list.verify();
 473 }
 474 
 475 #ifndef PRODUCT
 476 void HeapRegionManager::verify_optional() {
 477   verify();
 478 }
 479 #endif // PRODUCT
 480 
 481 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
 482     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
 483   assert(n_workers > 0, "Need at least one worker.");
 484   uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
 485   memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
 486   _claims = new_claims;
 487 }
 488 
 489 HeapRegionClaimer::~HeapRegionClaimer() {
 490   if (_claims != NULL) {
 491     FREE_C_HEAP_ARRAY(uint, _claims);
 492   }
 493 }
 494 
 495 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 496   assert(worker_id < _n_workers, "Invalid worker_id.");
 497   return _n_regions * worker_id / _n_workers;
 498 }
 499 
 500 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 501   assert(region_index < _n_regions, "Invalid index.");
 502   return _claims[region_index] == Claimed;
 503 }
 504 
 505 bool HeapRegionClaimer::claim_region(uint region_index) {
 506   assert(region_index < _n_regions, "Invalid index.");
< prev index next >