1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp Thu Aug 21 11:47:10 2014 +0200 1.3 @@ -0,0 +1,111 @@ 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_G1PAGEBASEDVIRTUALSPACE_HPP 1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP 1.30 + 1.31 +#include "memory/allocation.hpp" 1.32 +#include "memory/memRegion.hpp" 1.33 +#include "runtime/virtualspace.hpp" 1.34 +#include "utilities/bitMap.hpp" 1.35 + 1.36 +// Virtual space management helper for a virtual space with an OS page allocation 1.37 +// granularity. 1.38 +// (De-)Allocation requests are always OS page aligned by passing a page index 1.39 +// and multiples of pages. 1.40 +// The implementation gives an error when trying to commit or uncommit pages that 1.41 +// have already been committed or uncommitted. 1.42 +class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC { 1.43 + friend class VMStructs; 1.44 + private: 1.45 + // Reserved area addresses. 1.46 + char* _low_boundary; 1.47 + char* _high_boundary; 1.48 + 1.49 + // The commit/uncommit granularity in bytes. 1.50 + size_t _page_size; 1.51 + 1.52 + // Bitmap used for verification of commit/uncommit operations. 1.53 + BitMap _committed; 1.54 + 1.55 + // Indicates that the entire space has been committed and pinned in memory, 1.56 + // os::commit_memory() or os::uncommit_memory() have no function. 1.57 + bool _special; 1.58 + 1.59 + // Indicates whether the committed space should be executable. 1.60 + bool _executable; 1.61 + 1.62 + // Returns the index of the page which contains the given address. 1.63 + uintptr_t addr_to_page_index(char* addr) const; 1.64 + // Returns the address of the given page index. 1.65 + char* page_start(uintptr_t index); 1.66 + // Returns the byte size of the given number of pages. 1.67 + size_t byte_size_for_pages(size_t num); 1.68 + 1.69 + // Returns true if the entire area is backed by committed memory. 1.70 + bool is_area_committed(uintptr_t start, size_t size_in_pages) const; 1.71 + // Returns true if the entire area is not backed by committed memory. 1.72 + bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const; 1.73 + 1.74 + public: 1.75 + 1.76 + // Commit the given area of pages starting at start being size_in_pages large. 1.77 + MemRegion commit(uintptr_t start, size_t size_in_pages); 1.78 + 1.79 + // Uncommit the given area of pages starting at start being size_in_pages large. 1.80 + MemRegion uncommit(uintptr_t start, size_t size_in_pages); 1.81 + 1.82 + bool special() const { return _special; } 1.83 + 1.84 + // Initialization 1.85 + G1PageBasedVirtualSpace(); 1.86 + bool initialize_with_granularity(ReservedSpace rs, size_t page_size); 1.87 + 1.88 + // Destruction 1.89 + ~G1PageBasedVirtualSpace(); 1.90 + 1.91 + // Amount of reserved memory. 1.92 + size_t reserved_size() const; 1.93 + // Memory used in this virtual space. 1.94 + size_t committed_size() const; 1.95 + // Memory left to use/expand in this virtual space. 1.96 + size_t uncommitted_size() const; 1.97 + 1.98 + bool contains(const void* p) const; 1.99 + 1.100 + MemRegion reserved() { 1.101 + MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize); 1.102 + return x; 1.103 + } 1.104 + 1.105 + void release(); 1.106 + 1.107 + void check_for_contiguity() PRODUCT_RETURN; 1.108 + 1.109 + // Debugging 1.110 + void print_on(outputStream* out) PRODUCT_RETURN; 1.111 + void print(); 1.112 +}; 1.113 + 1.114 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP