< prev index next >

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

Print this page
rev 13453 : imported patch Atomic_add
   1 /*
   2  * Copyright (c) 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  *


 392                                 workers->active_workers());
 393   workers->run_task(&cl);
 394 }
 395 
 396 class G1ClearCardLiveDataTask : public AbstractGangTask {
 397   BitMapView _bitmap;
 398   size_t     _num_chunks;
 399   size_t     _cur_chunk;
 400 public:
 401   G1ClearCardLiveDataTask(const BitMapView& bitmap, size_t num_tasks) :
 402     AbstractGangTask("G1 Clear Card Live Data"),
 403     _bitmap(bitmap),
 404     _num_chunks(num_tasks),
 405     _cur_chunk(0) {
 406   }
 407 
 408   static size_t chunk_size() { return M; }
 409 
 410   virtual void work(uint worker_id) {
 411     while (true) {
 412       size_t to_process = Atomic::add(1, &_cur_chunk) - 1;
 413       if (to_process >= _num_chunks) {
 414         break;
 415       }
 416 
 417       BitMap::idx_t start = M * BitsPerByte * to_process;
 418       BitMap::idx_t end = MIN2(start + M * BitsPerByte, _bitmap.size());
 419       _bitmap.clear_range(start, end);
 420     }
 421   }
 422 };
 423 
 424 void G1CardLiveData::clear(WorkGang* workers) {
 425   guarantee(Universe::is_fully_initialized(), "Should not call this during initialization.");
 426 
 427   size_t const num_chunks = align_up(live_cards_bm().size_in_bytes(), G1ClearCardLiveDataTask::chunk_size()) / G1ClearCardLiveDataTask::chunk_size();
 428   uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
 429 
 430   G1ClearCardLiveDataTask cl(live_cards_bm(), num_chunks);
 431 
 432   log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks);


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


 392                                 workers->active_workers());
 393   workers->run_task(&cl);
 394 }
 395 
 396 class G1ClearCardLiveDataTask : public AbstractGangTask {
 397   BitMapView _bitmap;
 398   size_t     _num_chunks;
 399   size_t     _cur_chunk;
 400 public:
 401   G1ClearCardLiveDataTask(const BitMapView& bitmap, size_t num_tasks) :
 402     AbstractGangTask("G1 Clear Card Live Data"),
 403     _bitmap(bitmap),
 404     _num_chunks(num_tasks),
 405     _cur_chunk(0) {
 406   }
 407 
 408   static size_t chunk_size() { return M; }
 409 
 410   virtual void work(uint worker_id) {
 411     while (true) {
 412       size_t to_process = Atomic::add(1u, &_cur_chunk) - 1;
 413       if (to_process >= _num_chunks) {
 414         break;
 415       }
 416 
 417       BitMap::idx_t start = M * BitsPerByte * to_process;
 418       BitMap::idx_t end = MIN2(start + M * BitsPerByte, _bitmap.size());
 419       _bitmap.clear_range(start, end);
 420     }
 421   }
 422 };
 423 
 424 void G1CardLiveData::clear(WorkGang* workers) {
 425   guarantee(Universe::is_fully_initialized(), "Should not call this during initialization.");
 426 
 427   size_t const num_chunks = align_up(live_cards_bm().size_in_bytes(), G1ClearCardLiveDataTask::chunk_size()) / G1ClearCardLiveDataTask::chunk_size();
 428   uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
 429 
 430   G1ClearCardLiveDataTask cl(live_cards_bm(), num_chunks);
 431 
 432   log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks);


< prev index next >