8336103: Clean up confusing Method::is_initializer

Reviewed-by: dholmes, coleenp
This commit is contained in:
Aleksey Shipilev 2024-10-15 12:16:15 +00:00
parent 2c0c65353b
commit 54c9348c8c
7 changed files with 11 additions and 20 deletions

View File

@ -1249,7 +1249,6 @@ bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs);
bool ciMethod::is_getter () const { FETCH_FLAG_FROM_VM(is_getter); }
bool ciMethod::is_setter () const { FETCH_FLAG_FROM_VM(is_setter); }
bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); }
bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); }
bool ciMethod::is_empty () const { FETCH_FLAG_FROM_VM(is_empty_method); }
bool ciMethod::is_boxing_method() const {

View File

@ -352,7 +352,6 @@ class ciMethod : public ciMetadata {
bool is_getter () const;
bool is_setter () const;
bool is_accessor () const;
bool is_initializer () const;
bool is_empty () const;
bool can_be_statically_bound() const { return _can_be_statically_bound; }
bool has_reserved_stack_access() const { return _has_reserved_stack_access; }

View File

@ -87,7 +87,7 @@ void JVMCICompiler::bootstrap(TRAPS) {
int len = objectMethods->length();
for (int i = 0; i < len; i++) {
methodHandle mh(THREAD, objectMethods->at(i));
if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) {
if (!mh->is_native() && !mh->is_static() && !mh->is_object_initializer() && !mh->is_static_initializer()) {
ResourceMark rm;
int hot_count = 10; // TODO: what's the appropriate value?
CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, CHECK);

View File

@ -2178,7 +2178,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredConstructors, (JNIEnv* env, jobject, A
GrowableArray<Method*> constructors_array;
for (int i = 0; i < iklass->methods()->length(); i++) {
Method* m = iklass->methods()->at(i);
if (m->is_initializer() && !m->is_static()) {
if (m->is_object_initializer()) {
constructors_array.append(m);
}
}
@ -2205,7 +2205,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, ARGUME
GrowableArray<Method*> methods_array;
for (int i = 0; i < iklass->methods()->length(); i++) {
Method* m = iklass->methods()->at(i);
if (!m->is_initializer() && !m->is_overpass()) {
if (!m->is_object_initializer() && !m->is_static_initializer() && !m->is_overpass()) {
methods_array.append(m);
}
}
@ -2921,12 +2921,11 @@ C2V_VMENTRY_NULL(jobject, asReflectionExecutable, (JNIEnv* env, jobject, ARGUMEN
requireInHotSpot("asReflectionExecutable", JVMCI_CHECK_NULL);
methodHandle m(THREAD, UNPACK_PAIR(Method, method));
oop executable;
if (m->is_initializer()) {
if (m->is_static_initializer()) {
JVMCI_THROW_MSG_NULL(IllegalArgumentException,
"Cannot create java.lang.reflect.Method for class initializer");
}
if (m->is_object_initializer()) {
executable = Reflection::new_constructor(m, CHECK_NULL);
} else if (m->is_static_initializer()) {
JVMCI_THROW_MSG_NULL(IllegalArgumentException,
"Cannot create java.lang.reflect.Method for class initializer");
} else {
executable = Reflection::new_method(m, false, CHECK_NULL);
}

View File

@ -1230,9 +1230,10 @@ void klassItable::initialize_itable_and_check_constraints(TRAPS) {
}
inline bool interface_method_needs_itable_index(Method* m) {
if (m->is_static()) return false; // e.g., Stream.empty
if (m->is_initializer()) return false; // <init> or <clinit>
if (m->is_private()) return false; // uses direct call
if (m->is_static()) return false; // e.g., Stream.empty
if (m->is_object_initializer()) return false; // <init>
if (m->is_static_initializer()) return false; // <clinit>
if (m->is_private()) return false; // uses direct call
// If an interface redeclares a method from java.lang.Object,
// it should already have a vtable index, don't touch it.
// e.g., CharSequence.toString (from initialize_vtable)

View File

@ -846,10 +846,6 @@ bool Method::is_constant_getter() const {
Bytecodes::is_return(java_code_at(last_index)));
}
bool Method::is_initializer() const {
return is_object_initializer() || is_static_initializer();
}
bool Method::has_valid_initializer_flags() const {
return (is_static() ||
method_holder()->major_version() < 51);

View File

@ -576,9 +576,6 @@ public:
// returns true if the method does nothing but return a constant of primitive type
bool is_constant_getter() const;
// returns true if the method is an initializer (<init> or <clinit>).
bool is_initializer() const;
// returns true if the method is static OR if the classfile version < 51
bool has_valid_initializer_flags() const;