8307959: Remove explicit type casts from SerializeClosure::do_xxx() calls

Reviewed-by: matsaave, ccheung
This commit is contained in:
Ioi Lam 2023-05-15 16:33:37 +00:00
parent 97b2ca3de7
commit 57e7a3fbea
15 changed files with 47 additions and 28 deletions

View File

@ -301,6 +301,11 @@ void ReadClosure::do_u4(u4* p) {
*p = (u4)(uintx(obj));
}
void ReadClosure::do_int(int* p) {
intptr_t obj = nextPtr();
*p = (int)(intx(obj));
}
void ReadClosure::do_bool(bool* p) {
intptr_t obj = nextPtr();
*p = (bool)(uintx(obj));

View File

@ -192,6 +192,10 @@ public:
_dump_region->append_intptr_t((intptr_t)(*p));
}
void do_int(int* p) {
_dump_region->append_intptr_t((intptr_t)(*p));
}
void do_bool(bool *p) {
_dump_region->append_intptr_t((intptr_t)(*p));
}
@ -221,6 +225,7 @@ public:
void do_ptr(void** p);
void do_u4(u4* p);
void do_int(int* p);
void do_bool(bool *p);
void do_tag(int tag);
void do_oop(oop *p);

View File

@ -228,7 +228,7 @@ char* CppVtables::dumptime_init(ArchiveBuilder* builder) {
}
void CppVtables::serialize(SerializeClosure* soc) {
soc->do_ptr((void**)&_index);
soc->do_ptr(&_index);
if (soc->reading()) {
CPP_VTABLE_TYPES_DO(INITIALIZE_VTABLE);
}

View File

@ -855,7 +855,7 @@ void HeapShared::serialize_root(SerializeClosure* soc) {
void HeapShared::serialize_tables(SerializeClosure* soc) {
#ifndef PRODUCT
soc->do_ptr((void**)&_archived_ArchiveHeapTestClass);
soc->do_ptr(&_archived_ArchiveHeapTestClass);
if (soc->reading() && _archived_ArchiveHeapTestClass != nullptr) {
_test_class_name = _archived_ArchiveHeapTestClass->adr_at(0);
setup_test_class(_test_class_name);

View File

@ -266,5 +266,5 @@ void LambdaFormInvokers::read_static_archive_invokers() {
}
void LambdaFormInvokers::serialize(SerializeClosure* soc) {
soc->do_ptr((void**)&_static_archive_invokers);
soc->do_ptr(&_static_archive_invokers);
}

View File

@ -56,8 +56,8 @@ public:
void init_archived_entries(ClassLoaderData* loader_data);
void serialize(SerializeClosure* f) {
f->do_ptr((void**)&_packages);
f->do_ptr((void**)&_modules);
f->do_ptr(&_packages);
f->do_ptr(&_modules);
}
void restore(ClassLoaderData* loader_data, bool do_entries, bool do_oops);
@ -169,7 +169,7 @@ void ClassLoaderDataShared::serialize(SerializeClosure* f) {
_archived_boot_loader_data.serialize(f);
_archived_platform_loader_data.serialize(f);
_archived_system_loader_data.serialize(f);
f->do_ptr((void**)&_archived_javabase_moduleEntry);
f->do_ptr(&_archived_javabase_moduleEntry);
if (f->reading() && MetaspaceShared::use_full_module_graph()) {
// Must be done before ClassLoader::create_javabase()

View File

@ -213,8 +213,8 @@ void SimpleCompactHashtable::serialize_header(SerializeClosure* soc) {
// calculate_header_size() accordingly.
soc->do_u4(&_entry_count);
soc->do_u4(&_bucket_count);
soc->do_ptr((void**)&_buckets);
soc->do_ptr((void**)&_entries);
soc->do_ptr(&_buckets);
soc->do_ptr(&_entries);
if (soc->reading()) {
_base_address = (address)SharedBaseAddress;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -47,12 +47,12 @@
#if INCLUDE_CDS
#define INJECTED_FIELD_SERIALIZE_OFFSET(klass, name, signature, may_be_java) \
f->do_u4((u4*)&_##name##_offset);
f->do_int(&_##name##_offset);
#endif
#if INCLUDE_CDS
#define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
f->do_u4((u4*)&offset)
f->do_int(&offset)
#endif
#define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \

View File

@ -932,6 +932,6 @@ void StringTable::serialize_shared_table_header(SerializeClosure* soc) {
}
soc->do_bool(&_is_two_dimensional_shared_strings_array);
soc->do_u4((u4*)(&_shared_strings_array_root_index));
soc->do_int(&_shared_strings_array_root_index);
}
#endif //INCLUDE_CDS_JAVA_HEAP

View File

@ -1268,7 +1268,7 @@ void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc,
void SystemDictionaryShared::serialize_vm_classes(SerializeClosure* soc) {
for (auto id : EnumRange<vmClassID>{}) {
soc->do_ptr((void**)vmClasses::klass_addr_at(id));
soc->do_ptr(vmClasses::klass_addr_at(id));
}
}

View File

@ -341,6 +341,9 @@ public:
// Read/write the 32-bit unsigned integer pointed to by p.
virtual void do_u4(u4* p) = 0;
// Read/write the int pointed to by p.
virtual void do_int(int* p) = 0;
// Read/write the bool pointed to by p.
virtual void do_bool(bool* p) = 0;
@ -359,6 +362,9 @@ public:
bool writing() {
return !reading();
}
// Useful alias
template <typename T> void do_ptr(T** p) { do_ptr((void**)p); }
};
class SymbolClosure : public StackObj {

View File

@ -261,25 +261,25 @@ void Universe::serialize(SerializeClosure* f) {
#if INCLUDE_CDS_JAVA_HEAP
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
f->do_u4((u4*)&_archived_basic_type_mirror_indices[i]);
f->do_int(&_archived_basic_type_mirror_indices[i]);
// if f->reading(): We can't call HeapShared::get_root() yet, as the heap
// contents may need to be relocated. _basic_type_mirrors[i] will be
// updated later in Universe::update_archived_basic_type_mirrors().
}
#endif
f->do_ptr((void**)&_fillerArrayKlassObj);
f->do_ptr(&_fillerArrayKlassObj);
for (int i = 0; i < T_LONG+1; i++) {
f->do_ptr((void**)&_typeArrayKlassObjs[i]);
f->do_ptr(&_typeArrayKlassObjs[i]);
}
f->do_ptr((void**)&_objectArrayKlassObj);
f->do_ptr((void**)&_the_array_interfaces_array);
f->do_ptr((void**)&_the_empty_int_array);
f->do_ptr((void**)&_the_empty_short_array);
f->do_ptr((void**)&_the_empty_method_array);
f->do_ptr((void**)&_the_empty_klass_array);
f->do_ptr((void**)&_the_empty_instance_klass_array);
f->do_ptr(&_objectArrayKlassObj);
f->do_ptr(&_the_array_interfaces_array);
f->do_ptr(&_the_empty_int_array);
f->do_ptr(&_the_empty_short_array);
f->do_ptr(&_the_empty_method_array);
f->do_ptr(&_the_empty_klass_array);
f->do_ptr(&_the_empty_instance_klass_array);
_finalizer_register_cache->serialize(f);
_loader_addClass_cache->serialize(f);
_throw_illegal_access_error_cache->serialize(f);
@ -1268,6 +1268,10 @@ Method* LatestMethodCache::get_method() {
return m;
}
void LatestMethodCache::serialize(SerializeClosure* f) {
f->do_ptr(&_klass);
}
#ifdef ASSERT
// Release dummy object(s) at bottom of heap
bool Universe::release_fullgc_alot_dummy() {

View File

@ -43,6 +43,7 @@ class CollectedHeap;
class DeferredObjAllocEvent;
class OopStorage;
class ReservedHeapSpace;
class SerializeClosure;
// A helper class for caching a Method* when the user of the cache
// only cares about the latest version of the Method*. This cache safely
@ -67,9 +68,7 @@ class LatestMethodCache : public CHeapObj<mtClass> {
// CDS support. Replace the klass in this with the archive version
// could use this for Enhanced Class Redefinition also.
void serialize(SerializeClosure* f) {
f->do_ptr((void**)&_klass);
}
void serialize(SerializeClosure* f);
void metaspace_pointers_do(MetaspaceClosure* it);
};

View File

@ -69,6 +69,6 @@ int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
#if INCLUDE_CDS
void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) {
f->do_u4((u4*)&_offset_of_static_fields);
f->do_int(&_offset_of_static_fields);
}
#endif

View File

@ -46,7 +46,7 @@ int InstanceStackChunkKlass::_offset_of_stack = 0;
#if INCLUDE_CDS
void InstanceStackChunkKlass::serialize_offsets(SerializeClosure* f) {
f->do_u4((u4*)&_offset_of_stack);
f->do_int(&_offset_of_stack);
}
#endif