Skip to content

Commit 316d303

Browse files
committed
8306851: Move Method access flags
Reviewed-by: cjplummer, dholmes, dnsimon, matsaave, fparain
1 parent a6b4f25 commit 316d303

27 files changed

+484
-465
lines changed

src/hotspot/share/ci/ciMethod.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
8484
_code_size = h_m->code_size();
8585
_handler_count = h_m->exception_table_length();
8686
_size_of_parameters = h_m->size_of_parameters();
87-
_uses_monitors = h_m->access_flags().has_monitor_bytecodes();
88-
_balanced_monitors = !_uses_monitors || h_m->access_flags().is_monitor_matching();
87+
_uses_monitors = h_m->has_monitor_bytecodes();
88+
_balanced_monitors = !_uses_monitors || h_m->guaranteed_monitor_matching();
8989
_is_c1_compilable = !h_m->is_not_c1_compilable();
9090
_is_c2_compilable = !h_m->is_not_c2_compilable();
9191
_can_be_parsed = true;

src/hotspot/share/classfile/classFileParser.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1978,27 +1978,27 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
19781978

19791979
void MethodAnnotationCollector::apply_to(const methodHandle& m) {
19801980
if (has_annotation(_method_CallerSensitive))
1981-
m->set_caller_sensitive(true);
1981+
m->set_caller_sensitive();
19821982
if (has_annotation(_method_ForceInline))
1983-
m->set_force_inline(true);
1983+
m->set_force_inline();
19841984
if (has_annotation(_method_DontInline))
1985-
m->set_dont_inline(true);
1985+
m->set_dont_inline();
19861986
if (has_annotation(_method_ChangesCurrentThread))
1987-
m->set_changes_current_thread(true);
1987+
m->set_changes_current_thread();
19881988
if (has_annotation(_method_JvmtiMountTransition))
1989-
m->set_jvmti_mount_transition(true);
1989+
m->set_jvmti_mount_transition();
19901990
if (has_annotation(_method_InjectedProfile))
1991-
m->set_has_injected_profile(true);
1991+
m->set_has_injected_profile();
19921992
if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
19931993
m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
19941994
if (has_annotation(_method_Hidden))
1995-
m->set_hidden(true);
1995+
m->set_is_hidden();
19961996
if (has_annotation(_method_Scoped))
1997-
m->set_scoped(true);
1997+
m->set_scoped();
19981998
if (has_annotation(_method_IntrinsicCandidate) && !m->is_synthetic())
1999-
m->set_intrinsic_candidate(true);
1999+
m->set_intrinsic_candidate();
20002000
if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
2001-
m->set_has_reserved_stack_access(true);
2001+
m->set_has_reserved_stack_access();
20022002
}
20032003

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

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

27452745
// Copy annotations

src/hotspot/share/interpreter/bytecodeUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ ExceptionMessageBuilder::ExceptionMessageBuilder(Method* method, int bci) :
476476
_stacks->at_put(0, new SimulatedOperandStack());
477477

