equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
125 static VirtualSpaceList* _class_space_list; |
125 static VirtualSpaceList* _class_space_list; |
126 |
126 |
127 static VirtualSpaceList* space_list() { return _space_list; } |
127 static VirtualSpaceList* space_list() { return _space_list; } |
128 static VirtualSpaceList* class_space_list() { return _class_space_list; } |
128 static VirtualSpaceList* class_space_list() { return _class_space_list; } |
129 |
129 |
|
130 // This is used by DumpSharedSpaces only, where only _vsm is used. So we will |
|
131 // maintain a single list for now. |
|
132 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
|
133 |
|
134 class AllocRecord : public CHeapObj<mtClass> { |
|
135 public: |
|
136 AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
|
137 : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
|
138 AllocRecord *_next; |
|
139 address _ptr; |
|
140 MetaspaceObj::Type _type; |
|
141 int _byte_size; |
|
142 }; |
|
143 |
|
144 AllocRecord * _alloc_record_head; |
|
145 AllocRecord * _alloc_record_tail; |
|
146 |
130 public: |
147 public: |
131 |
148 |
132 Metaspace(Mutex* lock, MetaspaceType type); |
149 Metaspace(Mutex* lock, MetaspaceType type); |
133 ~Metaspace(); |
150 ~Metaspace(); |
134 |
151 |
146 size_t waste_words(MetadataType mdtype) const; |
163 size_t waste_words(MetadataType mdtype) const; |
147 |
164 |
148 size_t used_bytes_slow(MetadataType mdtype) const; |
165 size_t used_bytes_slow(MetadataType mdtype) const; |
149 size_t capacity_bytes_slow(MetadataType mdtype) const; |
166 size_t capacity_bytes_slow(MetadataType mdtype) const; |
150 |
167 |
151 static Metablock* allocate(ClassLoaderData* loader_data, size_t size, |
168 static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, |
152 bool read_only, MetadataType mdtype, TRAPS); |
169 bool read_only, MetaspaceObj::Type type, TRAPS); |
153 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
170 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
154 |
171 |
155 MetaWord* expand_and_allocate(size_t size, |
172 MetaWord* expand_and_allocate(size_t size, |
156 MetadataType mdtype); |
173 MetadataType mdtype); |
157 |
174 |
164 static void purge(); |
181 static void purge(); |
165 |
182 |
166 void print_on(outputStream* st) const; |
183 void print_on(outputStream* st) const; |
167 // Debugging support |
184 // Debugging support |
168 void verify(); |
185 void verify(); |
|
186 |
|
187 class AllocRecordClosure : public StackObj { |
|
188 public: |
|
189 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
|
190 }; |
|
191 |
|
192 void iterate(AllocRecordClosure *closure); |
169 }; |
193 }; |
170 |
194 |
171 class MetaspaceAux : AllStatic { |
195 class MetaspaceAux : AllStatic { |
172 |
196 |
173 // Statistics for class space and data space in metaspace. |
197 // Statistics for class space and data space in metaspace. |