Skip to content

Commit

Permalink
8320522: Remove code related to RegisterFinalizersAtInit
Browse files Browse the repository at this point in the history
Reviewed-by: coleenp, ayang, kbarrett
  • Loading branch information
Dan Heidinga authored and coleenp committed Apr 19, 2024
1 parent 650ca65 commit 3c1d1d9
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3611,7 +3611,7 @@ void TemplateTable::_new() {
__ ldrw(r3,
Address(r4,
Klass::layout_helper_offset()));
// test to see if it has a finalizer or is malformed in some way
// test to see if it is malformed in some way
__ tbnz(r3, exact_log2(Klass::_lh_instance_slow_path_bit), slow_case);

// Allocate the instance:
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/templateTable_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3971,7 +3971,7 @@ void TemplateTable::_new() {
__ b(slow_case, ne);
__ load_resolved_klass_at_offset(Rcpool, Rindex, Rklass);

// make sure klass is initialized & doesn't have finalizer
// make sure klass is initialized
// make sure klass is fully initialized
__ ldrb(Rtemp, Address(Rklass, InstanceKlass::init_state_offset()));
__ cmp(Rtemp, InstanceKlass::fully_initialized);
Expand All @@ -3980,7 +3980,7 @@ void TemplateTable::_new() {
// get instance_size in InstanceKlass (scaled to a count of bytes)
__ ldr_u32(Rsize, Address(Rklass, Klass::layout_helper_offset()));

// test to see if it has a finalizer or is malformed in some way
// test to see if it is malformed in some way
// Klass::_lh_instance_slow_path_bit is really a bit mask, not bit number
__ tbnz(Rsize, exact_log2(Klass::_lh_instance_slow_path_bit), slow_case);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3809,7 +3809,7 @@ void TemplateTable::_new() {

__ lwz(Rinstance_size, in_bytes(Klass::layout_helper_offset()), RinstanceKlass);

// Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
// Make sure klass is not abstract, or interface or java/lang/Class.
__ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
__ bne(CCR0, Lslow_case);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/templateTable_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3554,7 +3554,7 @@ void TemplateTable::_new() {

// get instance_size in InstanceKlass (scaled to a count of bytes)
__ lwu(x13, Address(x14, Klass::layout_helper_offset()));
// test to see if it has a finalizer or is malformed in some way
// test to see if is malformed in some way
__ test_bit(t0, x13, exact_log2(Klass::_lh_instance_slow_path_bit));
__ bnez(t0, slow_case);

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/x86/templateTable_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4057,10 +4057,9 @@ void TemplateTable::_new() {
__ jcc(Assembler::notEqual, slow_case);
#endif

// make sure klass doesn't have finalizer
// get instance_size in InstanceKlass (scaled to a count of bytes)
__ movl(rdx, Address(rcx, Klass::layout_helper_offset()));
// test to see if it has a finalizer or is malformed in some way
// test to see if it is malformed in some way
__ testl(rdx, Klass::_lh_instance_slow_path_bit);
__ jcc(Assembler::notZero, slow_case);

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,7 @@ void GraphBuilder::call_register_finalizer() {


void GraphBuilder::method_return(Value x, bool ignore_return) {
if (RegisterFinalizersAtInit &&
method()->intrinsic_id() == vmIntrinsics::_Object_init) {
if (method()->intrinsic_id() == vmIntrinsics::_Object_init) {
call_register_finalizer();
}

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4188,8 +4188,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) {
// If it cannot be fast-path allocated, set a bit in the layout helper.
// See documentation of InstanceKlass::can_be_fastpath_allocated().
assert(ik->size_helper() > 0, "layout_helper is initialized");
if ((!RegisterFinalizersAtInit && ik->has_finalizer())
|| ik->is_abstract() || ik->is_interface()
if (ik->is_abstract() || ik->is_interface()
|| (ik->name() == vmSymbols::java_lang_Class() && ik->class_loader() == nullptr)
|| ik->size_helper() >= FastAllocateSizeLimit) {
// Forbid fast-path allocation.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/interpreter/abstractInterpreter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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
Expand Down Expand Up @@ -149,7 +149,7 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHan
case vmIntrinsics::_dsqrt_strict: return java_lang_math_sqrt_strict;
case vmIntrinsics::_Reference_get: return java_lang_ref_reference_get;
case vmIntrinsics::_Object_init:
if (RegisterFinalizersAtInit && m->code_size() == 1) {
if (m->code_size() == 1) {
// We need to execute the special return bytecode to check for
// finalizer registration so create a normal frame.
return zerolocals;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void Rewriter::rewrite_bytecodes(TRAPS) {
// determine index maps for Method* rewriting
compute_index_maps();

if (RegisterFinalizersAtInit && _klass->name() == vmSymbols::java_lang_Object()) {
if (_klass->name() == vmSymbols::java_lang_Object()) {
bool did_rewrite = false;
int i = _methods->length();
while (i-- > 0) {
Expand Down
10 changes: 1 addition & 9 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,16 +1509,8 @@ instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
}

instanceOop InstanceKlass::allocate_instance(TRAPS) {
bool has_finalizer_flag = has_finalizer(); // Query before possible GC
size_t size = size_helper(); // Query before forming handle.

instanceOop i;

i = (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
if (has_finalizer_flag && !RegisterFinalizersAtInit) {
i = register_finalizer(i, CHECK_NULL);
}
return i;
return (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
}

instanceOop InstanceKlass::allocate_instance(oop java_class, TRAPS) {
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/oops/instanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,6 @@ class InstanceKlass: public Klass {
// This bit is initialized in classFileParser.cpp.
// It is false under any of the following conditions:
// - the class is abstract (including any interface)
// - the class has a finalizer (if !RegisterFinalizersAtInit)
// - the class size is larger than FastAllocateSizeLimit
// - the class is java/lang/Class, which cannot be allocated directly
bool can_be_fastpath_allocated() const {
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/opto/parse1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,7 @@ void Parse::rtm_deopt() {
//------------------------------return_current---------------------------------
// Append current _map to _exit_return
void Parse::return_current(Node* value) {
if (RegisterFinalizersAtInit &&
method()->intrinsic_id() == vmIntrinsics::_Object_init) {
if (method()->intrinsic_id() == vmIntrinsics::_Object_init) {
call_register_finalizer();
}

Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,6 @@ const int ObjectAlignmentInBytes = 8;
product(bool, PrintWarnings, true, \
"Print JVM warnings to output stream") \
\
product(bool, RegisterFinalizersAtInit, true, \
"(Deprecated) Register finalizable objects at end of " \
"Object.<init> or after allocation") \
\
develop(bool, RegisterReferences, true, \
"Tell whether the VM should register soft/weak/final/phantom " \
"references") \
Expand Down

1 comment on commit 3c1d1d9

@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.