Skip to content

Commit

Permalink
8230841: Remove oopDesc::equals()
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke, clanger
Backport-of: 2d6874b
  • Loading branch information
shipilev committed Aug 15, 2021
1 parent 8a470e1 commit 12312a3
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 84 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
// Calculate accessibility the hard way.
if (!k->is_loaded()) {
is_accessible = false;
} else if (!oopDesc::equals(k->loader(), accessor->loader()) &&
} else if (k->loader() != accessor->loader() &&
get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
// Loaded only remotely. Not linked yet.
is_accessible = false;
Expand Down Expand Up @@ -596,7 +596,7 @@ ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,
index = cpool->object_to_cp_index(cache_index);
oop obj = cpool->resolved_references()->obj_at(cache_index);
if (obj != NULL) {
if (oopDesc::equals(obj, Universe::the_null_sentinel())) {
if (obj == Universe::the_null_sentinel()) {
return ciConstant(T_OBJECT, get_object(NULL));
}
BasicType bt = T_OBJECT;
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/ci/ciObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ciObject* ciObjectFactory::get(oop key) {
// into the cache.
Handle keyHandle(Thread::current(), key);
ciObject* new_object = create_new_object(keyHandle());
assert(oopDesc::equals(keyHandle(), new_object->get_oop()), "must be properly recorded");
assert(keyHandle() == new_object->get_oop(), "must be properly recorded");
init_ident_of(new_object);
assert(Universe::heap()->is_in_reserved(new_object->get_oop()), "must be");

Expand Down Expand Up @@ -450,8 +450,8 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass,
for (int i=0; i<_unloaded_klasses->length(); i++) {
ciKlass* entry = _unloaded_klasses->at(i);
if (entry->name()->equals(name) &&
oopDesc::equals(entry->loader(), loader) &&
oopDesc::equals(entry->protection_domain(), domain)) {
entry->loader() == loader &&
entry->protection_domain() == domain) {
// We've found a match.
return entry;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/classLoaderData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class VerifyContainsOopClosure : public OopClosure {
VerifyContainsOopClosure(oop target) : _target(target), _found(false) {}

void do_oop(oop* p) {
if (p != NULL && oopDesc::equals(RawAccess<>::oop_load(p), _target)) {
if (p != NULL && RawAccess<>::oop_load(p) == _target) {
_found = true;
}
}
Expand Down Expand Up @@ -425,7 +425,7 @@ void ClassLoaderData::record_dependency(const Klass* k) {

// Just return if this dependency is to a class with the same or a parent
// class_loader.
if (oopDesc::equals(from, to) || java_lang_ClassLoader::isAncestor(from, to)) {
if (from == to || java_lang_ClassLoader::isAncestor(from, to)) {
return; // this class loader is in the parent list, no need to add it.
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/classfile/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ bool Dictionary::resize_if_needed() {

bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
#ifdef ASSERT
if (oopDesc::equals(protection_domain, instance_klass()->protection_domain())) {
if (protection_domain == instance_klass()->protection_domain()) {
// Ensure this doesn't show up in the pd_set (invariant)
bool in_pd_set = false;
for (ProtectionDomainEntry* current = pd_set_acquire();
current != NULL;
current = current->next()) {
if (oopDesc::equals(current->object_no_keepalive(), protection_domain)) {
if (current->object_no_keepalive() == protection_domain) {
in_pd_set = true;
break;
}
Expand All @@ -178,15 +178,15 @@ bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
}
#endif /* ASSERT */

if (oopDesc::equals(protection_domain, instance_klass()->protection_domain())) {
if (protection_domain == instance_klass()->protection_domain()) {
// Succeeds trivially
return true;
}

for (ProtectionDomainEntry* current = pd_set_acquire();
current != NULL;
current = current->next()) {
if (oopDesc::equals(current->object_no_keepalive(), protection_domain)) return true;
if (current->object_no_keepalive() == protection_domain) return true;
}
return false;
}
Expand Down
18 changes: 9 additions & 9 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo
} else {
assert(Universe::is_module_initialized() ||
(ModuleEntryTable::javabase_defined() &&
(oopDesc::equals(module(), ModuleEntryTable::javabase_moduleEntry()->module()))),
(module() == ModuleEntryTable::javabase_moduleEntry()->module())),
"Incorrect java.lang.Module specification while creating mirror");
set_module(mirror(), module());
}
Expand Down Expand Up @@ -947,7 +947,7 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
}

// set the classLoader field in the java_lang_Class instance
assert(oopDesc::equals(class_loader(), k->class_loader()), "should be same");
assert(class_loader() == k->class_loader(), "should be same");
set_class_loader(mirror(), class_loader());

// Setup indirection from klass->mirror
Expand Down Expand Up @@ -1501,9 +1501,9 @@ BasicType java_lang_Class::primitive_type(oop java_class) {
// Note: create_basic_type_mirror above initializes ak to a non-null value.
type = ArrayKlass::cast(ak)->element_type();
} else {
assert(oopDesc::equals(java_class, Universe::void_mirror()), "only valid non-array primitive");
assert(java_class == Universe::void_mirror(), "only valid non-array primitive");
}
assert(oopDesc::equals(Universe::java_mirror(type), java_class), "must be consistent");
assert(Universe::java_mirror(type) == java_class, "must be consistent");
return type;
}

Expand Down Expand Up @@ -3865,14 +3865,14 @@ Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_fou
}

bool java_lang_invoke_MethodType::equals(oop mt1, oop mt2) {
if (oopDesc::equals(mt1, mt2))
if (mt1 == mt2)
return true;
if (!oopDesc::equals(rtype(mt1), rtype(mt2)))
if (rtype(mt1) != rtype(mt2))
return false;
if (ptype_count(mt1) != ptype_count(mt2))
return false;
for (int i = ptype_count(mt1) - 1; i >= 0; i--) {
if (!oopDesc::equals(ptype(mt1, i), ptype(mt2, i)))
if (ptype(mt1, i) != ptype(mt2, i))
return false;
}
return true;
Expand Down Expand Up @@ -4091,7 +4091,7 @@ bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) {
// This loop taken verbatim from ClassLoader.java:
do {
acl = parent(acl);
if (oopDesc::equals(cl, acl)) {
if (cl == acl) {
return true;
}
assert(++loop_count > 0, "loop_count overflow");
Expand Down Expand Up @@ -4121,7 +4121,7 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) {

oop cl = SystemDictionary::java_system_loader();
while(cl != NULL) {
if (oopDesc::equals(cl, loader)) return true;
if (cl == loader) return true;
cl = parent(cl);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/protectionDomainCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ProtectionDomainCacheEntry* ProtectionDomainCacheTable::get(Handle protection_do

ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
if (oopDesc::equals(e->object_no_keepalive(), protection_domain())) {
if (e->object_no_keepalive() == protection_domain()) {
return e;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ bool SystemDictionary::is_system_class_loader(oop class_loader) {
return false;
}
return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() ||
oopDesc::equals(class_loader, _java_system_loader));
class_loader == _java_system_loader);
}

// Returns true if the passed class loader is the platform class loader.
Expand Down Expand Up @@ -384,7 +384,7 @@ Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
((quicksuperk = childk->super()) != NULL) &&

((quicksuperk->name() == class_name) &&
(oopDesc::equals(quicksuperk->class_loader(), class_loader())))) {
(quicksuperk->class_loader() == class_loader()))) {
return quicksuperk;
} else {
PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
Expand Down Expand Up @@ -518,7 +518,7 @@ void SystemDictionary::double_lock_wait(Handle lockObject, TRAPS) {
bool calledholdinglock
= ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, lockObject);
assert(calledholdinglock,"must hold lock for notify");
assert((!oopDesc::equals(lockObject(), _system_loader_lock_obj) && !is_parallelCapable(lockObject)), "unexpected double_lock_wait");
assert((lockObject() != _system_loader_lock_obj && !is_parallelCapable(lockObject)), "unexpected double_lock_wait");
ObjectSynchronizer::notifyall(lockObject, THREAD);
intptr_t recursions = ObjectSynchronizer::complete_exit(lockObject, THREAD);
SystemDictionary_lock->wait();
Expand Down Expand Up @@ -824,7 +824,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// If everything was OK (no exceptions, no null return value), and
// class_loader is NOT the defining loader, do a little more bookkeeping.
if (!HAS_PENDING_EXCEPTION && k != NULL &&
!oopDesc::equals(k->class_loader(), class_loader())) {
k->class_loader() != class_loader()) {

check_constraints(d_hash, k, class_loader, false, THREAD);

Expand Down Expand Up @@ -977,7 +977,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
if (host_klass != NULL) {
// Create a new CLD for anonymous class, that uses the same class loader
// as the host_klass
guarantee(oopDesc::equals(host_klass->class_loader(), class_loader()), "should be the same");
guarantee(host_klass->class_loader() == class_loader(), "should be the same");
loader_data = ClassLoaderData::anonymous_class_loader_data(class_loader);
} else {
loader_data = ClassLoaderData::class_loader_data(class_loader());
Expand Down Expand Up @@ -1750,7 +1750,7 @@ void SystemDictionary::check_loader_lock_contention(Handle loader_lock, TRAPS) {
== ObjectSynchronizer::owner_other) {
// contention will likely happen, so increment the corresponding
// contention counter.
if (oopDesc::equals(loader_lock(), _system_loader_lock_obj)) {
if (loader_lock() == _system_loader_lock_obj) {
ClassLoader::sync_systemLoaderLockContentionRate()->inc();
} else {
ClassLoader::sync_nonSystemLoaderLockContentionRate()->inc();
Expand Down Expand Up @@ -2186,7 +2186,7 @@ void SystemDictionary::update_dictionary(unsigned int d_hash,
// cleared if revocation occurs too often for this type
// NOTE that we must only do this when the class is initally
// defined, not each time it is referenced from a new class loader
if (oopDesc::equals(k->class_loader(), class_loader())) {
if (k->class_loader() == class_loader()) {
k->set_prototype_header(markOopDesc::biased_locking_prototype());
}
}
Expand Down Expand Up @@ -2379,7 +2379,7 @@ Symbol* SystemDictionary::check_signature_loaders(Symbol* signature,
Handle loader1, Handle loader2,
bool is_method, TRAPS) {
// Nothing to do if loaders are the same.
if (oopDesc::equals(loader1(), loader2())) {
if (loader1() == loader2()) {
return NULL;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/code/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,12 +1945,12 @@ Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_hand

if (changes == NULL) {
// Validate all CallSites
if (!oopDesc::equals(java_lang_invoke_CallSite::target(call_site), method_handle))
if (java_lang_invoke_CallSite::target(call_site) != method_handle)
return call_site->klass(); // assertion failed
} else {
// Validate the given CallSite
if (oopDesc::equals(call_site, changes->call_site()) && !oopDesc::equals(java_lang_invoke_CallSite::target(call_site), changes->method_handle())) {
assert(!oopDesc::equals(method_handle, changes->method_handle()), "must be");
if (call_site == changes->call_site() && java_lang_invoke_CallSite::target(call_site) != changes->method_handle()) {
assert(method_handle != changes->method_handle(), "must be");
return call_site->klass(); // assertion failed
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ bool CompileBroker::can_remove(CompilerThread *ct, bool do_it) {
// We only allow the last compiler thread of each type to get removed.
jobject last_compiler = c1 ? compiler1_object(compiler_count - 1)
: compiler2_object(compiler_count - 1);
if (oopDesc::equals(ct->threadObj(), JNIHandles::resolve_non_null(last_compiler))) {
if (ct->threadObj() == JNIHandles::resolve_non_null(last_compiler)) {
if (do_it) {
assert_locked_or_safepoint(CompileThread_lock); // Update must be consistent.
compiler->set_num_compiler_threads(compiler_count - 1);
Expand Down Expand Up @@ -1765,7 +1765,7 @@ CompileLog* CompileBroker::get_log(CompilerThread* ct) {
int compiler_number = 0;
bool found = false;
for (; compiler_number < count; compiler_number++) {
if (oopDesc::equals(JNIHandles::resolve_non_null(compiler_objects[compiler_number]), compiler_obj)) {
if (JNIHandles::resolve_non_null(compiler_objects[compiler_number]) == compiler_obj) {
found = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void StringDedupTable::transfer(StringDedupEntry** pentry, StringDedupTable* des
}

bool StringDedupTable::equals(typeArrayOop value1, typeArrayOop value2) {
return (oopDesc::equals(value1, value2) ||
return (value1 == value2 ||
(value1->length() == value2->length() &&
(!memcmp(value1->base(T_BYTE),
value2->base(T_BYTE),
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ BytecodeInterpreter::run(interpreterState istate) {
handle_exception);
result = THREAD->vm_result();
}
if (oopDesc::equals(result, Universe::the_null_sentinel()))
if (result == Universe::the_null_sentinel())
result = NULL;

VERIFY_OOP(result);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/interpreterRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::C
if (rindex >= 0) {
oop coop = m->constants()->resolved_references()->obj_at(rindex);
oop roop = (result == NULL ? Universe::the_null_sentinel() : result);
assert(oopDesc::equals(roop, coop), "expected result for assembly code");
assert(roop == coop, "expected result for assembly code");
}
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/memory/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,12 @@ bool Universe::should_fill_in_stack_trace(Handle throwable) {
// preallocated errors with backtrace have been consumed. Also need to avoid
// a potential loop which could happen if an out of memory occurs when attempting
// to allocate the backtrace.
return ((!oopDesc::equals(throwable(), Universe::_out_of_memory_error_java_heap)) &&
(!oopDesc::equals(throwable(), Universe::_out_of_memory_error_metaspace)) &&
(!oopDesc::equals(throwable(), Universe::_out_of_memory_error_class_metaspace)) &&
(!oopDesc::equals(throwable(), Universe::_out_of_memory_error_array_size)) &&
(!oopDesc::equals(throwable(), Universe::_out_of_memory_error_gc_overhead_limit)) &&
(!oopDesc::equals(throwable(), Universe::_out_of_memory_error_realloc_objects)));
return ((throwable() != Universe::_out_of_memory_error_java_heap) &&
(throwable() != Universe::_out_of_memory_error_metaspace) &&
(throwable() != Universe::_out_of_memory_error_class_metaspace) &&
(throwable() != Universe::_out_of_memory_error_array_size) &&
(throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
(throwable() != Universe::_out_of_memory_error_realloc_objects));
}


Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/oops/constantPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
if (cache_index >= 0) {
result_oop = this_cp->resolved_references()->obj_at(cache_index);
if (result_oop != NULL) {
if (oopDesc::equals(result_oop, Universe::the_null_sentinel())) {
if (result_oop == Universe::the_null_sentinel()) {
DEBUG_ONLY(int temp_index = (index >= 0 ? index : this_cp->object_to_cp_index(cache_index)));
assert(this_cp->tag_at(temp_index).is_dynamic_constant(), "only condy uses the null sentinel");
result_oop = NULL;
Expand Down Expand Up @@ -1093,12 +1093,12 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp,
} else {
// Return the winning thread's result. This can be different than
// the result here for MethodHandles.
if (oopDesc::equals(old_result, Universe::the_null_sentinel()))
if (old_result == Universe::the_null_sentinel())
old_result = NULL;
return old_result;
}
} else {
assert(!oopDesc::equals(result_oop, Universe::the_null_sentinel()), "");
assert(result_oop != Universe::the_null_sentinel(), "");
return result_oop;
}
}
Expand Down Expand Up @@ -1264,7 +1264,7 @@ void ConstantPool::copy_bootstrap_arguments_at_impl(const constantPoolHandle& th
oop ConstantPool::string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS) {
// If the string has already been interned, this entry will be non-null
oop str = this_cp->resolved_references()->obj_at(obj_index);
assert(!oopDesc::equals(str, Universe::the_null_sentinel()), "");
assert(str != Universe::the_null_sentinel(), "");
if (str != NULL) return str;
Symbol* sym = this_cp->unresolved_string_at(which);
str = StringTable::intern(sym, CHECK_(NULL));
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ bool InstanceKlass::is_same_class_package(const Klass* class2) const {
// and package entries. Both must be the same. This rule
// applies even to classes that are defined in the unnamed
// package, they still must have the same class loader.
if (oopDesc::equals(classloader1, classloader2) && (classpkg1 == classpkg2)) {
if ((classloader1 == classloader2) && (classpkg1 == classpkg2)) {
return true;
}

Expand All @@ -2665,7 +2665,7 @@ bool InstanceKlass::is_same_class_package(const Klass* class2) const {
// and classname information is enough to determine a class's package
bool InstanceKlass::is_same_class_package(oop other_class_loader,
const Symbol* other_class_name) const {
if (!oopDesc::equals(class_loader(), other_class_loader)) {
if (class_loader() != other_class_loader) {
return false;
}
if (name()->fast_compare(other_class_name) == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/klassVtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHand
// to link to the first super, and we get all the others.
Handle super_loader(THREAD, super_klass->class_loader());

if (!oopDesc::equals(target_loader(), super_loader())) {
if (target_loader() != super_loader()) {
ResourceMark rm(THREAD);
Symbol* failed_type_symbol =
SystemDictionary::check_signature_loaders(signature, target_loader,
Expand Down Expand Up @@ -1241,7 +1241,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass
// if checkconstraints requested
if (checkconstraints) {
Handle method_holder_loader (THREAD, target->method_holder()->class_loader());
if (!oopDesc::equals(method_holder_loader(), interface_loader())) {
if (method_holder_loader() != interface_loader()) {
ResourceMark rm(THREAD);
Symbol* failed_type_symbol =
SystemDictionary::check_signature_loaders(m->signature(),
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/objArrayKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
// Either oop or narrowOop depending on UseCompressedOops.
void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset,
arrayOop d, size_t dst_offset, int length, TRAPS) {
if (oopDesc::equals(s, d)) {
if (s == d) {
// since source and destination are equal we do not need conversion checks.
assert(length > 0, "sanity check");
ArrayAccess<>::oop_arraycopy(s, src_offset, d, dst_offset, length);
Expand Down
Loading

1 comment on commit 12312a3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.