From 4fc72b8e4b22db2aa3217afb5b8c30d496589eb8 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 4 Mar 2025 05:23:30 +0000 Subject: [PATCH] 8351082: Remove dead code for estimating CDS archive size Reviewed-by: ccheung --- .../share/classfile/compactHashtable.cpp | 13 ------- .../share/classfile/compactHashtable.hpp | 2 - src/hotspot/share/classfile/moduleEntry.hpp | 3 +- src/hotspot/share/classfile/symbolTable.cpp | 7 ---- src/hotspot/share/classfile/symbolTable.hpp | 1 - .../classfile/systemDictionaryShared.cpp | 39 ------------------- .../classfile/systemDictionaryShared.hpp | 1 - 7 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/hotspot/share/classfile/compactHashtable.cpp b/src/hotspot/share/classfile/compactHashtable.cpp index 5a3c6998904..8d50e8136a3 100644 --- a/src/hotspot/share/classfile/compactHashtable.cpp +++ b/src/hotspot/share/classfile/compactHashtable.cpp @@ -72,19 +72,6 @@ CompactHashtableWriter::~CompactHashtableWriter() { FREE_C_HEAP_ARRAY(GrowableArray*, _buckets); } -size_t CompactHashtableWriter::estimate_size(int num_entries) { - int num_buckets = calculate_num_buckets(num_entries); - size_t bucket_bytes = ArchiveBuilder::ro_array_bytesize(num_buckets + 1); - - // In worst case, we have no VALUE_ONLY_BUCKET_TYPE, so each entry takes 2 slots - int entries_space = 2 * num_entries; - size_t entry_bytes = ArchiveBuilder::ro_array_bytesize(entries_space); - - return bucket_bytes - + entry_bytes - + SimpleCompactHashtable::calculate_header_size(); -} - // Add a symbol entry to the temporary hash table void CompactHashtableWriter::add(unsigned int hash, u4 value) { int index = hash % _num_buckets; diff --git a/src/hotspot/share/classfile/compactHashtable.hpp b/src/hotspot/share/classfile/compactHashtable.hpp index 73e9f7fc092..161f21eac99 100644 --- a/src/hotspot/share/classfile/compactHashtable.hpp +++ b/src/hotspot/share/classfile/compactHashtable.hpp @@ -134,8 +134,6 @@ private: public: void dump(SimpleCompactHashtable *cht, const char* table_name); - - static size_t estimate_size(int num_entries); }; #endif // INCLUDE_CDS diff --git a/src/hotspot/share/classfile/moduleEntry.hpp b/src/hotspot/share/classfile/moduleEntry.hpp index 9ad7bde8954..c2d07a78512 100644 --- a/src/hotspot/share/classfile/moduleEntry.hpp +++ b/src/hotspot/share/classfile/moduleEntry.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,7 +207,6 @@ public: void load_from_archive(ClassLoaderData* loader_data); void restore_archived_oops(ClassLoaderData* loader_data); void clear_archived_oops(); - void update_oops_in_archived_module(int root_oop_index); static void verify_archived_module_entries() PRODUCT_RETURN; #endif }; diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index 3cb453aaecb..04640b672f6 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -705,13 +705,6 @@ void SymbolTable::copy_shared_symbol_table(GrowableArray* symbols, } } -size_t SymbolTable::estimate_size_for_archive() { - if (_items_count > (size_t)max_jint) { - fatal("Too many symbols to be archived: %zu", _items_count); - } - return CompactHashtableWriter::estimate_size(int(_items_count)); -} - void SymbolTable::write_to_archive(GrowableArray* symbols) { CompactHashtableWriter writer(int(_items_count), ArchiveBuilder::symbol_stats()); copy_shared_symbol_table(symbols, &writer); diff --git a/src/hotspot/share/classfile/symbolTable.hpp b/src/hotspot/share/classfile/symbolTable.hpp index a1e585e97de..ee2cfe19d8e 100644 --- a/src/hotspot/share/classfile/symbolTable.hpp +++ b/src/hotspot/share/classfile/symbolTable.hpp @@ -161,7 +161,6 @@ private: static void copy_shared_symbol_table(GrowableArray* symbols, CompactHashtableWriter* ch_table); public: - static size_t estimate_size_for_archive() NOT_CDS_RETURN_(0); static void write_to_archive(GrowableArray* symbols) NOT_CDS_RETURN; static void serialize_shared_table_header(SerializeClosure* soc, bool is_static_archive = true) NOT_CDS_RETURN; diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 6bd573ea465..8b815cf9cb7 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1223,45 +1223,6 @@ bool SystemDictionaryShared::is_supported_invokedynamic(BootstrapInfo* bsi) { return false; } -class EstimateSizeForArchive : StackObj { - size_t _shared_class_info_size; - int _num_builtin_klasses; - int _num_unregistered_klasses; - -public: - EstimateSizeForArchive() { - _shared_class_info_size = 0; - _num_builtin_klasses = 0; - _num_unregistered_klasses = 0; - } - - void do_entry(InstanceKlass* k, DumpTimeClassInfo& info) { - if (!info.is_excluded()) { - size_t byte_size = info.runtime_info_bytesize(); - _shared_class_info_size += align_up(byte_size, SharedSpaceObjectAlignment); - } - } - - size_t total() { - return _shared_class_info_size; - } -}; - -size_t SystemDictionaryShared::estimate_size_for_archive() { - EstimateSizeForArchive est; - _dumptime_table->iterate_all_live_classes(&est); - size_t total_size = est.total() + - CompactHashtableWriter::estimate_size(_dumptime_table->count_of(true)) + - CompactHashtableWriter::estimate_size(_dumptime_table->count_of(false)); - - size_t bytesize = align_up(sizeof(RunTimeLambdaProxyClassInfo), SharedSpaceObjectAlignment); - total_size += - (bytesize * _dumptime_lambda_proxy_class_dictionary->_count) + - CompactHashtableWriter::estimate_size(_dumptime_lambda_proxy_class_dictionary->_count); - - return total_size; -} - unsigned int SystemDictionaryShared::hash_for_shared_dictionary(address ptr) { if (ArchiveBuilder::is_active()) { uintx offset = ArchiveBuilder::current()->any_to_offset(ptr); diff --git a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp index 7286bdad3fd..c7f38880837 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.hpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp @@ -294,7 +294,6 @@ public: static void set_excluded_locked(InstanceKlass* k); static bool warn_excluded(InstanceKlass* k, const char* reason); static void dumptime_classes_do(class MetaspaceClosure* it); - static size_t estimate_size_for_archive(); static void write_to_archive(bool is_static_archive = true); static void adjust_lambda_proxy_class_dictionary(); static void serialize_dictionary_headers(class SerializeClosure* soc,