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

Tue, 26 Aug 2014 09:36:53 +0200

author
tschatzl
date
Tue, 26 Aug 2014 09:36:53 +0200
changeset 7091
a8ea2f110d87
parent 7053
7b2fc3129653
child 7257
e7d0505c8a30
permissions
-rw-r--r--

8054819: Rename HeapRegionSeq to HeapRegionManager
Reviewed-by: jwilhelm, jmasa

tschatzl@7051 1 /*
tschatzl@7051 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
tschatzl@7051 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tschatzl@7051 4 *
tschatzl@7051 5 * This code is free software; you can redistribute it and/or modify it
tschatzl@7051 6 * under the terms of the GNU General Public License version 2 only, as
tschatzl@7051 7 * published by the Free Software Foundation.
tschatzl@7051 8 *
tschatzl@7051 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tschatzl@7051 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tschatzl@7051 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tschatzl@7051 12 * version 2 for more details (a copy is included in the LICENSE file that
tschatzl@7051 13 * accompanied this code).
tschatzl@7051 14 *
tschatzl@7051 15 * You should have received a copy of the GNU General Public License version
tschatzl@7051 16 * 2 along with this work; if not, write to the Free Software Foundation,
tschatzl@7051 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tschatzl@7051 18 *
tschatzl@7051 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tschatzl@7051 20 * or visit www.oracle.com if you need additional information or have any
tschatzl@7051 21 * questions.
tschatzl@7051 22 *
tschatzl@7051 23 */
tschatzl@7051 24
tschatzl@7051 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP
tschatzl@7051 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP
tschatzl@7051 27
tschatzl@7051 28 #include "gc_implementation/g1/g1PageBasedVirtualSpace.hpp"
tschatzl@7053 29 #include "memory/allocation.hpp"
tschatzl@7051 30 #include "utilities/debug.hpp"
tschatzl@7051 31
tschatzl@7051 32 class G1MappingChangedListener VALUE_OBJ_CLASS_SPEC {
tschatzl@7051 33 public:
tschatzl@7051 34 // Fired after commit of the memory, i.e. the memory this listener is registered
tschatzl@7051 35 // for can be accessed.
tschatzl@7051 36 virtual void on_commit(uint start_idx, size_t num_regions) = 0;
tschatzl@7051 37 };
tschatzl@7051 38
tschatzl@7051 39 // Maps region based commit/uncommit requests to the underlying page sized virtual
tschatzl@7051 40 // space.
tschatzl@7051 41 class G1RegionToSpaceMapper : public CHeapObj<mtGC> {
tschatzl@7051 42 private:
tschatzl@7051 43 G1MappingChangedListener* _listener;
tschatzl@7051 44 protected:
tschatzl@7051 45 // Backing storage.
tschatzl@7051 46 G1PageBasedVirtualSpace _storage;
tschatzl@7051 47 size_t _commit_granularity;
tschatzl@7051 48 size_t _region_granularity;
tschatzl@7051 49 // Mapping management
tschatzl@7051 50 BitMap _commit_map;
tschatzl@7051 51
tschatzl@7051 52 G1RegionToSpaceMapper(ReservedSpace rs, size_t commit_granularity, size_t region_granularity, MemoryType type);
tschatzl@7051 53
tschatzl@7051 54 void fire_on_commit(uint start_idx, size_t num_regions);
tschatzl@7051 55 public:
tschatzl@7051 56 MemRegion reserved() { return _storage.reserved(); }
tschatzl@7051 57
tschatzl@7051 58 void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
tschatzl@7051 59
tschatzl@7051 60 virtual ~G1RegionToSpaceMapper() {
tschatzl@7051 61 _commit_map.resize(0, /* in_resource_area */ false);
tschatzl@7051 62 }
tschatzl@7051 63
tschatzl@7051 64 bool is_committed(uintptr_t idx) const {
tschatzl@7051 65 return _commit_map.at(idx);
tschatzl@7051 66 }
tschatzl@7051 67
tschatzl@7051 68 virtual void commit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
tschatzl@7051 69 virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
tschatzl@7051 70
tschatzl@7051 71 // Creates an appropriate G1RegionToSpaceMapper for the given parameters.
tschatzl@7051 72 // The byte_translation_factor defines how many bytes in a region correspond to
tschatzl@7051 73 // a single byte in the data structure this mapper is for.
tschatzl@7051 74 // Eg. in the card table, this value corresponds to the size a single card
tschatzl@7051 75 // table entry corresponds to.
tschatzl@7051 76 static G1RegionToSpaceMapper* create_mapper(ReservedSpace rs,
tschatzl@7051 77 size_t os_commit_granularity,
tschatzl@7051 78 size_t region_granularity,
tschatzl@7051 79 size_t byte_translation_factor,
tschatzl@7051 80 MemoryType type);
tschatzl@7051 81 };
tschatzl@7051 82
tschatzl@7051 83 #endif /* SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP */

mercurial