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

Print this page


   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  *


 491   if (_claims != NULL) {
 492     FREE_C_HEAP_ARRAY(uint, _claims);
 493   }
 494 }
 495 
 496 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 497   assert(worker_id < _n_workers, "Invalid worker_id.");
 498   return _n_regions * worker_id / _n_workers;
 499 }
 500 
 501 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 502   assert(region_index < _n_regions, "Invalid index.");
 503   return _claims[region_index] == Claimed;
 504 }
 505 
 506 bool HeapRegionClaimer::claim_region(uint region_index) {
 507   assert(region_index < _n_regions, "Invalid index.");
 508   uint old_val = Atomic::cmpxchg(Claimed, &_claims[region_index], Unclaimed);
 509   return old_val == Unclaimed;
 510 }








   1 /*
   2  * Copyright (c) 2001, 2017, 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  *


 491   if (_claims != NULL) {
 492     FREE_C_HEAP_ARRAY(uint, _claims);
 493   }
 494 }
 495 
 496 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 497   assert(worker_id < _n_workers, "Invalid worker_id.");
 498   return _n_regions * worker_id / _n_workers;
 499 }
 500 
 501 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 502   assert(region_index < _n_regions, "Invalid index.");
 503   return _claims[region_index] == Claimed;
 504 }
 505 
 506 bool HeapRegionClaimer::claim_region(uint region_index) {
 507   assert(region_index < _n_regions, "Invalid index.");
 508   uint old_val = Atomic::cmpxchg(Claimed, &_claims[region_index], Unclaimed);
 509   return old_val == Unclaimed;
 510 }
 511 
 512 void G1ParallelizeByRegionsTask::all_heap_regions_work(HeapRegionClosure* cl,
 513                                                        uint worker_id,
 514                                                        bool concurrent) {
 515   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 516   g1h->heap_region_par_iterate(cl, worker_id, &_hrclaimer, concurrent);
 517 }
 518