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

changeset 7051
1f1d373cd044
child 7053
7b2fc3129653
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.hpp	Thu Aug 21 11:47:10 2014 +0200
     1.3 @@ -0,0 +1,82 @@
     1.4 +/*
     1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP
    1.30 +
    1.31 +#include "gc_implementation/g1/g1PageBasedVirtualSpace.hpp"
    1.32 +#include "utilities/debug.hpp"
    1.33 +
    1.34 +class G1MappingChangedListener VALUE_OBJ_CLASS_SPEC {
    1.35 + public:
    1.36 +  // Fired after commit of the memory, i.e. the memory this listener is registered
    1.37 +  // for can be accessed.
    1.38 +  virtual void on_commit(uint start_idx, size_t num_regions) = 0;
    1.39 +};
    1.40 +
    1.41 +// Maps region based commit/uncommit requests to the underlying page sized virtual
    1.42 +// space.
    1.43 +class G1RegionToSpaceMapper : public CHeapObj<mtGC> {
    1.44 + private:
    1.45 +  G1MappingChangedListener* _listener;
    1.46 + protected:
    1.47 +  // Backing storage.
    1.48 +  G1PageBasedVirtualSpace _storage;
    1.49 +  size_t _commit_granularity;
    1.50 +  size_t _region_granularity;
    1.51 +  // Mapping management
    1.52 +  BitMap _commit_map;
    1.53 +
    1.54 +  G1RegionToSpaceMapper(ReservedSpace rs, size_t commit_granularity, size_t region_granularity, MemoryType type);
    1.55 +
    1.56 +  void fire_on_commit(uint start_idx, size_t num_regions);
    1.57 + public:
    1.58 +  MemRegion reserved() { return _storage.reserved(); }
    1.59 +
    1.60 +  void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
    1.61 +
    1.62 +  virtual ~G1RegionToSpaceMapper() {
    1.63 +    _commit_map.resize(0, /* in_resource_area */ false);
    1.64 +  }
    1.65 +
    1.66 +  bool is_committed(uintptr_t idx) const {
    1.67 +    return _commit_map.at(idx);
    1.68 +  }
    1.69 +
    1.70 +  virtual void commit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
    1.71 +  virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions = 1) = 0;
    1.72 +
    1.73 +  // Creates an appropriate G1RegionToSpaceMapper for the given parameters.
    1.74 +  // The byte_translation_factor defines how many bytes in a region correspond to
    1.75 +  // a single byte in the data structure this mapper is for.
    1.76 +  // Eg. in the card table, this value corresponds to the size a single card
    1.77 +  // table entry corresponds to.
    1.78 +  static G1RegionToSpaceMapper* create_mapper(ReservedSpace rs,
    1.79 +                                              size_t os_commit_granularity,
    1.80 +                                              size_t region_granularity,
    1.81 +                                              size_t byte_translation_factor,
    1.82 +                                              MemoryType type);
    1.83 +};
    1.84 +
    1.85 +#endif /* SHARE_VM_GC_IMPLEMENTATION_G1_G1REGIONTOSPACEMAPPER_HPP */

mercurial