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

Thu, 21 Aug 2014 11:47:10 +0200

author
tschatzl
date
Thu, 21 Aug 2014 11:47:10 +0200
changeset 7051
1f1d373cd044
child 7053
7b2fc3129653
permissions
-rw-r--r--

8038423: G1: Decommit memory within heap
Summary: Allow G1 to decommit memory of arbitrary regions within the heap and their associated auxiliary data structures card table, BOT, hot card cache, and mark bitmaps.
Reviewed-by: mgerdin, brutisso, jwilhelm

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@7051 29 #include "utilities/debug.hpp"
tschatzl@7051 30
tschatzl@7051 31 class G1MappingChangedListener VALUE_OBJ_CLASS_SPEC {
tschatzl@7051 32 public:
tschatzl@7051 33 // Fired after commit of the memory, i.e. the memory this listener is registered
tschatzl@7051 34 // for can be accessed.
tschatzl@7051 35 virtual void on_commit(uint start_idx, size_t num_regions) = 0;
tschatzl@7051 36 };
tschatzl@7051 37
tschatzl@7051 38 // Maps region based commit/uncommit requests to the underlying page sized virtual
tschatzl@7051 39 // space.
tschatzl@7051 40 class G1RegionToSpaceMapper : public CHeapObj<mtGC> {
tschatzl@7051 41 private:
tschatzl@7051 42 G1MappingChangedListener* _listener;
tschatzl@7051 43 protected:
tschatzl@7051 44 // Backing storage.
tschatzl@7051 45 G1PageBasedVirtualSpace _storage;
tschatzl@7051 46 size_t _commit_granularity;
tschatzl@7051 47 size_t _region_granularity;
tschatzl@7051 48 // Mapping management
tschatzl@7051 49 BitMap _commit_map;
tschatzl@7051 50
tschatzl@7051 51 G1RegionToSpaceMapper(ReservedSpace rs, size_t commit_granularity, size_t region_granularity, MemoryType type);
tschatzl@7051 52
tschatzl@7051 53 void fire_on_commit(uint start_idx, size_t num_regions);
tschatzl@7051 54 public:
tschatzl@7051 55 MemRegion reserved() { return _storage.reserved(); }
tschatzl@7051 56
tschatzl@7051 57 void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
tschatzl@7051 58
tschatzl@7051 59 virtual ~G1RegionToSpaceMapper() {
tschatzl@7051 60 _commit_map.resize(0, /* in_resource_area */ false);
tschatzl@7051 61 }
tschatzl@7051 62
tschatzl@7051 63 bool is_committed(uintptr_t idx) const {
tschatzl@7051 64 return _commit_map.at(idx);
tschatzl@7051 65 }
tschatzl@7051 66
tschatzl@7051 67 virtual void commit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
tschatzl@7051 68 virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
tschatzl@7051 69
tschatzl@7051 70 // Creates an appropriate G1RegionToSpaceMapper for the given parameters.
tschatzl@7051 71 // The byte_translation_factor defines how many bytes in a region correspond to
tschatzl@7051 72 // a single byte in the data structure this mapper is for.
tschatzl@7051 73 // Eg. in the card table, this value corresponds to the size a single card
tschatzl@7051 74 // table entry corresponds to.
tschatzl@7051 75 static G1RegionToSpaceMapper* create_mapper(ReservedSpace rs,
tschatzl@7051 76 size_t os_commit_granularity,
tschatzl@7051 77 size_t region_granularity,
tschatzl@7051 78 size_t byte_translation_factor,
tschatzl@7051 79 MemoryType type);
tschatzl@7051 80 };
tschatzl@7051 81
tschatzl@7051 82 #endif /* SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP */

mercurial