Mercurial > hg > graal-jvmci-8
annotate src/share/vm/memory/metachunk.cpp @ 10241:d17700c82d7d
8006088: Incompatible heap size flags accepted by VM
Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing.
Reviewed-by: johnc, jwilhelm, tamao
author | tschatzl |
---|---|
date | Mon, 06 May 2013 17:19:42 +0200 |
parents | c23dbf0e8ab7 |
children | bdfbb1fb19ca |
rev | line source |
---|---|
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
1 /* |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
4 * |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
8 * |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
13 * accompanied this code). |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
14 * |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
18 * |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
21 * questions. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
22 * |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
23 */ |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
24 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
26 #include "memory/allocation.hpp" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
27 #include "memory/metachunk.hpp" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
28 #include "utilities/copy.hpp" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
29 #include "utilities/debug.hpp" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
30 |
10175 | 31 class VirtualSpaceNode; |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
32 // |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
33 // Future modification |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
34 // |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
35 // The Metachunk can conceivable be replaced by the Chunk in |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
36 // allocation.hpp. Note that the latter Chunk is the space for |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
37 // allocation (allocations from the chunk are out of the space in |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
38 // the Chunk after the header for the Chunk) where as Metachunks |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
39 // point to space in a VirtualSpace. To replace Metachunks with |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
40 // Chunks, change Chunks so that they can be allocated out of a VirtualSpace. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
41 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
42 const size_t metadata_chunk_initialize = 0xf7f7f7f7; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
43 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
44 size_t Metachunk::_overhead = |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
45 Chunk::aligned_overhead_size(sizeof(Metachunk)) / BytesPerWord; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
46 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
47 // Metachunk methods |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
48 |
10175 | 49 Metachunk::Metachunk(size_t word_size, |
50 VirtualSpaceNode* container) : | |
51 _word_size(word_size), | |
52 _bottom(NULL), | |
53 _end(NULL), | |
54 _top(NULL), | |
55 _next(NULL), | |
56 _prev(NULL), | |
57 _container(container) | |
58 { | |
59 _bottom = (MetaWord*)this; | |
60 _top = (MetaWord*)this + _overhead; | |
61 _end = (MetaWord*)this + word_size; | |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
62 #ifdef ASSERT |
10175 | 63 set_is_free(false); |
64 size_t data_word_size = pointer_delta(end(), | |
65 top(), | |
66 sizeof(MetaWord)); | |
67 Copy::fill_to_words((HeapWord*) top(), | |
68 data_word_size, | |
69 metadata_chunk_initialize); | |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
70 #endif |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
71 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
72 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
73 MetaWord* Metachunk::allocate(size_t word_size) { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
74 MetaWord* result = NULL; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
75 // If available, bump the pointer to allocate. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
76 if (free_word_size() >= word_size) { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
77 result = _top; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
78 _top = _top + word_size; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
79 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
80 return result; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
81 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
82 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
83 // _bottom points to the start of the chunk including the overhead. |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
84 size_t Metachunk::used_word_size() const { |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
85 return pointer_delta(_top, _bottom, sizeof(MetaWord)); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
86 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
87 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
88 size_t Metachunk::free_word_size() const { |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
89 return pointer_delta(_end, _top, sizeof(MetaWord)); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
90 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
91 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
92 size_t Metachunk::capacity_word_size() const { |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
93 return pointer_delta(_end, _bottom, sizeof(MetaWord)); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
94 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
95 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
96 void Metachunk::print_on(outputStream* st) const { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
97 st->print_cr("Metachunk:" |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
98 " bottom " PTR_FORMAT " top " PTR_FORMAT |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
99 " end " PTR_FORMAT " size " SIZE_FORMAT, |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
100 bottom(), top(), end(), word_size()); |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
101 if (Verbose) { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
102 st->print_cr(" used " SIZE_FORMAT " free " SIZE_FORMAT, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
103 used_word_size(), free_word_size()); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7208
diff
changeset
|
104 } |
7208
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
105 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
106 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
107 #ifndef PRODUCT |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
108 void Metachunk::mangle() { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
109 // Mangle the payload of the chunk and not the links that |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
110 // maintain list of chunks. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
111 HeapWord* start = (HeapWord*)(bottom() + overhead()); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
112 size_t word_size = capacity_word_size() - overhead(); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
113 Copy::fill_to_words(start, word_size, metadata_chunk_initialize); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
114 } |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
115 #endif // PRODUCT |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
116 |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
117 void Metachunk::verify() { |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
118 #ifdef ASSERT |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
119 // Cannot walk through the blocks unless the blocks have |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
120 // headers with sizes. |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
121 assert(_bottom <= _top && |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
122 _top <= _end, |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
123 "Chunk has been smashed"); |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
124 #endif |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
125 return; |
eade6b2e4782
8003554: NPG: move Metablock and Metachunk code out of metaspace.cpp
jmasa
parents:
diff
changeset
|
126 } |