Mercurial > hg > truffle
annotate src/share/vm/memory/freeList.hpp @ 20543:e7d0505c8a30
8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso
author | tschatzl |
---|---|
date | Fri, 10 Oct 2014 15:51:58 +0200 |
parents | 55fb97c4c58d |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
0 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
10334
diff
changeset
|
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
6026 | 25 #ifndef SHARE_VM_MEMORY_FREELIST_HPP |
26 #define SHARE_VM_MEMORY_FREELIST_HPP | |
1972 | 27 |
28 #include "gc_implementation/shared/allocationStats.hpp" | |
29 | |
0 | 30 class CompactibleFreeListSpace; |
31 | |
6026 | 32 // A class for maintaining a free list of Chunk's. The FreeList |
0 | 33 // maintains a the structure of the list (head, tail, etc.) plus |
34 // statistics for allocations from the list. The links between items | |
35 // are not part of FreeList. The statistics are | |
6026 | 36 // used to make decisions about coalescing Chunk's when they |
0 | 37 // are swept during collection. |
38 // | |
39 // See the corresponding .cpp file for a description of the specifics | |
40 // for that implementation. | |
41 | |
42 class Mutex; | |
43 | |
6885 | 44 template <class Chunk_t> |
0 | 45 class FreeList VALUE_OBJ_CLASS_SPEC { |
46 friend class CompactibleFreeListSpace; | |
152
c70a245cad3a
6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents:
12
diff
changeset
|
47 friend class VMStructs; |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
48 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
49 private: |
6885 | 50 Chunk_t* _head; // Head of list of free chunks |
51 Chunk_t* _tail; // Tail of list of free chunks | |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
52 size_t _size; // Size in Heap words of each chunk |
0 | 53 ssize_t _count; // Number of entries in list |
54 | |
6885 | 55 protected: |
0 | 56 |
57 #ifdef ASSERT | |
58 Mutex* _protecting_lock; | |
59 #endif | |
60 | |
61 // Asserts false if the protecting lock (if any) is not held. | |
62 void assert_proper_lock_protection_work() const PRODUCT_RETURN; | |
63 void assert_proper_lock_protection() const { | |
64 #ifdef ASSERT | |
65 if (_protecting_lock != NULL) | |
66 assert_proper_lock_protection_work(); | |
67 #endif | |
68 } | |
69 | |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
70 void increment_count() { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
71 _count++; |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
72 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
196
diff
changeset
|
73 |
0 | 74 void decrement_count() { |
75 _count--; | |
12
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
76 assert(_count >= 0, "Count should not be negative"); |
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
77 } |
0 | 78 |
79 public: | |
80 // Constructor | |
81 // Construct a list without any entries. | |
82 FreeList(); | |
83 | |
6885 | 84 // Do initialization |
85 void initialize(); | |
86 | |
87 // Reset the head, tail, and count of a free list. | |
88 void reset(); | |
0 | 89 |
90 // Declare the current free list to be protected by the given lock. | |
91 #ifdef ASSERT | |
6885 | 92 Mutex* protecting_lock() const { return _protecting_lock; } |
93 void set_protecting_lock(Mutex* v) { | |
94 _protecting_lock = v; | |
0 | 95 } |
96 #endif | |
97 | |
98 // Accessors. | |
6885 | 99 Chunk_t* head() const { |
0 | 100 assert_proper_lock_protection(); |
101 return _head; | |
102 } | |
6885 | 103 void set_head(Chunk_t* v) { |
0 | 104 assert_proper_lock_protection(); |
105 _head = v; | |
106 assert(!_head || _head->size() == _size, "bad chunk size"); | |
107 } | |
108 // Set the head of the list and set the prev field of non-null | |
109 // values to NULL. | |
6885 | 110 void link_head(Chunk_t* v); |
0 | 111 |
6885 | 112 Chunk_t* tail() const { |
0 | 113 assert_proper_lock_protection(); |
114 return _tail; | |
115 } | |
6885 | 116 void set_tail(Chunk_t* v) { |
0 | 117 assert_proper_lock_protection(); |
118 _tail = v; | |
119 assert(!_tail || _tail->size() == _size, "bad chunk size"); | |
120 } | |
121 // Set the tail of the list and set the next field of non-null | |
122 // values to NULL. | |
6885 | 123 void link_tail(Chunk_t* v) { |
0 | 124 assert_proper_lock_protection(); |
125 set_tail(v); | |
126 if (v != NULL) { | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
6026
diff
changeset
|
127 v->clear_next(); |
0 | 128 } |
129 } | |
130 | |
131 // No locking checks in read-accessors: lock-free reads (only) are benign. | |
132 // Readers are expected to have the lock if they are doing work that | |
133 // requires atomicity guarantees in sections of code. | |
134 size_t size() const { | |
135 return _size; | |
136 } | |
137 void set_size(size_t v) { | |
138 assert_proper_lock_protection(); | |
139 _size = v; | |
140 } | |
6885 | 141 ssize_t count() const { return _count; } |
142 void set_count(ssize_t v) { _count = v;} | |
0 | 143 |
6885 | 144 size_t get_better_size() { return size(); } |
0 | 145 |
6885 | 146 size_t returned_bytes() const { ShouldNotReachHere(); return 0; } |
147 void set_returned_bytes(size_t v) {} | |
148 void increment_returned_bytes_by(size_t v) {} | |
0 | 149 |
150 // Unlink head of list and return it. Returns NULL if | |
151 // the list is empty. | |
6885 | 152 Chunk_t* get_chunk_at_head(); |
0 | 153 |
154 // Remove the first "n" or "count", whichever is smaller, chunks from the | |
155 // list, setting "fl", which is required to be empty, to point to them. | |
6885 | 156 void getFirstNChunksFromList(size_t n, FreeList<Chunk_t>* fl); |
0 | 157 |
158 // Unlink this chunk from it's free list | |
6885 | 159 void remove_chunk(Chunk_t* fc); |
0 | 160 |
161 // Add this chunk to this free list. | |
6885 | 162 void return_chunk_at_head(Chunk_t* fc); |
163 void return_chunk_at_tail(Chunk_t* fc); | |
0 | 164 |
165 // Similar to returnChunk* but also records some diagnostic | |
166 // information. | |
6885 | 167 void return_chunk_at_head(Chunk_t* fc, bool record_return); |
168 void return_chunk_at_tail(Chunk_t* fc, bool record_return); | |
0 | 169 |
170 // Prepend "fl" (whose size is required to be the same as that of "this") | |
171 // to the front of "this" list. | |
6885 | 172 void prepend(FreeList<Chunk_t>* fl); |
0 | 173 |
174 // Verify that the chunk is in the list. | |
175 // found. Return NULL if "fc" is not found. | |
6885 | 176 bool verify_chunk_in_free_list(Chunk_t* fc) const; |
12
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
177 |
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
178 // Printing support |
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
179 static void print_labels_on(outputStream* st, const char* c); |
6432c3bb6240
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
0
diff
changeset
|
180 void print_on(outputStream* st, const char* c = NULL) const; |
0 | 181 }; |
1972 | 182 |
6026 | 183 #endif // SHARE_VM_MEMORY_FREELIST_HPP |