|
23 | 23 | */
|
24 | 24 |
|
25 | 25 | #include "precompiled.hpp"
|
26 |
| -#include "classfile/altHashing.hpp" |
27 | 26 | #include "classfile/dictionary.hpp"
|
28 | 27 | #include "classfile/javaClasses.inline.hpp"
|
29 | 28 | #include "classfile/moduleEntry.hpp"
|
30 | 29 | #include "classfile/packageEntry.hpp"
|
31 | 30 | #include "classfile/placeholders.hpp"
|
32 | 31 | #include "classfile/protectionDomainCache.hpp"
|
33 |
| -#include "classfile/stringTable.hpp" |
34 | 32 | #include "classfile/vmClasses.hpp"
|
35 | 33 | #include "code/nmethod.hpp"
|
36 | 34 | #include "logging/log.hpp"
|
37 | 35 | #include "memory/allocation.inline.hpp"
|
38 | 36 | #include "memory/resourceArea.hpp"
|
39 | 37 | #include "oops/oop.inline.hpp"
|
| 38 | +#include "oops/symbol.hpp" |
40 | 39 | #include "oops/weakHandle.inline.hpp"
|
41 | 40 | #include "prims/jvmtiTagMapTable.hpp"
|
42 | 41 | #include "runtime/safepoint.hpp"
|
|
45 | 44 | #include "utilities/hashtable.inline.hpp"
|
46 | 45 | #include "utilities/numberSeq.hpp"
|
47 | 46 |
|
48 |
| - |
49 | 47 | // This hashtable is implemented as an open hash table with a fixed number of buckets.
|
50 | 48 |
|
51 |
| -template <MEMFLAGS F> BasicHashtableEntry<F>* BasicHashtable<F>::new_entry_free_list() { |
52 |
| - BasicHashtableEntry<F>* entry = NULL; |
53 |
| - if (_free_list != NULL) { |
54 |
| - entry = _free_list; |
55 |
| - _free_list = _free_list->next(); |
56 |
| - } |
57 |
| - return entry; |
58 |
| -} |
| 49 | +// Hashtable entry allocates in the C heap directly. |
59 | 50 |
|
60 |
| -// HashtableEntrys are allocated in blocks to reduce the space overhead. |
61 | 51 | template <MEMFLAGS F> BasicHashtableEntry<F>* BasicHashtable<F>::new_entry(unsigned int hashValue) {
|
62 |
| - BasicHashtableEntry<F>* entry = new_entry_free_list(); |
63 |
| - |
64 |
| - if (entry == NULL) { |
65 |
| - if (_first_free_entry + _entry_size >= _end_block) { |
66 |
| - int block_size = MAX2((int)_table_size / 2, (int)_number_of_entries); // pick a reasonable value |
67 |
| - block_size = clamp(block_size, 2, 512); // but never go out of this range |
68 |
| - int len = round_down_power_of_2(_entry_size * block_size); |
69 |
| - assert(len >= _entry_size, ""); |
70 |
| - _first_free_entry = NEW_C_HEAP_ARRAY2(char, len, F, CURRENT_PC); |
71 |
| - _entry_blocks.append(_first_free_entry); |
72 |
| - _end_block = _first_free_entry + len; |
73 |
| - } |
74 |
| - entry = (BasicHashtableEntry<F>*)_first_free_entry; |
75 |
| - _first_free_entry += _entry_size; |
76 |
| - } |
77 |
| - |
78 |
| - assert(_entry_size % HeapWordSize == 0, ""); |
79 |
| - entry->set_hash(hashValue); |
| 52 | + BasicHashtableEntry<F>* entry = ::new (NEW_C_HEAP_ARRAY(char, this->entry_size(), F)) |
| 53 | + BasicHashtableEntry<F>(hashValue); |
80 | 54 | return entry;
|
81 | 55 | }
|
82 | 56 |
|
83 | 57 |
|
84 | 58 | template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::new_entry(unsigned int hashValue, T obj) {
|
85 |
| - HashtableEntry<T, F>* entry; |
86 |
| - |
87 |
| - entry = (HashtableEntry<T, F>*)BasicHashtable<F>::new_entry(hashValue); |
88 |
| - entry->set_literal(obj); |
| 59 | + HashtableEntry<T, F>* entry = ::new (NEW_C_HEAP_ARRAY(char, this->entry_size(), F)) |
| 60 | + HashtableEntry<T, F>(hashValue, obj); |
89 | 61 | return entry;
|
90 | 62 | }
|
91 | 63 |
|
92 |
| -// Version of hashtable entry allocation that allocates in the C heap directly. |
93 |
| -// The block allocator in BasicHashtable has less fragmentation, but the memory is not freed until |
94 |
| -// the whole table is freed. Use allocate_new_entry() if you want to individually free the memory |
95 |
| -// used by each entry |
96 |
| -template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::allocate_new_entry(unsigned int hashValue, T obj) { |
97 |
| - HashtableEntry<T, F>* entry = (HashtableEntry<T, F>*) NEW_C_HEAP_ARRAY(char, this->entry_size(), F); |
98 |
| - |
99 |
| - if (DumpSharedSpaces) { |
100 |
| - // Avoid random bits in structure padding so we can have deterministic content in CDS archive |
101 |
| - memset((void*)entry, 0, this->entry_size()); |
102 |
| - } |
103 |
| - entry->set_hash(hashValue); |
104 |
| - entry->set_literal(obj); |
105 |
| - entry->set_next(NULL); |
106 |
| - return entry; |
| 64 | +template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) { |
| 65 | + // Unlink from the Hashtable prior to freeing |
| 66 | + unlink_entry(entry); |
| 67 | + FREE_C_HEAP_ARRAY(char, entry); |
| 68 | + JFR_ONLY(_stats_rate.remove();) |
107 | 69 | }
|
108 | 70 |
|
| 71 | + |
109 | 72 | template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
|
110 | 73 | FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
|
111 | 74 | _buckets = NULL;
|
|
0 commit comments