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
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "classfile/compactHashtable.inline.hpp"
28 #include "classfile/javaClasses.hpp"
29 #include "logging/logMessage.hpp"
30 #include "memory/metadataFactory.hpp"
31 #include "memory/metaspaceShared.hpp"
32 #include "oops/compressedOops.inline.hpp"
33 #include "runtime/vmThread.hpp"
34 #include "utilities/numberSeq.hpp"
35 #include <sys/stat.h>
36
37 /////////////////////////////////////////////////////
38 //
39 // The compact hash table writer implementations
40 //
41 CompactHashtableWriter::CompactHashtableWriter(int num_buckets,
42 CompactHashtableStats* stats) {
43 assert(DumpSharedSpaces, "dump-time only");
44 assert(num_buckets > 0, "no buckets");
45 _num_buckets = num_buckets;
46 _num_entries = 0;
47 _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
48 for (int i=0; i<_num_buckets; i++) {
49 _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray<Entry>(0, true, mtSymbol);
263 class CompactHashtable_SymbolIterator {
264 SymbolClosure* const _closure;
265 public:
266 CompactHashtable_SymbolIterator(SymbolClosure *cl) : _closure(cl) {}
267 inline void do_value(address base_address, u4 offset) const {
268 Symbol* sym = (Symbol*)((void*)(base_address + offset));
269 _closure->do_symbol(&sym);
270 }
271 };
272
273 template <class T, class N> void CompactHashtable<T, N>::symbols_do(SymbolClosure *cl) {
274 CompactHashtable_SymbolIterator iterator(cl);
275 iterate(iterator);
276 }
277
278 class CompactHashtable_OopIterator {
279 OopClosure* const _closure;
280 public:
281 CompactHashtable_OopIterator(OopClosure *cl) : _closure(cl) {}
282 inline void do_value(address base_address, u4 offset) const {
283 narrowOop o = (narrowOop)offset;
284 _closure->do_oop(&o);
285 }
286 };
287
288 template <class T, class N> void CompactHashtable<T, N>::oops_do(OopClosure* cl) {
289 assert(_type == _string_table || _bucket_count == 0, "sanity");
290 CompactHashtable_OopIterator iterator(cl);
291 iterate(iterator);
292 }
293
294 // Explicitly instantiate these types
295 template class CompactHashtable<Symbol*, char>;
296 template class CompactHashtable<oop, char>;
297
298 #ifndef O_BINARY // if defined (Win32) use binary files.
299 #define O_BINARY 0 // otherwise do nothing.
300 #endif
301
302 ////////////////////////////////////////////////////////
303 //
304 // HashtableTextDump
|
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
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "classfile/compactHashtable.inline.hpp"
28 #include "classfile/javaClasses.hpp"
29 #include "logging/logMessage.hpp"
30 #include "memory/heapShared.inline.hpp"
31 #include "memory/metadataFactory.hpp"
32 #include "memory/metaspaceShared.hpp"
33 #include "oops/compressedOops.inline.hpp"
34 #include "runtime/vmThread.hpp"
35 #include "utilities/numberSeq.hpp"
36 #include <sys/stat.h>
37
38 /////////////////////////////////////////////////////
39 //
40 // The compact hash table writer implementations
41 //
42 CompactHashtableWriter::CompactHashtableWriter(int num_buckets,
43 CompactHashtableStats* stats) {
44 assert(DumpSharedSpaces, "dump-time only");
45 assert(num_buckets > 0, "no buckets");
46 _num_buckets = num_buckets;
47 _num_entries = 0;
48 _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
49 for (int i=0; i<_num_buckets; i++) {
50 _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray<Entry>(0, true, mtSymbol);
264 class CompactHashtable_SymbolIterator {
265 SymbolClosure* const _closure;
266 public:
267 CompactHashtable_SymbolIterator(SymbolClosure *cl) : _closure(cl) {}
268 inline void do_value(address base_address, u4 offset) const {
269 Symbol* sym = (Symbol*)((void*)(base_address + offset));
270 _closure->do_symbol(&sym);
271 }
272 };
273
274 template <class T, class N> void CompactHashtable<T, N>::symbols_do(SymbolClosure *cl) {
275 CompactHashtable_SymbolIterator iterator(cl);
276 iterate(iterator);
277 }
278
279 class CompactHashtable_OopIterator {
280 OopClosure* const _closure;
281 public:
282 CompactHashtable_OopIterator(OopClosure *cl) : _closure(cl) {}
283 inline void do_value(address base_address, u4 offset) const {
284 narrowOop v = (narrowOop)offset;
285 oop obj = HeapShared::decode_with_archived_oop_encoding_mode(v);
286 _closure->do_oop(&obj);
287 }
288 };
289
290 template <class T, class N> void CompactHashtable<T, N>::oops_do(OopClosure* cl) {
291 assert(_type == _string_table || _bucket_count == 0, "sanity");
292 CompactHashtable_OopIterator iterator(cl);
293 iterate(iterator);
294 }
295
296 // Explicitly instantiate these types
297 template class CompactHashtable<Symbol*, char>;
298 template class CompactHashtable<oop, char>;
299
300 #ifndef O_BINARY // if defined (Win32) use binary files.
301 #define O_BINARY 0 // otherwise do nothing.
302 #endif
303
304 ////////////////////////////////////////////////////////
305 //
306 // HashtableTextDump
|