Skip to content
Permalink
Browse files
8247220: Make OopHandle constructor explicit
Fix null initializations to explicitly call the OopHandle constructor

Reviewed-by: lfoltan, kbarrett
  • Loading branch information
coleenp committed Jun 10, 2020
1 parent 65c461e commit f3c2a17a3041016338b1e8d0e7d04eef7de9a1b6
Showing 9 changed files with 19 additions and 19 deletions.
@@ -183,15 +183,15 @@ ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() {
}
}

oop* ClassLoaderData::ChunkedHandleList::add(oop o) {
OopHandle ClassLoaderData::ChunkedHandleList::add(oop o) {
if (_head == NULL || _head->_size == Chunk::CAPACITY) {
Chunk* next = new Chunk(_head);
Atomic::release_store(&_head, next);
}
oop* handle = &_head->_data[_head->_size];
NativeAccess<IS_DEST_UNINITIALIZED>::oop_store(handle, o);
Atomic::release_store(&_head->_size, _head->_size + 1);
return handle;
return OopHandle(handle);
}

int ClassLoaderData::ChunkedHandleList::count() const {
@@ -776,7 +776,7 @@ ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() {
OopHandle ClassLoaderData::add_handle(Handle h) {
MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
record_modified_oops();
return OopHandle(_handles.add(h()));
return _handles.add(h());
}

void ClassLoaderData::remove_handle(OopHandle h) {
@@ -90,7 +90,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {

// Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
// However, multiple threads can execute oops_do concurrently with add.
oop* add(oop o);
OopHandle add(oop o);
bool contains(oop p);
NOT_PRODUCT(bool owner_of(oop* p);)
void oops_do(OopClosure* f);
@@ -895,7 +895,7 @@ void java_lang_Class::fixup_mirror(Klass* k, TRAPS) {
assert(present, "Missing archived mirror for %s", k->external_name());
return;
} else {
k->set_java_mirror_handle(NULL);
k->set_java_mirror_handle(OopHandle());
k->clear_has_raw_archived_mirror();
}
}
@@ -1201,7 +1201,7 @@ oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
ik->is_shared_app_class())) {
// Archiving mirror for classes from non-builtin loaders is not
// supported. Clear the _java_mirror within the archived class.
k->set_java_mirror_handle(NULL);
k->set_java_mirror_handle(OopHandle());
return NULL;
}
}
@@ -79,9 +79,9 @@ class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {

public:
void init() {
_module = NULL;
_module = OopHandle();
_pd = OopHandle();
_loader_data = NULL;
_pd = NULL;
_reads = NULL;
_version = NULL;
_location = NULL;
@@ -61,9 +61,9 @@
#include "utilities/stringUtils.hpp"


OopHandle SystemDictionaryShared::_shared_protection_domains = NULL;
OopHandle SystemDictionaryShared::_shared_jar_urls = NULL;
OopHandle SystemDictionaryShared::_shared_jar_manifests = NULL;
OopHandle SystemDictionaryShared::_shared_protection_domains;
OopHandle SystemDictionaryShared::_shared_jar_urls;
OopHandle SystemDictionaryShared::_shared_jar_manifests;
DEBUG_ONLY(bool SystemDictionaryShared::_no_class_loading_should_happen = false;)

class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
@@ -283,7 +283,7 @@ void ConstantPool::archive_resolved_references(Thread* THREAD) {
ik->is_shared_app_class())) {
// Archiving resolved references for classes from non-builtin loaders
// is not yet supported.
set_resolved_references(NULL);
set_resolved_references(OopHandle());
return;
}

@@ -315,7 +315,7 @@ void ConstantPool::archive_resolved_references(Thread* THREAD) {
// resolved references will be created using the normal process
// when there is no archived value.
_cache->set_archived_references(archived);
set_resolved_references(NULL);
set_resolved_references(OopHandle());
}
}

@@ -389,7 +389,7 @@ void ConstantPool::remove_unshareable_info() {
// If DynamicDumpSharedSpaces is enabled, clear the resolved references also
// as java objects are not archived in the top layer.
if (!HeapShared::is_heap_object_archiving_allowed() || DynamicDumpSharedSpaces) {
set_resolved_references(NULL);
set_resolved_references(OopHandle());
}

// Shared ConstantPools are in the RO region, so the _flags cannot be modified.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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
@@ -767,7 +767,7 @@ void ConstantPoolCache::walk_entries_for_initialization(bool check_only) {
void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) {
assert(!is_shared(), "shared caches are not deallocated");
data->remove_handle(_resolved_references);
set_resolved_references(NULL);
set_resolved_references(OopHandle());
MetadataFactory::free_array<u2>(data, _reference_map);
set_reference_map(NULL);
}
@@ -555,7 +555,7 @@ void Klass::remove_java_mirror() {
log_trace(cds, unshareable)("remove java_mirror: %s", external_name());
}
// Just null out the mirror. The class_loader_data() no longer exists.
_java_mirror = NULL;
_java_mirror = OopHandle();
}

void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
@@ -609,7 +609,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec

// No archived mirror data
log_debug(cds, mirror)("No archived mirror data for %s", external_name());
_java_mirror = NULL;
_java_mirror = OopHandle();
this->clear_has_raw_archived_mirror();
}

@@ -42,7 +42,7 @@ class OopHandle {

public:
OopHandle() : _obj(NULL) {}
OopHandle(oop* w) : _obj(w) {}
explicit OopHandle(oop* w) : _obj(w) {}

inline static OopHandle create(oop obj);

0 comments on commit f3c2a17

Please sign in to comment.