Mercurial > hg > truffle
annotate src/share/vm/memory/metachunk.hpp @ 12888:4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
Reviewed-by: kvn, twisti
author | rbackman |
---|---|
date | Fri, 11 Oct 2013 12:06:14 +0200 |
parents | c23dbf0e8ab7 |
children | bdfbb1fb19ca |
rev | line source |
---|---|
6885 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
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 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 #ifndef SHARE_VM_MEMORY_METACHUNK_HPP | |
25 #define SHARE_VM_MEMORY_METACHUNK_HPP | |
26 | |
27 // Metachunk - Quantum of allocation from a Virtualspace | |
28 // Metachunks are reused (when freed are put on a global freelist) and | |
29 // have no permanent association to a SpaceManager. | |
30 | |
31 // +--------------+ <- end | |
32 // | | --+ ---+ | |
33 // | | | free | | |
34 // | | | | | |
35 // | | | | capacity | |
36 // | | | | | |
37 // | | <- top --+ | | |
38 // | | ---+ | | |
39 // | | | used | | |
40 // | | | | | |
41 // | | | | | |
42 // +--------------+ <- bottom ---+ ---+ | |
43 | |
10175 | 44 class VirtualSpaceNode; |
45 | |
6885 | 46 class Metachunk VALUE_OBJ_CLASS_SPEC { |
47 // link to support lists of chunks | |
48 Metachunk* _next; | |
49 Metachunk* _prev; | |
10175 | 50 VirtualSpaceNode* _container; |
6885 | 51 |
52 MetaWord* _bottom; | |
53 MetaWord* _end; | |
54 MetaWord* _top; | |
55 size_t _word_size; | |
56 // Used in a guarantee() so included in the Product builds | |
57 // even through it is only for debugging. | |
58 bool _is_free; | |
59 | |
60 // Metachunks are allocated out of a MetadataVirtualSpace and | |
61 // and use some of its space to describe itself (plus alignment | |
62 // considerations). Metadata is allocated in the rest of the chunk. | |
63 // This size is the overhead of maintaining the Metachunk within | |
64 // the space. | |
65 static size_t _overhead; | |
66 | |
67 public: | |
10175 | 68 Metachunk(size_t word_size , VirtualSpaceNode* container); |
6885 | 69 |
70 // Used to add a Metachunk to a list of Metachunks | |
71 void set_next(Metachunk* v) { _next = v; assert(v != this, "Boom");} | |
72 void set_prev(Metachunk* v) { _prev = v; assert(v != this, "Boom");} | |
10175 | 73 void set_container(VirtualSpaceNode* v) { _container = v; } |
6885 | 74 |
75 MetaWord* allocate(size_t word_size); | |
76 | |
77 // Accessors | |
78 Metachunk* next() const { return _next; } | |
79 Metachunk* prev() const { return _prev; } | |
10175 | 80 VirtualSpaceNode* container() const { return _container; } |
6885 | 81 MetaWord* bottom() const { return _bottom; } |
82 MetaWord* end() const { return _end; } | |
83 MetaWord* top() const { return _top; } | |
84 size_t word_size() const { return _word_size; } | |
85 size_t size() const volatile { return _word_size; } | |
86 void set_size(size_t v) { _word_size = v; } | |
87 bool is_free() { return _is_free; } | |
88 void set_is_free(bool v) { _is_free = v; } | |
89 static size_t overhead() { return _overhead; } | |
90 void clear_next() { set_next(NULL); } | |
91 void link_prev(Metachunk* ptr) { set_prev(ptr); } | |
92 uintptr_t* end() { return ((uintptr_t*) this) + size(); } | |
93 bool cantCoalesce() const { return false; } | |
94 void link_next(Metachunk* ptr) { set_next(ptr); } | |
95 void link_after(Metachunk* ptr){ | |
96 link_next(ptr); | |
97 if (ptr != NULL) ptr->link_prev(this); | |
98 } | |
99 | |
100 // Reset top to bottom so chunk can be reused. | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7185
diff
changeset
|
101 void reset_empty() { _top = (_bottom + _overhead); _next = NULL; _prev = NULL; } |
6885 | 102 bool is_empty() { return _top == (_bottom + _overhead); } |
103 | |
104 // used (has been allocated) | |
105 // free (available for future allocations) | |
106 // capacity (total size of chunk) | |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7185
diff
changeset
|
107 size_t used_word_size() const; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7185
diff
changeset
|
108 size_t free_word_size() const; |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7185
diff
changeset
|
109 size_t capacity_word_size()const; |
6885 | 110 |
111 // Debug support | |
112 #ifdef ASSERT | |
113 void* prev_addr() const { return (void*)&_prev; } | |
114 void* next_addr() const { return (void*)&_next; } | |
115 void* size_addr() const { return (void*)&_word_size; } | |
116 #endif | |
117 bool verify_chunk_in_free_list(Metachunk* tc) const { return true; } | |
118 bool verify_par_locked() { return true; } | |
119 | |
120 void assert_is_mangled() const {/* Don't check "\*/} | |
121 | |
7185
90273fc0a981
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
6885
diff
changeset
|
122 NOT_PRODUCT(void mangle();) |
6885 | 123 |
124 void print_on(outputStream* st) const; | |
125 void verify(); | |
126 }; | |
127 #endif // SHARE_VM_MEMORY_METACHUNK_HPP |