Skip to content

Commit

Permalink
8306851: Move Method access flags
Browse files Browse the repository at this point in the history
Reviewed-by: cjplummer, dholmes, dnsimon, matsaave, fparain
  • Loading branch information
coleenp committed May 1, 2023
1 parent a6b4f25 commit 316d303
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 465 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciMethod.cpp
Expand Up @@ -84,8 +84,8 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
_code_size = h_m->code_size();
_handler_count = h_m->exception_table_length();
_size_of_parameters = h_m->size_of_parameters();
_uses_monitors = h_m->access_flags().has_monitor_bytecodes();
_balanced_monitors = !_uses_monitors || h_m->access_flags().is_monitor_matching();
_uses_monitors = h_m->has_monitor_bytecodes();
_balanced_monitors = !_uses_monitors || h_m->guaranteed_monitor_matching();
_is_c1_compilable = !h_m->is_not_c1_compilable();
_is_c2_compilable = !h_m->is_not_c2_compilable();
_can_be_parsed = true;
Expand Down
22 changes: 11 additions & 11 deletions src/hotspot/share/classfile/classFileParser.cpp
Expand Up @@ -1978,27 +1978,27 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {

void MethodAnnotationCollector::apply_to(const methodHandle& m) {
if (has_annotation(_method_CallerSensitive))
m->set_caller_sensitive(true);
m->set_caller_sensitive();
if (has_annotation(_method_ForceInline))
m->set_force_inline(true);
m->set_force_inline();
if (has_annotation(_method_DontInline))
m->set_dont_inline(true);
m->set_dont_inline();
if (has_annotation(_method_ChangesCurrentThread))
m->set_changes_current_thread(true);
m->set_changes_current_thread();
if (has_annotation(_method_JvmtiMountTransition))
m->set_jvmti_mount_transition(true);
m->set_jvmti_mount_transition();
if (has_annotation(_method_InjectedProfile))
m->set_has_injected_profile(true);
m->set_has_injected_profile();
if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
if (has_annotation(_method_Hidden))
m->set_hidden(true);
m->set_is_hidden();
if (has_annotation(_method_Scoped))
m->set_scoped(true);
m->set_scoped();
if (has_annotation(_method_IntrinsicCandidate) && !m->is_synthetic())
m->set_intrinsic_candidate(true);
m->set_intrinsic_candidate();
if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
m->set_has_reserved_stack_access(true);
m->set_has_reserved_stack_access();
}

void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
Expand Down Expand Up @@ -2739,7 +2739,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
parsed_annotations.apply_to(methodHandle(THREAD, m));

if (is_hidden()) { // Mark methods in hidden classes as 'hidden'.
m->set_hidden(true);
m->set_is_hidden();
}

// Copy annotations
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/bytecodeUtils.cpp
Expand Up @@ -476,7 +476,7 @@ ExceptionMessageBuilder::ExceptionMessageBuilder(Method* method, int bci) :
_stacks->at_put(0, new SimulatedOperandStack());

// And initialize the start of all exception handlers.
if (const_method->has_exception_handler()) {
if (const_method->has_exception_table()) {
ExceptionTableElement *et = const_method->exception_table_start();
for (int i = 0; i < const_method->exception_table_length(); ++i) {
u2 index = et[i].handler_pc;
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/interpreter/rewriter.cpp
Expand Up @@ -473,7 +473,7 @@ void Rewriter::scan_method(Thread* thread, Method* method, bool reverse, bool* i
}
}

// Update access flags
// Update flags
if (has_monitor_bytecodes) {
method->set_has_monitor_bytecodes();
}
Expand All @@ -482,8 +482,6 @@ void Rewriter::scan_method(Thread* thread, Method* method, bool reverse, bool* i
// have to be rewritten, so we run the oopMapGenerator on the method
if (nof_jsrs > 0) {
method->set_has_jsrs();
// Second pass will revisit this method.
assert(method->has_jsrs(), "didn't we just set this?");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Expand Up @@ -926,8 +926,8 @@ C2V_END

C2V_VMENTRY(void, setNotInlinableOrCompilable,(JNIEnv* env, jobject, ARGUMENT_PAIR(method)))
methodHandle method(THREAD, UNPACK_PAIR(Method, method));
method->set_not_c1_compilable();
method->set_not_c2_compilable();
method->set_is_not_c1_compilable();
method->set_is_not_c2_compilable();
method->set_dont_inline(true);
C2V_END

Expand Down
30 changes: 14 additions & 16 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Expand Up @@ -129,7 +129,7 @@
nonstatic_field(ConstantPool, _source_file_name_index, u2) \
\
nonstatic_field(ConstMethod, _constants, ConstantPool*) \
nonstatic_field(ConstMethod, _flags, u2) \
nonstatic_field(ConstMethod, _flags._flags, u4) \
nonstatic_field(ConstMethod, _code_size, u2) \
nonstatic_field(ConstMethod, _name_index, u2) \
nonstatic_field(ConstMethod, _signature_index, u2) \
Expand Down Expand Up @@ -228,7 +228,7 @@
nonstatic_field(Method, _access_flags, AccessFlags) \
nonstatic_field(Method, _vtable_index, int) \
nonstatic_field(Method, _intrinsic_id, u2) \
nonstatic_field(Method, _flags, u2) \
nonstatic_field(Method, _flags._status, u4) \
volatile_nonstatic_field(Method, _code, CompiledMethod*) \
volatile_nonstatic_field(Method, _from_compiled_entry, address) \
\
Expand Down Expand Up @@ -416,8 +416,6 @@
declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS) \
\
declare_constant(JVM_ACC_WRITTEN_FLAGS) \
declare_constant(JVM_ACC_MONITOR_MATCH) \
declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES) \
declare_constant(JVM_ACC_HAS_FINALIZER) \
declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \
declare_constant(JVM_ACC_IS_HIDDEN_CLASS) \
Expand Down Expand Up @@ -582,11 +580,16 @@
declare_constant(ConstantPool::CPCACHE_INDEX_TAG) \
declare_constant(ConstantPool::_has_dynamic_constant) \
\
declare_constant(ConstMethod::_has_linenumber_table) \
declare_constant(ConstMethod::_has_localvariable_table) \
declare_constant(ConstMethod::_has_exception_table) \
declare_constant(ConstMethod::_has_method_annotations) \
declare_constant(ConstMethod::_has_parameter_annotations) \
declare_constant(ConstMethodFlags::_misc_has_linenumber_table) \
declare_constant(ConstMethodFlags::_misc_has_localvariable_table) \
declare_constant(ConstMethodFlags::_misc_has_exception_table) \
declare_constant(ConstMethodFlags::_misc_has_method_annotations) \
declare_constant(ConstMethodFlags::_misc_has_parameter_annotations) \
declare_constant(ConstMethodFlags::_misc_caller_sensitive) \
declare_constant(ConstMethodFlags::_misc_is_hidden) \
declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \
declare_constant(ConstMethodFlags::_misc_reserved_stack_access) \
declare_constant(ConstMethodFlags::_misc_changes_current_thread) \
\
declare_constant(CounterData::count_off) \
\
Expand Down Expand Up @@ -683,13 +686,8 @@
\
declare_constant(markWord::no_hash) \
\
declare_constant(Method::_caller_sensitive) \
declare_constant(Method::_force_inline) \
declare_constant(Method::_dont_inline) \
declare_constant(Method::_hidden) \
declare_constant(Method::_intrinsic_candidate) \
declare_constant(Method::_reserved_stack_access) \
declare_constant(Method::_changes_current_thread) \
declare_constant(MethodFlags::_misc_force_inline) \
declare_constant(MethodFlags::_misc_dont_inline) \
\
declare_constant(Method::nonvirtual_vtable_index) \
declare_constant(Method::invalid_vtable_index) \
Expand Down
36 changes: 18 additions & 18 deletions src/hotspot/share/oops/constMethod.cpp
Expand Up @@ -199,7 +199,7 @@ u2* ConstMethod::checked_exceptions_length_addr() const {
}

u2* ConstMethod::exception_table_length_addr() const {
assert(has_exception_handler(), "called only if table is present");
assert(has_exception_table(), "called only if table is present");
if (has_checked_exceptions()) {
// If checked_exception present, locate immediately before them.
return (u2*) checked_exceptions_start() - 1;
Expand All @@ -217,7 +217,7 @@ u2* ConstMethod::exception_table_length_addr() const {

u2* ConstMethod::localvariable_table_length_addr() const {
assert(has_localvariable_table(), "called only if table is present");
if (has_exception_handler()) {
if (has_exception_table()) {
// If exception_table present, locate immediately before them.
return (u2*) exception_table_start() - 1;
} else {
Expand All @@ -239,30 +239,29 @@ u2* ConstMethod::localvariable_table_length_addr() const {

// Update the flags to indicate the presence of these optional fields.
void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) {
_flags = 0;
if (sizes->compressed_linenumber_size() > 0)
_flags |= _has_linenumber_table;
set_has_linenumber_table();
if (sizes->generic_signature_index() != 0)
_flags |= _has_generic_signature;
set_has_generic_signature();
if (sizes->method_parameters_length() >= 0)
_flags |= _has_method_parameters;
set_has_method_parameters();
if (sizes->checked_exceptions_length() > 0)
_flags |= _has_checked_exceptions;
set_has_checked_exceptions();
if (sizes->exception_table_length() > 0)
_flags |= _has_exception_table;
set_has_exception_table();
if (sizes->localvariable_table_length() > 0)
_flags |= _has_localvariable_table;
set_has_localvariable_table();

// annotations, they are all pointer sized embedded objects so don't have
// a length embedded also.
if (sizes->method_annotations_length() > 0)
_flags |= _has_method_annotations;
set_has_method_annotations();
if (sizes->parameter_annotations_length() > 0)
_flags |= _has_parameter_annotations;
set_has_parameter_annotations();
if (sizes->type_annotations_length() > 0)
_flags |= _has_type_annotations;
set_has_type_annotations();
if (sizes->default_annotations_length() > 0)
_flags |= _has_default_annotations;
set_has_default_annotations();

// This code is extremely brittle and should possibly be revised.
// The *_length_addr functions walk backwards through the
Expand Down Expand Up @@ -329,7 +328,7 @@ LocalVariableTableElement* ConstMethod::localvariable_table_start() const {
}

int ConstMethod::exception_table_length() const {
return has_exception_handler() ? *(exception_table_length_addr()) : 0;
return has_exception_table() ? *(exception_table_length_addr()) : 0;
}

ExceptionTableElement* ConstMethod::exception_table_start() const {
Expand Down Expand Up @@ -431,13 +430,14 @@ void ConstMethod::print_on(outputStream* st) const {
ResourceMark rm;
st->print_cr("%s", internal_name());
Method* m = method();
st->print(" - method: " PTR_FORMAT " ", p2i(m));
st->print(" - method: " PTR_FORMAT " ", p2i(m));
if (m != nullptr) {
m->print_value_on(st);
}
st->cr();
st->print(" - flags: 0x%x ", _flags.as_int()); _flags.print_on(st); st->cr();
if (has_stackmap_table()) {
st->print(" - stackmap data: ");
st->print(" - stackmap data: ");
stackmap_data()->print_value_on(st);
st->cr();
}
Expand Down Expand Up @@ -484,7 +484,7 @@ void ConstMethod::verify_on(outputStream* st) {
u2* addr = checked_exceptions_length_addr();
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
}
if (has_exception_handler()) {
if (has_exception_table()) {
u2* addr = exception_table_length_addr();
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
}
Expand All @@ -496,7 +496,7 @@ void ConstMethod::verify_on(outputStream* st) {
u2* uncompressed_table_start;
if (has_localvariable_table()) {
uncompressed_table_start = (u2*) localvariable_table_start();
} else if (has_exception_handler()) {
} else if (has_exception_table()) {
uncompressed_table_start = (u2*) exception_table_start();
} else if (has_checked_exceptions()) {
uncompressed_table_start = (u2*) checked_exceptions_start();
Expand Down
61 changes: 11 additions & 50 deletions src/hotspot/share/oops/constMethod.hpp
Expand Up @@ -25,6 +25,7 @@
#ifndef SHARE_OOPS_CONSTMETHOD_HPP
#define SHARE_OOPS_CONSTMETHOD_HPP

#include "oops/constMethodFlags.hpp"
#include "oops/oop.hpp"
#include "utilities/align.hpp"

Expand Down Expand Up @@ -173,19 +174,6 @@ class ConstMethod : public MetaspaceObj {
typedef enum { NORMAL, OVERPASS } MethodType;

private:
enum {
_has_linenumber_table = 0x0001,
_has_checked_exceptions = 0x0002,
_has_localvariable_table = 0x0004,
_has_exception_table = 0x0008,
_has_generic_signature = 0x0010,
_has_method_parameters = 0x0020,
_is_overpass = 0x0040,
_has_method_annotations = 0x0080,
_has_parameter_annotations = 0x0100,
_has_type_annotations = 0x0200,
_has_default_annotations = 0x0400
};

// Bit vector of signature
// Callers interpret 0=not initialized yet and
Expand All @@ -204,7 +192,7 @@ class ConstMethod : public MetaspaceObj {
Array<u1>* _stackmap_data;

int _constMethod_size;
u2 _flags;
ConstMethodFlags _flags; // for sizing
u1 _result_type; // BasicType of result

// Size of Java bytecodes allocated immediately after Method*.
Expand Down Expand Up @@ -236,33 +224,20 @@ class ConstMethod : public MetaspaceObj {
// Inlined tables
void set_inlined_tables_length(InlineTableSizes* sizes);

bool has_generic_signature() const
{ return (_flags & _has_generic_signature) != 0; }

bool has_linenumber_table() const
{ return (_flags & _has_linenumber_table) != 0; }

bool has_checked_exceptions() const
{ return (_flags & _has_checked_exceptions) != 0; }

bool has_localvariable_table() const
{ return (_flags & _has_localvariable_table) != 0; }

bool has_exception_handler() const
{ return (_flags & _has_exception_table) != 0; }

bool has_method_parameters() const
{ return (_flags & _has_method_parameters) != 0; }
// Create getters and setters for the flag values.
#define CM_FLAGS_GET_SET(name, ignore) \
bool name() const { return _flags.name(); } \
void set_##name() { _flags.set_##name(); }
CM_FLAGS_DO(CM_FLAGS_GET_SET)
#undef CM_FLAGS_GET_SET

MethodType method_type() const {
return ((_flags & _is_overpass) == 0) ? NORMAL : OVERPASS;
return (_flags.is_overpass()) ? OVERPASS : NORMAL;
}

void set_method_type(MethodType mt) {
if (mt == NORMAL) {
_flags &= ~(_is_overpass);
} else {
_flags |= _is_overpass;
if (mt != NORMAL) {
set_is_overpass();
}
}

Expand Down Expand Up @@ -382,20 +357,6 @@ class ConstMethod : public MetaspaceObj {
int method_parameters_length() const;
MethodParametersElement* method_parameters_start() const;

// method annotations
bool has_method_annotations() const
{ return (_flags & _has_method_annotations) != 0; }

bool has_parameter_annotations() const
{ return (_flags & _has_parameter_annotations) != 0; }

bool has_type_annotations() const
{ return (_flags & _has_type_annotations) != 0; }

bool has_default_annotations() const
{ return (_flags & _has_default_annotations) != 0; }


AnnotationArray** method_annotations_addr() const;
AnnotationArray* method_annotations() const {
return has_method_annotations() ? *(method_annotations_addr()) : nullptr;
Expand Down

1 comment on commit 316d303

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