< prev index next >

src/share/vm/gc/parallel/psParallelCompact.hpp

Print this page
rev 13430 : imported patch fix_calls
rev 13432 : imported patch fix_claim
   1 /*
   2  * Copyright (c) 2005, 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  *


 576 }
 577 
 578 inline void ParallelCompactData::RegionData::add_live_obj(size_t words)
 579 {
 580   assert(words <= (size_t)los_mask - live_obj_size(), "overflow");
 581   Atomic::add((int) words, (volatile int*) &_dc_and_los);
 582 }
 583 
 584 inline void ParallelCompactData::RegionData::set_highest_ref(HeapWord* addr)
 585 {
 586 #ifdef ASSERT
 587   HeapWord* tmp = _highest_ref;
 588   while (addr > tmp) {
 589     tmp = (HeapWord*)Atomic::cmpxchg_ptr(addr, &_highest_ref, tmp);
 590   }
 591 #endif  // #ifdef ASSERT
 592 }
 593 
 594 inline bool ParallelCompactData::RegionData::claim()
 595 {
 596   const int los = (int) live_obj_size();
 597   const int old = Atomic::cmpxchg(dc_claimed | los,
 598                                   (volatile int*) &_dc_and_los, los);
 599   return old == los;
 600 }
 601 
 602 inline ParallelCompactData::RegionData*
 603 ParallelCompactData::region(size_t region_idx) const
 604 {
 605   assert(region_idx <= region_count(), "bad arg");
 606   return _region_data + region_idx;
 607 }
 608 
 609 inline size_t
 610 ParallelCompactData::region(const RegionData* const region_ptr) const
 611 {
 612   assert(region_ptr >= _region_data, "bad arg");
 613   assert(region_ptr <= _region_data + region_count(), "bad arg");
 614   return pointer_delta(region_ptr, _region_data, sizeof(RegionData));
 615 }
 616 
 617 inline ParallelCompactData::BlockData*
 618 ParallelCompactData::block(size_t n) const {


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


 576 }
 577 
 578 inline void ParallelCompactData::RegionData::add_live_obj(size_t words)
 579 {
 580   assert(words <= (size_t)los_mask - live_obj_size(), "overflow");
 581   Atomic::add((int) words, (volatile int*) &_dc_and_los);
 582 }
 583 
 584 inline void ParallelCompactData::RegionData::set_highest_ref(HeapWord* addr)
 585 {
 586 #ifdef ASSERT
 587   HeapWord* tmp = _highest_ref;
 588   while (addr > tmp) {
 589     tmp = (HeapWord*)Atomic::cmpxchg_ptr(addr, &_highest_ref, tmp);
 590   }
 591 #endif  // #ifdef ASSERT
 592 }
 593 
 594 inline bool ParallelCompactData::RegionData::claim()
 595 {
 596   const region_sz_t los = static_cast<region_sz_t>(live_obj_size());
 597   const region_sz_t old = Atomic::cmpxchg(dc_claimed | los, &_dc_and_los, los);

 598   return old == los;
 599 }
 600 
 601 inline ParallelCompactData::RegionData*
 602 ParallelCompactData::region(size_t region_idx) const
 603 {
 604   assert(region_idx <= region_count(), "bad arg");
 605   return _region_data + region_idx;
 606 }
 607 
 608 inline size_t
 609 ParallelCompactData::region(const RegionData* const region_ptr) const
 610 {
 611   assert(region_ptr >= _region_data, "bad arg");
 612   assert(region_ptr <= _region_data + region_count(), "bad arg");
 613   return pointer_delta(region_ptr, _region_data, sizeof(RegionData));
 614 }
 615 
 616 inline ParallelCompactData::BlockData*
 617 ParallelCompactData::block(size_t n) const {


< prev index next >