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 "runtime/vmThread.hpp"
33 #include "utilities/numberSeq.hpp"
34 #include <sys/stat.h>
35
36 /////////////////////////////////////////////////////
37 //
38 // The compact hash table writer implementations
39 //
40 CompactHashtableWriter::CompactHashtableWriter(int num_buckets,
41 CompactHashtableStats* stats) {
42 assert(DumpSharedSpaces, "dump-time only");
43 assert(num_buckets > 0, "no buckets");
44 _num_buckets = num_buckets;
45 _num_entries = 0;
46 _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
47 for (int i=0; i<_num_buckets; i++) {
48 _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray<Entry>(0, true, mtSymbol);
49 }
50
51 _stats = stats;
165 msg.info("Other buckets : %9d", _num_other_buckets);
166 }
167 }
168
169 /////////////////////////////////////////////////////////////
170 //
171 // Customization for dumping Symbol and String tables
172
173 void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) {
174 uintx deltax = MetaspaceShared::object_delta(symbol);
175 // When the symbols are stored into the archive, we already check that
176 // they won't be more than MAX_SHARED_DELTA from the base address, or
177 // else the dumping would have been aborted.
178 assert(deltax <= MAX_SHARED_DELTA, "must not be");
179 u4 delta = u4(deltax);
180
181 CompactHashtableWriter::add(hash, delta);
182 }
183
184 void CompactStringTableWriter::add(unsigned int hash, oop string) {
185 CompactHashtableWriter::add(hash, oopDesc::encode_heap_oop(string));
186 }
187
188 void CompactSymbolTableWriter::dump(CompactHashtable<Symbol*, char> *cht) {
189 CompactHashtableWriter::dump(cht, "symbol");
190 }
191
192 void CompactStringTableWriter::dump(CompactHashtable<oop, char> *cht) {
193 CompactHashtableWriter::dump(cht, "string");
194 }
195
196 /////////////////////////////////////////////////////////////
197 //
198 // The CompactHashtable implementation
199 //
200
201 void SimpleCompactHashtable::serialize(SerializeClosure* soc) {
202 soc->do_ptr((void**)&_base_address);
203 soc->do_u4(&_entry_count);
204 soc->do_u4(&_bucket_count);
205 soc->do_ptr((void**)&_buckets);
|
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);
50 }
51
52 _stats = stats;
166 msg.info("Other buckets : %9d", _num_other_buckets);
167 }
168 }
169
170 /////////////////////////////////////////////////////////////
171 //
172 // Customization for dumping Symbol and String tables
173
174 void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) {
175 uintx deltax = MetaspaceShared::object_delta(symbol);
176 // When the symbols are stored into the archive, we already check that
177 // they won't be more than MAX_SHARED_DELTA from the base address, or
178 // else the dumping would have been aborted.
179 assert(deltax <= MAX_SHARED_DELTA, "must not be");
180 u4 delta = u4(deltax);
181
182 CompactHashtableWriter::add(hash, delta);
183 }
184
185 void CompactStringTableWriter::add(unsigned int hash, oop string) {
186 CompactHashtableWriter::add(hash, CompressedOops::encode(string));
187 }
188
189 void CompactSymbolTableWriter::dump(CompactHashtable<Symbol*, char> *cht) {
190 CompactHashtableWriter::dump(cht, "symbol");
191 }
192
193 void CompactStringTableWriter::dump(CompactHashtable<oop, char> *cht) {
194 CompactHashtableWriter::dump(cht, "string");
195 }
196
197 /////////////////////////////////////////////////////////////
198 //
199 // The CompactHashtable implementation
200 //
201
202 void SimpleCompactHashtable::serialize(SerializeClosure* soc) {
203 soc->do_ptr((void**)&_base_address);
204 soc->do_u4(&_entry_count);
205 soc->do_u4(&_bucket_count);
206 soc->do_ptr((void**)&_buckets);
|