8284161: Implementation of Virtual Threads (Preview)

Co-authored-by: Ron Pressler <rpressler@openjdk.org>
Co-authored-by: Alan Bateman <alanb@openjdk.org>
Co-authored-by: Erik Österlund <eosterlund@openjdk.org>
Co-authored-by: Andrew Haley <aph@openjdk.org>
Co-authored-by: Rickard Bäckman <rbackman@openjdk.org>
Co-authored-by: Markus Grönlund <mgronlun@openjdk.org>
Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org>
Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org>
Co-authored-by: Chris Plummer <cjplummer@openjdk.org>
Co-authored-by: Coleen Phillimore <coleenp@openjdk.org>
Co-authored-by: Robbin Ehn <rehn@openjdk.org>
Co-authored-by: Stefan Karlsson <stefank@openjdk.org>
Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org>
Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org>
Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
Alan Bateman 2022-05-07 08:06:16 +00:00
parent 5212535a27
commit 9583e3657e
1133 changed files with 95935 additions and 8335 deletions

View file

@ -104,6 +104,7 @@ Method::Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name) {
set_force_inline(false);
set_hidden(false);
set_dont_inline(false);
set_changes_current_thread(false);
set_has_injected_profile(false);
set_method_data(NULL);
clear_method_counters();
@ -662,6 +663,7 @@ void Method::compute_from_signature(Symbol* sig) {
// we might as well compute the whole fingerprint.
Fingerprinter fp(sig, is_static());
set_size_of_parameters(fp.size_of_parameters());
set_num_stack_arg_slots(fp.num_stack_arg_slots());
constMethod()->set_result_type(fp.return_type());
constMethod()->set_fingerprint(fp.fingerprint());
}
@ -987,7 +989,7 @@ bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
void Method::set_native_function(address function, bool post_event_flag) {
assert(function != NULL, "use clear_native_function to unregister natives");
assert(!is_method_handle_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), "");
assert(!is_special_native_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), "");
address* native_function = native_function_addr();
// We can see racers trying to place the same native function into place. Once
@ -1017,7 +1019,7 @@ void Method::set_native_function(address function, bool post_event_flag) {
bool Method::has_native_function() const {
if (is_method_handle_intrinsic())
if (is_special_native_intrinsic())
return false; // special-cased in SharedRuntime::generate_native_wrapper
address func = native_function();
return (func != NULL && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
@ -1074,7 +1076,7 @@ void Method::print_made_not_compilable(int comp_level, bool is_osr, bool report,
bool Method::is_always_compilable() const {
// Generated adapters must be compiled
if (is_method_handle_intrinsic() && is_synthetic()) {
if (is_special_native_intrinsic() && is_synthetic()) {
assert(!is_not_c1_compilable(), "sanity check");
assert(!is_not_c2_compilable(), "sanity check");
return true;
@ -1318,6 +1320,11 @@ void Method::set_code(const methodHandle& mh, CompiledMethod *code) {
// Instantly compiled code can execute.
if (!mh->is_method_handle_intrinsic())
mh->_from_interpreted_entry = mh->get_i2c_entry();
if (mh->is_continuation_enter_intrinsic()) {
// this is the entry used when we're in interpreter-only mode; see InterpreterMacroAssembler::jump_from_interpreted
mh->_i2i_entry = mh->get_i2c_entry();
mh->_from_interpreted_entry = mh->get_i2c_entry();
}
}
@ -1725,7 +1732,7 @@ bool Method::has_unloaded_classes_in_signature(const methodHandle& m, TRAPS) {
}
// Exposed so field engineers can debug VM
void Method::print_short_name(outputStream* st) {
void Method::print_short_name(outputStream* st) const {
ResourceMark rm;
#ifdef PRODUCT
st->print(" %s::", method_holder()->external_name());
@ -1793,7 +1800,7 @@ class SignatureTypePrinter : public SignatureTypeNames {
};
void Method::print_name(outputStream* st) {
void Method::print_name(outputStream* st) const {
Thread *thread = Thread::current();
ResourceMark rm(thread);
st->print("%s ", is_static() ? "static" : "virtual");
@ -2278,6 +2285,13 @@ void Method::set_on_stack(const bool value) {
}
}
void Method::record_gc_epoch() {
// If any method is on the stack in continuations, none of them can be reclaimed,
// so save the marking cycle to check for the whole class in the cpCache.
// The cpCache is writeable.
constants()->cache()->record_gc_epoch();
}
// Called when the class loader is unloaded to make all methods weak.
void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
loader_data->jmethod_ids()->clear_all_methods();