8332745: Method::is_vanilla_constructor is never used
Reviewed-by: coleenp, ayang
This commit is contained in:
parent
cfdc64fcb4
commit
6d2aeb82bc
@ -2827,11 +2827,6 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
|
||||
_has_finalizer = true;
|
||||
}
|
||||
}
|
||||
if (name == vmSymbols::object_initializer_name() &&
|
||||
signature == vmSymbols::void_method_signature() &&
|
||||
m->is_vanilla_constructor()) {
|
||||
_has_vanilla_constructor = true;
|
||||
}
|
||||
|
||||
NOT_PRODUCT(m->verify());
|
||||
return m;
|
||||
@ -4162,29 +4157,6 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this klass has a vanilla default constructor
|
||||
if (super == nullptr) {
|
||||
// java.lang.Object has empty default constructor
|
||||
ik->set_has_vanilla_constructor();
|
||||
} else {
|
||||
if (super->has_vanilla_constructor() &&
|
||||
_has_vanilla_constructor) {
|
||||
ik->set_has_vanilla_constructor();
|
||||
}
|
||||
#ifdef ASSERT
|
||||
bool v = false;
|
||||
if (super->has_vanilla_constructor()) {
|
||||
const Method* const constructor =
|
||||
ik->find_method(vmSymbols::object_initializer_name(),
|
||||
vmSymbols::void_method_signature());
|
||||
if (constructor != nullptr && constructor->is_vanilla_constructor()) {
|
||||
v = true;
|
||||
}
|
||||
}
|
||||
assert(v == ik->has_vanilla_constructor(), "inconsistent has_vanilla_constructor");
|
||||
#endif
|
||||
}
|
||||
|
||||
// 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");
|
||||
@ -5371,7 +5343,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
|
||||
ik->set_has_contended_annotations(true);
|
||||
}
|
||||
|
||||
// Fill in has_finalizer, has_vanilla_constructor, and layout_helper
|
||||
// Fill in has_finalizer and layout_helper
|
||||
set_precomputed_flags(ik);
|
||||
|
||||
// check if this class can access its super class
|
||||
@ -5557,7 +5529,6 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
|
||||
_has_contended_fields(false),
|
||||
_has_finalizer(false),
|
||||
_has_empty_finalizer(false),
|
||||
_has_vanilla_constructor(false),
|
||||
_max_bootstrap_specifier_index(-1) {
|
||||
|
||||
_class_name = name != nullptr ? name : vmSymbols::unknown_class_name();
|
||||
|
@ -197,7 +197,6 @@ class ClassFileParser {
|
||||
// precomputed flags
|
||||
bool _has_finalizer;
|
||||
bool _has_empty_finalizer;
|
||||
bool _has_vanilla_constructor;
|
||||
int _max_bootstrap_specifier_index; // detects BSS values
|
||||
|
||||
void parse_stream(const ClassFileStream* const stream, TRAPS);
|
||||
|
@ -766,8 +766,6 @@ public:
|
||||
bool declares_nonstatic_concrete_methods() const { return _misc_flags.declares_nonstatic_concrete_methods(); }
|
||||
void set_declares_nonstatic_concrete_methods(bool b) { _misc_flags.set_declares_nonstatic_concrete_methods(b); }
|
||||
|
||||
bool has_vanilla_constructor() const { return _misc_flags.has_vanilla_constructor(); }
|
||||
void set_has_vanilla_constructor() { _misc_flags.set_has_vanilla_constructor(true); }
|
||||
bool has_miranda_methods () const { return _misc_flags.has_miranda_methods(); }
|
||||
void set_has_miranda_methods() { _misc_flags.set_has_miranda_methods(true); }
|
||||
bool has_final_method() const { return _misc_flags.has_final_method(); }
|
||||
|
@ -53,8 +53,7 @@ class InstanceKlassFlags {
|
||||
flag(has_contended_annotations , 1 << 10) /* has @Contended annotation */ \
|
||||
flag(has_localvariable_table , 1 << 11) /* has localvariable information */ \
|
||||
flag(has_miranda_methods , 1 << 12) /* True if this class has miranda methods in it's vtable */ \
|
||||
flag(has_vanilla_constructor , 1 << 13) /* True if klass has a vanilla default constructor */ \
|
||||
flag(has_final_method , 1 << 14) /* True if klass has final method */ \
|
||||
flag(has_final_method , 1 << 13) /* True if klass has final method */ \
|
||||
/* end of list */
|
||||
|
||||
#define IK_FLAGS_ENUM_NAME(name, value) _misc_##name = value,
|
||||
|
@ -661,49 +661,6 @@ int Method::extra_stack_words() {
|
||||
return extra_stack_entries() * Interpreter::stackElementSize;
|
||||
}
|
||||
|
||||
bool Method::is_vanilla_constructor() const {
|
||||
// Returns true if this method is a vanilla constructor, i.e. an "<init>" "()V" method
|
||||
// which only calls the superclass vanilla constructor and possibly does stores of
|
||||
// zero constants to local fields:
|
||||
//
|
||||
// aload_0
|
||||
// invokespecial
|
||||
// indexbyte1
|
||||
// indexbyte2
|
||||
//
|
||||
// followed by an (optional) sequence of:
|
||||
//
|
||||
// aload_0
|
||||
// aconst_null / iconst_0 / fconst_0 / dconst_0
|
||||
// putfield
|
||||
// indexbyte1
|
||||
// indexbyte2
|
||||
//
|
||||
// followed by:
|
||||
//
|
||||
// return
|
||||
|
||||
assert(name() == vmSymbols::object_initializer_name(), "Should only be called for default constructors");
|
||||
assert(signature() == vmSymbols::void_method_signature(), "Should only be called for default constructors");
|
||||
int size = code_size();
|
||||
// Check if size match
|
||||
if (size == 0 || size % 5 != 0) return false;
|
||||
address cb = code_base();
|
||||
int last = size - 1;
|
||||
if (cb[0] != Bytecodes::_aload_0 || cb[1] != Bytecodes::_invokespecial || cb[last] != Bytecodes::_return) {
|
||||
// Does not call superclass default constructor
|
||||
return false;
|
||||
}
|
||||
// Check optional sequence
|
||||
for (int i = 4; i < last; i += 5) {
|
||||
if (cb[i] != Bytecodes::_aload_0) return false;
|
||||
if (!Bytecodes::is_zero_const(Bytecodes::cast(cb[i+1]))) return false;
|
||||
if (cb[i+2] != Bytecodes::_putfield) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Method::compute_has_loops_flag() {
|
||||
BytecodeStream bcs(methodHandle(Thread::current(), this));
|
||||
Bytecodes::Code bc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user