478478
// And initialize the start of all exception handlers.
479-
if (const_method->has_exception_handler()) {
479+
if (const_method->has_exception_table()) {
480480
ExceptionTableElement *et = const_method->exception_table_start();
481481
for (int i = 0; i < const_method->exception_table_length(); ++i) {
482482
u2 index = et[i].handler_pc;

src/hotspot/share/interpreter/rewriter.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void Rewriter::scan_method(Thread* thread, Method* method, bool reverse, bool* i
473473
}
474474
}
475475

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

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,8 @@ C2V_END
926926

927927
C2V_VMENTRY(void, setNotInlinableOrCompilable,(JNIEnv* env, jobject, ARGUMENT_PAIR(method)))
928928
methodHandle method(THREAD, UNPACK_PAIR(Method, method));
929-
method->set_not_c1_compilable();
930-
method->set_not_c2_compilable();
929+
method->set_is_not_c1_compilable();
930+
method->set_is_not_c2_compilable();
931931
method->set_dont_inline(true);
932932
C2V_END
933933

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
nonstatic_field(ConstantPool, _source_file_name_index, u2) \
130130
\
131131
nonstatic_field(ConstMethod, _constants, ConstantPool*) \
132-
nonstatic_field(ConstMethod, _flags, u2) \
132+
nonstatic_field(ConstMethod, _flags._flags, u4) \
133133
nonstatic_field(ConstMethod, _code_size, u2) \
134134
nonstatic_field(ConstMethod, _name_index, u2) \
135135
nonstatic_field(ConstMethod, _signature_index, u2) \
@@ -228,7 +228,7 @@
228228
nonstatic_field(Method, _access_flags, AccessFlags) \
229229
nonstatic_field(Method, _vtable_index, int) \
230230
nonstatic_field(Method, _intrinsic_id, u2) \
231-
nonstatic_field(Method, _flags, u2) \
231+
nonstatic_field(Method, _flags._status, u4) \
232232
volatile_nonstatic_field(Method, _code, CompiledMethod*) \
233233
volatile_nonstatic_field(Method, _from_compiled_entry, address) \
234234
\
@@ -416,8 +416,6 @@
416416
declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS) \
417417
\
418418
declare_constant(JVM_ACC_WRITTEN_FLAGS) \
419-
declare_constant(JVM_ACC_MONITOR_MATCH) \
420-
declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES) \
421419
declare_constant(JVM_ACC_HAS_FINALIZER) \
422420
declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \
423421
declare_constant(JVM_ACC_IS_HIDDEN_CLASS) \
@@ -582,11 +580,16 @@
582580
declare_constant(ConstantPool::CPCACHE_INDEX_TAG) \
583581
declare_constant(ConstantPool::_has_dynamic_constant) \
584582
\
585-
declare_constant(ConstMethod::_has_linenumber_table) \
586-
declare_constant(ConstMethod::_has_localvariable_table) \
587-
declare_constant(ConstMethod::_has_exception_table) \
588-
declare_constant(ConstMethod::_has_method_annotations) \
589-
declare_constant(ConstMethod::_has_parameter_annotations) \
583+
declare_constant(ConstMethodFlags::_misc_has_linenumber_table) \
584+
declare_constant(ConstMethodFlags::_misc_has_localvariable_table) \
585+
declare_constant(ConstMethodFlags::_misc_has_exception_table) \
586+
declare_constant(ConstMethodFlags::_misc_has_method_annotations) \
587+
declare_constant(ConstMethodFlags::_misc_has_parameter_annotations) \
588+
declare_constant(ConstMethodFlags::_misc_caller_sensitive) \
589+
declare_constant(ConstMethodFlags::_misc_is_hidden) \
590+
declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \
591+
declare_constant(ConstMethodFlags::_misc_reserved_stack_access) \
592+
declare_constant(ConstMethodFlags::_misc_changes_current_thread) \
590593
\
591594
declare_constant(CounterData::count_off) \
592595
\
@@ -683,13 +686,8 @@
683686
\
684687
declare_constant(markWord::no_hash) \
685688
\
686-
declare_constant(Method::_caller_sensitive) \
687-
declare_constant(Method::_force_inline) \
688-
declare_constant(Method::_dont_inline) \
689-
declare_constant(Method::_hidden) \
690-
declare_constant(Method::_intrinsic_candidate) \
691-
declare_constant(Method::_reserved_stack_access) \
692-
declare_constant(Method::_changes_current_thread) \
689+
declare_constant(MethodFlags::_misc_force_inline) \
690+
declare_constant(MethodFlags::_misc_dont_inline) \
693691
\
694692
declare_constant(Method::nonvirtual_vtable_index) \
695693
declare_constant(Method::invalid_vtable_index) \

src/hotspot/share/oops/constMethod.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ u2* ConstMethod::checked_exceptions_length_addr() const {
199199
}
200200

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

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

240240
// Update the flags to indicate the presence of these optional fields.
241241
void ConstMethod::set_inlined_tables_length(InlineTableSizes* sizes) {
242-
_flags = 0;
243242
if (sizes->compressed_linenumber_size() > 0)
244-
_flags |= _has_linenumber_table;
243+
set_has_linenumber_table();
245244
if (sizes->generic_signature_index() != 0)
246-
_flags |= _has_generic_signature;
245+
set_has_generic_signature();
247246
if (sizes->method_parameters_length() >= 0)
248-
_flags |= _has_method_parameters;
247+
set_has_method_parameters();
249248
if (sizes->checked_exceptions_length() > 0)
250-
_flags |= _has_checked_exceptions;
249+
set_has_checked_exceptions();
251250
if (sizes->exception_table_length() > 0)
252-
_flags |= _has_exception_table;
251+
set_has_exception_table();
253252
if (sizes->localvariable_table_length() > 0)
254-
_flags |= _has_localvariable_table;
253+
set_has_localvariable_table();
255254

256255
// annotations, they are all pointer sized embedded objects so don't have
257256
// a length embedded also.
258257
if (sizes->method_annotations_length() > 0)
259-
_flags |= _has_method_annotations;
258+
set_has_method_annotations();
260259
if (sizes->parameter_annotations_length() > 0)
261-
_flags |= _has_parameter_annotations;
260+
set_has_parameter_annotations();
262261
if (sizes->type_annotations_length() > 0)
263-
_flags |= _has_type_annotations;
262+
set_has_type_annotations();
264263
if (sizes->default_annotations_length() > 0)
265-
_flags |= _has_default_annotations;
264+
set_has_default_annotations();
266265

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

331330
int ConstMethod::exception_table_length() const {
332-
return has_exception_handler() ? *(exception_table_length_addr()) : 0;
331+
return has_exception_table() ? *(exception_table_length_addr()) : 0;
333332
}
334333

335334
ExceptionTableElement* ConstMethod::exception_table_start() const {
@@ -431,13 +430,14 @@ void ConstMethod::print_on(outputStream* st) const {
431430
ResourceMark rm;
432431
st->print_cr("%s", internal_name());
433432
Method* m = method();
434-
st->print(" - method: " PTR_FORMAT " ", p2i(m));
433+
st->print(" - method: " PTR_FORMAT " ", p2i(m));
435434
if (m != nullptr) {
436435
m->print_value_on(st);
437436
}
438437
st->cr();
438+
st->print(" - flags: 0x%x ", _flags.as_int()); _flags.print_on(st); st->cr();
439439
if (has_stackmap_table()) {
440-
st->print(" - stackmap data: ");
440+
st->print(" - stackmap data: ");
441441
stackmap_data()->print_value_on(st);
442442
st->cr();
443443
}
@@ -484,7 +484,7 @@ void ConstMethod::verify_on(outputStream* st) {
484484
u2* addr = checked_exceptions_length_addr();
485485
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
486486
}
487-
if (has_exception_handler()) {
487+
if (has_exception_table()) {
488488
u2* addr = exception_table_length_addr();
489489
guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
490490
}
@@ -496,7 +496,7 @@ void ConstMethod::verify_on(outputStream* st) {
496496
u2* uncompressed_table_start;
497497
if (has_localvariable_table()) {
498498
uncompressed_table_start = (u2*) localvariable_table_start();
499-
} else if (has_exception_handler()) {
499+
} else if (has_exception_table()) {
500500
uncompressed_table_start = (u2*) exception_table_start();
501501
} else if (has_checked_exceptions()) {
502502
uncompressed_table_start = (u2*) checked_exceptions_start();

src/hotspot/share/oops/constMethod.hpp

+11-50
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef SHARE_OOPS_CONSTMETHOD_HPP
2626
#define SHARE_OOPS_CONSTMETHOD_HPP
2727

28+
#include "oops/constMethodFlags.hpp"
2829
#include "oops/oop.hpp"
2930
#include "utilities/align.hpp"
3031

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

175176
private:
176-
enum {
177-
_has_linenumber_table = 0x0001,
178-
_has_checked_exceptions = 0x0002,
179-
_has_localvariable_table = 0x0004,
180-
_has_exception_table = 0x0008,
181-
_has_generic_signature = 0x0010,
182-
_has_method_parameters = 0x0020,
183-
_is_overpass = 0x0040,
184-
_has_method_annotations = 0x0080,
185-
_has_parameter_annotations = 0x0100,
186-
_has_type_annotations = 0x0200,
187-
_has_default_annotations = 0x0400
188-
};
189177

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

206194
int _constMethod_size;
207-
u2 _flags;
195+
ConstMethodFlags _flags; // for sizing
208196
u1 _result_type; // BasicType of result
209197

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

239-
bool has_generic_signature() const
240-
{ return (_flags & _has_generic_signature) != 0; }
241-
242-
bool has_linenumber_table() const
243-
{ return (_flags & _has_linenumber_table) != 0; }
244-
245-
bool has_checked_exceptions() const
246-
{ return (_flags & _has_checked_exceptions) != 0; }
247-
248-
bool has_localvariable_table() const
249-
{ return (_flags & _has_localvariable_table) != 0; }
250-
251-
bool has_exception_handler() const
252-
{ return (_flags & _has_exception_table) != 0; }
253-
254-
bool has_method_parameters() const
255-
{ return (_flags & _has_method_parameters) != 0; }
227+
// Create getters and setters for the flag values.
228+
#define CM_FLAGS_GET_SET(name, ignore) \
229+
bool name() const { return _flags.name(); } \
230+
void set_##name() { _flags.set_##name(); }
231+
CM_FLAGS_DO(CM_FLAGS_GET_SET)
232+
#undef CM_FLAGS_GET_SET
256233

257234
MethodType method_type() const {
258-
return ((_flags & _is_overpass) == 0) ? NORMAL : OVERPASS;
235+
return (_flags.is_overpass()) ? OVERPASS : NORMAL;
259236
}
260237

261238
void set_method_type(MethodType mt) {
262-
if (mt == NORMAL) {
263-
_flags &= ~(_is_overpass);
264-
} else {
265-
_flags |= _is_overpass;
239+
if (mt != NORMAL) {
240+
set_is_overpass();
266241
}
267242
}
268243

@@ -382,20 +357,6 @@ class ConstMethod : public MetaspaceObj {
382357
int method_parameters_length() const;
383358
MethodParametersElement* method_parameters_start() const;
384359

385-
// method annotations
386-
bool has_method_annotations() const
387-
{ return (_flags & _has_method_annotations) != 0; }
388-
389-
bool has_parameter_annotations() const
390-
{ return (_flags & _has_parameter_annotations) != 0; }
391-
392-
bool has_type_annotations() const
393-
{ return (_flags & _has_type_annotations) != 0; }
394-
395-
bool has_default_annotations() const
396-
{ return (_flags & _has_default_annotations) != 0; }
397-
398-
399360
AnnotationArray** method_annotations_addr() const;
400361
AnnotationArray* method_annotations() const {
401362
return has_method_annotations() ? *(method_annotations_addr()) : nullptr;

0 commit comments

Comments
 (0)