src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp

Print this page


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







  25 // The CollectedHeap type requires subtypes to implement a method
  26 // "block_start".  For some subtypes, notably generational
  27 // systems using card-table-based write barriers, the efficiency of this
  28 // operation may be important.  Implementations of the "BlockOffsetArray"
  29 // class may be useful in providing such efficient implementations.
  30 //
  31 // While generally mirroring the structure of the BOT for GenCollectedHeap,
  32 // the following types are tailored more towards G1's uses; these should,
  33 // however, be merged back into a common BOT to avoid code duplication
  34 // and reduce maintenance overhead.
  35 //
  36 //    G1BlockOffsetTable (abstract)
  37 //    -- G1BlockOffsetArray                (uses G1BlockOffsetSharedArray)
  38 //       -- G1BlockOffsetArrayContigSpace
  39 //
  40 // A main impediment to the consolidation of this code might be the
  41 // effect of making some of the block_start*() calls non-const as
  42 // below. Whether that might adversely affect performance optimizations
  43 // that compilers might normally perform in the case of non-G1
  44 // collectors needs to be carefully investigated prior to any such


 468 
 469   // Return the next threshold, the point at which the table should be
 470   // updated.
 471   HeapWord* threshold() const { return _next_offset_threshold; }
 472 
 473   // These must be guaranteed to work properly (i.e., do nothing)
 474   // when "blk_start" ("blk" for second version) is "NULL".  In this
 475   // implementation, that's true because NULL is represented as 0, and thus
 476   // never exceeds the "_next_offset_threshold".
 477   void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
 478     if (blk_end > _next_offset_threshold)
 479       alloc_block_work1(blk_start, blk_end);
 480   }
 481   void alloc_block(HeapWord* blk, size_t size) {
 482      alloc_block(blk, blk+size);
 483   }
 484 
 485   HeapWord* block_start_unsafe(const void* addr);
 486   HeapWord* block_start_unsafe_const(const void* addr) const;
 487 };


   1 /*
   2  * Copyright (c) 2001, 2010, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
  27 
  28 #include "memory/memRegion.hpp"
  29 #include "runtime/virtualspace.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 // The CollectedHeap type requires subtypes to implement a method
  33 // "block_start".  For some subtypes, notably generational
  34 // systems using card-table-based write barriers, the efficiency of this
  35 // operation may be important.  Implementations of the "BlockOffsetArray"
  36 // class may be useful in providing such efficient implementations.
  37 //
  38 // While generally mirroring the structure of the BOT for GenCollectedHeap,
  39 // the following types are tailored more towards G1's uses; these should,
  40 // however, be merged back into a common BOT to avoid code duplication
  41 // and reduce maintenance overhead.
  42 //
  43 //    G1BlockOffsetTable (abstract)
  44 //    -- G1BlockOffsetArray                (uses G1BlockOffsetSharedArray)
  45 //       -- G1BlockOffsetArrayContigSpace
  46 //
  47 // A main impediment to the consolidation of this code might be the
  48 // effect of making some of the block_start*() calls non-const as
  49 // below. Whether that might adversely affect performance optimizations
  50 // that compilers might normally perform in the case of non-G1
  51 // collectors needs to be carefully investigated prior to any such


 475 
 476   // Return the next threshold, the point at which the table should be
 477   // updated.
 478   HeapWord* threshold() const { return _next_offset_threshold; }
 479 
 480   // These must be guaranteed to work properly (i.e., do nothing)
 481   // when "blk_start" ("blk" for second version) is "NULL".  In this
 482   // implementation, that's true because NULL is represented as 0, and thus
 483   // never exceeds the "_next_offset_threshold".
 484   void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
 485     if (blk_end > _next_offset_threshold)
 486       alloc_block_work1(blk_start, blk_end);
 487   }
 488   void alloc_block(HeapWord* blk, size_t size) {
 489      alloc_block(blk, blk+size);
 490   }
 491 
 492   HeapWord* block_start_unsafe(const void* addr);
 493   HeapWord* block_start_unsafe_const(const void* addr) const;
 494 };
 495 
 496 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP