Skip to content

Commit 19a6ac4

Browse files
author
Harold Seigel
committed
8264142: Remove TRAPS/THREAD parameters for verifier related functions
Reviewed-by: gziemski, coleenp, iklam, dholmes
1 parent aefc156 commit 19a6ac4

File tree

8 files changed

+46
-52
lines changed

8 files changed

+46
-52
lines changed

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,7 @@ static void parse_annotations(const ConstantPool* const cp,
12401240
const u1* buffer, int limit,
12411241
AnnotationCollector* coll,
12421242
ClassLoaderData* loader_data,
1243-
const bool can_access_vm_annotations,
1244-
TRAPS) {
1243+
const bool can_access_vm_annotations) {
12451244

12461245
assert(cp != NULL, "invariant");
12471246
assert(buffer != NULL, "invariant");
@@ -1418,8 +1417,7 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs,
14181417
runtime_visible_annotations_length,
14191418
parsed_annotations,
14201419
_loader_data,
1421-
_can_access_vm_annotations,
1422-
CHECK);
1420+
_can_access_vm_annotations);
14231421
cfs->skip_u1_fast(runtime_visible_annotations_length);
14241422
} else if (attribute_name == vmSymbols::tag_runtime_invisible_annotations()) {
14251423
if (runtime_invisible_annotations_exists) {
@@ -2734,8 +2732,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
27342732
runtime_visible_annotations_length,
27352733
&parsed_annotations,
27362734
_loader_data,
2737-
_can_access_vm_annotations,
2738-
CHECK_NULL);
2735+
_can_access_vm_annotations);
27392736
cfs->skip_u1_fast(runtime_visible_annotations_length);
27402737
} else if (method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) {
27412738
if (runtime_invisible_annotations_exists) {
@@ -3563,7 +3560,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons
35633560
return calculate_attr_size;
35643561
}
35653562

3566-
void ClassFileParser::parse_classfile_synthetic_attribute(TRAPS) {
3563+
void ClassFileParser::parse_classfile_synthetic_attribute() {
35673564
set_class_synthetic_flag(true);
35683565
}
35693566

@@ -3763,7 +3760,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
37633760
attribute_length, THREAD);
37643761
return;
37653762
}
3766-
parse_classfile_synthetic_attribute(CHECK);
3763+
parse_classfile_synthetic_attribute();
37673764
} else if (tag == vmSymbols::tag_deprecated()) {
37683765
// Check for Deprecated tag - 4276120
37693766
if (attribute_length != 0) {
@@ -3801,8 +3798,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
38013798
runtime_visible_annotations_length,
38023799
parsed_annotations,
38033800
_loader_data,
3804-
_can_access_vm_annotations,
3805-
CHECK);
3801+
_can_access_vm_annotations);
38063802
cfs->skip_u1_fast(runtime_visible_annotations_length);
38073803
} else if (tag == vmSymbols::tag_runtime_invisible_annotations()) {
38083804
if (runtime_invisible_annotations_exists) {
@@ -4072,8 +4068,7 @@ void ClassFileParser::create_combined_annotations(TRAPS) {
40724068
// Transfer ownership of metadata allocated to the InstanceKlass.
40734069
void ClassFileParser::apply_parsed_class_metadata(
40744070
InstanceKlass* this_klass,
4075-
int java_fields_count,
4076-
TRAPS) {
4071+
int java_fields_count) {
40774072
assert(this_klass != NULL, "invariant");
40784073

40794074
_cp->set_pool_holder(this_klass);
@@ -5418,7 +5413,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
54185413

54195414
// this transfers ownership of a lot of arrays from
54205415
// the parser onto the InstanceKlass*
5421-
apply_parsed_class_metadata(ik, _java_fields_count, CHECK);
5416+
apply_parsed_class_metadata(ik, _java_fields_count);
54225417

54235418
// can only set dynamic nest-host after static nest information is set
54245419
if (cl_inst_info.dynamic_nest_host() != NULL) {
@@ -5637,8 +5632,8 @@ void ClassFileParser::update_class_name(Symbol* new_class_name) {
56375632
// For an unsafe anonymous class that is in the unnamed package, move it to its host class's
56385633
// package by prepending its host class's package name to its class name and setting
56395634
// its _class_name field.
5640-
void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS) {
5641-
ResourceMark rm(THREAD);
5635+
void ClassFileParser::prepend_host_package_name(Thread* current, const InstanceKlass* unsafe_anonymous_host) {
5636+
ResourceMark rm(current);
56425637
assert(strrchr(_class_name->as_C_string(), JVM_SIGNATURE_SLASH) == NULL,
56435638
"Unsafe anonymous class should not be in a package");
56445639
TempNewSymbol host_pkg_name =
@@ -5674,7 +5669,7 @@ void ClassFileParser::fix_unsafe_anonymous_class_name(TRAPS) {
56745669
const jbyte* anon_last_slash = UTF8::strrchr((const jbyte*)_class_name->base(),
56755670
_class_name->utf8_length(), JVM_SIGNATURE_SLASH);
56765671
if (anon_last_slash == NULL) { // Unnamed package
5677-
prepend_host_package_name(_unsafe_anonymous_host, CHECK);
5672+
prepend_host_package_name(THREAD, _unsafe_anonymous_host);
56785673
} else {
56795674
if (!_unsafe_anonymous_host->is_same_class_package(_unsafe_anonymous_host->class_loader(), _class_name)) {
56805675
ResourceMark rm(THREAD);

src/hotspot/share/classfile/classFileParser.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -211,7 +211,7 @@ class ClassFileParser {
211211
ConstantPool* cp,
212212
TRAPS);
213213

214-
void prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS);
214+
void prepend_host_package_name(Thread* current, const InstanceKlass* unsafe_anonymous_host);
215215
void fix_unsafe_anonymous_class_name(TRAPS);
216216

217217
void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
@@ -228,7 +228,7 @@ class ClassFileParser {
228228

229229
void create_combined_annotations(TRAPS);
230230
void apply_parsed_class_attributes(InstanceKlass* k); // update k
231-
void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS);
231+
void apply_parsed_class_metadata(InstanceKlass* k, int fields_count);
232232
void clear_class_metadata();
233233

234234
// Constant pool parsing
@@ -349,7 +349,7 @@ class ClassFileParser {
349349
ClassAnnotationCollector* parsed_annotations,
350350
TRAPS);
351351

352-
void parse_classfile_synthetic_attribute(TRAPS);
352+
void parse_classfile_synthetic_attribute();
353353
void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
354354
void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
355355
ConstantPool* cp,

src/hotspot/share/classfile/stackMapFrame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@ void StackMapFrame::initialize_object(
7575
}
7676

7777
VerificationType StackMapFrame::set_locals_from_arg(
78-
const methodHandle& m, VerificationType thisKlass, TRAPS) {
78+
const methodHandle& m, VerificationType thisKlass) {
7979
SignatureStream ss(m->signature());
8080
int init_local_num = 0;
8181
if (!m->is_static()) {

src/hotspot/share/classfile/stackMapFrame.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -153,7 +153,7 @@ class StackMapFrame : public ResourceObj {
153153

154154
// Set local variable type array based on m's signature.
155155
VerificationType set_locals_from_arg(
156-
const methodHandle& m, VerificationType thisKlass, TRAPS);
156+
const methodHandle& m, VerificationType thisKlass);
157157

158158
// Search local variable type array and stack type array.
159159
// Set every element with type of old_object to new_object.

src/hotspot/share/classfile/verificationType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ bool VerificationType::is_reference_assignable_from(
122122
return resolve_and_check_assignability(klass, name(), from.name(),
123123
from_field_is_protected, from.is_array(), from.is_object(), THREAD);
124124
} else if (is_array() && from.is_array()) {
125-
VerificationType comp_this = get_component(context, CHECK_false);
126-
VerificationType comp_from = from.get_component(context, CHECK_false);
125+
VerificationType comp_this = get_component(context);
126+
VerificationType comp_from = from.get_component(context);
127127
if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
128128
return comp_this.is_component_assignable_from(comp_from, context,
129129
from_field_is_protected, THREAD);
@@ -132,7 +132,7 @@ bool VerificationType::is_reference_assignable_from(
132132
return false;
133133
}
134134

135-
VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const {
135+
VerificationType VerificationType::get_component(ClassVerifier *context) const {
136136
assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
137137
SignatureStream ss(name(), false);
138138
ss.skip_array_prefix(1);

src/hotspot/share/classfile/verificationType.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class VerificationType {
316316
}
317317
}
318318

319-
VerificationType get_component(ClassVerifier* context, TRAPS) const;
319+
VerificationType get_component(ClassVerifier* context) const;
320320

321321
int dimensions() const {
322322
assert(is_array(), "Must be an array");

src/hotspot/share/classfile/verifier.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verif
134134
}
135135

136136
// Prints the end-verification message to the appropriate output.
137-
void Verifier::log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS) {
138-
if (HAS_PENDING_EXCEPTION) {
137+
void Verifier::log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, oop pending_exception) {
138+
if (pending_exception != NULL) {
139139
st->print("Verification for %s has", klassName);
140-
oop message = java_lang_Throwable::message(PENDING_EXCEPTION);
140+
oop message = java_lang_Throwable::message(pending_exception);
141141
if (message != NULL) {
142142
char* ex_msg = java_lang_String::as_utf8_string(message);
143143
st->print_cr(" exception pending '%s %s'",
144-
PENDING_EXCEPTION->klass()->external_name(), ex_msg);
144+
pending_exception->klass()->external_name(), ex_msg);
145145
} else {
146146
st->print_cr(" exception pending %s ",
147-
PENDING_EXCEPTION->klass()->external_name());
147+
pending_exception->klass()->external_name());
148148
}
149149
} else if (exception_name != NULL) {
150150
st->print_cr("Verification for %s failed", klassName);
@@ -193,7 +193,8 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
193193

194194
log_info(class, init)("Start class verification for: %s", klass->external_name());
195195
if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
196-
ClassVerifier split_verifier(klass, THREAD);
196+
ClassVerifier split_verifier(jt, klass);
197+
// We don't use CHECK here, or on inference_verify below, so that we can log any exception.
197198
split_verifier.verify_class(THREAD);
198199
exception_name = split_verifier.result();
199200

@@ -228,12 +229,12 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
228229
LogTarget(Info, class, init) lt1;
229230
if (lt1.is_enabled()) {
230231
LogStream ls(lt1);
231-
log_end_verification(&ls, klass->external_name(), exception_name, THREAD);
232+
log_end_verification(&ls, klass->external_name(), exception_name, PENDING_EXCEPTION);
232233
}
233234
LogTarget(Info, verification) lt2;
234235
if (lt2.is_enabled()) {
235236
LogStream ls(lt2);
236-
log_end_verification(&ls, klass->external_name(), exception_name, THREAD);
237+
log_end_verification(&ls, klass->external_name(), exception_name, PENDING_EXCEPTION);
237238
}
238239

239240
if (HAS_PENDING_EXCEPTION) {
@@ -589,9 +590,8 @@ void ErrorContext::stackmap_details(outputStream* ss, const Method* method) cons
589590

590591
// Methods in ClassVerifier
591592

592-
ClassVerifier::ClassVerifier(
593-
InstanceKlass* klass, TRAPS)
594-
: _thread(THREAD), _previous_symbol(NULL), _symbols(NULL), _exception_type(NULL),
593+
ClassVerifier::ClassVerifier(JavaThread* current, InstanceKlass* klass)
594+
: _thread(current), _previous_symbol(NULL), _symbols(NULL), _exception_type(NULL),
595595
_message(NULL), _method_signatures_table(NULL), _klass(klass) {
596596
_this_type = VerificationType::reference_type(klass->name());
597597
}
@@ -616,6 +616,7 @@ TypeOrigin ClassVerifier::ref_ctx(const char* sig) {
616616
return TypeOrigin::implicit(vt);
617617
}
618618

619+
619620
void ClassVerifier::verify_class(TRAPS) {
620621
log_info(verification)("Verifying class %s with new format", _klass->external_name());
621622

@@ -653,8 +654,7 @@ void ClassVerifier::verify_class(TRAPS) {
653654
// Translate the signature entries into verification types and save them in
654655
// the growable array. Also, save the count of arguments.
655656
void ClassVerifier::translate_signature(Symbol* const method_sig,
656-
sig_as_verification_types* sig_verif_types,
657-
TRAPS) {
657+
sig_as_verification_types* sig_verif_types) {
658658
SignatureStream sig_stream(method_sig);
659659
VerificationType sig_type[2];
660660
int sig_i = 0;
@@ -688,11 +688,11 @@ void ClassVerifier::translate_signature(Symbol* const method_sig,
688688
}
689689

690690
void ClassVerifier::create_method_sig_entry(sig_as_verification_types* sig_verif_types,
691-
int sig_index, TRAPS) {
691+
int sig_index) {
692692
// Translate the signature into verification types.
693693
ConstantPool* cp = _klass->constants();
694694
Symbol* const method_sig = cp->symbol_at(sig_index);
695-
translate_signature(method_sig, sig_verif_types, CHECK_VERIFY(this));
695+
translate_signature(method_sig, sig_verif_types);
696696

697697
// Add the list of this signature's verification types to the table.
698698
bool is_unique = method_signatures_table()->put(sig_index, sig_verif_types);
@@ -718,8 +718,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
718718
// Initial stack map frame: offset is 0, stack is initially empty.
719719
StackMapFrame current_frame(max_locals, max_stack, this);
720720
// Set initial locals
721-
VerificationType return_type = current_frame.set_locals_from_arg(
722-
m, current_type(), CHECK_VERIFY(this));
721+
VerificationType return_type = current_frame.set_locals_from_arg( m, current_type());
723722

724723
int32_t stackmap_index = 0; // index to the stackmap array
725724

@@ -1049,8 +1048,7 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
10491048
current_frame.push_stack(
10501049
VerificationType::null_type(), CHECK_VERIFY(this));
10511050
} else {
1052-
VerificationType component =
1053-
atype.get_component(this, CHECK_VERIFY(this));
1051+
VerificationType component = atype.get_component(this);
10541052
current_frame.push_stack(component, CHECK_VERIFY(this));
10551053
}
10561054
no_control_flow = false; break;
@@ -2827,7 +2825,7 @@ void ClassVerifier::verify_invoke_instructions(
28272825
// Not found, add the entry to the table.
28282826
GrowableArray<VerificationType>* verif_types = new GrowableArray<VerificationType>(10);
28292827
mth_sig_verif_types = new sig_as_verification_types(verif_types);
2830-
create_method_sig_entry(mth_sig_verif_types, sig_index, CHECK_VERIFY(this));
2828+
create_method_sig_entry(mth_sig_verif_types, sig_index);
28312829
}
28322830

28332831
// Get the number of arguments for this signature.

src/hotspot/share/classfile/verifier.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class Verifier : AllStatic {
4646
// Verify the bytecodes for a class.
4747
static bool verify(InstanceKlass* klass, bool should_verify_class, TRAPS);
4848

49-
static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS);
49+
static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name,
50+
oop pending_exception);
5051

5152
// Return false if the class is loaded by the bootstrap loader,
5253
// or if defineClass was called requesting skipping verification
@@ -398,7 +399,7 @@ class ClassVerifier : public StackObj {
398399
};
399400

400401
// constructor
401-
ClassVerifier(InstanceKlass* klass, TRAPS);
402+
ClassVerifier(JavaThread* current, InstanceKlass* klass);
402403

403404
// destructor
404405
~ClassVerifier();
@@ -415,10 +416,10 @@ class ClassVerifier : public StackObj {
415416

416417
// Translates method signature entries into verificationTypes and saves them
417418
// in the growable array.
418-
void translate_signature(Symbol* const method_sig, sig_as_verification_types* sig_verif_types, TRAPS);
419+
void translate_signature(Symbol* const method_sig, sig_as_verification_types* sig_verif_types);
419420

420421
// Initializes a sig_as_verification_types entry and puts it in the hash table.
421-
void create_method_sig_entry(sig_as_verification_types* sig_verif_types, int sig_index, TRAPS);
422+
void create_method_sig_entry(sig_as_verification_types* sig_verif_types, int sig_index);
422423

423424
// Return status modes
424425
Symbol* result() const { return _exception_type; }

0 commit comments

Comments
 (0)