annotate src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp @ 20652:e8bf410d5e23

8058209: Race in G1 card scanning could allow scanning of memory covered by PLABs Summary: Read _top before _gc_time_stamp in saved_mark_word() with LoadLoad order to ensure we get a consistent view Reviewed-by: brutisso, dcubed, dholmes, stefank
author mgerdin
date Fri, 14 Nov 2014 14:23:25 +0100
parents 1f1d373cd044
children ae52ee069062
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
1 /*
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
4 *
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
7 * published by the Free Software Foundation.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
8 *
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
13 * accompanied this code).
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
14 *
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
18 *
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
21 * questions.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
22 *
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
23 */
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
24
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
27
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
28 #include "memory/allocation.hpp"
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
29 #include "memory/memRegion.hpp"
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
30 #include "runtime/virtualspace.hpp"
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
31 #include "utilities/bitMap.hpp"
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
32
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
33 // Virtual space management helper for a virtual space with an OS page allocation
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
34 // granularity.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
35 // (De-)Allocation requests are always OS page aligned by passing a page index
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
36 // and multiples of pages.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
37 // The implementation gives an error when trying to commit or uncommit pages that
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
38 // have already been committed or uncommitted.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
39 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
40 friend class VMStructs;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
41 private:
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
42 // Reserved area addresses.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
43 char* _low_boundary;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
44 char* _high_boundary;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
45
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
46 // The commit/uncommit granularity in bytes.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
47 size_t _page_size;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
48
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
49 // Bitmap used for verification of commit/uncommit operations.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
50 BitMap _committed;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
51
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
52 // Indicates that the entire space has been committed and pinned in memory,
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
53 // os::commit_memory() or os::uncommit_memory() have no function.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
54 bool _special;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
55
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
56 // Indicates whether the committed space should be executable.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
57 bool _executable;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
58
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
59 // Returns the index of the page which contains the given address.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
60 uintptr_t addr_to_page_index(char* addr) const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
61 // Returns the address of the given page index.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
62 char* page_start(uintptr_t index);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
63 // Returns the byte size of the given number of pages.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
64 size_t byte_size_for_pages(size_t num);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
65
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
66 // Returns true if the entire area is backed by committed memory.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
67 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
68 // Returns true if the entire area is not backed by committed memory.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
69 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
70
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
71 public:
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
72
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
73 // Commit the given area of pages starting at start being size_in_pages large.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
74 MemRegion commit(uintptr_t start, size_t size_in_pages);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
75
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
76 // Uncommit the given area of pages starting at start being size_in_pages large.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
77 MemRegion uncommit(uintptr_t start, size_t size_in_pages);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
78
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
79 bool special() const { return _special; }
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
80
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
81 // Initialization
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
82 G1PageBasedVirtualSpace();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
83 bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
84
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
85 // Destruction
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
86 ~G1PageBasedVirtualSpace();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
87
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
88 // Amount of reserved memory.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
89 size_t reserved_size() const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
90 // Memory used in this virtual space.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
91 size_t committed_size() const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
92 // Memory left to use/expand in this virtual space.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
93 size_t uncommitted_size() const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
94
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
95 bool contains(const void* p) const;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
96
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
97 MemRegion reserved() {
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
98 MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
99 return x;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
100 }
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
101
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
102 void release();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
103
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
104 void check_for_contiguity() PRODUCT_RETURN;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
105
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
106 // Debugging
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
107 void print_on(outputStream* out) PRODUCT_RETURN;
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
108 void print();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
109 };
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
110
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
111 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP