mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-24 18:29:46 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2cbcbeeef | ||
|
|
aba2a258bb | ||
|
|
53c9198350 | ||
|
|
e27b2fbf84 |
@@ -36,7 +36,7 @@ REPRODUCIBLE_BUILD_OPTS="--enable-reproducible-build
|
||||
--with-source-date=$SOURCE_DATE_EPOCH
|
||||
--with-hotspot-build-time=$BUILD_TIME
|
||||
--with-copyright-year=$COPYRIGHT_YEAR
|
||||
--disable-absolute-paths-in-output"
|
||||
--with-native-debug-symbols=none"
|
||||
|
||||
function do_exit() {
|
||||
exit_code=$1
|
||||
|
||||
@@ -100,6 +100,12 @@ case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=1
|
||||
;;
|
||||
"dcevm")
|
||||
HEAD_REVISION=$(git rev-parse HEAD)
|
||||
git am jb/project/tools/patches/dcevm/*.patch || do_exit $?
|
||||
do_reset_dcevm=1
|
||||
do_reset_changes=1
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
;;
|
||||
@@ -124,7 +130,7 @@ JBRSDK_BUNDLE=jbrsdk
|
||||
echo Fixing permissions
|
||||
chmod -R a+r $JSDK
|
||||
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ]; then
|
||||
git apply -p0 < jb/project/tools/patches/add_jcef_module.patch || do_exit $?
|
||||
update_jsdk_mods $JSDK $JCEF_PATH/jmods $JSDK/jmods $JSDK_MODS_DIR || do_exit $?
|
||||
cp $JCEF_PATH/jmods/* $JSDK_MODS_DIR # $JSDK/jmods is not changed
|
||||
@@ -138,7 +144,7 @@ create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" ||
|
||||
|
||||
# create sdk image bundle
|
||||
modules=$(cat $JSDK/release | grep MODULES | sed s/MODULES=//g | sed s/' '/','/g | sed s/\"//g | sed s/\\n//g) || do_exit $?
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
modules=${modules},$(get_mods_list "$JCEF_PATH"/jmods)
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" $JBRSDK_BUNDLE $JSDK_MODS_DIR "$modules" || do_exit $?
|
||||
|
||||
@@ -142,6 +142,12 @@ case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=1
|
||||
;;
|
||||
"dcevm")
|
||||
HEAD_REVISION=$(git rev-parse HEAD)
|
||||
git am jb/project/tools/patches/dcevm/*.patch || do_exit $?
|
||||
do_reset_dcevm=1
|
||||
do_reset_changes=1
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
;;
|
||||
@@ -168,7 +174,7 @@ JSDK=$IMAGES_DIR/jdk-bundle/jdk-$version_dir.jdk/Contents/Home
|
||||
JSDK_MODS_DIR=$IMAGES_DIR/jmods
|
||||
JBRSDK_BUNDLE=jbrsdk
|
||||
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ]; then
|
||||
git apply -p0 < jb/project/tools/patches/add_jcef_module.patch || do_exit $?
|
||||
update_jsdk_mods "$JSDK" "$JCEF_PATH"/jmods "$JSDK"/jmods "$JSDK_MODS_DIR" || do_exit $?
|
||||
cp $JCEF_PATH/jmods/* $JSDK_MODS_DIR # $JSDK/jmods is not changed
|
||||
@@ -182,7 +188,7 @@ create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" ||
|
||||
|
||||
# create sdk image bundle
|
||||
modules=$(cat "$JSDK"/release | grep MODULES | sed s/MODULES=//g | sed s/' '/','/g | sed s/\"//g | sed s/\\n//g) || do_exit $?
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
modules=${modules},$(get_mods_list "$JCEF_PATH"/jmods)
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" "$JBRSDK_BUNDLE" "$JSDK_MODS_DIR" "$modules" || do_exit $?
|
||||
|
||||
8834
jb/project/tools/patches/dcevm/0001-Apply-basic-dcevm11-patch.patch
Normal file
8834
jb/project/tools/patches/dcevm/0001-Apply-basic-dcevm11-patch.patch
Normal file
File diff suppressed because it is too large
Load Diff
5615
jb/project/tools/patches/dcevm/0002-dcevm11-fixes.patch
Normal file
5615
jb/project/tools/patches/dcevm/0002-dcevm11-fixes.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
From 9b18096f241be0350245868e8cf26729f6c3d110 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Wed, 11 Mar 2020 14:19:34 +0100
|
||||
Subject: [PATCH 03/45] Fix class cast exception on redefinition of class A,
|
||||
that is superclass of B that has anonymous class C
|
||||
|
||||
---
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index db5b8da58fc..6d9e5116df1 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -908,7 +908,10 @@ bool InstanceKlass::link_class_impl(TRAPS) {
|
||||
|
||||
if (!is_linked()) {
|
||||
if (!is_rewritten()) {
|
||||
- {
|
||||
+ // (DCEVM): If class A is being redefined and class B->A (B is extended from A) and B is host class of anonymous class C
|
||||
+ // then second redefinition fails with cannot cast klass exception. So we currently turn off bytecode verification
|
||||
+ // on redefinition.
|
||||
+ if (!AllowEnhancedClassRedefinition || !newest_version()->is_redefining()) {
|
||||
bool verify_ok = verify_code(THREAD);
|
||||
if (!verify_ok) {
|
||||
return false;
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
From 784dd5e16922110b0ee802d5bf1063e2b94499bc Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 4 Oct 2020 21:12:12 +0200
|
||||
Subject: [PATCH 04/45] Support for Lambda class redefinition
|
||||
|
||||
---
|
||||
.../share/classfile/classLoaderData.cpp | 9 +++
|
||||
.../share/classfile/classLoaderData.hpp | 2 +-
|
||||
.../share/classfile/systemDictionary.cpp | 10 ++-
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 65 +++++++++++++++++--
|
||||
.../prims/jvmtiEnhancedRedefineClasses.hpp | 1 +
|
||||
.../share/prims/resolvedMethodTable.cpp | 2 +
|
||||
6 files changed, 80 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
index 340ffadf837..db50b3edee8 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
@@ -599,6 +599,15 @@ Dictionary* ClassLoaderData::create_dictionary() {
|
||||
return new Dictionary(this, size, resizable);
|
||||
}
|
||||
|
||||
+void ClassLoaderData::exchange_holders(ClassLoaderData* cld) {
|
||||
+ oop holder_oop = _holder.peek();
|
||||
+ _holder.replace(cld->_holder.peek());
|
||||
+ cld->_holder.replace(holder_oop);
|
||||
+ WeakHandle<vm_class_loader_data> exchange = _holder;
|
||||
+ _holder = cld->_holder;
|
||||
+ cld->_holder = exchange;
|
||||
+}
|
||||
+
|
||||
// Tell the GC to keep this klass alive while iterating ClassLoaderDataGraph
|
||||
oop ClassLoaderData::holder_phantom() const {
|
||||
// A klass that was previously considered dead can be looked up in the
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderData.hpp b/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
index 5a81ab90ca3..bda39f3e353 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
@@ -175,7 +175,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
|
||||
oop holder_no_keepalive() const;
|
||||
oop holder_phantom() const;
|
||||
-
|
||||
+ void exchange_holders(ClassLoaderData* cld);
|
||||
private:
|
||||
void unload();
|
||||
bool keep_alive() const { return _keep_alive > 0; }
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
index 2bfd9cb802f..cea614a574f 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
@@ -825,10 +825,14 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream(
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
+ InstanceKlass* old_klass,
|
||||
TRAPS) {
|
||||
|
||||
EventClassLoad class_load_start_event;
|
||||
ClassLoaderData* loader_data;
|
||||
+
|
||||
+ bool is_redefining = (old_klass != NULL);
|
||||
+
|
||||
|
||||
// - for hidden classes that are not strong: create a new CLD that has a class holder and
|
||||
// whose loader is the Lookup class's loader.
|
||||
@@ -845,9 +849,13 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream(
|
||||
class_name,
|
||||
loader_data,
|
||||
cl_info,
|
||||
- false, // pick_newest
|
||||
+ is_redefining, // pick_newest
|
||||
CHECK_NULL);
|
||||
assert(k != NULL, "no klass created");
|
||||
+ if (is_redefining && k != NULL) {
|
||||
+ k->set_redefining(true);
|
||||
+ k->set_old_version(old_klass);
|
||||
+ }
|
||||
|
||||
// Hidden classes that are not strong must update ClassLoaderData holder
|
||||
// so that they can be unloaded when the mirror is no longer referenced.
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 5308b079e67..c1b1b354541 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -492,6 +492,8 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
ClassLoaderDataGraph::classes_do(&clear_cpool_cache);
|
||||
|
||||
|
||||
+ // SystemDictionary::methods_do(fix_invoke_method);
|
||||
+
|
||||
// JSR-292 support
|
||||
if (_any_class_has_resolved_methods) {
|
||||
bool trace_name_printed = false;
|
||||
@@ -754,12 +756,34 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
// load hook event.
|
||||
state->set_class_being_redefined(the_class, _class_load_kind);
|
||||
|
||||
- InstanceKlass* k = SystemDictionary::resolve_from_stream(the_class_sym,
|
||||
- the_class_loader,
|
||||
- protection_domain,
|
||||
- &st,
|
||||
- the_class,
|
||||
- THREAD);
|
||||
+ InstanceKlass* k;
|
||||
+
|
||||
+ if (InstanceKlass::cast(the_class)->is_anonymous()) {
|
||||
+ const InstanceKlass* host_class = the_class->host_klass();
|
||||
+
|
||||
+ // Make sure it's the real host class, not another anonymous class.
|
||||
+ while (host_class != NULL && host_class->is_anonymous()) {
|
||||
+ host_class = host_class->host_klass();
|
||||
+ }
|
||||
+
|
||||
+ k = SystemDictionary::parse_stream(the_class_sym,
|
||||
+ the_class_loader,
|
||||
+ protection_domain,
|
||||
+ &st,
|
||||
+ host_class,
|
||||
+ the_class,
|
||||
+ NULL,
|
||||
+ THREAD);
|
||||
+ k->class_loader_data()->exchange_holders(the_class->class_loader_data());
|
||||
+ the_class->class_loader_data()->inc_keep_alive();
|
||||
+ } else {
|
||||
+ k = SystemDictionary::resolve_from_stream(the_class_sym,
|
||||
+ the_class_loader,
|
||||
+ protection_domain,
|
||||
+ &st,
|
||||
+ the_class,
|
||||
+ THREAD);
|
||||
+ }
|
||||
// Clear class_being_redefined just to be sure.
|
||||
state->clear_class_being_redefined();
|
||||
|
||||
@@ -1440,6 +1464,30 @@ void VM_EnhancedRedefineClasses::MethodDataCleaner::do_klass(Klass* k) {
|
||||
}
|
||||
}
|
||||
|
||||
+void VM_EnhancedRedefineClasses::fix_invoke_method(Method* method) {
|
||||
+
|
||||
+ constantPoolHandle other_cp = constantPoolHandle(method->constants());
|
||||
+
|
||||
+ for (int i = 0; i < other_cp->length(); i++) {
|
||||
+ if (other_cp->tag_at(i).is_klass()) {
|
||||
+ Klass* klass = other_cp->resolved_klass_at(i);
|
||||
+ if (klass->new_version() != NULL) {
|
||||
+ // Constant pool entry points to redefined class -- update to the new version
|
||||
+ other_cp->klass_at_put(i, klass->newest_version());
|
||||
+ }
|
||||
+ assert(other_cp->resolved_klass_at(i)->new_version() == NULL, "Must be new klass!");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ConstantPoolCache* cp_cache = other_cp->cache();
|
||||
+ if (cp_cache != NULL) {
|
||||
+ cp_cache->clear_entries();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
void VM_EnhancedRedefineClasses::update_jmethod_ids() {
|
||||
for (int j = 0; j < _matching_methods_length; ++j) {
|
||||
Method* old_method = _matching_old_methods[j];
|
||||
@@ -1977,7 +2025,10 @@ jvmtiError VM_EnhancedRedefineClasses::find_sorted_affected_classes(TRAPS) {
|
||||
// Find classes not directly redefined, but affected by a redefinition (because one of its supertypes is redefined)
|
||||
AffectedKlassClosure closure(_affected_klasses);
|
||||
// Updated in j10, from original SystemDictionary::classes_do
|
||||
- ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
+
|
||||
+ ClassLoaderDataGraph::classes_do(&closure);
|
||||
+ //ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
+
|
||||
log_trace(redefine, class, load)("%d classes affected", _affected_klasses->length());
|
||||
|
||||
// Sort the affected klasses such that a supertype is always on a smaller array index than its subtype.
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
index a48e07e3a6a..3551b06ecde 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
@@ -116,6 +116,7 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
void rollback();
|
||||
static void mark_as_scavengable(nmethod* nm);
|
||||
static void unpatch_bytecode(Method* method);
|
||||
+ static void fix_invoke_method(Method* method);
|
||||
|
||||
// Figure out which new methods match old methods in name and signature,
|
||||
// which methods have been added, and which are no longer present
|
||||
diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
index 6a8128e844f..8644937dbbb 100644
|
||||
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
@@ -409,6 +409,8 @@ void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed)
|
||||
InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
|
||||
Method* newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());
|
||||
|
||||
+ log_info(redefine, class, load, exceptions)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
|
||||
+
|
||||
assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
|
||||
assert(newer_method != NULL, "method_with_idnum() should not be NULL");
|
||||
assert(old_method != newer_method, "sanity check");
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
From 97ab12615a56e90993b5df4615c6dbd7eb856ebb Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 23 May 2020 10:02:15 +0200
|
||||
Subject: [PATCH 05/45] Fix "no original bytecode found" error if method with
|
||||
bkp is missing
|
||||
|
||||
Sometimes IDE can deploy class with erroneous method, such method has
|
||||
n bytecode, but breakpoint position can still exist.
|
||||
---
|
||||
src/hotspot/share/interpreter/bytecodes.cpp | 2 +-
|
||||
.../share/interpreter/interpreterRuntime.cpp | 2 +-
|
||||
src/hotspot/share/oops/method.cpp | 8 ++++----
|
||||
src/hotspot/share/oops/method.hpp | 4 ++--
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 18 ++++++++++--------
|
||||
5 files changed, 18 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/interpreter/bytecodes.cpp b/src/hotspot/share/interpreter/bytecodes.cpp
|
||||
index 6711ba735db..4f0b655265a 100644
|
||||
--- a/src/hotspot/share/interpreter/bytecodes.cpp
|
||||
+++ b/src/hotspot/share/interpreter/bytecodes.cpp
|
||||
@@ -84,7 +84,7 @@ Bytecodes::Code Bytecodes::code_at(Method* method, int bci) {
|
||||
Bytecodes::Code Bytecodes::non_breakpoint_code_at(const Method* method, address bcp) {
|
||||
assert(method != NULL, "must have the method for breakpoint conversion");
|
||||
assert(method->contains(bcp), "must be valid bcp in method");
|
||||
- return method->orig_bytecode_at(method->bci_from(bcp));
|
||||
+ return method->orig_bytecode_at(method->bci_from(bcp), false);
|
||||
}
|
||||
|
||||
int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) {
|
||||
diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp
|
||||
index d66ed24d862..9bfcd9eb479 100644
|
||||
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp
|
||||
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp
|
||||
@@ -788,7 +788,7 @@ JRT_END
|
||||
// Invokes
|
||||
|
||||
JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
|
||||
- return method->orig_bytecode_at(method->bci_from(bcp));
|
||||
+ return method->orig_bytecode_at(method->bci_from(bcp), false);
|
||||
JRT_END
|
||||
|
||||
JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
|
||||
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
|
||||
index 613c10a9d8c..a5a12599997 100644
|
||||
--- a/src/hotspot/share/oops/method.cpp
|
||||
+++ b/src/hotspot/share/oops/method.cpp
|
||||
@@ -1853,14 +1853,14 @@ bool CompressedLineNumberReadStream::read_pair() {
|
||||
|
||||
#if INCLUDE_JVMTI
|
||||
|
||||
-Bytecodes::Code Method::orig_bytecode_at(int bci) const {
|
||||
+Bytecodes::Code Method::orig_bytecode_at(int bci, bool no_fatal) const {
|
||||
BreakpointInfo* bp = method_holder()->breakpoints();
|
||||
for (; bp != NULL; bp = bp->next()) {
|
||||
if (bp->match(this, bci)) {
|
||||
return bp->orig_bytecode();
|
||||
}
|
||||
}
|
||||
- {
|
||||
+ if (!no_fatal) {
|
||||
ResourceMark rm;
|
||||
fatal("no original bytecode found in %s at bci %d", name_and_sig_as_C_string(), bci);
|
||||
}
|
||||
@@ -1998,7 +1998,7 @@ BreakpointInfo::BreakpointInfo(Method* m, int bci) {
|
||||
_signature_index = m->signature_index();
|
||||
_orig_bytecode = (Bytecodes::Code) *m->bcp_from(_bci);
|
||||
if (_orig_bytecode == Bytecodes::_breakpoint)
|
||||
- _orig_bytecode = m->orig_bytecode_at(_bci);
|
||||
+ _orig_bytecode = m->orig_bytecode_at(_bci, false);
|
||||
_next = NULL;
|
||||
}
|
||||
|
||||
@@ -2007,7 +2007,7 @@ void BreakpointInfo::set(Method* method) {
|
||||
{
|
||||
Bytecodes::Code code = (Bytecodes::Code) *method->bcp_from(_bci);
|
||||
if (code == Bytecodes::_breakpoint)
|
||||
- code = method->orig_bytecode_at(_bci);
|
||||
+ code = method->orig_bytecode_at(_bci, false);
|
||||
assert(orig_bytecode() == code, "original bytecode must be the same");
|
||||
}
|
||||
#endif
|
||||
diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp
|
||||
index 030ddd1f675..a8d6507ff6c 100644
|
||||
--- a/src/hotspot/share/oops/method.hpp
|
||||
+++ b/src/hotspot/share/oops/method.hpp
|
||||
@@ -226,7 +226,7 @@ class Method : public Metadata {
|
||||
|
||||
// JVMTI breakpoints
|
||||
#if !INCLUDE_JVMTI
|
||||
- Bytecodes::Code orig_bytecode_at(int bci) const {
|
||||
+ Bytecodes::Code orig_bytecode_at(int bci, bool no_fatal) const {
|
||||
ShouldNotReachHere();
|
||||
return Bytecodes::_shouldnotreachhere;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ class Method : public Metadata {
|
||||
};
|
||||
u2 number_of_breakpoints() const {return 0;}
|
||||
#else // !INCLUDE_JVMTI
|
||||
- Bytecodes::Code orig_bytecode_at(int bci) const;
|
||||
+ Bytecodes::Code orig_bytecode_at(int bci, bool no_fatal) const;
|
||||
void set_orig_bytecode_at(int bci, Bytecodes::Code code);
|
||||
void set_breakpoint(int bci);
|
||||
void clear_breakpoint(int bci);
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index c1b1b354541..ad05b4f34cf 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -1360,14 +1360,16 @@ void VM_EnhancedRedefineClasses::unpatch_bytecode(Method* method) {
|
||||
|
||||
if (code == Bytecodes::_breakpoint) {
|
||||
int bci = method->bci_from(bcp);
|
||||
- code = method->orig_bytecode_at(bci);
|
||||
- java_code = Bytecodes::java_code(code);
|
||||
- if (code != java_code &&
|
||||
- (java_code == Bytecodes::_getfield ||
|
||||
- java_code == Bytecodes::_putfield ||
|
||||
- java_code == Bytecodes::_aload_0)) {
|
||||
- // Let breakpoint table handling unpatch bytecode
|
||||
- method->set_orig_bytecode_at(bci, java_code);
|
||||
+ code = method->orig_bytecode_at(bci, true);
|
||||
+ if (code != Bytecodes::_shouldnotreachhere) {
|
||||
+ java_code = Bytecodes::java_code(code);
|
||||
+ if (code != java_code &&
|
||||
+ (java_code == Bytecodes::_getfield ||
|
||||
+ java_code == Bytecodes::_putfield ||
|
||||
+ java_code == Bytecodes::_aload_0)) {
|
||||
+ // Let breakpoint table handling unpatch bytecode
|
||||
+ method->set_orig_bytecode_at(bci, java_code);
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
java_code = Bytecodes::java_code(code);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
From cb8d0e41bed94d0c8b8a4c51f692a4ca66dc3672 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 24 May 2020 12:07:42 +0200
|
||||
Subject: [PATCH 06/45] Replace deleted method with
|
||||
Universe::throw_no_such_method_error
|
||||
|
||||
+ Change log level in advanced redefinition
|
||||
- Change log level for "Comparing different class ver.." to debug
|
||||
- Fix adjust_method_entries_dcevm logging levels and severity
|
||||
---
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 2 +-
|
||||
.../share/prims/resolvedMethodTable.cpp | 30 +++++++++----------
|
||||
2 files changed, 16 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index ad05b4f34cf..95be32f0070 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -881,7 +881,7 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
// Calculated the difference between new and old class (field change, method change, supertype change, ...).
|
||||
int VM_EnhancedRedefineClasses::calculate_redefinition_flags(InstanceKlass* new_class) {
|
||||
int result = Klass::NoRedefinition;
|
||||
- log_info(redefine, class, load)("Comparing different class versions of class %s",new_class->name()->as_C_string());
|
||||
+ log_debug(redefine, class, load)("Comparing different class versions of class %s",new_class->name()->as_C_string());
|
||||
|
||||
assert(new_class->old_version() != NULL, "must have old version");
|
||||
InstanceKlass* the_class = InstanceKlass::cast(new_class->old_version());
|
||||
diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
index 8644937dbbb..b8d039adff6 100644
|
||||
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
@@ -399,25 +399,25 @@ void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed)
|
||||
|
||||
if (old_method->is_old()) {
|
||||
|
||||
+ InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
|
||||
+ Method* newer_method;
|
||||
+
|
||||
// Method* new_method;
|
||||
if (old_method->is_deleted()) {
|
||||
- // FIXME:(DCEVM) - check if exception can be thrown
|
||||
- // new_method = Universe::throw_no_such_method_error();
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
|
||||
- Method* newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());
|
||||
+ newer_method = Universe::throw_no_such_method_error();
|
||||
+ } else {
|
||||
+ newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());
|
||||
|
||||
- log_info(redefine, class, load, exceptions)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
|
||||
+ log_debug(redefine, class, update)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
|
||||
|
||||
- assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
|
||||
- assert(newer_method != NULL, "method_with_idnum() should not be NULL");
|
||||
- assert(old_method != newer_method, "sanity check");
|
||||
+ assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
|
||||
+ assert(newer_method != NULL, "method_with_idnum() should not be NULL");
|
||||
+ assert(old_method != newer_method, "sanity check");
|
||||
|
||||
- if (_the_table->lookup(newer_method) != NULL) {
|
||||
- // old method was already adjusted if new method exists in _the_table
|
||||
- continue;
|
||||
+ if (_the_table->lookup(newer_method) != NULL) {
|
||||
+ // old method was already adjusted if new method exists in _the_table
|
||||
+ continue;
|
||||
+ }
|
||||
}
|
||||
|
||||
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, newer_method);
|
||||
@@ -428,7 +428,7 @@ void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed)
|
||||
|
||||
ResourceMark rm;
|
||||
if (!(*trace_name_printed)) {
|
||||
- log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
|
||||
+ log_debug(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
|
||||
*trace_name_printed = true;
|
||||
}
|
||||
log_debug(redefine, class, update, constantpool)
|
||||
--
|
||||
2.23.0
|
||||
|
||||
1315
jb/project/tools/patches/dcevm/0007-Support-for-G1-gc.patch
Normal file
1315
jb/project/tools/patches/dcevm/0007-Support-for-G1-gc.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
From 74de59c61db380a0e1c85686714bd9a3f1b29210 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Tue, 6 Oct 2020 22:15:31 +0200
|
||||
Subject: [PATCH 08/45] AllowEnhancedClassRedefinition is false (disabled) by
|
||||
default
|
||||
|
||||
---
|
||||
src/hotspot/share/runtime/globals.hpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
|
||||
index 845a39b0225..fb6d1667156 100644
|
||||
--- a/src/hotspot/share/runtime/globals.hpp
|
||||
+++ b/src/hotspot/share/runtime/globals.hpp
|
||||
@@ -2088,7 +2088,7 @@ const intx ObjectAlignmentInBytes = 8;
|
||||
develop(bool, TraceOptimizedUpcallStubs, false, \
|
||||
"Trace optimized upcall stub generation") \
|
||||
\
|
||||
- product(bool, AllowEnhancedClassRedefinition, true, \
|
||||
+ product(bool, AllowEnhancedClassRedefinition, false, \
|
||||
"Allow enhanced class redefinition beyond swapping method " \
|
||||
"bodies")
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
From c00c2a58550ae33ab2c842b521bf3b73163a93a1 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Mon, 19 Oct 2020 20:00:04 +0200
|
||||
Subject: [PATCH 09/45] Set HOTSPOT_VM_DISTRO=Dynamic Code Evolution
|
||||
|
||||
---
|
||||
make/autoconf/version-numbers | 55 +++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 55 insertions(+)
|
||||
create mode 100644 make/autoconf/version-numbers
|
||||
|
||||
diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers
|
||||
new file mode 100644
|
||||
index 00000000000..df8025a2e84
|
||||
--- /dev/null
|
||||
+++ b/make/autoconf/version-numbers
|
||||
@@ -0,0 +1,55 @@
|
||||
+#
|
||||
+# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
+#
|
||||
+# This code is free software; you can redistribute it and/or modify it
|
||||
+# under the terms of the GNU General Public License version 2 only, as
|
||||
+# published by the Free Software Foundation. Oracle designates this
|
||||
+# particular file as subject to the "Classpath" exception as provided
|
||||
+# by Oracle in the LICENSE file that accompanied this code.
|
||||
+#
|
||||
+# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
+# version 2 for more details (a copy is included in the LICENSE file that
|
||||
+# accompanied this code).
|
||||
+#
|
||||
+# You should have received a copy of the GNU General Public License version
|
||||
+# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
+#
|
||||
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
+# or visit www.oracle.com if you need additional information or have any
|
||||
+# questions.
|
||||
+#
|
||||
+
|
||||
+# Default version, product, and vendor information to use,
|
||||
+# unless overridden by configure
|
||||
+
|
||||
+DEFAULT_VERSION_FEATURE=15
|
||||
+DEFAULT_VERSION_INTERIM=0
|
||||
+DEFAULT_VERSION_UPDATE=0
|
||||
+DEFAULT_VERSION_PATCH=0
|
||||
+DEFAULT_VERSION_EXTRA1=0
|
||||
+DEFAULT_VERSION_EXTRA2=0
|
||||
+DEFAULT_VERSION_EXTRA3=0
|
||||
+DEFAULT_VERSION_DATE=2020-09-15
|
||||
+DEFAULT_VERSION_CLASSFILE_MAJOR=59 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
|
||||
+DEFAULT_VERSION_CLASSFILE_MINOR=0
|
||||
+DEFAULT_ACCEPTABLE_BOOT_VERSIONS="14 15"
|
||||
+DEFAULT_JDK_SOURCE_TARGET_VERSION=15
|
||||
+DEFAULT_PROMOTED_VERSION_PRE=
|
||||
+
|
||||
+LAUNCHER_NAME=openjdk
|
||||
+PRODUCT_NAME=OpenJDK
|
||||
+PRODUCT_SUFFIX="Runtime Environment"
|
||||
+JDK_RC_PLATFORM_NAME=Platform
|
||||
+COMPANY_NAME=N/A
|
||||
+HOTSPOT_VM_DISTRO="Dynamic Code Evolution"
|
||||
+VENDOR_URL=https://openjdk.java.net/
|
||||
+VENDOR_URL_BUG=https://bugreport.java.com/bugreport/
|
||||
+VENDOR_URL_VM_BUG=https://bugreport.java.com/bugreport/crash.jsp
|
||||
+
|
||||
+# Might need better names for these
|
||||
+MACOSX_BUNDLE_NAME_BASE="OpenJDK"
|
||||
+MACOSX_BUNDLE_ID_BASE="net.java.openjdk"
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
From c04d57e5278aa5d3cb6ef53fc161d2b6b4f19f3c Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 23 Oct 2020 10:20:26 +0200
|
||||
Subject: [PATCH 10/45] Clear dcevm code separation
|
||||
|
||||
---
|
||||
src/hotspot/share/classfile/systemDictionary.cpp | 3 +--
|
||||
src/hotspot/share/gc/serial/genMarkSweep.cpp | 8 +++++---
|
||||
src/hotspot/share/interpreter/linkResolver.cpp | 14 ++++++++++----
|
||||
.../instrumentation/jfrEventClassTransformer.cpp | 2 +-
|
||||
src/hotspot/share/oops/cpCache.hpp | 8 +++++---
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 6 +++---
|
||||
src/hotspot/share/oops/method.cpp | 2 +-
|
||||
src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp | 2 +-
|
||||
src/hotspot/share/runtime/reflection.cpp | 2 +-
|
||||
9 files changed, 28 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
index cea614a574f..98e2541c79b 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
@@ -830,9 +830,8 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream(
|
||||
|
||||
EventClassLoad class_load_start_event;
|
||||
ClassLoaderData* loader_data;
|
||||
-
|
||||
+
|
||||
bool is_redefining = (old_klass != NULL);
|
||||
-
|
||||
|
||||
// - for hidden classes that are not strong: create a new CLD that has a class holder and
|
||||
// whose loader is the Lookup class's loader.
|
||||
diff --git a/src/hotspot/share/gc/serial/genMarkSweep.cpp b/src/hotspot/share/gc/serial/genMarkSweep.cpp
|
||||
index bbb2c02f2b2..00b8e44078e 100644
|
||||
--- a/src/hotspot/share/gc/serial/genMarkSweep.cpp
|
||||
+++ b/src/hotspot/share/gc/serial/genMarkSweep.cpp
|
||||
@@ -316,7 +316,9 @@ void GenMarkSweep::mark_sweep_phase4() {
|
||||
|
||||
GenCompactClosure blk;
|
||||
gch->generation_iterate(&blk, true);
|
||||
- DcevmSharedGC::copy_rescued_objects_back(MarkSweep::_rescued_oops, true);
|
||||
- DcevmSharedGC::clear_rescued_objects_resource(MarkSweep::_rescued_oops);
|
||||
- MarkSweep::_rescued_oops = NULL;
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ DcevmSharedGC::copy_rescued_objects_back(MarkSweep::_rescued_oops, true);
|
||||
+ DcevmSharedGC::clear_rescued_objects_resource(MarkSweep::_rescued_oops);
|
||||
+ MarkSweep::_rescued_oops = NULL;
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
index 8fb336762df..74a6af13ea4 100644
|
||||
--- a/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
+++ b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
@@ -287,9 +287,14 @@ void LinkResolver::check_klass_accessibility(Klass* ref_klass, Klass* sel_klass,
|
||||
if (!base_klass->is_instance_klass()) {
|
||||
return; // no relevant check to do
|
||||
}
|
||||
-
|
||||
+ Klass* refKlassNewest = ref_klass;
|
||||
+ Klass* baseKlassNewest = base_klass;
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ refKlassNewest = ref_klass->newest_version();
|
||||
+ baseKlassNewest = base_klass->newest_version();
|
||||
+ }
|
||||
Reflection::VerifyClassAccessResults vca_result =
|
||||
- Reflection::verify_class_access(ref_klass->newest_version(), InstanceKlass::cast(base_klass->newest_version()), true);
|
||||
+ Reflection::verify_class_access(refKlassNewest, InstanceKlass::cast(baseKlassNewest), true);
|
||||
if (vca_result != Reflection::ACCESS_OK) {
|
||||
ResourceMark rm(THREAD);
|
||||
char* msg = Reflection::verify_class_access_msg(ref_klass,
|
||||
@@ -551,7 +556,8 @@ void LinkResolver::check_method_accessability(Klass* ref_klass,
|
||||
// We'll check for the method name first, as that's most likely
|
||||
// to be false (so we'll short-circuit out of these tests).
|
||||
if (sel_method->name() == vmSymbols::clone_name() &&
|
||||
- sel_klass->newest_version() == vmClasses::Object_klass()->newest_version() &&
|
||||
+ ( !AllowEnhancedClassRedefinition && sel_klass == vmClasses::Object_klass() ||
|
||||
+ AllowEnhancedClassRedefinition && sel_klass->newest_version() == vmClasses::Object_klass()->newest_version()) &&
|
||||
resolved_klass->is_array_klass()) {
|
||||
// We need to change "protected" to "public".
|
||||
assert(flags.is_protected(), "clone not protected?");
|
||||
@@ -997,7 +1003,7 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
|
||||
// or by the <init> method (in case of an instance field).
|
||||
if (is_put && fd.access_flags().is_final()) {
|
||||
|
||||
- if (sel_klass != current_klass && sel_klass != current_klass->active_version()) {
|
||||
+ if (sel_klass != current_klass && (!AllowEnhancedClassRedefinition || sel_klass != current_klass->active_version())) {
|
||||
ResourceMark rm(THREAD);
|
||||
stringStream ss;
|
||||
ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class",
|
||||
diff --git a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp
|
||||
index 88e520ec475..73832251f3f 100644
|
||||
--- a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp
|
||||
+++ b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp
|
||||
@@ -1475,7 +1475,7 @@ static InstanceKlass* create_new_instance_klass(InstanceKlass* ik, ClassFileStre
|
||||
cld,
|
||||
&cl_info,
|
||||
ClassFileParser::INTERNAL, // internal visibility
|
||||
- false,
|
||||
+ false,
|
||||
THREAD);
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
log_pending_exception(PENDING_EXCEPTION);
|
||||
diff --git a/src/hotspot/share/oops/cpCache.hpp b/src/hotspot/share/oops/cpCache.hpp
|
||||
index b934302f422..d7ae5edc7b3 100644
|
||||
--- a/src/hotspot/share/oops/cpCache.hpp
|
||||
+++ b/src/hotspot/share/oops/cpCache.hpp
|
||||
@@ -148,13 +148,13 @@ class ConstantPoolCacheEntry {
|
||||
void set_bytecode_2(Bytecodes::Code code);
|
||||
void set_f1(Metadata* f1) {
|
||||
Metadata* existing_f1 = _f1; // read once
|
||||
- //assert(existing_f1 == NULL || existing_f1 == f1, "illegal field change");
|
||||
+ assert(AllowEnhancedClassRedefinition || existing_f1 == NULL || existing_f1 == f1, "illegal field change");
|
||||
_f1 = f1;
|
||||
}
|
||||
void release_set_f1(Metadata* f1);
|
||||
void set_f2(intx f2) {
|
||||
intx existing_f2 = _f2; // read once
|
||||
- //assert(existing_f2 == 0 || existing_f2 == f2, "illegal field change");
|
||||
+ assert(AllowEnhancedClassRedefinition || existing_f2 == 0 || existing_f2 == f2, "illegal field change");
|
||||
_f2 = f2;
|
||||
}
|
||||
void set_f2_as_vfinal_method(Method* f2) {
|
||||
@@ -215,7 +215,9 @@ class ConstantPoolCacheEntry {
|
||||
void initialize_resolved_reference_index(int ref_index) {
|
||||
assert(_f2 == 0, "set once"); // note: ref_index might be zero also
|
||||
_f2 = ref_index;
|
||||
- _flags = 1 << is_resolved_ref_shift;
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ _flags = 1 << is_resolved_ref_shift;
|
||||
+ }
|
||||
}
|
||||
|
||||
void set_field( // sets entry to resolved field state
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index 6d9e5116df1..1e2b40dd1f2 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -968,7 +968,7 @@ bool InstanceKlass::link_class_impl(TRAPS) {
|
||||
set_init_state(linked);
|
||||
}
|
||||
// (DCEVM) Must check for old version in order to prevent infinite loops.
|
||||
- if (JvmtiExport::should_post_class_prepare() && old_version() == NULL /* JVMTI deadlock otherwise */) {
|
||||
+ if (JvmtiExport::should_post_class_prepare() && (!AllowEnhancedClassRedefinition || old_version() == NULL /* JVMTI deadlock otherwise */) {
|
||||
JvmtiExport::post_class_prepare(THREAD, this);
|
||||
}
|
||||
}
|
||||
@@ -1046,7 +1046,7 @@ void InstanceKlass::initialize_impl(TRAPS) {
|
||||
// we might end up throwing IE from link/symbol resolution sites
|
||||
// that aren't expected to throw. This would wreak havoc. See 6320309.
|
||||
while ((is_being_initialized() && !is_reentrant_initialization(jt))
|
||||
- || (old_version() != NULL && InstanceKlass::cast(old_version())->is_being_initialized())) {
|
||||
+ || (AllowEnhancedClassRedefinition && old_version() != NULL && InstanceKlass::cast(old_version())->is_being_initialized())) {
|
||||
wait = true;
|
||||
jt->set_class_to_be_initialized(this);
|
||||
ol.wait_uninterruptibly(jt);
|
||||
@@ -3808,7 +3808,7 @@ void InstanceKlass::verify_on(outputStream* st) {
|
||||
|
||||
guarantee(sib->is_klass(), "should be klass");
|
||||
// TODO: (DCEVM) explain
|
||||
- guarantee(sib->super() == super || super->newest_version() == SystemDictionary::Object_klass(), "siblings should have same superklass");
|
||||
+ guarantee(sib->super() == super || AllowEnhancedClassRedefinition && super->newest_version() == SystemDictionary::Object_klass(), "siblings should have same superklass");
|
||||
}
|
||||
|
||||
// Verify local interfaces
|
||||
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
|
||||
index a5a12599997..4426f03fd40 100644
|
||||
--- a/src/hotspot/share/oops/method.cpp
|
||||
+++ b/src/hotspot/share/oops/method.cpp
|
||||
@@ -2199,7 +2199,7 @@ void Method::ensure_jmethod_ids(ClassLoaderData* loader_data, int capacity) {
|
||||
// Add a method id to the jmethod_ids
|
||||
jmethodID Method::make_jmethod_id(ClassLoaderData* loader_data, Method* m) {
|
||||
// FIXME: (DCEVM) ???
|
||||
- if (m != m->newest_version()) {
|
||||
+ if (AllowEnhancedClassRedefinition && m != m->newest_version()) {
|
||||
m = m->newest_version();
|
||||
}
|
||||
ClassLoaderData* cld = loader_data;
|
||||
diff --git a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
index 42e72c67879..c860ee24f80 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
// the new version (SystemDictionary stores only new versions). But the LoadedClassesClosure's functionality was
|
||||
// changed in java8 where jvmtiLoadedClasses collects all classes from all classloaders, therefore we
|
||||
// must use new versions only.
|
||||
- if (k->new_version()==NULL) {
|
||||
+ if (AllowEnhancedClassRedefinition && k->new_version()==NULL) {
|
||||
_classStack.push((jclass) _env->jni_reference(Handle(_cur_thread, k->java_mirror())));
|
||||
if (_dictionary_walk) {
|
||||
// Collect array classes this way when walking the dictionary (because array classes are
|
||||
diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp
|
||||
index cc58f913ed5..21104c18423 100644
|
||||
--- a/src/hotspot/share/runtime/reflection.cpp
|
||||
+++ b/src/hotspot/share/runtime/reflection.cpp
|
||||
@@ -608,7 +608,7 @@ bool Reflection::verify_member_access(const Klass* current_class,
|
||||
TRAPS) {
|
||||
|
||||
// (DCEVM) Decide accessibility based on active version
|
||||
- if (current_class != NULL) {
|
||||
+ if (AllowEnhancedClassRedefinition && current_class != NULL) {
|
||||
current_class = current_class->active_version();
|
||||
}
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From 3e9df9bdd901f1a7f7af57f2d37a738c059e3bb3 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Wed, 11 Nov 2020 18:45:15 +0100
|
||||
Subject: [PATCH 11/45] Fix LoadedClassesClosure - fixes problems with remote
|
||||
debugging
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
index c860ee24f80..dfe0bb8d96a 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
// the new version (SystemDictionary stores only new versions). But the LoadedClassesClosure's functionality was
|
||||
// changed in java8 where jvmtiLoadedClasses collects all classes from all classloaders, therefore we
|
||||
// must use new versions only.
|
||||
- if (AllowEnhancedClassRedefinition && k->new_version()==NULL) {
|
||||
+ if (!AllowEnhancedClassRedefinition || k->new_version()==NULL) {
|
||||
_classStack.push((jclass) _env->jni_reference(Handle(_cur_thread, k->java_mirror())));
|
||||
if (_dictionary_walk) {
|
||||
// Collect array classes this way when walking the dictionary (because array classes are
|
||||
--
|
||||
2.23.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
From 2a27d36f5fbb0ebd94da192355f3946138c495bd Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 22 Nov 2020 19:51:46 +0100
|
||||
Subject: [PATCH 13/45] dcevm15 - add ClassLoaderDataGraph_lock on
|
||||
ClassLoaderDataGraph::classes_do
|
||||
|
||||
ClassLoaderDataGraph::classes_do and need safepoint or lock,
|
||||
find_sorted_affected_classes is not in safepoint therefore it must be
|
||||
locked
|
||||
ClassLoaderDataGraph::rollback_redefinition need safepoint too
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index a27c2ff87ae..001d2c782d8 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -1380,7 +1380,9 @@ void VM_EnhancedRedefineClasses::calculate_instance_update_information(Klass* ne
|
||||
// Rollback all changes - clear new classes from the system dictionary, return old classes to directory, free memory.
|
||||
void VM_EnhancedRedefineClasses::rollback() {
|
||||
log_info(redefine, class, load)("Rolling back redefinition, result=%d", _res);
|
||||
+ ClassLoaderDataGraph_lock->lock();
|
||||
ClassLoaderDataGraph::rollback_redefinition();
|
||||
+ ClassLoaderDataGraph_lock->unlock();
|
||||
|
||||
for (int i = 0; i < _new_classes->length(); i++) {
|
||||
SystemDictionary::remove_from_hierarchy(_new_classes->at(i));
|
||||
@@ -2063,7 +2065,10 @@ jvmtiError VM_EnhancedRedefineClasses::find_sorted_affected_classes(TRAPS) {
|
||||
AffectedKlassClosure closure(_affected_klasses);
|
||||
// Updated in j10, from original SystemDictionary::classes_do
|
||||
|
||||
- ClassLoaderDataGraph::classes_do(&closure);
|
||||
+ {
|
||||
+ MutexLocker mcld(ClassLoaderDataGraph_lock);
|
||||
+ ClassLoaderDataGraph::classes_do(&closure);
|
||||
+ }
|
||||
//ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
|
||||
log_trace(redefine, class, load)("%d classes affected", _affected_klasses->length());
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
From 09af8da3c8fcb6d97917951673a56696fd7d6a2b Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 22 Nov 2020 12:05:50 +0100
|
||||
Subject: [PATCH 14/45] dcevm15 - fix Universe::root_oops_do
|
||||
|
||||
Removed ClassLoaderDataGraph::cld_do was cause of crashes due multiple
|
||||
oop patching. ClassLoaderDataGraph::cld_do replaced in dcevm15
|
||||
previously used and removed SystemDictionary:oops_do
|
||||
---
|
||||
src/hotspot/share/memory/universe.cpp | 45 +++++++++++----------------
|
||||
1 file changed, 19 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp
|
||||
index 9fcbb6c41b3..247f2b3e8c0 100644
|
||||
--- a/src/hotspot/share/memory/universe.cpp
|
||||
+++ b/src/hotspot/share/memory/universe.cpp
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "gc/shared/oopStorageSet.hpp"
|
||||
#include "gc/shared/stringdedup/stringDedup.hpp"
|
||||
#include "gc/shared/tlab_globals.hpp"
|
||||
+#include "gc/shared/weakProcessor.hpp"
|
||||
+#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
@@ -71,6 +73,8 @@
|
||||
#include "runtime/jniHandles.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
#include "runtime/timerTrace.hpp"
|
||||
+#include "runtime/vmOperations.hpp"
|
||||
+#include "services/management.hpp"
|
||||
#include "services/memoryService.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/autoRestore.hpp"
|
||||
@@ -209,45 +213,34 @@ void Universe::basic_type_classes_do(KlassClosure *closure) {
|
||||
|
||||
// FIXME: (DCEVM) This method should iterate all pointers that are not within heap objects.
|
||||
void Universe::root_oops_do(OopClosure *oopClosure) {
|
||||
-
|
||||
- class AlwaysTrueClosure: public BoolObjectClosure {
|
||||
- public:
|
||||
- void do_object(oop p) { ShouldNotReachHere(); }
|
||||
- bool do_object_b(oop p) { return true; }
|
||||
- };
|
||||
- AlwaysTrueClosure always_true;
|
||||
-
|
||||
Universe::oops_do(oopClosure);
|
||||
// ReferenceProcessor::oops_do(oopClosure); (tw) check why no longer there
|
||||
JNIHandles::oops_do(oopClosure); // Global (strong) JNI handles
|
||||
Threads::oops_do(oopClosure, NULL);
|
||||
ObjectSynchronizer::oops_do(oopClosure);
|
||||
- // TODO: review, flat profiler was removed in j10
|
||||
- // FlatProfiler::oops_do(oopClosure);
|
||||
- JvmtiExport::oops_do(oopClosure);
|
||||
+ // (DCEVM) TODO: Check if this is correct?
|
||||
+ Management::oops_do(oopClosure);
|
||||
+ OopStorageSet::vm_global()->oops_do(oopClosure);
|
||||
+ // CLDToOopClosure cld_closure(oopClosure, ClassLoaderData::_claim_none);
|
||||
+ // ClassLoaderDataGraph::cld_do(&cld_closure);
|
||||
|
||||
// Now adjust pointers in remaining weak roots. (All of which should
|
||||
// have been cleared if they pointed to non-surviving objects.)
|
||||
// Global (weak) JNI handles
|
||||
- JNIHandles::weak_oops_do(&always_true, oopClosure);
|
||||
+ WeakProcessor::oops_do(oopClosure);
|
||||
+
|
||||
+ JvmtiExport::oops_do(oopClosure);
|
||||
|
||||
CodeBlobToOopClosure blobClosure(oopClosure, CodeBlobToOopClosure::FixRelocations);
|
||||
CodeCache::blobs_do(&blobClosure);
|
||||
- StringTable::oops_do(oopClosure);
|
||||
+
|
||||
+ AOT_ONLY(AOTLoader::oops_do(oopClosure);)
|
||||
+
|
||||
+ // StringTable::oops_do was removed in j15
|
||||
+ // StringTable::oops_do(oopClosure);
|
||||
+
|
||||
+ // OopStorageSet::vm_global()->oops_do(oopClosure);
|
||||
|
||||
- // (DCEVM) TODO: Check if this is correct?
|
||||
- //CodeCache::scavenge_root_nmethods_oops_do(oopClosure);
|
||||
- //Management::oops_do(oopClosure);
|
||||
- //ref_processor()->weak_oops_do(&oopClosure);
|
||||
- //PSScavenge::reference_processor()->weak_oops_do(&oopClosure);
|
||||
-
|
||||
-#if INCLUDE_AOT
|
||||
- if (UseAOT) {
|
||||
- AOTLoader::oops_do(oopClosure);
|
||||
- }
|
||||
-#endif
|
||||
- // SO_AllClasses
|
||||
- SystemDictionary::oops_do(oopClosure);
|
||||
}
|
||||
|
||||
void Universe::oops_do(OopClosure* f) {
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
From fc0d2894212fd2186498d3341dddf2f201965686 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 28 Nov 2020 19:29:42 +0100
|
||||
Subject: [PATCH 15/45] dcevm15 - check if has_nestmate_access_to has newest
|
||||
host class
|
||||
|
||||
---
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index c181fe044e2..a8ac12450d7 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -398,6 +398,11 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ // TODO: (DCEVM) check if it correct. It fix problems with lambdas (hidden)
|
||||
+ cur_host = InstanceKlass::cast(cur_host->newest_version());
|
||||
+ }
|
||||
+
|
||||
Klass* k_nest_host = k->nest_host(CHECK_false);
|
||||
if (k_nest_host == NULL) {
|
||||
return false;
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From d20a52a5e7a87003da6f3e4bda39ec2976868a75 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 29 Nov 2020 17:18:16 +0100
|
||||
Subject: [PATCH 16/45] dcevm15 - mark_as_scavengable only alive methods
|
||||
|
||||
---
|
||||
.../share/prims/jvmtiEnhancedRedefineClasses.cpp | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 001d2c782d8..d742679d199 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -223,19 +223,21 @@ class FieldCopier : public FieldClosure {
|
||||
|
||||
// TODO: review...
|
||||
void VM_EnhancedRedefineClasses::mark_as_scavengable(nmethod* nm) {
|
||||
- ScavengableNMethods::register_nmethod(nm);
|
||||
+ if (nm->is_alive()) {
|
||||
+ ScavengableNMethods::register_nmethod(nm);
|
||||
+ }
|
||||
}
|
||||
|
||||
void VM_EnhancedRedefineClasses::unregister_nmethod_g1(nmethod* nm) {
|
||||
// It should work not only for G1 but also for another GCs, but this way is safer now
|
||||
- if (!nm->is_zombie() && !nm->is_unloaded()) {
|
||||
+ if (nm->is_alive()) {
|
||||
Universe::heap()->unregister_nmethod(nm);
|
||||
}
|
||||
}
|
||||
|
||||
void VM_EnhancedRedefineClasses::register_nmethod_g1(nmethod* nm) {
|
||||
// It should work not only for G1 but also for another GCs, but this way is safer now
|
||||
- if (!nm->is_zombie() && !nm->is_unloaded()) {
|
||||
+ if (nm->is_alive()) {
|
||||
Universe::heap()->register_nmethod(nm);
|
||||
}
|
||||
}
|
||||
@@ -511,9 +513,9 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
flush_dependent_code(thread);
|
||||
// }
|
||||
|
||||
- // Adjust constantpool caches for all classes that reference methods of the evolved class.
|
||||
- ClearCpoolCacheAndUnpatch clear_cpool_cache(thread);
|
||||
- ClassLoaderDataGraph::classes_do(&clear_cpool_cache);
|
||||
+ // Adjust constantpool caches for all classes that reference methods of the evolved class.
|
||||
+ ClearCpoolCacheAndUnpatch clear_cpool_cache(thread);
|
||||
+ ClassLoaderDataGraph::classes_do(&clear_cpool_cache);
|
||||
|
||||
// JSR-292 support
|
||||
if (_any_class_has_resolved_methods) {
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
From b315e7cd828e79d63562b0296b97795015b644af Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 29 Nov 2020 20:05:03 +0100
|
||||
Subject: [PATCH 17/45] dcevm15 - fix hidded classes
|
||||
|
||||
---
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 41 ++++++++++++++-----
|
||||
1 file changed, 30 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index d742679d199..1433e429e30 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -722,7 +722,8 @@ bool VM_EnhancedRedefineClasses::is_modifiable_class(oop klass_mirror) {
|
||||
}
|
||||
|
||||
// Cannot redefine or retransform an anonymous class.
|
||||
- if (InstanceKlass::cast(k)->is_unsafe_anonymous()) {
|
||||
+ // TODO: check if is correct in j15
|
||||
+ if (InstanceKlass::cast(k)->is_unsafe_anonymous() || InstanceKlass::cast(k)->is_hidden()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -808,21 +809,27 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
|
||||
InstanceKlass* k;
|
||||
|
||||
- if (InstanceKlass::cast(the_class)->is_unsafe_anonymous()) {
|
||||
- const InstanceKlass* host_class = the_class->unsafe_anonymous_host();
|
||||
+ if (the_class->is_unsafe_anonymous() || the_class->is_hidden()) {
|
||||
+ InstanceKlass* dynamic_host_class = NULL;
|
||||
+ InstanceKlass* unsafe_anonymous_host = NULL;
|
||||
|
||||
- // Make sure it's the real host class, not another anonymous class.
|
||||
- while (host_class != NULL && host_class->is_unsafe_anonymous()) {
|
||||
- host_class = host_class->unsafe_anonymous_host();
|
||||
+ if (the_class->is_hidden()) {
|
||||
+ log_debug(redefine, class, load)("loading hidden class %s", the_class->name()->as_C_string());
|
||||
+ dynamic_host_class = the_class->nest_host(THREAD);
|
||||
+ }
|
||||
+
|
||||
+ if (the_class->is_unsafe_anonymous()) {
|
||||
+ log_debug(redefine, class, load)("loading usafe anonymous %s", the_class->name()->as_C_string());
|
||||
+ unsafe_anonymous_host = the_class->unsafe_anonymous_host();
|
||||
}
|
||||
|
||||
ClassLoadInfo cl_info(protection_domain,
|
||||
- host_class,
|
||||
- NULL, // dynamic_nest_host
|
||||
+ unsafe_anonymous_host,
|
||||
NULL, // cp_patches
|
||||
+ dynamic_host_class, // dynamic_nest_host
|
||||
Handle(), // classData
|
||||
- false, // is_hidden
|
||||
- false, // is_strong_hidden
|
||||
+ the_class->is_hidden(), // is_hidden
|
||||
+ !the_class->is_non_strong_hidden(), // is_strong_hidden
|
||||
true); // FIXME: check if correct. can_access_vm_annotations
|
||||
|
||||
k = SystemDictionary::parse_stream(the_class_sym,
|
||||
@@ -833,7 +840,17 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
THREAD);
|
||||
|
||||
k->class_loader_data()->exchange_holders(the_class->class_loader_data());
|
||||
- the_class->class_loader_data()->inc_keep_alive();
|
||||
+
|
||||
+ if (the_class->is_hidden()) {
|
||||
+ // from jvm_lookup_define_class() (jvm.cpp):
|
||||
+ // The hidden class loader data has been artificially been kept alive to
|
||||
+ // this point. The mirror and any instances of this class have to keep
|
||||
+ // it alive afterwards.
|
||||
+ the_class->class_loader_data()->dec_keep_alive();
|
||||
+ } else {
|
||||
+ the_class->class_loader_data()->inc_keep_alive();
|
||||
+ }
|
||||
+
|
||||
} else {
|
||||
k = SystemDictionary::resolve_from_stream(the_class_sym,
|
||||
the_class_loader,
|
||||
@@ -1475,6 +1492,8 @@ void VM_EnhancedRedefineClasses::ClearCpoolCacheAndUnpatch::do_klass(Klass* k) {
|
||||
ik->set_unsafe_anonymous_host(InstanceKlass::cast(ik->unsafe_anonymous_host()->newest_version()));
|
||||
}
|
||||
|
||||
+ // FIXME: check new nest_host for hidden
|
||||
+
|
||||
// Update implementor if there is only one, in this case implementor() can reference old class
|
||||
if (ik->is_interface()) {
|
||||
Klass* implKlass = ik->implementor();
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From 25d78e62a702ad754c1a3a0136db1453089f008e Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 29 Nov 2020 20:08:57 +0100
|
||||
Subject: [PATCH 18/45] dcevm15 - DON'T clear F2 in CP cache after indy
|
||||
unevolving
|
||||
|
||||
It's not clear why it was cleared in dcevm7-11
|
||||
---
|
||||
src/hotspot/share/oops/cpCache.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp
|
||||
index 167cb274661..7e72641ec5a 100644
|
||||
--- a/src/hotspot/share/oops/cpCache.cpp
|
||||
+++ b/src/hotspot/share/oops/cpCache.cpp
|
||||
@@ -654,7 +654,7 @@ void ConstantPoolCacheEntry::clear_entry() {
|
||||
|
||||
if (clearData) {
|
||||
if (!is_resolved_reference()) {
|
||||
- _f2 = 0;
|
||||
+ // _f2 = 0;
|
||||
}
|
||||
// FIXME: (DCEVM) we want to clear flags, but parameter size is actually used
|
||||
// after we return from the method, before entry is re-initialized. So let's
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
From b84814b31883b0f5441fca6d77b18c7426d26c36 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 22 Nov 2020 12:03:32 +0100
|
||||
Subject: [PATCH 19/45] Cleanup and review comments
|
||||
|
||||
---
|
||||
src/hotspot/share/classfile/classLoaderDataGraph.hpp | 2 +-
|
||||
src/hotspot/share/gc/shared/gcConfig.cpp | 2 +-
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 1 +
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp | 2 +-
|
||||
4 files changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.hpp b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
index 5f8913001b0..c3bcc7271e6 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
@@ -105,7 +105,7 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
|
||||
static void dictionary_classes_do(KlassClosure* klass_closure);
|
||||
|
||||
- // Enhanced class redefinition
|
||||
+ // (DCEVM) Enhanced class redefinition
|
||||
static void rollback_redefinition();
|
||||
|
||||
// VM_CounterDecay iteration support
|
||||
diff --git a/src/hotspot/share/gc/shared/gcConfig.cpp b/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
index 26a2b67b8e9..8e78696bef5 100644
|
||||
--- a/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
+++ b/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
@@ -97,7 +97,7 @@ void GCConfig::fail_if_non_included_gc_is_selected() {
|
||||
|
||||
void GCConfig::select_gc_ergonomically() {
|
||||
if (AllowEnhancedClassRedefinition && !UseG1GC) {
|
||||
- // Enhanced class redefinition only supports serial GC at the moment
|
||||
+ // (DCEVM) Enhanced class redefinition only supports serial GC at the moment
|
||||
FLAG_SET_ERGO(UseSerialGC, true);
|
||||
} else if (os::is_server_class_machine()) {
|
||||
#if INCLUDE_G1GC
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 1433e429e30..af34d751bdb 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -842,6 +842,7 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
k->class_loader_data()->exchange_holders(the_class->class_loader_data());
|
||||
|
||||
if (the_class->is_hidden()) {
|
||||
+ // TODO: (DCEVM) review if is correct
|
||||
// from jvm_lookup_define_class() (jvm.cpp):
|
||||
// The hidden class loader data has been artificially been kept alive to
|
||||
// this point. The mirror and any instances of this class have to keep
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
index 61f62e7f831..43f1aff8e91 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
@@ -78,7 +78,7 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
// have any entries.
|
||||
bool _any_class_has_resolved_methods;
|
||||
|
||||
- // Enhanced class redefinition, affected klasses contain all classes which should be redefined
|
||||
+ // (DCEVM) Enhanced class redefinition, affected klasses contain all classes which should be redefined
|
||||
// either because of redefine, class hierarchy or interface change
|
||||
GrowableArray<Klass*>* _affected_klasses;
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From 9da70fec073a442e9c0aee19a5ec643c1f84cea5 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 12 Feb 2021 10:11:10 +0100
|
||||
Subject: [PATCH 20/45] Disable AllowEnhancedClassRedefinition in flight
|
||||
recorder
|
||||
|
||||
---
|
||||
src/hotspot/share/runtime/arguments.cpp | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
|
||||
index 9661f2b62b9..252ebbc4e57 100644
|
||||
--- a/src/hotspot/share/runtime/arguments.cpp
|
||||
+++ b/src/hotspot/share/runtime/arguments.cpp
|
||||
@@ -4027,6 +4027,13 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
|
||||
// Set object alignment values.
|
||||
set_object_alignment();
|
||||
|
||||
+ if (FlightRecorder) {
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ warning("EnhancedClassRedefinition was disabled, it is not allowed in FlightRecorder.");
|
||||
+ AllowEnhancedClassRedefinition = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
#if !INCLUDE_CDS
|
||||
if (DumpSharedSpaces || RequireSharedSpaces) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,695 @@
|
||||
From 5d065e823c431a80251696c2543f6c98e68f00a6 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 12 Feb 2021 09:44:28 +0100
|
||||
Subject: [PATCH 21/45] dcevm17 - fix compilation issues
|
||||
|
||||
---
|
||||
.../share/classfile/classLoaderData.cpp | 2 +-
|
||||
src/hotspot/share/classfile/javaClasses.cpp | 4 +-
|
||||
src/hotspot/share/classfile/javaClasses.hpp | 4 +-
|
||||
.../share/classfile/lambdaFormInvokers.cpp | 152 ++++++++++++++++++
|
||||
.../share/classfile/systemDictionary.cpp | 5 +-
|
||||
.../share/classfile/systemDictionary.hpp | 6 +
|
||||
src/hotspot/share/classfile/vmClassMacros.hpp | 2 +
|
||||
.../share/gc/g1/g1FullGCCompactTask.cpp | 9 +-
|
||||
.../share/gc/g1/g1FullGCCompactionPoint.cpp | 12 +-
|
||||
src/hotspot/share/gc/shared/dcevmSharedGC.cpp | 2 +-
|
||||
src/hotspot/share/gc/shared/space.inline.hpp | 2 +-
|
||||
src/hotspot/share/memory/universe.cpp | 71 --------
|
||||
src/hotspot/share/memory/universe.hpp | 7 -
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 4 +-
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 47 ++++--
|
||||
.../prims/jvmtiEnhancedRedefineClasses.hpp | 2 +
|
||||
.../share/prims/resolvedMethodTable.cpp | 5 +-
|
||||
src/hotspot/share/runtime/arguments.hpp | 2 +
|
||||
18 files changed, 221 insertions(+), 117 deletions(-)
|
||||
create mode 100644 src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
index 2a826ff50a7..65ce4c4af8c 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
@@ -603,7 +603,7 @@ void ClassLoaderData::exchange_holders(ClassLoaderData* cld) {
|
||||
oop holder_oop = _holder.peek();
|
||||
_holder.replace(cld->_holder.peek());
|
||||
cld->_holder.replace(holder_oop);
|
||||
- WeakHandle<vm_weak_data> exchange = _holder;
|
||||
+ WeakHandle exchange = _holder;
|
||||
_holder = cld->_holder;
|
||||
cld->_holder = exchange;
|
||||
}
|
||||
diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp
|
||||
index dc800debea4..66ff72b2f02 100644
|
||||
--- a/src/hotspot/share/classfile/javaClasses.cpp
|
||||
+++ b/src/hotspot/share/classfile/javaClasses.cpp
|
||||
@@ -3827,7 +3827,7 @@ void java_lang_invoke_DirectMethodHandle_StaticAccessor::set_static_offset(oop d
|
||||
macro(_static_offset_offset, k, vmSymbols::static_offset_name(), long_signature, false)
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_StaticAccessor::compute_offsets() {
|
||||
- InstanceKlass* k = SystemDictionary::DirectMethodHandle_StaticAccessor_klass();
|
||||
+ InstanceKlass* k = vmClasses::DirectMethodHandle_StaticAccessor_klass();
|
||||
DIRECTMETHODHANDLE_STATIC_ACCESSOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
@@ -3855,7 +3855,7 @@ void java_lang_invoke_DirectMethodHandle_Accessor::set_field_offset(oop dmh, int
|
||||
macro(_field_offset_offset, k, vmSymbols::field_offset_name(), int_signature, false)
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_Accessor::compute_offsets() {
|
||||
- InstanceKlass* k = SystemDictionary::DirectMethodHandle_Accessor_klass();
|
||||
+ InstanceKlass* k = vmClasses::DirectMethodHandle_Accessor_klass();
|
||||
DIRECTMETHODHANDLE_ACCESSOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp
|
||||
index 32348c90ef9..f7dc5ccbd8c 100644
|
||||
--- a/src/hotspot/share/classfile/javaClasses.hpp
|
||||
+++ b/src/hotspot/share/classfile/javaClasses.hpp
|
||||
@@ -1029,7 +1029,7 @@ class java_lang_invoke_DirectMethodHandle_StaticAccessor: AllStatic {
|
||||
|
||||
// Testers
|
||||
static bool is_subclass(Klass* klass) {
|
||||
- return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_StaticAccessor_klass());
|
||||
+ return klass->is_subclass_of(vmClasses::DirectMethodHandle_StaticAccessor_klass());
|
||||
}
|
||||
static bool is_instance(oop obj);
|
||||
|
||||
@@ -1053,7 +1053,7 @@ class java_lang_invoke_DirectMethodHandle_Accessor: AllStatic {
|
||||
|
||||
// Testers
|
||||
static bool is_subclass(Klass* klass) {
|
||||
- return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_Accessor_klass());
|
||||
+ return klass->is_subclass_of(vmClasses::DirectMethodHandle_Accessor_klass());
|
||||
}
|
||||
static bool is_instance(oop obj);
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/lambdaFormInvokers.cpp b/src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
new file mode 100644
|
||||
index 00000000000..281de58b482
|
||||
--- /dev/null
|
||||
+++ b/src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
@@ -0,0 +1,152 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
+ *
|
||||
+ * This code is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 2 only, as
|
||||
+ * published by the Free Software Foundation.
|
||||
+ *
|
||||
+ * This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
+ * version 2 for more details (a copy is included in the LICENSE file that
|
||||
+ * accompanied this code).
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License version
|
||||
+ * 2 along with this work; if not, write to the Free Software Foundation,
|
||||
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
+ *
|
||||
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
+ * or visit www.oracle.com if you need additional information or have any
|
||||
+ * questions.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include "precompiled.hpp"
|
||||
+#include "classfile/classLoadInfo.hpp"
|
||||
+#include "classfile/classFileStream.hpp"
|
||||
+#include "classfile/javaClasses.inline.hpp"
|
||||
+#include "classfile/klassFactory.hpp"
|
||||
+#include "classfile/lambdaFormInvokers.hpp"
|
||||
+#include "classfile/symbolTable.hpp"
|
||||
+#include "classfile/systemDictionary.hpp"
|
||||
+#include "classfile/systemDictionaryShared.hpp"
|
||||
+#include "classfile/vmClasses.hpp"
|
||||
+#include "classfile/vmSymbols.hpp"
|
||||
+#include "logging/log.hpp"
|
||||
+#include "memory/oopFactory.hpp"
|
||||
+#include "memory/metaspaceShared.hpp"
|
||||
+#include "memory/resourceArea.hpp"
|
||||
+#include "oops/instanceKlass.hpp"
|
||||
+#include "oops/klass.hpp"
|
||||
+#include "oops/objArrayKlass.hpp"
|
||||
+#include "oops/objArrayOop.hpp"
|
||||
+#include "oops/oop.inline.hpp"
|
||||
+#include "oops/typeArrayOop.inline.hpp"
|
||||
+#include "runtime/handles.inline.hpp"
|
||||
+#include "runtime/javaCalls.hpp"
|
||||
+
|
||||
+GrowableArray<char*>* LambdaFormInvokers::_lambdaform_lines = NULL;
|
||||
+
|
||||
+void LambdaFormInvokers::append(char* line) {
|
||||
+ if (_lambdaform_lines == NULL) {
|
||||
+ _lambdaform_lines = new GrowableArray<char*>(100);
|
||||
+ }
|
||||
+ _lambdaform_lines->append(line);
|
||||
+}
|
||||
+
|
||||
+void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
|
||||
+ assert(_lambdaform_lines != NULL, "Bad List");
|
||||
+ ResourceMark rm(THREAD);
|
||||
+
|
||||
+ Symbol* cds_name = vmSymbols::jdk_internal_misc_CDS();
|
||||
+ Klass* cds_klass = SystemDictionary::resolve_or_null(cds_name, THREAD);
|
||||
+ guarantee(cds_klass != NULL, "jdk/internal/misc/CDS must exist!");
|
||||
+
|
||||
+ int len = _lambdaform_lines->length();
|
||||
+ objArrayHandle list_lines = oopFactory::new_objArray_handle(vmClasses::String_klass(), len, CHECK);
|
||||
+ for (int i = 0; i < len; i++) {
|
||||
+ Handle h_line = java_lang_String::create_from_str(_lambdaform_lines->at(i), CHECK);
|
||||
+ list_lines->obj_at_put(i, h_line());
|
||||
+ }
|
||||
+
|
||||
+ //
|
||||
+ // Object[] CDS.generateLambdaFormHolderClasses(String[] lines)
|
||||
+ // the returned Object[] layout:
|
||||
+ // name, byte[], name, byte[] ....
|
||||
+ Symbol* method = vmSymbols::generateLambdaFormHolderClasses();
|
||||
+ Symbol* signrs = vmSymbols::generateLambdaFormHolderClasses_signature();
|
||||
+
|
||||
+ JavaValue result(T_OBJECT);
|
||||
+ JavaCalls::call_static(&result, cds_klass, method, signrs, list_lines, THREAD);
|
||||
+
|
||||
+ if (HAS_PENDING_EXCEPTION) {
|
||||
+ log_info(cds)("%s: %s", THREAD->pending_exception()->klass()->external_name(),
|
||||
+ java_lang_String::as_utf8_string(java_lang_Throwable::message(THREAD->pending_exception())));
|
||||
+ CLEAR_PENDING_EXCEPTION;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ objArrayHandle h_array(THREAD, (objArrayOop)result.get_oop());
|
||||
+ int sz = h_array->length();
|
||||
+ assert(sz % 2 == 0 && sz >= 2, "Must be even size of length");
|
||||
+ for (int i = 0; i < sz; i+= 2) {
|
||||
+ Handle h_name(THREAD, h_array->obj_at(i));
|
||||
+ typeArrayHandle h_bytes(THREAD, (typeArrayOop)h_array->obj_at(i+1));
|
||||
+ assert(h_name != NULL, "Class name is NULL");
|
||||
+ assert(h_bytes != NULL, "Class bytes is NULL");
|
||||
+
|
||||
+ char *class_name = java_lang_String::as_utf8_string(h_name());
|
||||
+ int len = h_bytes->length();
|
||||
+ // make a copy of class bytes so GC will not affect us.
|
||||
+ char *buf = resource_allocate_bytes(THREAD, len);
|
||||
+ memcpy(buf, (char*)h_bytes->byte_at_addr(0), len);
|
||||
+ ClassFileStream st((u1*)buf, len, NULL, ClassFileStream::verify);
|
||||
+
|
||||
+ reload_class(class_name, st, THREAD);
|
||||
+ // free buf
|
||||
+ resource_free_bytes(buf, len);
|
||||
+
|
||||
+ if (HAS_PENDING_EXCEPTION) {
|
||||
+ log_info(cds)("Exception happened: %s", PENDING_EXCEPTION->klass()->name()->as_C_string());
|
||||
+ log_info(cds)("Could not create InstanceKlass for class %s", class_name);
|
||||
+ CLEAR_PENDING_EXCEPTION;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+// class_handle - the class name, bytes_handle - the class bytes
|
||||
+void LambdaFormInvokers::reload_class(char* name, ClassFileStream& st, TRAPS) {
|
||||
+ Symbol* class_name = SymbolTable::new_symbol((const char*)name);
|
||||
+ // the class must exist
|
||||
+ Klass* klass = SystemDictionary::resolve_or_null(class_name, THREAD);
|
||||
+ if (klass == NULL) {
|
||||
+ log_info(cds)("Class %s not present, skip", name);
|
||||
+ return;
|
||||
+ }
|
||||
+ assert(klass->is_instance_klass(), "Should be");
|
||||
+
|
||||
+ ClassLoaderData* cld = ClassLoaderData::the_null_class_loader_data();
|
||||
+ Handle protection_domain;
|
||||
+ ClassLoadInfo cl_info(protection_domain);
|
||||
+
|
||||
+ InstanceKlass* result = KlassFactory::create_from_stream(&st,
|
||||
+ class_name,
|
||||
+ cld,
|
||||
+ cl_info,
|
||||
+ false,
|
||||
+ CHECK);
|
||||
+
|
||||
+ {
|
||||
+ MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
|
||||
+ SystemDictionary::add_to_hierarchy(result);
|
||||
+ }
|
||||
+ // new class not linked yet.
|
||||
+ MetaspaceShared::try_link_class(THREAD, result);
|
||||
+ assert(!HAS_PENDING_EXCEPTION, "Invariant");
|
||||
+
|
||||
+ // exclude the existing class from dump
|
||||
+ SystemDictionaryShared::set_excluded(InstanceKlass::cast(klass));
|
||||
+ log_info(cds, lambda)("Replaced class %s, old: %p new: %p", name, klass, result);
|
||||
+}
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
index 98e2541c79b..63de2e2f099 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
@@ -963,11 +963,12 @@ InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
+ InstanceKlass* old_klass,
|
||||
TRAPS) {
|
||||
if (cl_info.is_hidden()) {
|
||||
- return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
|
||||
+ return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, old_klass, CHECK_NULL);
|
||||
} else {
|
||||
- return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
|
||||
+ return resolve_class_from_stream(st, class_name, class_loader, cl_info, old_klass, CHECK_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp
|
||||
index 0c774dfeb51..65185a29b10 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.hpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.hpp
|
||||
@@ -124,6 +124,7 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
+ InstanceKlass* old_klass,
|
||||
TRAPS);
|
||||
|
||||
// Resolve a class from stream (called by jni_DefineClass and JVM_DefineClass)
|
||||
@@ -132,6 +133,7 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
+ InstanceKlass* old_klass,
|
||||
TRAPS);
|
||||
|
||||
public:
|
||||
@@ -203,6 +205,10 @@ class SystemDictionary : AllStatic {
|
||||
// Initialization
|
||||
static void initialize(TRAPS);
|
||||
|
||||
+ // (DCEVM) Enhanced class redefinition
|
||||
+ static void remove_from_hierarchy(InstanceKlass* k);
|
||||
+ static void update_constraints_after_redefinition();
|
||||
+
|
||||
protected:
|
||||
// Returns the class loader data to be used when looking up/updating the
|
||||
// system dictionary.
|
||||
diff --git a/src/hotspot/share/classfile/vmClassMacros.hpp b/src/hotspot/share/classfile/vmClassMacros.hpp
|
||||
index a4f55641b51..fb205721a39 100644
|
||||
--- a/src/hotspot/share/classfile/vmClassMacros.hpp
|
||||
+++ b/src/hotspot/share/classfile/vmClassMacros.hpp
|
||||
@@ -109,6 +109,8 @@
|
||||
\
|
||||
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
|
||||
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
|
||||
+ do_klass(DirectMethodHandle_StaticAccessor_klass, java_lang_invoke_DirectMethodHandle_StaticAccessor ) \
|
||||
+ do_klass(DirectMethodHandle_Accessor_klass, java_lang_invoke_DirectMethodHandle_Accessor ) \
|
||||
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle ) \
|
||||
do_klass(VarHandle_klass, java_lang_invoke_VarHandle ) \
|
||||
do_klass(MemberName_klass, java_lang_invoke_MemberName ) \
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
index 54edc9dffb5..058dea90828 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
@@ -141,7 +141,10 @@ void G1FullGCCompactTask::compact_region_dcevm(HeapRegion* hr, GrowableArray<Hea
|
||||
// Once all objects have been moved the liveness information
|
||||
// needs be cleared.
|
||||
collector()->mark_bitmap()->clear_region(hr);
|
||||
- hr->complete_compaction();
|
||||
+ if (G1VerifyBitmaps) {
|
||||
+ collector()->mark_bitmap()->clear_region(hr);
|
||||
+ }
|
||||
+ hr->reset_compacted_after_full_gc();
|
||||
}
|
||||
|
||||
void G1FullGCCompactTask::serial_compaction_dcevm() {
|
||||
@@ -184,13 +187,13 @@ size_t G1FullGCCompactTask::G1CompactRegionClosureDcevm::apply(oop obj) {
|
||||
} else {
|
||||
DcevmSharedGC::update_fields(obj, oop(destination));
|
||||
}
|
||||
- oop(destination)->init_mark_raw();
|
||||
+ oop(destination)->init_mark();
|
||||
assert(oop(destination)->klass() != NULL, "should have a class");
|
||||
return size;
|
||||
}
|
||||
|
||||
Copy::aligned_conjoint_words(obj_addr, destination, size);
|
||||
- oop(destination)->init_mark_raw();
|
||||
+ oop(destination)->init_mark();
|
||||
assert(oop(destination)->klass() != NULL, "should have a class");
|
||||
|
||||
return size;
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
index 71a46b88f9e..87b1977128a 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
@@ -36,8 +36,8 @@ G1FullGCCompactionPoint::G1FullGCCompactionPoint() :
|
||||
{
|
||||
_compaction_regions = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapRegion*>(32, mtGC);
|
||||
_compaction_region_iterator = _compaction_regions->begin();
|
||||
- _rescued_oops = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapWord*>(128, true, mtGC);
|
||||
- _rescued_oops_values = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapWord*>(128, true, mtGC);
|
||||
+ _rescued_oops = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapWord*>(128, mtGC);
|
||||
+ _rescued_oops_values = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapWord*>(128, mtGC);
|
||||
}
|
||||
|
||||
G1FullGCCompactionPoint::~G1FullGCCompactionPoint() {
|
||||
@@ -180,15 +180,15 @@ void G1FullGCCompactionPoint::forward_dcevm(oop object, size_t size, bool force_
|
||||
// with BiasedLocking, in this case forwardee() will return NULL
|
||||
// even if the mark-word is used. This is no problem since
|
||||
// forwardee() will return NULL in the compaction phase as well.
|
||||
- object->init_mark_raw();
|
||||
+ object->init_mark();
|
||||
} else {
|
||||
// Make sure object has the correct mark-word set or that it will be
|
||||
// fixed when restoring the preserved marks.
|
||||
- assert(object->mark_raw() == markWord::prototype_for_klass(object->klass()) || // Correct mark
|
||||
+ assert(object->mark() == markWord::prototype_for_klass(object->klass()) || // Correct mark
|
||||
object->mark_must_be_preserved() || // Will be restored by PreservedMarksSet
|
||||
- (UseBiasedLocking && object->has_bias_pattern_raw()), // Will be restored by BiasedLocking
|
||||
+ (UseBiasedLocking && object->has_bias_pattern()), // Will be restored by BiasedLocking
|
||||
"should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
|
||||
- p2i(object), object->mark_raw().value(), markWord::prototype_for_klass(object->klass()).value());
|
||||
+ p2i(object), object->mark().value(), markWord::prototype_for_klass(object->klass()).value());
|
||||
}
|
||||
assert(object->forwardee() == NULL, "should be forwarded to NULL");
|
||||
}
|
||||
diff --git a/src/hotspot/share/gc/shared/dcevmSharedGC.cpp b/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
index 3dee097f1d3..edc19a3077d 100644
|
||||
--- a/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
+++ b/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
@@ -64,7 +64,7 @@ void DcevmSharedGC::copy_rescued_objects_back(GrowableArray<HeapWord*>* rescued_
|
||||
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(rescued_obj), cast_from_oop<HeapWord*>(new_obj), size);
|
||||
}
|
||||
|
||||
- new_obj->init_mark_raw();
|
||||
+ new_obj->init_mark();
|
||||
assert(oopDesc::is_oop(new_obj), "must be a valid oop");
|
||||
}
|
||||
}
|
||||
diff --git a/src/hotspot/share/gc/shared/space.inline.hpp b/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
index e3a37280268..cafa2503ef4 100644
|
||||
--- a/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
+++ b/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
@@ -371,7 +371,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space, bool redefiniti
|
||||
} else {
|
||||
DcevmSharedGC::update_fields(oop(cur_obj), oop(compaction_top));
|
||||
}
|
||||
- oop(compaction_top)->init_mark_raw();
|
||||
+ oop(compaction_top)->init_mark();
|
||||
assert(oop(compaction_top)->klass() != NULL, "should have a class");
|
||||
|
||||
debug_only(prev_obj = cur_obj);
|
||||
diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp
|
||||
index 247f2b3e8c0..4ae3b382b67 100644
|
||||
--- a/src/hotspot/share/memory/universe.cpp
|
||||
+++ b/src/hotspot/share/memory/universe.cpp
|
||||
@@ -44,8 +44,6 @@
|
||||
#include "gc/shared/oopStorageSet.hpp"
|
||||
#include "gc/shared/stringdedup/stringDedup.hpp"
|
||||
#include "gc/shared/tlab_globals.hpp"
|
||||
-#include "gc/shared/weakProcessor.hpp"
|
||||
-#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
@@ -73,8 +71,6 @@
|
||||
#include "runtime/jniHandles.hpp"
|
||||
#include "runtime/thread.inline.hpp"
|
||||
#include "runtime/timerTrace.hpp"
|
||||
-#include "runtime/vmOperations.hpp"
|
||||
-#include "services/management.hpp"
|
||||
#include "services/memoryService.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/autoRestore.hpp"
|
||||
@@ -208,73 +204,6 @@ void Universe::basic_type_classes_do(KlassClosure *closure) {
|
||||
}
|
||||
}
|
||||
|
||||
-#define DO_PRIMITIVE_MIRROR(m) \
|
||||
- f->do_oop((oop*) &m);
|
||||
-
|
||||
-// FIXME: (DCEVM) This method should iterate all pointers that are not within heap objects.
|
||||
-void Universe::root_oops_do(OopClosure *oopClosure) {
|
||||
- Universe::oops_do(oopClosure);
|
||||
-// ReferenceProcessor::oops_do(oopClosure); (tw) check why no longer there
|
||||
- JNIHandles::oops_do(oopClosure); // Global (strong) JNI handles
|
||||
- Threads::oops_do(oopClosure, NULL);
|
||||
- ObjectSynchronizer::oops_do(oopClosure);
|
||||
- // (DCEVM) TODO: Check if this is correct?
|
||||
- Management::oops_do(oopClosure);
|
||||
- OopStorageSet::vm_global()->oops_do(oopClosure);
|
||||
- // CLDToOopClosure cld_closure(oopClosure, ClassLoaderData::_claim_none);
|
||||
- // ClassLoaderDataGraph::cld_do(&cld_closure);
|
||||
-
|
||||
- // Now adjust pointers in remaining weak roots. (All of which should
|
||||
- // have been cleared if they pointed to non-surviving objects.)
|
||||
- // Global (weak) JNI handles
|
||||
- WeakProcessor::oops_do(oopClosure);
|
||||
-
|
||||
- JvmtiExport::oops_do(oopClosure);
|
||||
-
|
||||
- CodeBlobToOopClosure blobClosure(oopClosure, CodeBlobToOopClosure::FixRelocations);
|
||||
- CodeCache::blobs_do(&blobClosure);
|
||||
-
|
||||
- AOT_ONLY(AOTLoader::oops_do(oopClosure);)
|
||||
-
|
||||
- // StringTable::oops_do was removed in j15
|
||||
- // StringTable::oops_do(oopClosure);
|
||||
-
|
||||
- // OopStorageSet::vm_global()->oops_do(oopClosure);
|
||||
-
|
||||
-}
|
||||
-
|
||||
-void Universe::oops_do(OopClosure* f) {
|
||||
- PRIMITIVE_MIRRORS_DO(DO_PRIMITIVE_MIRROR);
|
||||
-
|
||||
- for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||
- f->do_oop((oop*) &_mirrors[i]);
|
||||
- }
|
||||
- assert(_mirrors[0] == NULL && _mirrors[T_BOOLEAN - 1] == NULL, "checking");
|
||||
-
|
||||
- f->do_oop((oop*)&_the_empty_class_array);
|
||||
- f->do_oop((oop*)&_the_null_sentinel);
|
||||
- f->do_oop((oop*)&_the_null_string);
|
||||
- f->do_oop((oop*)&_the_min_jint_string);
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_java_heap));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_c_heap));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_metaspace));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_class_metaspace));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_array_size));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_gc_overhead_limit));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_realloc_objects));
|
||||
- f->do_oop((oop*)&out_of_memory_errors()->obj_at(_oom_retry));
|
||||
- f->do_oop((oop*)&_delayed_stack_overflow_error_message);
|
||||
- f->do_oop((oop*)&_preallocated_out_of_memory_error_array);
|
||||
- f->do_oop((oop*)&_null_ptr_exception_instance);
|
||||
- f->do_oop((oop*)&_arithmetic_exception_instance);
|
||||
- f->do_oop((oop*)&_virtual_machine_error_instance);
|
||||
- f->do_oop((oop*)&_main_thread_group);
|
||||
- f->do_oop((oop*)&_system_thread_group);
|
||||
- f->do_oop((oop*)&_reference_pending_list);
|
||||
- debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);)
|
||||
- ThreadsSMRSupport::exiting_threads_oops_do(f);
|
||||
-}
|
||||
-
|
||||
void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
it->push(&_klass);
|
||||
}
|
||||
diff --git a/src/hotspot/share/memory/universe.hpp b/src/hotspot/share/memory/universe.hpp
|
||||
index cb320076a55..4b2211c415e 100644
|
||||
--- a/src/hotspot/share/memory/universe.hpp
|
||||
+++ b/src/hotspot/share/memory/universe.hpp
|
||||
@@ -326,13 +326,6 @@ class Universe: AllStatic {
|
||||
static bool should_fill_in_stack_trace(Handle throwable);
|
||||
static void check_alignment(uintx size, uintx alignment, const char* name);
|
||||
|
||||
- // Iteration
|
||||
-
|
||||
- static void root_oops_do(OopClosure *oopClosure); // FIXME: kill...
|
||||
- // Apply "f" to the addresses of all the direct heap pointers maintained
|
||||
- // as static fields of "Universe".
|
||||
- static void oops_do(OopClosure* f);
|
||||
-
|
||||
// CDS support
|
||||
static void serialize(SerializeClosure* f);
|
||||
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index a8ac12450d7..ab2d7f10f9c 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -1286,7 +1286,7 @@ void InstanceKlass::init_implementor() {
|
||||
// (DCEVM) - init_implementor() for dcevm
|
||||
void InstanceKlass::init_implementor_from_redefine() {
|
||||
assert(is_interface(), "not interface");
|
||||
- Klass* volatile* addr = adr_implementor();
|
||||
+ InstanceKlass* volatile* addr = adr_implementor();
|
||||
assert(addr != NULL, "null addr");
|
||||
if (addr != NULL) {
|
||||
*addr = NULL;
|
||||
@@ -3828,7 +3828,7 @@ void InstanceKlass::verify_on(outputStream* st) {
|
||||
|
||||
guarantee(sib->is_klass(), "should be klass");
|
||||
// TODO: (DCEVM) explain
|
||||
- guarantee(sib->super() == super || AllowEnhancedClassRedefinition && super->newest_version() == SystemDictionary::Object_klass(), "siblings should have same superklass");
|
||||
+ guarantee(sib->super() == super || AllowEnhancedClassRedefinition && super->newest_version() == vmClasses::Object_klass(), "siblings should have same superklass");
|
||||
}
|
||||
|
||||
// Verify local interfaces
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index af34d751bdb..0b1db1581d1 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -26,8 +26,10 @@
|
||||
#include "aot/aotLoader.hpp"
|
||||
#include "classfile/classFileParser.hpp"
|
||||
#include "classfile/classFileStream.hpp"
|
||||
+#include "classfile/classLoadInfo.hpp"
|
||||
#include "classfile/metadataOnStackMark.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
+#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/verifier.hpp"
|
||||
#include "classfile/dictionary.hpp"
|
||||
#include "classfile/classLoaderDataGraph.hpp"
|
||||
@@ -198,8 +200,8 @@ class FieldCopier : public FieldClosure {
|
||||
if (found && result.is_static()) {
|
||||
log_trace(redefine, class, obsolete, metadata)("Copying static field value for field %s old_offset=%d new_offset=%d",
|
||||
fd->name()->as_C_string(), result.offset(), fd->offset());
|
||||
- memcpy(cur_oop->obj_field_addr_raw<HeapWord>(fd->offset()),
|
||||
- old_oop->obj_field_addr_raw<HeapWord>(result.offset()),
|
||||
+ memcpy(cur_oop->obj_field_addr<HeapWord>(fd->offset()),
|
||||
+ old_oop->obj_field_addr<HeapWord>(result.offset()),
|
||||
type2aelembytes(fd->field_type()));
|
||||
|
||||
// Static fields may have references to java.lang.Class
|
||||
@@ -242,6 +244,17 @@ void VM_EnhancedRedefineClasses::register_nmethod_g1(nmethod* nm) {
|
||||
}
|
||||
}
|
||||
|
||||
+void VM_EnhancedRedefineClasses::root_oops_do(OopClosure *oopClosure) {
|
||||
+ Universe::vm_global()->oops_do(oopClosure);
|
||||
+
|
||||
+ Threads::oops_do(oopClosure, NULL);
|
||||
+ AOT_ONLY(AOTLoader::oops_do(oopClosure);)
|
||||
+ OopStorageSet::strong_oops_do(oopClosure);
|
||||
+
|
||||
+ CodeBlobToOopClosure blobClosure(oopClosure, CodeBlobToOopClosure::FixRelocations);
|
||||
+ CodeCache::blobs_do(&blobClosure);
|
||||
+}
|
||||
+
|
||||
// TODO comment
|
||||
struct StoreBarrier {
|
||||
// TODO: j10 review change ::oop_store -> HeapAccess<>::oop_store
|
||||
@@ -558,7 +571,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
_timer_heap_iterate.stop();
|
||||
}
|
||||
|
||||
- Universe::root_oops_do(&oopClosureNoBarrier);
|
||||
+ root_oops_do(&oopClosureNoBarrier);
|
||||
|
||||
if (UseG1GC) {
|
||||
// this should work also for other GCs
|
||||
@@ -737,8 +750,8 @@ bool VM_EnhancedRedefineClasses::is_modifiable_class(oop klass_mirror) {
|
||||
// - link new classes
|
||||
jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
|
||||
- _affected_klasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Klass*>(_class_count, true);
|
||||
- _new_classes = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<InstanceKlass*>(_class_count, true);
|
||||
+ _affected_klasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Klass*>(_class_count);
|
||||
+ _new_classes = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<InstanceKlass*>(_class_count);
|
||||
|
||||
ResourceMark rm(THREAD);
|
||||
|
||||
@@ -832,12 +845,12 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
!the_class->is_non_strong_hidden(), // is_strong_hidden
|
||||
true); // FIXME: check if correct. can_access_vm_annotations
|
||||
|
||||
- k = SystemDictionary::parse_stream(the_class_sym,
|
||||
- the_class_loader,
|
||||
- &st,
|
||||
- cl_info,
|
||||
- the_class,
|
||||
- THREAD);
|
||||
+ k = SystemDictionary::resolve_from_stream(&st,
|
||||
+ the_class_sym,
|
||||
+ the_class_loader,
|
||||
+ cl_info,
|
||||
+ the_class,
|
||||
+ THREAD);
|
||||
|
||||
k->class_loader_data()->exchange_holders(the_class->class_loader_data());
|
||||
|
||||
@@ -853,12 +866,12 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
}
|
||||
|
||||
} else {
|
||||
- k = SystemDictionary::resolve_from_stream(the_class_sym,
|
||||
- the_class_loader,
|
||||
- protection_domain,
|
||||
- &st,
|
||||
- the_class,
|
||||
- THREAD);
|
||||
+ k = SystemDictionary::resolve_from_stream(&st,
|
||||
+ the_class_sym,
|
||||
+ the_class_loader,
|
||||
+ protection_domain,
|
||||
+ the_class,
|
||||
+ THREAD);
|
||||
}
|
||||
// Clear class_being_redefined just to be sure.
|
||||
state->clear_class_being_redefined();
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
index 43f1aff8e91..ae0a15281f3 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
@@ -124,6 +124,8 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
static void register_nmethod_g1(nmethod* nm);
|
||||
static void unpatch_bytecode(Method* method, TRAPS);
|
||||
|
||||
+ void root_oops_do(OopClosure *oopClosure);
|
||||
+
|
||||
// Figure out which new methods match old methods in name and signature,
|
||||
// which methods have been added, and which are no longer present
|
||||
void compute_added_deleted_matching_methods();
|
||||
diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
index 3c29eda4da0..a1eadc2958a 100644
|
||||
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/method.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
+#include "oops/klass.inline.hpp"
|
||||
#include "oops/weakHandle.inline.hpp"
|
||||
#include "prims/resolvedMethodTable.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
@@ -375,7 +376,7 @@ class AdjustMethodEntriesDcevm : public StackObj {
|
||||
GrowableArray<oop>* _oops_to_add;
|
||||
public:
|
||||
AdjustMethodEntriesDcevm(GrowableArray<oop>* oops_to_add, bool* trace_name_printed) : _trace_name_printed(trace_name_printed), _oops_to_add(oops_to_add) {};
|
||||
- bool operator()(WeakHandle<vm_resolved_method_table_data>* entry) {
|
||||
+ bool operator()(WeakHandle* entry) {
|
||||
oop mem_name = entry->peek();
|
||||
if (mem_name == NULL) {
|
||||
// Removed
|
||||
@@ -460,7 +461,7 @@ void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed)
|
||||
if (_local_table->get(thread, lookup, rmg)) {
|
||||
break;
|
||||
}
|
||||
- WeakHandle<vm_resolved_method_table_data> wh = WeakHandle<vm_resolved_method_table_data>::create(Handle(thread, mem_name));
|
||||
+ WeakHandle wh(_oop_storage, mem_name);
|
||||
// The hash table takes ownership of the WeakHandle, even if it's not inserted.
|
||||
if (_local_table->insert(thread, lookup, wh)) {
|
||||
log_insert(method);
|
||||
diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp
|
||||
index 3adc03a6583..b8eb4d0ab24 100644
|
||||
--- a/src/hotspot/share/runtime/arguments.hpp
|
||||
+++ b/src/hotspot/share/runtime/arguments.hpp
|
||||
@@ -487,6 +487,8 @@ class Arguments : AllStatic {
|
||||
// Adjusts the arguments after the OS have adjusted the arguments
|
||||
static jint adjust_after_os();
|
||||
|
||||
+ // Check for consistency in the selection of the garbage collector.
|
||||
+ static bool check_gc_consistency(); // Check user-selected gc
|
||||
// Check consistency or otherwise of VM argument settings
|
||||
static bool check_vm_args_consistency();
|
||||
// Used by os_solaris
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From 09f5f22d61675a9f8909e903fa6e6f51507b656c Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 12 Feb 2021 11:38:48 +0100
|
||||
Subject: [PATCH 22/45] Fix crash on GrowableArray allocation in C_HEAP
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 0b1db1581d1..b88c071be13 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -750,8 +750,8 @@ bool VM_EnhancedRedefineClasses::is_modifiable_class(oop klass_mirror) {
|
||||
// - link new classes
|
||||
jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
|
||||
- _affected_klasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Klass*>(_class_count);
|
||||
- _new_classes = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<InstanceKlass*>(_class_count);
|
||||
+ _affected_klasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Klass*>(_class_count, mtInternal);
|
||||
+ _new_classes = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<InstanceKlass*>(_class_count, mtInternal);
|
||||
|
||||
ResourceMark rm(THREAD);
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
From 90b8572ff42dd5f64a6d2063aab6842bceddcf55 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 12 Feb 2021 11:39:05 +0100
|
||||
Subject: [PATCH 23/45] Rename confusing method name old_if_redefined to
|
||||
old_if_redefining
|
||||
|
||||
---
|
||||
src/hotspot/share/classfile/dictionary.cpp | 4 ++--
|
||||
src/hotspot/share/classfile/dictionary.hpp | 2 +-
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/dictionary.cpp b/src/hotspot/share/classfile/dictionary.cpp
|
||||
index 223b9e1e7a9..2b236a7724e 100644
|
||||
--- a/src/hotspot/share/classfile/dictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/dictionary.cpp
|
||||
@@ -359,7 +359,7 @@ InstanceKlass* Dictionary::find(unsigned int hash, Symbol* name,
|
||||
int index = hash_to_index(hash);
|
||||
DictionaryEntry* entry = get_entry(index, hash, name);
|
||||
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
|
||||
- return old_if_redefined(entry->instance_klass());
|
||||
+ return old_if_redefining(entry->instance_klass());
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ InstanceKlass* Dictionary::find_class(unsigned int hash,
|
||||
assert (index == index_for(name), "incorrect index?");
|
||||
|
||||
DictionaryEntry* entry = get_entry(index, hash, name);
|
||||
- return old_if_redefined((entry != NULL) ? entry->instance_klass() : NULL);
|
||||
+ return old_if_redefining((entry != NULL) ? entry->instance_klass() : NULL);
|
||||
}
|
||||
|
||||
void Dictionary::add_protection_domain(int index, unsigned int hash,
|
||||
diff --git a/src/hotspot/share/classfile/dictionary.hpp b/src/hotspot/share/classfile/dictionary.hpp
|
||||
index bdfef5c8663..e997cfdcabd 100644
|
||||
--- a/src/hotspot/share/classfile/dictionary.hpp
|
||||
+++ b/src/hotspot/share/classfile/dictionary.hpp
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
Handle protection_domain);
|
||||
|
||||
// (DCEVM) return old class if redefining in AllowEnhancedClassRedefinition, otherwise return "k"
|
||||
- static InstanceKlass* old_if_redefined(InstanceKlass* k) {
|
||||
+ static InstanceKlass* old_if_redefining(InstanceKlass* k) {
|
||||
return (k != NULL && k->is_redefining()) ? ((InstanceKlass* )k->old_version()) : k;
|
||||
}
|
||||
};
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 86f7318e889fcb0d883501b4a70105d087b39482 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Fri, 12 Feb 2021 12:33:47 +0100
|
||||
Subject: [PATCH 24/45] Check InstanceKlass::has_nestmate_access_to with active
|
||||
classes
|
||||
|
||||
Dcevm can leave old host in nested class if nested class is not
|
||||
redefined together with host class
|
||||
---
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index ab2d7f10f9c..bcb0da6301f 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -398,9 +398,9 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // (DCEVM) cur_host can be old, decide accessibility based on active version
|
||||
if (AllowEnhancedClassRedefinition) {
|
||||
- // TODO: (DCEVM) check if it correct. It fix problems with lambdas (hidden)
|
||||
- cur_host = InstanceKlass::cast(cur_host->newest_version());
|
||||
+ cur_host = InstanceKlass::cast(cur_host->active_version());
|
||||
}
|
||||
|
||||
Klass* k_nest_host = k->nest_host(CHECK_false);
|
||||
@@ -408,6 +408,11 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // (DCEVM) k_nest_host can be old, decide accessibility based on active version
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ k_nest_host = InstanceKlass::cast(k_nest_host->active_version());
|
||||
+ }
|
||||
+
|
||||
bool access = (cur_host == k_nest_host);
|
||||
|
||||
ResourceMark rm(THREAD);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
From 79ea607bf68161cfcee3a681d14540cffe5589a3 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 13 Feb 2021 20:47:52 +0100
|
||||
Subject: [PATCH 25/45] JBR-3111 Update class in all dictionaries where it was
|
||||
already defined
|
||||
|
||||
This patch keeps compatibility with std redefinition, that does not
|
||||
create a new Klass, but modifies it, then it is modified in all
|
||||
dictionaries containing this class.
|
||||
---
|
||||
src/hotspot/share/classfile/classLoaderDataGraph.cpp | 9 +++++++++
|
||||
src/hotspot/share/classfile/classLoaderDataGraph.hpp | 3 +++
|
||||
src/hotspot/share/classfile/dictionary.cpp | 2 +-
|
||||
src/hotspot/share/classfile/dictionary.hpp | 2 +-
|
||||
src/hotspot/share/classfile/systemDictionary.cpp | 4 +++-
|
||||
5 files changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
index fda5d2eb1ba..67ade5709f6 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
@@ -455,6 +455,15 @@ void ClassLoaderDataGraph::rollback_redefinition() {
|
||||
}
|
||||
}
|
||||
|
||||
+// (DCEVM) - iterate over all classes in all dictionaries
|
||||
+bool ClassLoaderDataGraph::dictionary_classes_do_update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass) {
|
||||
+ bool ok = false;
|
||||
+ FOR_ALL_DICTIONARY(cld) {
|
||||
+ ok = cld->dictionary()->update_klass(name, k, old_klass) || ok;
|
||||
+ }
|
||||
+ return ok;
|
||||
+}
|
||||
+
|
||||
void ClassLoaderDataGraph::verify_dictionary() {
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
cld->dictionary()->verify();
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.hpp b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
index c3bcc7271e6..ebdb0bc2c8c 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
@@ -108,6 +108,9 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
static void rollback_redefinition();
|
||||
|
||||
+ // Enhanced class redefinition
|
||||
+ static bool dictionary_classes_do_update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass);
|
||||
+
|
||||
// VM_CounterDecay iteration support
|
||||
static InstanceKlass* try_get_next_class();
|
||||
static void adjust_saved_class(ClassLoaderData* cld);
|
||||
diff --git a/src/hotspot/share/classfile/dictionary.cpp b/src/hotspot/share/classfile/dictionary.cpp
|
||||
index 2b236a7724e..bb1d09fa7a2 100644
|
||||
--- a/src/hotspot/share/classfile/dictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/dictionary.cpp
|
||||
@@ -322,7 +322,7 @@ DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
|
||||
}
|
||||
|
||||
// (DCEVM) replace old_class by new class in dictionary
|
||||
-bool Dictionary::update_klass(unsigned int hash, Symbol* name, ClassLoaderData* loader_data, InstanceKlass* k, InstanceKlass* old_klass) {
|
||||
+bool Dictionary::update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass) {
|
||||
// There are several entries for the same class in the dictionary: One extra entry for each parent classloader of the classloader of the class.
|
||||
bool found = false;
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
diff --git a/src/hotspot/share/classfile/dictionary.hpp b/src/hotspot/share/classfile/dictionary.hpp
|
||||
index e997cfdcabd..7f8d8e35fc3 100644
|
||||
--- a/src/hotspot/share/classfile/dictionary.hpp
|
||||
+++ b/src/hotspot/share/classfile/dictionary.hpp
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void verify();
|
||||
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
- bool update_klass(unsigned int hash, Symbol* name, ClassLoaderData* loader_data, InstanceKlass* k, InstanceKlass* old_klass);
|
||||
+ bool update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass);
|
||||
|
||||
void rollback_redefinition();
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
index 63de2e2f099..35e2f376870 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
@@ -1441,7 +1441,9 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, InstanceKlass* ol
|
||||
|
||||
unsigned int name_hash = dictionary->compute_hash(name_h);
|
||||
if (is_redefining) {
|
||||
- bool ok = dictionary->update_klass(name_hash, name_h, loader_data, k, old_klass);
|
||||
+ // Update all dictionaries containing old_class to new_class
|
||||
+ // outcome must be same as result of standard redefinition, that does not create a new Klass
|
||||
+ bool ok = ClassLoaderDataGraph::dictionary_classes_do_update_klass(name_h, k, old_klass);
|
||||
assert (ok, "must have found old class and updated!");
|
||||
}
|
||||
check_constraints(name_hash, k, class_loader, !is_redefining, CHECK);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
From 99c65ab84080d35c1ba1df6efd5641ad3ab9e1e8 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 20 Feb 2021 15:47:47 +0100
|
||||
Subject: [PATCH 26/45] Add ClassLoaderDataGraph_lock to define new class in
|
||||
enhanced redefiniton
|
||||
|
||||
ClassLoaderDataGraph locking for introduced in redefinition in
|
||||
java.version>11
|
||||
---
|
||||
src/hotspot/share/classfile/systemDictionary.cpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
index 35e2f376870..c628cb9da83 100644
|
||||
--- a/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
+++ b/src/hotspot/share/classfile/systemDictionary.cpp
|
||||
@@ -1443,7 +1443,9 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, InstanceKlass* ol
|
||||
if (is_redefining) {
|
||||
// Update all dictionaries containing old_class to new_class
|
||||
// outcome must be same as result of standard redefinition, that does not create a new Klass
|
||||
+ ClassLoaderDataGraph_lock->lock();
|
||||
bool ok = ClassLoaderDataGraph::dictionary_classes_do_update_klass(name_h, k, old_klass);
|
||||
+ ClassLoaderDataGraph_lock->unlock();
|
||||
assert (ok, "must have found old class and updated!");
|
||||
}
|
||||
check_constraints(name_hash, k, class_loader, !is_redefining, CHECK);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
From e7e7920986355d6fd5ad0c333ec780c93583d030 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Thu, 18 Jun 2020 18:40:11 +0200
|
||||
Subject: [PATCH 27/45] JBR-3140 - support for modularized HotswapAgent
|
||||
|
||||
Add -XX:HotswapAgent=[disabled,fatjar.core]
|
||||
---
|
||||
src/hotspot/share/runtime/arguments.cpp | 77 +++++++++++++++++++
|
||||
src/hotspot/share/runtime/arguments.hpp | 4 +
|
||||
.../flags/jvmFlagConstraintsRuntime.cpp | 9 +++
|
||||
.../flags/jvmFlagConstraintsRuntime.hpp | 3 +-
|
||||
src/hotspot/share/runtime/globals.hpp | 11 ++-
|
||||
5 files changed, 102 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
|
||||
index 252ebbc4e57..9c6fab8ae4b 100644
|
||||
--- a/src/hotspot/share/runtime/arguments.cpp
|
||||
+++ b/src/hotspot/share/runtime/arguments.cpp
|
||||
@@ -4034,6 +4034,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
|
||||
}
|
||||
}
|
||||
|
||||
+ setup_hotswap_agent();
|
||||
+
|
||||
#if !INCLUDE_CDS
|
||||
if (DumpSharedSpaces || RequireSharedSpaces) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
@@ -4390,3 +4392,78 @@ bool Arguments::copy_expand_pid(const char* src, size_t srclen,
|
||||
*b = '\0';
|
||||
return (p == src_end); // return false if not all of the source was copied
|
||||
}
|
||||
+
|
||||
+void Arguments::setup_hotswap_agent() {
|
||||
+
|
||||
+ if (DumpSharedSpaces)
|
||||
+ return;
|
||||
+
|
||||
+ if (HotswapAgent == NULL || strcmp(HotswapAgent, "disabled") == 0)
|
||||
+ return;
|
||||
+
|
||||
+ // Force AllowEnhancedClassRedefinition if HA is enabled
|
||||
+ AllowEnhancedClassRedefinition = true;
|
||||
+
|
||||
+ bool ha_fatjar = strcmp(HotswapAgent, "fatjar") == 0;
|
||||
+ bool ha_core = strcmp(HotswapAgent, "core") == 0;
|
||||
+
|
||||
+ // Set HotswapAgent
|
||||
+ if (ha_fatjar || ha_core) {
|
||||
+
|
||||
+ char ext_path_str[JVM_MAXPATHLEN];
|
||||
+
|
||||
+ os::jvm_path(ext_path_str, sizeof(ext_path_str));
|
||||
+ for (int i = 0; i < 3; i++) {
|
||||
+ char *end = strrchr(ext_path_str, *os::file_separator());
|
||||
+ if (end != NULL) *end = '\0';
|
||||
+ }
|
||||
+ size_t ext_path_length = strlen(ext_path_str);
|
||||
+ if (ext_path_length >= 3) {
|
||||
+ if (strcmp(ext_path_str + ext_path_length - 3, "lib") != 0) {
|
||||
+ if (ext_path_length < JVM_MAXPATHLEN - 4) {
|
||||
+ jio_snprintf(ext_path_str + ext_path_length, sizeof(ext_path_str) - ext_path_length, "%slib", os::file_separator());
|
||||
+ ext_path_length += 4;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (ext_path_length < JVM_MAXPATHLEN - 10) {
|
||||
+ if (ha_fatjar) {
|
||||
+ jio_snprintf(ext_path_str + ext_path_length, sizeof(ext_path_str) - ext_path_length,
|
||||
+ "%shotswap%shotswap-agent.jar", os::file_separator(), os::file_separator());
|
||||
+ } else {
|
||||
+ jio_snprintf(ext_path_str + ext_path_length, sizeof(ext_path_str) - ext_path_length,
|
||||
+ "%shotswap%shotswap-agent-core.jar", os::file_separator(), os::file_separator());
|
||||
+ }
|
||||
+ int fd = ::open(ext_path_str, O_RDONLY);
|
||||
+ if (fd >= 0) {
|
||||
+ os::close(fd);
|
||||
+ size_t length = strlen(ext_path_str) + 1;
|
||||
+ char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
|
||||
+ jio_snprintf(options, length, "%s", ext_path_str);
|
||||
+ add_init_agent("instrument", ext_path_str, false);
|
||||
+ jio_fprintf(defaultStream::output_stream(), "Starting HotswapAgent '%s'\n", ext_path_str);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ jio_fprintf(defaultStream::error_stream(), "HotswapAgent not found on path:'%s'!\n", ext_path_str);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // TODO: open it only for org.hotswap.agent module
|
||||
+ // Use to access java.lang.reflect.Proxy/proxyCache
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.base/java.lang=ALL-UNNAMED", addopens_count++);
|
||||
+ // Class of field java.lang.reflect.Proxy/proxyCache
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.base/jdk.internal.loader=ALL-UNNAMED", addopens_count++);
|
||||
+ // Use to access java.io.Reader, java.io.InputStream, java.io.FileInputStream
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.base/java.io=ALL-UNNAMED", addopens_count++);
|
||||
+ // java.beans.Introspector access
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.desktop/java.beans=ALL-UNNAMED", addopens_count++);
|
||||
+ // java.beans.Introspector access
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.desktop/com.sun.beans=ALL-UNNAMED", addopens_count++);
|
||||
+ // com.sun.beans.introspect.ClassInfo access
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.desktop/com.sun.beans.introspect=ALL-UNNAMED", addopens_count++);
|
||||
+ // com.sun.beans.introspect.util.Cache access
|
||||
+ create_numbered_module_property("jdk.module.addopens", "java.desktop/com.sun.beans.util=ALL-UNNAMED", addopens_count++);
|
||||
+
|
||||
+}
|
||||
diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp
|
||||
index b8eb4d0ab24..a14e11b48ef 100644
|
||||
--- a/src/hotspot/share/runtime/arguments.hpp
|
||||
+++ b/src/hotspot/share/runtime/arguments.hpp
|
||||
@@ -496,6 +496,10 @@ class Arguments : AllStatic {
|
||||
|
||||
static size_t conservative_max_heap_alignment() { return _conservative_max_heap_alignment; }
|
||||
|
||||
+
|
||||
+ // Initialize HotswapAgent
|
||||
+ static void setup_hotswap_agent();
|
||||
+
|
||||
// Return the maximum size a heap with compressed oops can take
|
||||
static size_t max_heap_for_compressed_oops();
|
||||
|
||||
diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp
|
||||
index 5b09758e089..e55b68e63a6 100644
|
||||
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp
|
||||
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp
|
||||
@@ -158,6 +158,15 @@ JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbos
|
||||
" ... " UINTX_FORMAT " ]\n", value, min, max);
|
||||
return JVMFlag::VIOLATES_CONSTRAINT;
|
||||
}
|
||||
+ return JVMFlag::SUCCESS;
|
||||
+}
|
||||
|
||||
+JVMFlag::Error HotswapAgentConstraintFunc(ccstr value, bool verbose) {
|
||||
+ if (value != NULL) {
|
||||
+ if (strcmp("disabled", value) != 0 && strcmp("fatjar", value) != 0 && strcmp("core", value) != 0 && strcmp("external", value) != 0) {
|
||||
+ JVMFlag::printError(verbose, "HotswapAgent(%s) must be one of disabled,fatjar,core or external.\n", value);
|
||||
+ return JVMFlag::VIOLATES_CONSTRAINT;
|
||||
+ }
|
||||
+ }
|
||||
return JVMFlag::SUCCESS;
|
||||
}
|
||||
diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp
|
||||
index 8bc3a9a1548..c5f58fd16ee 100644
|
||||
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp
|
||||
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp
|
||||
@@ -42,7 +42,8 @@
|
||||
f(intx, BiasedLockingDecayTimeFunc) \
|
||||
f(intx, PerfDataSamplingIntervalFunc) \
|
||||
f(uintx, VMPageSizeConstraintFunc) \
|
||||
- f(size_t, NUMAInterleaveGranularityConstraintFunc)
|
||||
+ f(size_t, NUMAInterleaveGranularityConstraintFunc) \
|
||||
+ f(ccstr, HotswapAgentConstraintFunc)
|
||||
|
||||
RUNTIME_CONSTRAINTS(DECLARE_CONSTRAINT)
|
||||
|
||||
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
|
||||
index fb6d1667156..20838a878ce 100644
|
||||
--- a/src/hotspot/share/runtime/globals.hpp
|
||||
+++ b/src/hotspot/share/runtime/globals.hpp
|
||||
@@ -2090,7 +2090,16 @@ const intx ObjectAlignmentInBytes = 8;
|
||||
\
|
||||
product(bool, AllowEnhancedClassRedefinition, false, \
|
||||
"Allow enhanced class redefinition beyond swapping method " \
|
||||
- "bodies")
|
||||
+ "bodies") \
|
||||
+ \
|
||||
+ product(ccstr, HotswapAgent, "disabled", \
|
||||
+ "Specify HotswapAgent image to be used." \
|
||||
+ "disabled: hotswap agent is disabled (default)" \
|
||||
+ "fatjar: full HA. Use integrated hotswap-agent.jar" \
|
||||
+ "core: core HA. Use integrated hotswap-agent-core.jar" \
|
||||
+ "external: external HA. use external HA, open required JDK " \
|
||||
+ "modules.") \
|
||||
+ constraint(HotswapAgentConstraintFunc, AfterErgo)
|
||||
|
||||
|
||||
// end of RUNTIME_FLAGS
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
From 854df9651b358f3a8d89cd8a7d60fed26ca3d1d5 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 7 Mar 2021 20:22:54 +0100
|
||||
Subject: [PATCH 28/45] Support for redefinition of Well Known classses
|
||||
(java.*,jdk.*, sun.*)
|
||||
|
||||
---
|
||||
src/hotspot/share/ci/ciKlass.hpp | 1 +
|
||||
src/hotspot/share/ci/ciObjectFactory.cpp | 34 ++++++++++
|
||||
src/hotspot/share/ci/ciObjectFactory.hpp | 6 ++
|
||||
src/hotspot/share/classfile/vmClasses.cpp | 10 +++
|
||||
src/hotspot/share/classfile/vmClasses.hpp | 4 ++
|
||||
src/hotspot/share/classfile/vmSymbols.hpp | 2 +
|
||||
src/hotspot/share/compiler/compileBroker.cpp | 11 ++++
|
||||
src/hotspot/share/memory/universe.cpp | 8 +++
|
||||
src/hotspot/share/memory/universe.hpp | 2 +
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 63 ++++++++++++++++++-
|
||||
.../prims/jvmtiEnhancedRedefineClasses.hpp | 2 +
|
||||
11 files changed, 142 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/ci/ciKlass.hpp b/src/hotspot/share/ci/ciKlass.hpp
|
||||
index 467284b7cde..644993a7513 100644
|
||||
--- a/src/hotspot/share/ci/ciKlass.hpp
|
||||
+++ b/src/hotspot/share/ci/ciKlass.hpp
|
||||
@@ -129,6 +129,7 @@ public:
|
||||
void print_name_on(outputStream* st);
|
||||
|
||||
const char* external_name() const;
|
||||
+ Klass* new_version() { return get_Klass()->new_version(); }
|
||||
};
|
||||
|
||||
#endif // SHARE_CI_CIKLASS_HPP
|
||||
diff --git a/src/hotspot/share/ci/ciObjectFactory.cpp b/src/hotspot/share/ci/ciObjectFactory.cpp
|
||||
index 664062a0f74..e9cb49be3ff 100644
|
||||
--- a/src/hotspot/share/ci/ciObjectFactory.cpp
|
||||
+++ b/src/hotspot/share/ci/ciObjectFactory.cpp
|
||||
@@ -74,7 +74,10 @@ GrowableArray<ciMetadata*>* ciObjectFactory::_shared_ci_metadata = NULL;
|
||||
ciSymbol* ciObjectFactory::_shared_ci_symbols[vmSymbols::number_of_symbols()];
|
||||
int ciObjectFactory::_shared_ident_limit = 0;
|
||||
volatile bool ciObjectFactory::_initialized = false;
|
||||
+volatile bool ciObjectFactory::_reinitialize_vm_klasses = false;
|
||||
|
||||
+// TODO: review...
|
||||
+Arena* ciObjectFactory::_initial_arena = NULL;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciObjectFactory::ciObjectFactory
|
||||
@@ -110,6 +113,7 @@ void ciObjectFactory::initialize() {
|
||||
// compiler thread that initializes the initial ciObjectFactory which
|
||||
// creates the shared ciObjects that all later ciObjectFactories use.
|
||||
Arena* arena = new (mtCompiler) Arena(mtCompiler);
|
||||
+ ciObjectFactory::_initial_arena = arena;
|
||||
ciEnv initial(arena);
|
||||
ciEnv* env = ciEnv::current();
|
||||
env->_factory->init_shared_objects();
|
||||
@@ -118,6 +122,36 @@ void ciObjectFactory::initialize() {
|
||||
|
||||
}
|
||||
|
||||
+// (DCEVM) vm classes could be modified
|
||||
+void ciObjectFactory::reinitialize_vm_classes() {
|
||||
+ ASSERT_IN_VM;
|
||||
+ JavaThread* thread = JavaThread::current();
|
||||
+ HandleMark handle_mark(thread);
|
||||
+
|
||||
+ // This Arena is long lived and exists in the resource mark of the
|
||||
+ // compiler thread that initializes the initial ciObjectFactory which
|
||||
+ // creates the shared ciObjects that all later ciObjectFactories use.
|
||||
+ // Arena* arena = new (mtCompiler) Arena(mtCompiler);
|
||||
+ ciEnv initial(ciObjectFactory::_initial_arena);
|
||||
+ ciEnv* env = ciEnv::current();
|
||||
+ env->_factory->do_reinitialize_vm_classes();
|
||||
+ _reinitialize_vm_klasses = false;
|
||||
+}
|
||||
+
|
||||
+// (DCEVM) vm classes could be modified
|
||||
+void ciObjectFactory::do_reinitialize_vm_classes() {
|
||||
+#define VM_CLASS_DEFN(name, ignore_s) \
|
||||
+ if (ciEnv::_##name != NULL && ciEnv::_##name->new_version() != NULL) { \
|
||||
+ int old_ident = ciEnv::_##name->ident(); \
|
||||
+ ciEnv::_##name = get_metadata(vmClasses::name())->as_instance_klass(); \
|
||||
+ ciEnv::_##name->compute_nonstatic_fields(); \
|
||||
+ ciEnv::_##name->set_ident(old_ident); \
|
||||
+ }
|
||||
+
|
||||
+ VM_CLASSES_DO(VM_CLASS_DEFN)
|
||||
+#undef VM_CLASS_DEFN
|
||||
+}
|
||||
+
|
||||
void ciObjectFactory::init_shared_objects() {
|
||||
|
||||
_next_ident = 1; // start numbering CI objects at 1
|
||||
diff --git a/src/hotspot/share/ci/ciObjectFactory.hpp b/src/hotspot/share/ci/ciObjectFactory.hpp
|
||||
index fdefc8e3b92..1ed8732cb40 100644
|
||||
--- a/src/hotspot/share/ci/ciObjectFactory.hpp
|
||||
+++ b/src/hotspot/share/ci/ciObjectFactory.hpp
|
||||
@@ -42,9 +42,11 @@ class ciObjectFactory : public ResourceObj {
|
||||
|
||||
private:
|
||||
static volatile bool _initialized;
|
||||
+ static volatile bool _reinitialize_vm_klasses;
|
||||
static GrowableArray<ciMetadata*>* _shared_ci_metadata;
|
||||
static ciSymbol* _shared_ci_symbols[];
|
||||
static int _shared_ident_limit;
|
||||
+ static Arena* _initial_arena;
|
||||
|
||||
Arena* _arena;
|
||||
GrowableArray<ciMetadata*> _ci_metadata;
|
||||
@@ -90,10 +92,14 @@ private:
|
||||
ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
|
||||
|
||||
static int compare_cimetadata(ciMetadata** a, ciMetadata** b);
|
||||
+ void do_reinitialize_vm_classes();
|
||||
public:
|
||||
static bool is_initialized() { return _initialized; }
|
||||
+ static bool is_reinitialize_vm_klasses() { return _reinitialize_vm_klasses; }
|
||||
+ static void set_reinitialize_vm_klasses() { _reinitialize_vm_klasses = true; }
|
||||
|
||||
static void initialize();
|
||||
+ static void reinitialize_vm_classes();
|
||||
void init_shared_objects();
|
||||
void remove_symbols();
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp
|
||||
index 2bd1ca65cc0..3ec13d952d8 100644
|
||||
--- a/src/hotspot/share/classfile/vmClasses.cpp
|
||||
+++ b/src/hotspot/share/classfile/vmClasses.cpp
|
||||
@@ -259,3 +259,13 @@ BasicType vmClasses::box_klass_type(Klass* k) {
|
||||
}
|
||||
return T_OBJECT;
|
||||
}
|
||||
+
|
||||
+bool vmClasses::update_vm_klass(InstanceKlass* old_klass, InstanceKlass* new_klass) {
|
||||
+ for (int id = static_cast<int>(vmClassID::FIRST); id < static_cast<int>(vmClassID::LIMIT); id++) {
|
||||
+ if (_klasses[id] == old_klass) {
|
||||
+ _klasses[id] = new_klass;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
diff --git a/src/hotspot/share/classfile/vmClasses.hpp b/src/hotspot/share/classfile/vmClasses.hpp
|
||||
index 364014a2514..b637ff0ae3d 100644
|
||||
--- a/src/hotspot/share/classfile/vmClasses.hpp
|
||||
+++ b/src/hotspot/share/classfile/vmClasses.hpp
|
||||
@@ -110,6 +110,10 @@ public:
|
||||
static bool Cloneable_klass_loaded() { return is_loaded(VM_CLASS_AT(Cloneable_klass)); }
|
||||
static bool Parameter_klass_loaded() { return is_loaded(VM_CLASS_AT(reflect_Parameter_klass)); }
|
||||
static bool ClassLoader_klass_loaded() { return is_loaded(VM_CLASS_AT(ClassLoader_klass)); }
|
||||
+
|
||||
+ // (DCEVM) vmClasses could be modified
|
||||
+ static bool update_vm_klass(InstanceKlass* new_klass, InstanceKlass* old_klass);
|
||||
+
|
||||
};
|
||||
|
||||
#endif // SHARE_CLASSFILE_VMCLASSES_HPP
|
||||
diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp
|
||||
index dad94005f5c..82fd593224a 100644
|
||||
--- a/src/hotspot/share/classfile/vmSymbols.hpp
|
||||
+++ b/src/hotspot/share/classfile/vmSymbols.hpp
|
||||
@@ -380,6 +380,8 @@
|
||||
template(exit_method_name, "exit") \
|
||||
template(add_method_name, "add") \
|
||||
template(remove_method_name, "remove") \
|
||||
+ template(registerNatives_method_name, "registerNatives") \
|
||||
+ template(initIDs_method_name, "initIDs") \
|
||||
template(parent_name, "parent") \
|
||||
template(threads_name, "threads") \
|
||||
template(groups_name, "groups") \
|
||||
diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
index cc1dff089e8..aaf8e4b1f1e 100644
|
||||
--- a/src/hotspot/share/compiler/compileBroker.cpp
|
||||
+++ b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
@@ -1982,6 +1982,17 @@ void CompileBroker::compiler_thread_loop() {
|
||||
if (method()->number_of_breakpoints() == 0) {
|
||||
// Compile the method.
|
||||
if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
|
||||
+
|
||||
+ // TODO: review usage of CompileThread_lock (DCEVM)
|
||||
+ if (ciObjectFactory::is_reinitialize_vm_klasses())
|
||||
+ {
|
||||
+ ASSERT_IN_VM;
|
||||
+ MutexLocker only_one(CompileThread_lock);
|
||||
+ if (ciObjectFactory::is_reinitialize_vm_klasses()) {
|
||||
+ ciObjectFactory::reinitialize_vm_classes();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
invoke_compiler_on_method(task);
|
||||
thread->start_idle_timer();
|
||||
} else {
|
||||
diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp
|
||||
index 4ae3b382b67..92da9bbe5f9 100644
|
||||
--- a/src/hotspot/share/memory/universe.cpp
|
||||
+++ b/src/hotspot/share/memory/universe.cpp
|
||||
@@ -924,6 +924,14 @@ void Universe::initialize_known_methods(TRAPS) {
|
||||
vmSymbols::doStackWalk_signature(), false, CHECK);
|
||||
}
|
||||
|
||||
+void Universe::reinitialize_loader_addClass_method(TRAPS) {
|
||||
+ // Set up method for registering loaded classes in class loader vector
|
||||
+ initialize_known_method(_loader_addClass_cache,
|
||||
+ vmClasses::ClassLoader_klass(),
|
||||
+ "addClass",
|
||||
+ vmSymbols::class_void_signature(), false, CHECK);
|
||||
+}
|
||||
+
|
||||
void universe2_init() {
|
||||
EXCEPTION_MARK;
|
||||
Universe::genesis(CATCH);
|
||||
diff --git a/src/hotspot/share/memory/universe.hpp b/src/hotspot/share/memory/universe.hpp
|
||||
index 4b2211c415e..4d4c444220e 100644
|
||||
--- a/src/hotspot/share/memory/universe.hpp
|
||||
+++ b/src/hotspot/share/memory/universe.hpp
|
||||
@@ -268,6 +268,8 @@ class Universe: AllStatic {
|
||||
// Function to initialize these
|
||||
static void initialize_known_methods(TRAPS);
|
||||
|
||||
+ static void reinitialize_loader_addClass_method(TRAPS);
|
||||
+
|
||||
static void create_preallocated_out_of_memory_errors(TRAPS);
|
||||
|
||||
// Reference pending list manipulation. Access is protected by
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index b88c071be13..fb9da134e97 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "prims/resolvedMethodTable.hpp"
|
||||
#include "prims/methodHandles.hpp"
|
||||
#include "runtime/deoptimization.hpp"
|
||||
+#include "runtime/javaCalls.hpp"
|
||||
#include "runtime/jniHandles.inline.hpp"
|
||||
#include "runtime/relocator.hpp"
|
||||
#include "runtime/fieldDescriptor.hpp"
|
||||
@@ -66,6 +67,7 @@
|
||||
#include "gc/g1/g1CollectedHeap.hpp"
|
||||
#include "gc/shared/dcevmSharedGC.hpp"
|
||||
#include "gc/shared/scavengableNMethods.hpp"
|
||||
+#include "gc/shared/oopStorageSet.inline.hpp"
|
||||
#include "ci/ciObjectFactory.hpp"
|
||||
|
||||
Array<Method*>* VM_EnhancedRedefineClasses::_old_methods = NULL;
|
||||
@@ -521,6 +523,16 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
redefine_single_class(_new_classes->at(i), thread);
|
||||
}
|
||||
|
||||
+ // Update possible redefinition of vm classes (like ClassLoader)
|
||||
+ for (int i = 0; i < _new_classes->length(); i++) {
|
||||
+ InstanceKlass* cur = _new_classes->at(i);
|
||||
+ if (cur->old_version() != NULL && vmClasses::update_vm_klass(InstanceKlass::cast(cur->old_version()), cur))
|
||||
+ {
|
||||
+ log_trace(redefine, class, obsolete, metadata)("Well known class updated %s", cur->external_name());
|
||||
+ ciObjectFactory::set_reinitialize_vm_klasses();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// Deoptimize all compiled code that depends on this class (do only once, because it clears whole cache)
|
||||
// if (_max_redefinition_flags > Klass::ModifyClass) {
|
||||
flush_dependent_code(thread);
|
||||
@@ -688,12 +700,56 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
_timer_vm_op_doit.stop();
|
||||
}
|
||||
|
||||
+void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
+ if (!_new_classes->is_empty()) {
|
||||
+ ResourceMark rm(Thread::current());
|
||||
+
|
||||
+ for (int i = 0; i < _new_classes->length(); i++) {
|
||||
+ InstanceKlass* cur = _new_classes->at(i);
|
||||
+
|
||||
+ if (cur->name()->starts_with("java/") || cur->name()->starts_with("jdk/") || cur->name()->starts_with("sun/")) {
|
||||
+
|
||||
+ if (cur == vmClasses::ClassLoader_klass()) {
|
||||
+ // ClassLoader.addClass method is cached in Universe, we must redefine
|
||||
+ Universe::reinitialize_loader_addClass_method(Thread::current());
|
||||
+ log_trace(redefine, class, obsolete, metadata)("Reinitialize ClassLoade addClass method cache.");
|
||||
+ }
|
||||
+
|
||||
+ // naive assumptions that only JDK classes has native static "registerNative" and "initIDs" methods
|
||||
+ int end;
|
||||
+ Symbol* signature = vmSymbols::registerNatives_method_name();
|
||||
+ int midx = cur->find_method_by_name(signature, &end);
|
||||
+ if (midx == -1) {
|
||||
+ signature = vmSymbols::initIDs_method_name();
|
||||
+ midx = cur->find_method_by_name(signature, &end);
|
||||
+ }
|
||||
+ Method* m = NULL;
|
||||
+ if (midx != -1) {
|
||||
+ m = cur->methods()->at(midx);
|
||||
+ }
|
||||
+ if (m != NULL && m->is_static() && m->is_native()) {
|
||||
+ // call static registerNative if present
|
||||
+ JavaValue result(T_VOID);
|
||||
+ JavaCalls::call_static(&result,
|
||||
+ cur,
|
||||
+ signature,
|
||||
+ vmSymbols::void_method_signature(),
|
||||
+ Thread::current());
|
||||
+ log_trace(redefine, class, obsolete, metadata)("Reregister natives of JDK class %s", cur->external_name());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
// Cleanup - runs in JVM thread
|
||||
// - free used memory
|
||||
// - end GC
|
||||
void VM_EnhancedRedefineClasses::doit_epilogue() {
|
||||
VM_GC_Operation::doit_epilogue();
|
||||
|
||||
+ reinitializeJDKClasses();
|
||||
+
|
||||
if (_new_classes != NULL) {
|
||||
delete _new_classes;
|
||||
}
|
||||
@@ -1623,7 +1679,12 @@ void VM_EnhancedRedefineClasses::check_methods_and_mark_as_obsolete() {
|
||||
|
||||
// obsolete methods need a unique idnum so they become new entries in
|
||||
// the jmethodID cache in InstanceKlass
|
||||
- assert(old_method->method_idnum() == new_method->method_idnum(), "must match");
|
||||
+ if (old_method->method_idnum() != new_method->method_idnum()) {
|
||||
+ log_error(redefine, class, normalize)
|
||||
+ ("Method not matched: %d != %d old: %s = new: %s", old_method->method_idnum(), new_method->method_idnum(),
|
||||
+ old_method->name_and_sig_as_C_string(), new_method->name_and_sig_as_C_string());
|
||||
+ // assert(old_method->method_idnum() == new_method->method_idnum(), "must match");
|
||||
+ }
|
||||
// u2 num = InstanceKlass::cast(_the_class_oop)->next_method_idnum();
|
||||
// if (num != ConstMethod::UNSET_IDNUM) {
|
||||
// old_method->set_method_idnum(num);
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
index ae0a15281f3..d0d2f78aa62 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
@@ -150,6 +150,8 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
|
||||
u8 next_id();
|
||||
|
||||
+ void reinitializeJDKClasses();
|
||||
+
|
||||
static void check_class(InstanceKlass* k_oop, TRAPS);
|
||||
|
||||
static void dump_methods();
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
From 01f4cb9929cad1512d02e20cc7538a29ff0d3ef1 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 15 May 2021 10:31:28 +0200
|
||||
Subject: [PATCH 29/45] Fix fastdebug compilation issues - cast_to_oop
|
||||
|
||||
---
|
||||
.../share/gc/g1/g1FullGCCompactTask.cpp | 12 +++++-----
|
||||
.../share/gc/g1/g1FullGCCompactionPoint.cpp | 10 ++++-----
|
||||
.../share/gc/g1/g1FullGCPrepareTask.cpp | 4 ++--
|
||||
src/hotspot/share/gc/shared/dcevmSharedGC.cpp | 6 ++---
|
||||
src/hotspot/share/gc/shared/space.cpp | 22 +++++++++----------
|
||||
src/hotspot/share/gc/shared/space.inline.hpp | 14 ++++++------
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 2 +-
|
||||
7 files changed, 35 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
index 058dea90828..765630a9826 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
@@ -183,18 +183,18 @@ size_t G1FullGCCompactTask::G1CompactRegionClosureDcevm::apply(oop obj) {
|
||||
Klass* new_version = obj->klass()->new_version();
|
||||
if (new_version->update_information() == NULL) {
|
||||
Copy::aligned_conjoint_words(obj_addr, destination, size);
|
||||
- oop(destination)->set_klass(new_version);
|
||||
+ cast_to_oop(destination)->set_klass(new_version);
|
||||
} else {
|
||||
- DcevmSharedGC::update_fields(obj, oop(destination));
|
||||
+ DcevmSharedGC::update_fields(obj, cast_to_oop(destination));
|
||||
}
|
||||
- oop(destination)->init_mark();
|
||||
- assert(oop(destination)->klass() != NULL, "should have a class");
|
||||
+ cast_to_oop(destination)->init_mark();
|
||||
+ assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
|
||||
return size;
|
||||
}
|
||||
|
||||
Copy::aligned_conjoint_words(obj_addr, destination, size);
|
||||
- oop(destination)->init_mark();
|
||||
- assert(oop(destination)->klass() != NULL, "should have a class");
|
||||
+ cast_to_oop(destination)->init_mark();
|
||||
+ assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
|
||||
|
||||
return size;
|
||||
}
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
index 87b1977128a..028c182e68f 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp
|
||||
@@ -171,7 +171,7 @@ void G1FullGCCompactionPoint::forward_dcevm(oop object, size_t size, bool force_
|
||||
|
||||
// Store a forwarding pointer if the object should be moved.
|
||||
if (cast_from_oop<HeapWord*>(object) != _compaction_top || force_forward) {
|
||||
- object->forward_to(oop(_compaction_top));
|
||||
+ object->forward_to(cast_to_oop(_compaction_top));
|
||||
} else {
|
||||
if (object->forwardee() != NULL) {
|
||||
// Object should not move but mark-word is used so it looks like the
|
||||
@@ -208,17 +208,17 @@ void G1FullGCCompactionPoint::forward_rescued() {
|
||||
for (;i<rescued_oops()->length(); i++) {
|
||||
HeapWord* q = rescued_oops()->at(i);
|
||||
|
||||
- size_t size = oop(q)->size();
|
||||
+ size_t size = cast_to_oop(q)->size();
|
||||
|
||||
// (DCEVM) There is a new version of the class of q => different size
|
||||
- if (oop(q)->klass()->new_version() != NULL) {
|
||||
+ if (cast_to_oop(q)->klass()->new_version() != NULL) {
|
||||
// assert(size != new_size, "instances without changed size have to be updated prior to GC run");
|
||||
- size = oop(q)->size_given_klass(oop(q)->klass()->new_version());
|
||||
+ size = cast_to_oop(q)->size_given_klass(cast_to_oop(q)->klass()->new_version());
|
||||
}
|
||||
if (forward_compact_top(size) == NULL) {
|
||||
break;
|
||||
}
|
||||
- forward_dcevm(oop(q), size, true);
|
||||
+ forward_dcevm(cast_to_oop(q), size, true);
|
||||
}
|
||||
_last_rescued_oop = i;
|
||||
}
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
index 05f0444cc7a..93c066383a1 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
@@ -297,7 +297,7 @@ size_t G1FullGCPrepareTask::G1PrepareCompactLiveClosureDcevm::apply(oop object)
|
||||
|
||||
HeapWord* compact_top = _cp->forward_compact_top(forward_size);
|
||||
|
||||
- if (compact_top == NULL || must_rescue(object, oop(compact_top))) {
|
||||
+ if (compact_top == NULL || must_rescue(object, cast_to_oop(compact_top))) {
|
||||
_cp->rescued_oops()->append(cast_from_oop<HeapWord*>(object));
|
||||
} else {
|
||||
_cp->forward_dcevm(object, forward_size, (size != forward_size));
|
||||
@@ -308,7 +308,7 @@ size_t G1FullGCPrepareTask::G1PrepareCompactLiveClosureDcevm::apply(oop object)
|
||||
|
||||
bool G1FullGCPrepareTask::G1PrepareCompactLiveClosureDcevm::must_rescue(oop old_obj, oop new_obj) {
|
||||
// Only redefined objects can have the need to be rescued.
|
||||
- if (oop(old_obj)->klass()->new_version() == NULL) {
|
||||
+ if (old_obj->klass()->new_version() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/src/hotspot/share/gc/shared/dcevmSharedGC.cpp b/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
index edc19a3077d..de3d518b696 100644
|
||||
--- a/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
+++ b/src/hotspot/share/gc/shared/dcevmSharedGC.cpp
|
||||
@@ -46,7 +46,7 @@ void DcevmSharedGC::copy_rescued_objects_back(GrowableArray<HeapWord*>* rescued_
|
||||
if (rescued_oops != NULL) {
|
||||
for (int i=from; i < to; i++) {
|
||||
HeapWord* rescued_ptr = rescued_oops->at(i);
|
||||
- oop rescued_obj = (oop) rescued_ptr;
|
||||
+ oop rescued_obj = cast_to_oop(rescued_ptr);
|
||||
|
||||
int size = rescued_obj->size();
|
||||
oop new_obj = rescued_obj->forwardee();
|
||||
@@ -75,7 +75,7 @@ void DcevmSharedGC::clear_rescued_objects_resource(GrowableArray<HeapWord*>* res
|
||||
if (rescued_oops != NULL) {
|
||||
for (int i=0; i < rescued_oops->length(); i++) {
|
||||
HeapWord* rescued_ptr = rescued_oops->at(i);
|
||||
- int size = ((oop) rescued_ptr)->size();
|
||||
+ int size = cast_to_oop(rescued_ptr)->size();
|
||||
FREE_RESOURCE_ARRAY(HeapWord, rescued_ptr, size);
|
||||
}
|
||||
rescued_oops->clear();
|
||||
@@ -114,7 +114,7 @@ void DcevmSharedGC::update_fields(oop q, oop new_location) {
|
||||
if ((cast_from_oop<HeapWord*>(q) >= cast_from_oop<HeapWord*>(new_location) && cast_from_oop<HeapWord*>(q) < cast_from_oop<HeapWord*>(new_location) + new_size) ||
|
||||
(cast_from_oop<HeapWord*>(new_location) >= cast_from_oop<HeapWord*>(q) && cast_from_oop<HeapWord*>(new_location) < cast_from_oop<HeapWord*>(q) + size)) {
|
||||
tmp = NEW_RESOURCE_ARRAY(HeapWord, size);
|
||||
- q = (oop) tmp;
|
||||
+ q = cast_to_oop(tmp);
|
||||
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(tmp_obj), cast_from_oop<HeapWord*>(q), size);
|
||||
}
|
||||
}
|
||||
diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp
|
||||
index 29a81348d2d..000760744f7 100644
|
||||
--- a/src/hotspot/share/gc/shared/space.cpp
|
||||
+++ b/src/hotspot/share/gc/shared/space.cpp
|
||||
@@ -475,7 +475,7 @@ bool CompactibleSpace::must_rescue(oop old_obj, oop new_obj) {
|
||||
|
||||
int new_size = old_obj->size_given_klass(oop(old_obj)->klass()->new_version());
|
||||
int original_size = old_obj->size();
|
||||
-
|
||||
+
|
||||
Generation* tenured_gen = GenCollectedHeap::heap()->old_gen();
|
||||
bool old_in_tenured = tenured_gen->is_in_reserved(old_obj);
|
||||
bool new_in_tenured = tenured_gen->is_in_reserved(new_obj);
|
||||
@@ -513,9 +513,9 @@ bool CompactibleSpace::must_rescue(oop old_obj, oop new_obj) {
|
||||
}
|
||||
|
||||
HeapWord* CompactibleSpace::rescue(HeapWord* old_obj) {
|
||||
- assert(must_rescue(oop(old_obj), oop(old_obj)->forwardee()), "do not call otherwise");
|
||||
+ assert(must_rescue(cast_to_oop(old_obj), cast_to_oop(old_obj)->forwardee()), "do not call otherwise");
|
||||
|
||||
- int size = oop(old_obj)->size();
|
||||
+ int size = cast_to_oop(old_obj)->size();
|
||||
HeapWord* rescued_obj = NEW_RESOURCE_ARRAY(HeapWord, size);
|
||||
Copy::aligned_disjoint_words(old_obj, rescued_obj, size);
|
||||
|
||||
@@ -803,16 +803,16 @@ HeapWord* CompactibleSpace::forward_with_rescue(HeapWord* q, size_t size,
|
||||
size_t forward_size = size;
|
||||
|
||||
// (DCEVM) There is a new version of the class of q => different size
|
||||
- if (oop(q)->klass()->new_version() != NULL) {
|
||||
+ if (cast_to_oop(q)->klass()->new_version() != NULL) {
|
||||
|
||||
- size_t new_size = oop(q)->size_given_klass(oop(q)->klass()->new_version());
|
||||
+ size_t new_size = cast_to_oop(q)->size_given_klass(cast_to_oop(q)->klass()->new_version());
|
||||
// assert(size != new_size, "instances without changed size have to be updated prior to GC run");
|
||||
forward_size = new_size;
|
||||
}
|
||||
|
||||
compact_top = forward_compact_top(forward_size, cp, compact_top);
|
||||
|
||||
- if (must_rescue(oop(q), oop(compact_top))) {
|
||||
+ if (must_rescue(cast_to_oop(q), cast_to_oop(compact_top))) {
|
||||
if (MarkSweep::_rescued_oops == NULL) {
|
||||
MarkSweep::_rescued_oops = new GrowableArray<HeapWord*>(128);
|
||||
}
|
||||
@@ -820,7 +820,7 @@ HeapWord* CompactibleSpace::forward_with_rescue(HeapWord* q, size_t size,
|
||||
return compact_top;
|
||||
}
|
||||
|
||||
- return forward(oop(q), forward_size, cp, compact_top, force_forward);
|
||||
+ return forward(cast_to_oop(q), forward_size, cp, compact_top, force_forward);
|
||||
}
|
||||
|
||||
// Compute the forwarding addresses for the objects that need to be rescued.
|
||||
@@ -830,17 +830,17 @@ HeapWord* CompactibleSpace::forward_rescued(CompactPoint* cp, HeapWord* compact_
|
||||
for (int i=0; i<MarkSweep::_rescued_oops->length(); i++) {
|
||||
HeapWord* q = MarkSweep::_rescued_oops->at(i);
|
||||
|
||||
- /* size_t size = oop(q)->size(); changing this for cms for perm gen */
|
||||
+ /* size_t size = cast_to_oop(q)->size(); changing this for cms for perm gen */
|
||||
size_t size = block_size(q);
|
||||
|
||||
// (DCEVM) There is a new version of the class of q => different size
|
||||
- if (oop(q)->klass()->new_version() != NULL) {
|
||||
- size_t new_size = oop(q)->size_given_klass(oop(q)->klass()->new_version());
|
||||
+ if (cast_to_oop(q)->klass()->new_version() != NULL) {
|
||||
+ size_t new_size = cast_to_oop(q)->size_given_klass(cast_to_oop(q)->klass()->new_version());
|
||||
// assert(size != new_size, "instances without changed size have to be updated prior to GC run");
|
||||
size = new_size;
|
||||
}
|
||||
|
||||
- compact_top = cp->space->forward(oop(q), size, cp, compact_top, true);
|
||||
+ compact_top = cp->space->forward(cast_to_oop(q), size, cp, compact_top, true);
|
||||
assert(compact_top <= end(), "must not write over end of space!");
|
||||
}
|
||||
MarkSweep::_rescued_oops->clear();
|
||||
diff --git a/src/hotspot/share/gc/shared/space.inline.hpp b/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
index cafa2503ef4..076ce6b0cce 100644
|
||||
--- a/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
+++ b/src/hotspot/share/gc/shared/space.inline.hpp
|
||||
@@ -351,7 +351,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space, bool redefiniti
|
||||
size_t size = space->obj_size(cur_obj);
|
||||
HeapWord* compaction_top = cast_from_oop<HeapWord*>(cast_to_oop(cur_obj)->forwardee());
|
||||
|
||||
- if (redefinition_run && space->must_rescue(oop(cur_obj), oop(cur_obj)->forwardee())) {
|
||||
+ if (redefinition_run && space->must_rescue(cast_to_oop(cur_obj), cast_to_oop(cur_obj)->forwardee())) {
|
||||
space->rescue(cur_obj);
|
||||
debug_only(Copy::fill_to_words(cur_obj, size, 0));
|
||||
cur_obj += size;
|
||||
@@ -363,16 +363,16 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space, bool redefiniti
|
||||
|
||||
// copy object and reinit its mark
|
||||
assert(redefinition_run || cur_obj != compaction_top, "everything in this pass should be moving");
|
||||
- if (redefinition_run && oop(cur_obj)->klass()->new_version() != NULL) {
|
||||
- Klass* new_version = oop(cur_obj)->klass()->new_version();
|
||||
+ if (redefinition_run && cast_to_oop(cur_obj)->klass()->new_version() != NULL) {
|
||||
+ Klass* new_version = cast_to_oop(cur_obj)->klass()->new_version();
|
||||
if (new_version->update_information() == NULL) {
|
||||
Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
|
||||
- oop(compaction_top)->set_klass(new_version);
|
||||
+ cast_to_oop(compaction_top)->set_klass(new_version);
|
||||
} else {
|
||||
- DcevmSharedGC::update_fields(oop(cur_obj), oop(compaction_top));
|
||||
+ DcevmSharedGC::update_fields(cast_to_oop(cur_obj), cast_to_oop(compaction_top));
|
||||
}
|
||||
- oop(compaction_top)->init_mark();
|
||||
- assert(oop(compaction_top)->klass() != NULL, "should have a class");
|
||||
+ cast_to_oop(compaction_top)->init_mark();
|
||||
+ assert(cast_to_oop(compaction_top)->klass() != NULL, "should have a class");
|
||||
|
||||
debug_only(prev_obj = cur_obj);
|
||||
cur_obj += size;
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index fb9da134e97..890382e2029 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -439,7 +439,7 @@ public:
|
||||
int size = o->size();
|
||||
if (_tmp_obj_size < size) {
|
||||
_tmp_obj_size = size;
|
||||
- _tmp_obj = (oop)resource_allocate_bytes(size * HeapWordSize);
|
||||
+ _tmp_obj = cast_to_oop(resource_allocate_bytes(size * HeapWordSize));
|
||||
}
|
||||
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(o), cast_from_oop<HeapWord*>(_tmp_obj), size);
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From cac2eac1986ae05e264b2213d0d2658e2f57f07f Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <lada.dvorak7@gmail.com>
|
||||
Date: Fri, 19 Mar 2021 19:13:38 +0100
|
||||
Subject: [PATCH 30/45] JBR-3458: Skip dynamic proxy classes based on
|
||||
com.sun.proxy
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 890382e2029..90dfc1ae545 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -707,7 +707,8 @@ void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
for (int i = 0; i < _new_classes->length(); i++) {
|
||||
InstanceKlass* cur = _new_classes->at(i);
|
||||
|
||||
- if (cur->name()->starts_with("java/") || cur->name()->starts_with("jdk/") || cur->name()->starts_with("sun/")) {
|
||||
+ if ((cur->name()->starts_with("java/") || cur->name()->starts_with("jdk/") || cur->name()->starts_with("sun/"))
|
||||
+ && cur->name()->index_of_at(0, "$$") == -1) { // skip dynamic proxies
|
||||
|
||||
if (cur == vmClasses::ClassLoader_klass()) {
|
||||
// ClassLoader.addClass method is cached in Universe, we must redefine
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
From 4c87af809d20a12553f155110592a9f230ec0ea5 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <lada.dvorak7@gmail.com>
|
||||
Date: Sat, 20 Mar 2021 20:51:08 +0100
|
||||
Subject: [PATCH 31/45] JBR-3459: Fix race condition in
|
||||
ClassLoaderDataGraph::classes_do
|
||||
|
||||
InstanceKlass in ClassLoaderData can be uninitialized when
|
||||
ClassLoaderDataGraph::classes_do is called. Using
|
||||
ClassLoaderDataGraph::dictionary_classes_do is safe but problem is still
|
||||
persisting with anonymous classes.
|
||||
---
|
||||
.../share/classfile/classLoaderDataGraph.cpp | 10 ++++++++++
|
||||
.../share/classfile/classLoaderDataGraph.hpp | 4 ++++
|
||||
.../share/prims/jvmtiEnhancedRedefineClasses.cpp | 14 ++++++++++++--
|
||||
3 files changed, 26 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
index 67ade5709f6..aa2a6bcec6b 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
@@ -361,6 +361,16 @@ void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
|
||||
}
|
||||
}
|
||||
|
||||
+void ClassLoaderDataGraph::anonymous_or_hidden_classes_do(KlassClosure* klass_closure) {
|
||||
+ Thread* thread = Thread::current();
|
||||
+ for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
||||
+ if (cld->has_class_mirror_holder()) {
|
||||
+ Handle holder(thread, cld->holder_phantom());
|
||||
+ cld->classes_do(klass_closure);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void ClassLoaderDataGraph::classes_do(void f(Klass* const)) {
|
||||
ClassLoaderDataGraphIterator iter;
|
||||
while (ClassLoaderData* cld = iter.get_next()) {
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.hpp b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
index ebdb0bc2c8c..da712eaf55f 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
@@ -78,6 +78,10 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
// for redefinition. These classes are removed during the next class unloading.
|
||||
// Walking the ClassLoaderDataGraph also includes hidden classes.
|
||||
static void classes_do(KlassClosure* klass_closure);
|
||||
+
|
||||
+ // Enhanced class redefinition
|
||||
+ static void anonymous_or_hidden_classes_do(KlassClosure* klass_closure);
|
||||
+
|
||||
static void classes_do(void f(Klass* const));
|
||||
static void methods_do(void f(Method*));
|
||||
static void modules_do(void f(ModuleEntry*));
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 90dfc1ae545..10407755457 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -2164,9 +2164,19 @@ jvmtiError VM_EnhancedRedefineClasses::find_sorted_affected_classes(TRAPS) {
|
||||
|
||||
{
|
||||
MutexLocker mcld(ClassLoaderDataGraph_lock);
|
||||
- ClassLoaderDataGraph::classes_do(&closure);
|
||||
+
|
||||
+ // 0. we can't use ClassLoaderDataGraph::classes_do since classes can be uninitialized in cld,
|
||||
+ // fully initialized class is in system dictionary
|
||||
+ // ClassLoaderDataGraph::classes_do(&closure);
|
||||
+
|
||||
+ // 1. Scan over dictionaries
|
||||
+ ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
+
|
||||
+ // 2. Anonymous or hidden class is not in dictionary, we have to iterate anonymous cld directly, but there is race cond...
|
||||
+ // TODO: review ... anonymous class is added to cld before InstanceKlass initialization,
|
||||
+ // find out how to check if the InstanceKlass is initialized
|
||||
+ ClassLoaderDataGraph::anonymous_or_hidden_classes_do(&closure);
|
||||
}
|
||||
- //ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
|
||||
log_trace(redefine, class, load)("%d classes affected", _affected_klasses->length());
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
From c4941350aa7d3c5df3a20652f640fe446ff00c5c Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 15 May 2021 13:01:25 +0200
|
||||
Subject: [PATCH 32/45] Fix compilation problems
|
||||
|
||||
---
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 2 +-
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index bcb0da6301f..c5f37d42a9a 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -978,7 +978,7 @@ bool InstanceKlass::link_class_impl(TRAPS) {
|
||||
set_init_state(linked);
|
||||
}
|
||||
// (DCEVM) Must check for old version in order to prevent infinite loops.
|
||||
- if (JvmtiExport::should_post_class_prepare() && (!AllowEnhancedClassRedefinition || old_version() == NULL /* JVMTI deadlock otherwise */) {
|
||||
+ if (JvmtiExport::should_post_class_prepare() && (!AllowEnhancedClassRedefinition || old_version() == NULL /* JVMTI deadlock otherwise */)) {
|
||||
JvmtiExport::post_class_prepare(THREAD, this);
|
||||
}
|
||||
}
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 10407755457..e87d4452d31 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -708,7 +708,7 @@ void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
InstanceKlass* cur = _new_classes->at(i);
|
||||
|
||||
if ((cur->name()->starts_with("java/") || cur->name()->starts_with("jdk/") || cur->name()->starts_with("sun/"))
|
||||
- && cur->name()->index_of_at(0, "$$") == -1) { // skip dynamic proxies
|
||||
+ && cur->name()->index_of_at(0, "$$", (int) strlen("$$")) == -1) { // skip dynamic proxies
|
||||
|
||||
if (cur == vmClasses::ClassLoader_klass()) {
|
||||
// ClassLoader.addClass method is cached in Universe, we must redefine
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
From dad40d31ec8a1633189e70eff57ae5fd21544b20 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 20 Jun 2021 19:11:16 +0200
|
||||
Subject: [PATCH 33/45] Fix dcevm issues related to refactorization of Thread
|
||||
to JavaThread
|
||||
|
||||
---
|
||||
src/hotspot/share/cds/lambdaFormInvokers.cpp | 1 +
|
||||
.../prims/jvmtiEnhancedRedefineClasses.cpp | 72 +++++++++----------
|
||||
.../prims/jvmtiEnhancedRedefineClasses.hpp | 12 ++--
|
||||
3 files changed, 39 insertions(+), 46 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/cds/lambdaFormInvokers.cpp b/src/hotspot/share/cds/lambdaFormInvokers.cpp
|
||||
index 5c058dc43ac..9de28f740ac 100644
|
||||
--- a/src/hotspot/share/cds/lambdaFormInvokers.cpp
|
||||
+++ b/src/hotspot/share/cds/lambdaFormInvokers.cpp
|
||||
@@ -178,6 +178,7 @@ void LambdaFormInvokers::reload_class(char* name, ClassFileStream& st, TRAPS) {
|
||||
class_name,
|
||||
cld,
|
||||
cl_info,
|
||||
+ false, // pick_newest
|
||||
CHECK);
|
||||
|
||||
{
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index e87d4452d31..0aeeea4e7a4 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
-#include "aot/aotLoader.hpp"
|
||||
#include "classfile/classFileParser.hpp"
|
||||
#include "classfile/classFileStream.hpp"
|
||||
#include "classfile/classLoadInfo.hpp"
|
||||
@@ -38,7 +37,7 @@
|
||||
#include "interpreter/rewriter.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
-#include "memory/metaspaceShared.hpp"
|
||||
+#include "cds/metaspaceShared.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/iterator.inline.hpp"
|
||||
#include "oops/fieldStreams.hpp"
|
||||
@@ -156,7 +155,7 @@ bool VM_EnhancedRedefineClasses::doit_prologue() {
|
||||
|
||||
// We first load new class versions in the prologue, because somewhere down the
|
||||
// call chain it is required that the current thread is a Java thread.
|
||||
- _res = load_new_class_versions(Thread::current());
|
||||
+ _res = load_new_class_versions(JavaThread::current());
|
||||
|
||||
// prepare GC, lock heap
|
||||
if (_res == JVMTI_ERROR_NONE && !VM_GC_Operation::doit_prologue()) {
|
||||
@@ -250,7 +249,6 @@ void VM_EnhancedRedefineClasses::root_oops_do(OopClosure *oopClosure) {
|
||||
Universe::vm_global()->oops_do(oopClosure);
|
||||
|
||||
Threads::oops_do(oopClosure, NULL);
|
||||
- AOT_ONLY(AOTLoader::oops_do(oopClosure);)
|
||||
OopStorageSet::strong_oops_do(oopClosure);
|
||||
|
||||
CodeBlobToOopClosure blobClosure(oopClosure, CodeBlobToOopClosure::FixRelocations);
|
||||
@@ -520,7 +518,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
// before the stack walk again.
|
||||
|
||||
for (int i = 0; i < _new_classes->length(); i++) {
|
||||
- redefine_single_class(_new_classes->at(i), thread);
|
||||
+ redefine_single_class(thread, _new_classes->at(i));
|
||||
}
|
||||
|
||||
// Update possible redefinition of vm classes (like ClassLoader)
|
||||
@@ -535,7 +533,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
|
||||
// Deoptimize all compiled code that depends on this class (do only once, because it clears whole cache)
|
||||
// if (_max_redefinition_flags > Klass::ModifyClass) {
|
||||
- flush_dependent_code(thread);
|
||||
+ flush_dependent_code();
|
||||
// }
|
||||
|
||||
// Adjust constantpool caches for all classes that reference methods of the evolved class.
|
||||
@@ -692,7 +690,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
assert(new_version->super() == NULL || new_version->super()->new_version() == NULL, "Super class must be newest version");
|
||||
}
|
||||
log_trace(redefine, class, obsolete, metadata)("calling check_class");
|
||||
- ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(check_class, thread);
|
||||
+ ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(check_class);
|
||||
#ifdef PRODUCT
|
||||
}
|
||||
#endif
|
||||
@@ -702,7 +700,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
|
||||
void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
if (!_new_classes->is_empty()) {
|
||||
- ResourceMark rm(Thread::current());
|
||||
+ ResourceMark rm(JavaThread::current());
|
||||
|
||||
for (int i = 0; i < _new_classes->length(); i++) {
|
||||
InstanceKlass* cur = _new_classes->at(i);
|
||||
@@ -712,7 +710,7 @@ void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
|
||||
if (cur == vmClasses::ClassLoader_klass()) {
|
||||
// ClassLoader.addClass method is cached in Universe, we must redefine
|
||||
- Universe::reinitialize_loader_addClass_method(Thread::current());
|
||||
+ Universe::reinitialize_loader_addClass_method(JavaThread::current());
|
||||
log_trace(redefine, class, obsolete, metadata)("Reinitialize ClassLoade addClass method cache.");
|
||||
}
|
||||
|
||||
@@ -735,7 +733,7 @@ void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
|
||||
cur,
|
||||
signature,
|
||||
vmSymbols::void_method_signature(),
|
||||
- Thread::current());
|
||||
+ JavaThread::current());
|
||||
log_trace(redefine, class, obsolete, metadata)("Reregister natives of JDK class %s", cur->external_name());
|
||||
}
|
||||
}
|
||||
@@ -793,7 +791,7 @@ bool VM_EnhancedRedefineClasses::is_modifiable_class(oop klass_mirror) {
|
||||
|
||||
// Cannot redefine or retransform an anonymous class.
|
||||
// TODO: check if is correct in j15
|
||||
- if (InstanceKlass::cast(k)->is_unsafe_anonymous() || InstanceKlass::cast(k)->is_hidden()) {
|
||||
+ if (InstanceKlass::cast(k)->is_hidden()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -879,23 +877,15 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
|
||||
InstanceKlass* k;
|
||||
|
||||
- if (the_class->is_unsafe_anonymous() || the_class->is_hidden()) {
|
||||
+ if (the_class->is_hidden()) {
|
||||
InstanceKlass* dynamic_host_class = NULL;
|
||||
- InstanceKlass* unsafe_anonymous_host = NULL;
|
||||
|
||||
if (the_class->is_hidden()) {
|
||||
log_debug(redefine, class, load)("loading hidden class %s", the_class->name()->as_C_string());
|
||||
dynamic_host_class = the_class->nest_host(THREAD);
|
||||
}
|
||||
|
||||
- if (the_class->is_unsafe_anonymous()) {
|
||||
- log_debug(redefine, class, load)("loading usafe anonymous %s", the_class->name()->as_C_string());
|
||||
- unsafe_anonymous_host = the_class->unsafe_anonymous_host();
|
||||
- }
|
||||
-
|
||||
ClassLoadInfo cl_info(protection_domain,
|
||||
- unsafe_anonymous_host,
|
||||
- NULL, // cp_patches
|
||||
dynamic_host_class, // dynamic_nest_host
|
||||
Handle(), // classData
|
||||
the_class->is_hidden(), // is_hidden
|
||||
@@ -1143,7 +1133,7 @@ int VM_EnhancedRedefineClasses::calculate_redefinition_flags(InstanceKlass* new_
|
||||
Array<Method*>* k_new_methods(new_class->methods());
|
||||
int n_old_methods = k_old_methods->length();
|
||||
int n_new_methods = k_new_methods->length();
|
||||
- Thread* thread = Thread::current();
|
||||
+ JavaThread* thread = JavaThread::current();
|
||||
|
||||
int ni = 0;
|
||||
int oi = 0;
|
||||
@@ -1491,8 +1481,8 @@ void VM_EnhancedRedefineClasses::rollback() {
|
||||
// Rewrite faster byte-codes back to their slower equivalent. Undoes rewriting happening in templateTable_xxx.cpp
|
||||
// The reason is that once we zero cpool caches, we need to re-resolve all entries again. Faster bytecodes do not
|
||||
// do that, they assume that cache entry is resolved already.
|
||||
-void VM_EnhancedRedefineClasses::unpatch_bytecode(Method* method, TRAPS) {
|
||||
- RawBytecodeStream bcs(methodHandle(THREAD, method));
|
||||
+void VM_EnhancedRedefineClasses::unpatch_bytecode(Method* method) {
|
||||
+ RawBytecodeStream bcs(methodHandle(Thread::current(), method));
|
||||
Bytecodes::Code code;
|
||||
Bytecodes::Code java_code;
|
||||
while (!bcs.is_last_bytecode()) {
|
||||
@@ -1535,10 +1525,10 @@ void VM_EnhancedRedefineClasses::unpatch_bytecode(Method* method, TRAPS) {
|
||||
assert(code2 == Bytecodes::_fast_igetfield ||
|
||||
code2 == Bytecodes::_fast_agetfield ||
|
||||
code2 == Bytecodes::_fast_fgetfield, "");
|
||||
- *(bcp + 1) = Bytecodes::java_code(code2);
|
||||
- }
|
||||
+ *(bcp + 1) = Bytecodes::java_code(code2);
|
||||
}
|
||||
}
|
||||
+}
|
||||
|
||||
// Unevolving classes may point to old methods directly
|
||||
// from their constant pool caches, itables, and/or vtables. We
|
||||
@@ -1559,9 +1549,11 @@ void VM_EnhancedRedefineClasses::ClearCpoolCacheAndUnpatch::do_klass(Klass* k) {
|
||||
constantPoolHandle other_cp = constantPoolHandle(_thread, ik->constants());
|
||||
|
||||
// Update host klass of anonymous classes (for example, produced by lambdas) to newest version.
|
||||
+ /*
|
||||
if (ik->is_unsafe_anonymous() && ik->unsafe_anonymous_host()->new_version() != NULL) {
|
||||
ik->set_unsafe_anonymous_host(InstanceKlass::cast(ik->unsafe_anonymous_host()->newest_version()));
|
||||
}
|
||||
+ */
|
||||
|
||||
// FIXME: check new nest_host for hidden
|
||||
|
||||
@@ -1596,7 +1588,7 @@ void VM_EnhancedRedefineClasses::ClearCpoolCacheAndUnpatch::do_klass(Klass* k) {
|
||||
|
||||
// If bytecode rewriting is enabled, we also need to unpatch bytecode to force resolution of zeroed entries
|
||||
if (RewriteBytecodes) {
|
||||
- ik->methods_do(unpatch_bytecode, _thread);
|
||||
+ ik->methods_do(unpatch_bytecode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1628,7 +1620,7 @@ void VM_EnhancedRedefineClasses::MethodDataCleaner::do_klass(Klass* k) {
|
||||
}
|
||||
|
||||
|
||||
-void VM_EnhancedRedefineClasses::update_jmethod_ids(TRAPS) {
|
||||
+void VM_EnhancedRedefineClasses::update_jmethod_ids(Thread* current) {
|
||||
for (int j = 0; j < _matching_methods_length; ++j) {
|
||||
Method* old_method = _matching_old_methods[j];
|
||||
jmethodID jmid = old_method->find_jmethod_id_or_null();
|
||||
@@ -1639,10 +1631,10 @@ void VM_EnhancedRedefineClasses::update_jmethod_ids(TRAPS) {
|
||||
|
||||
if (jmid != NULL) {
|
||||
// There is a jmethodID, change it to point to the new method
|
||||
- methodHandle new_method_h(THREAD, _matching_new_methods[j]);
|
||||
+ methodHandle new_method_h(current, _matching_new_methods[j]);
|
||||
|
||||
if (old_method->new_version() == NULL) {
|
||||
- methodHandle old_method_h(THREAD, _matching_old_methods[j]);
|
||||
+ methodHandle old_method_h(current, _matching_old_methods[j]);
|
||||
jmethodID new_jmethod_id = Method::make_jmethod_id(old_method_h->method_holder()->class_loader_data(), old_method_h());
|
||||
bool result = InstanceKlass::cast(old_method_h->method_holder())->update_jmethod_id(old_method_h(), new_jmethod_id);
|
||||
} else {
|
||||
@@ -1864,7 +1856,7 @@ void VM_EnhancedRedefineClasses::mark_dependent_code(InstanceKlass* ik) {
|
||||
// subsequent calls to RedefineClasses need only throw away code
|
||||
// that depends on the class.
|
||||
//
|
||||
-void VM_EnhancedRedefineClasses::flush_dependent_code(TRAPS) {
|
||||
+void VM_EnhancedRedefineClasses::flush_dependent_code() {
|
||||
assert_locked_or_safepoint(Compile_lock);
|
||||
|
||||
// All dependencies have been recorded from startup or this is a second or
|
||||
@@ -1959,9 +1951,9 @@ void VM_EnhancedRedefineClasses::compute_added_deleted_matching_methods() {
|
||||
// a helper method to be specified. The interesting parameters
|
||||
// that we would like to pass to the helper method are saved in
|
||||
// static global fields in the VM operation.
|
||||
-void VM_EnhancedRedefineClasses::redefine_single_class(InstanceKlass* new_class_oop, TRAPS) {
|
||||
+void VM_EnhancedRedefineClasses::redefine_single_class(Thread* current, InstanceKlass* new_class_oop) {
|
||||
|
||||
- HandleMark hm(THREAD); // make sure handles from this call are freed
|
||||
+ HandleMark hm(current); // make sure handles from this call are freed
|
||||
|
||||
InstanceKlass* new_class = new_class_oop;
|
||||
InstanceKlass* the_class = InstanceKlass::cast(new_class_oop->old_version());
|
||||
@@ -1980,7 +1972,7 @@ void VM_EnhancedRedefineClasses::redefine_single_class(InstanceKlass* new_class_
|
||||
|
||||
// track number of methods that are EMCP for add_previous_version() call below
|
||||
check_methods_and_mark_as_obsolete();
|
||||
- update_jmethod_ids(THREAD);
|
||||
+ update_jmethod_ids(current);
|
||||
|
||||
_any_class_has_resolved_methods = the_class->has_resolved_methods() || _any_class_has_resolved_methods;
|
||||
|
||||
@@ -2002,14 +1994,14 @@ void VM_EnhancedRedefineClasses::redefine_single_class(InstanceKlass* new_class_
|
||||
*/
|
||||
|
||||
{
|
||||
- ResourceMark rm(THREAD);
|
||||
+ ResourceMark rm(current);
|
||||
// increment the classRedefinedCount field in the_class and in any
|
||||
// direct and indirect subclasses of the_class
|
||||
- increment_class_counter(new_class, THREAD);
|
||||
+ increment_class_counter(current, new_class);
|
||||
log_info(redefine, class, load)
|
||||
("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)",
|
||||
new_class->external_name(), java_lang_Class::classRedefinedCount(new_class->java_mirror()), os::available_memory() >> 10);
|
||||
- Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
|
||||
+ Events::log_redefinition(current, "redefined class name=%s, count=%d",
|
||||
new_class->external_name(),
|
||||
java_lang_Class::classRedefinedCount(new_class->java_mirror()));
|
||||
}
|
||||
@@ -2018,21 +2010,21 @@ void VM_EnhancedRedefineClasses::redefine_single_class(InstanceKlass* new_class_
|
||||
|
||||
// Increment the classRedefinedCount field in the specific InstanceKlass
|
||||
// and in all direct and indirect subclasses.
|
||||
-void VM_EnhancedRedefineClasses::increment_class_counter(InstanceKlass *ik, TRAPS) {
|
||||
+void VM_EnhancedRedefineClasses::increment_class_counter(Thread* current, InstanceKlass *ik) {
|
||||
oop class_mirror = ik->old_version()->java_mirror();
|
||||
Klass* class_oop = java_lang_Class::as_Klass(class_mirror);
|
||||
int new_count = java_lang_Class::classRedefinedCount(class_mirror) + 1;
|
||||
java_lang_Class::set_classRedefinedCount(ik->java_mirror(), new_count);
|
||||
}
|
||||
|
||||
-void VM_EnhancedRedefineClasses::check_class(InstanceKlass* ik, TRAPS) {
|
||||
+void VM_EnhancedRedefineClasses::check_class(InstanceKlass* ik) {
|
||||
if (ik->is_instance_klass() && ik->old_version() != NULL) {
|
||||
- HandleMark hm(THREAD);
|
||||
+ HandleMark hm(Thread::current());
|
||||
|
||||
assert(ik->new_version() == NULL, "must be latest version in system dictionary");
|
||||
|
||||
if (ik->vtable_length() > 0) {
|
||||
- ResourceMark rm(THREAD);
|
||||
+ ResourceMark rm(Thread::current());
|
||||
assert(ik->vtable().check_no_old_or_obsolete_entries(), "old method found");
|
||||
ik->vtable().verify(tty, true);
|
||||
}
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
index d0d2f78aa62..252287a3697 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp
|
||||
@@ -122,7 +122,7 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
static void mark_as_scavengable(nmethod* nm);
|
||||
static void unregister_nmethod_g1(nmethod* nm);
|
||||
static void register_nmethod_g1(nmethod* nm);
|
||||
- static void unpatch_bytecode(Method* method, TRAPS);
|
||||
+ static void unpatch_bytecode(Method* method);
|
||||
|
||||
void root_oops_do(OopClosure *oopClosure);
|
||||
|
||||
@@ -131,28 +131,28 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
|
||||
void compute_added_deleted_matching_methods();
|
||||
|
||||
// Change jmethodIDs to point to the new methods
|
||||
- void update_jmethod_ids(TRAPS);
|
||||
+ void update_jmethod_ids(Thread* current);
|
||||
|
||||
// marking methods as old and/or obsolete
|
||||
void check_methods_and_mark_as_obsolete();
|
||||
void transfer_old_native_function_registrations(InstanceKlass* the_class);
|
||||
|
||||
// Install the redefinition of a class
|
||||
- void redefine_single_class(InstanceKlass* new_class_oop, TRAPS);
|
||||
+ void redefine_single_class(Thread* current, InstanceKlass* new_class_oop);
|
||||
|
||||
// Increment the classRedefinedCount field in the specific InstanceKlass
|
||||
// and in all direct and indirect subclasses.
|
||||
- void increment_class_counter(InstanceKlass *ik, TRAPS);
|
||||
+ void increment_class_counter(Thread* current, InstanceKlass *ik);
|
||||
|
||||
void mark_dependent_code(InstanceKlass* ik);
|
||||
|
||||
- void flush_dependent_code(TRAPS);
|
||||
+ void flush_dependent_code();
|
||||
|
||||
u8 next_id();
|
||||
|
||||
void reinitializeJDKClasses();
|
||||
|
||||
- static void check_class(InstanceKlass* k_oop, TRAPS);
|
||||
+ static void check_class(InstanceKlass* k_oop);
|
||||
|
||||
static void dump_methods();
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
From 7fcef1a84c37c568c0afafb8cb22303efda68f0d Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 20 Jun 2021 19:42:51 +0200
|
||||
Subject: [PATCH 34/45] Fix init_method_MemberName after Thread to JavaThread
|
||||
refactorization
|
||||
|
||||
---
|
||||
src/hotspot/share/interpreter/linkResolver.cpp | 14 ++++++++++----
|
||||
src/hotspot/share/interpreter/linkResolver.hpp | 3 ++-
|
||||
src/hotspot/share/oops/instanceKlass.cpp | 15 ---------------
|
||||
src/hotspot/share/oops/instanceKlass.hpp | 1 -
|
||||
.../share/prims/jvmtiEnhancedRedefineClasses.cpp | 11 +++++++++--
|
||||
5 files changed, 21 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
index 74a6af13ea4..78c9624a18b 100644
|
||||
--- a/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
+++ b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
@@ -131,14 +131,14 @@ void CallInfo::set_common(Klass* resolved_klass,
|
||||
}
|
||||
|
||||
// utility query for unreflecting a method
|
||||
-CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) {
|
||||
+CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, Thread* thread) {
|
||||
Klass* resolved_method_holder = resolved_method->method_holder();
|
||||
if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st
|
||||
resolved_klass = resolved_method_holder;
|
||||
}
|
||||
_resolved_klass = resolved_klass;
|
||||
- _resolved_method = methodHandle(THREAD, resolved_method);
|
||||
- _selected_method = methodHandle(THREAD, resolved_method);
|
||||
+ _resolved_method = methodHandle(thread, resolved_method);
|
||||
+ _selected_method = methodHandle(thread, resolved_method);
|
||||
// classify:
|
||||
CallKind kind = CallInfo::unknown_kind;
|
||||
int index = resolved_method->vtable_index();
|
||||
@@ -179,7 +179,9 @@ CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) {
|
||||
_call_index = index;
|
||||
_resolved_appendix = Handle();
|
||||
// Find or create a ResolvedMethod instance for this Method*
|
||||
- set_resolved_method_name(CHECK);
|
||||
+ if (thread->is_Java_thread()) { // exclude DCEVM VM thread
|
||||
+ set_resolved_method_name(thread->as_Java_thread());
|
||||
+ }
|
||||
|
||||
DEBUG_ONLY(verify());
|
||||
}
|
||||
@@ -190,6 +192,10 @@ void CallInfo::set_resolved_method_name(TRAPS) {
|
||||
_resolved_method_name = Handle(THREAD, rmethod_name);
|
||||
}
|
||||
|
||||
+void CallInfo::set_resolved_method_name_dcevm(oop rmethod_name, Thread* thread) {
|
||||
+ _resolved_method_name = Handle(thread, rmethod_name);
|
||||
+}
|
||||
+
|
||||
#ifdef ASSERT
|
||||
void CallInfo::verify() {
|
||||
switch (call_kind()) { // the meaning and allowed value of index depends on kind
|
||||
diff --git a/src/hotspot/share/interpreter/linkResolver.hpp b/src/hotspot/share/interpreter/linkResolver.hpp
|
||||
index 9eeb10cc6fd..871eaab7464 100644
|
||||
--- a/src/hotspot/share/interpreter/linkResolver.hpp
|
||||
+++ b/src/hotspot/share/interpreter/linkResolver.hpp
|
||||
@@ -91,7 +91,7 @@ class CallInfo : public StackObj {
|
||||
// utility to extract an effective CallInfo from a method and an optional receiver limit
|
||||
// does not queue the method for compilation. This also creates a ResolvedMethodName
|
||||
// object for the resolved_method.
|
||||
- CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS);
|
||||
+ CallInfo(Method* resolved_method, Klass* resolved_klass, Thread* thread);
|
||||
|
||||
Klass* resolved_klass() const { return _resolved_klass; }
|
||||
Method* resolved_method() const { return _resolved_method(); }
|
||||
@@ -100,6 +100,7 @@ class CallInfo : public StackObj {
|
||||
Handle resolved_method_name() const { return _resolved_method_name; }
|
||||
// Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method
|
||||
void set_resolved_method_name(TRAPS);
|
||||
+ void set_resolved_method_name_dcevm(oop rmethod_name, Thread* thread);
|
||||
|
||||
BasicType result_type() const { return selected_method()->result_type(); }
|
||||
CallKind call_kind() const { return _call_kind; }
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
index c5f37d42a9a..9920e7fb25d 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.cpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.cpp
|
||||
@@ -1643,21 +1643,6 @@ void InstanceKlass::methods_do(void f(Method* method)) {
|
||||
}
|
||||
}
|
||||
|
||||
-void InstanceKlass::methods_do(void f(Method* method, TRAPS), TRAPS) {
|
||||
- // Methods aren't stable until they are loaded. This can be read outside
|
||||
- // a lock through the ClassLoaderData for profiling
|
||||
- if (!is_loaded()) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- int len = methods()->length();
|
||||
- for (int index = 0; index < len; index++) {
|
||||
- Method* m = methods()->at(index);
|
||||
- assert(m->is_method(), "must be method");
|
||||
- f(m, CHECK);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
// (DCEVM) Update information contains mapping of fields from old class to the new class.
|
||||
// Info is stored on HEAP, you need to call clear_update_information to free the space.
|
||||
void InstanceKlass::store_update_information(GrowableArray<int> &values) {
|
||||
diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp
|
||||
index 317a006a4ec..36587031fec 100644
|
||||
--- a/src/hotspot/share/oops/instanceKlass.hpp
|
||||
+++ b/src/hotspot/share/oops/instanceKlass.hpp
|
||||
@@ -1017,7 +1017,6 @@ public:
|
||||
void clear_update_information();
|
||||
|
||||
void methods_do(void f(Method* method));
|
||||
- void methods_do(void f(Method* method, TRAPS), TRAPS);
|
||||
void array_klasses_do(void f(Klass* k));
|
||||
void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 0aeeea4e7a4..e7f26b7d08e 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -292,8 +292,15 @@ class ChangePointersOopClosure : public BasicOopIterateClosure {
|
||||
// Note: we might set NULL at this point, which should force AbstractMethodError at runtime
|
||||
Thread *thread = Thread::current();
|
||||
CallInfo info(new_method, newest, thread);
|
||||
- Handle objHandle(thread, obj);
|
||||
- MethodHandles::init_method_MemberName(objHandle, info);
|
||||
+ oop resolved_method = ResolvedMethodTable::find_method(info.resolved_method());
|
||||
+ if (resolved_method != NULL) {
|
||||
+ info.set_resolved_method_name_dcevm(resolved_method, thread);
|
||||
+ Handle objHandle(thread, obj);
|
||||
+ MethodHandles::init_method_MemberName(objHandle, info);
|
||||
+ } else {
|
||||
+ assert(0, "Must be resolved");
|
||||
+ java_lang_invoke_MemberName::set_method(obj, NULL);
|
||||
+ }
|
||||
} else {
|
||||
java_lang_invoke_MemberName::set_method(obj, NULL);
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From e16371268f8ba1c752dc61635a09c94e978f5117 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Mon, 21 Jun 2021 20:44:17 +0200
|
||||
Subject: [PATCH 35/45] Fix "implicit conversion of NULL constant to 'bool'"
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiRedefineClasses.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
|
||||
index 87b3b5f47ce..6915a09cf85 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
|
||||
@@ -1390,7 +1390,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions() {
|
||||
the_class->name(),
|
||||
the_class->class_loader_data(),
|
||||
cl_info,
|
||||
- NULL,
|
||||
+ false,
|
||||
THREAD);
|
||||
|
||||
// Clear class_being_redefined just to be sure.
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From 4d7390cedc3d06281f6a89f12b469108f11aab42 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Wed, 30 Jun 2021 18:30:00 +0200
|
||||
Subject: [PATCH 36/45] Fix, pass SystemDictionary::resolve_from_stream cl_info
|
||||
param
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index e7f26b7d08e..4d145f30100 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -920,10 +920,16 @@ jvmtiError VM_EnhancedRedefineClasses::load_new_class_versions(TRAPS) {
|
||||
}
|
||||
|
||||
} else {
|
||||
+ ClassLoadInfo cl_info(protection_domain,
|
||||
+ NULL, // dynamic_nest_host
|
||||
+ Handle(), // classData
|
||||
+ false, // is_hidden
|
||||
+ !the_class->is_non_strong_hidden(), // is_strong_hidden
|
||||
+ true); // FIXME: check if correct. can_access_vm_annotations
|
||||
k = SystemDictionary::resolve_from_stream(&st,
|
||||
the_class_sym,
|
||||
the_class_loader,
|
||||
- protection_domain,
|
||||
+ cl_info,
|
||||
the_class,
|
||||
THREAD);
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
From 24fe3ebd655068b819a437af62d40c2ee9ed7171 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Wed, 30 Jun 2021 18:50:38 +0200
|
||||
Subject: [PATCH 37/45] Search for affected classes in all initialized classes
|
||||
in cld
|
||||
|
||||
Fix also case when lambda interface is redefined. Lambda class is
|
||||
missing in cld dictionary since it is hidden since j17
|
||||
---
|
||||
src/hotspot/share/classfile/classLoaderData.cpp | 10 ++++++++++
|
||||
src/hotspot/share/classfile/classLoaderData.hpp | 1 +
|
||||
.../share/classfile/classLoaderDataGraph.cpp | 11 ++++-------
|
||||
.../share/classfile/classLoaderDataGraph.hpp | 2 +-
|
||||
.../share/prims/jvmtiEnhancedRedefineClasses.cpp | 13 ++++---------
|
||||
5 files changed, 20 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
index 65ce4c4af8c..1c51e83e86e 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderData.cpp
|
||||
@@ -337,6 +337,16 @@ void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
|
||||
}
|
||||
}
|
||||
|
||||
+void ClassLoaderData::initialized_classes_do(KlassClosure* klass_closure) {
|
||||
+ // Lock-free access requires load_acquire
|
||||
+ for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
||||
+ if (k->is_instance_klass() && InstanceKlass::cast(k)->is_initialized()) {
|
||||
+ klass_closure->do_klass(k);
|
||||
+ }
|
||||
+ assert(k != k->next_link(), "no loops!");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void ClassLoaderData::classes_do(void f(Klass * const)) {
|
||||
// Lock-free access requires load_acquire
|
||||
for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderData.hpp b/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
index bda39f3e353..28fc9060e03 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderData.hpp
|
||||
@@ -272,6 +272,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
void oops_do(OopClosure* f, int claim_value, bool clear_modified_oops = false);
|
||||
|
||||
void classes_do(KlassClosure* klass_closure);
|
||||
+ void initialized_classes_do(KlassClosure* klass_closure);
|
||||
Klass* klasses() { return _klasses; }
|
||||
|
||||
JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
index aa2a6bcec6b..f2394f72dbd 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp
|
||||
@@ -361,13 +361,10 @@ void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
|
||||
}
|
||||
}
|
||||
|
||||
-void ClassLoaderDataGraph::anonymous_or_hidden_classes_do(KlassClosure* klass_closure) {
|
||||
- Thread* thread = Thread::current();
|
||||
- for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
||||
- if (cld->has_class_mirror_holder()) {
|
||||
- Handle holder(thread, cld->holder_phantom());
|
||||
- cld->classes_do(klass_closure);
|
||||
- }
|
||||
+void ClassLoaderDataGraph::initialized_classes_do(KlassClosure* klass_closure) {
|
||||
+ ClassLoaderDataGraphIterator iter;
|
||||
+ while (ClassLoaderData* cld = iter.get_next()) {
|
||||
+ cld->initialized_classes_do(klass_closure);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.hpp b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
index da712eaf55f..ff391ec74fc 100644
|
||||
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp
|
||||
@@ -80,7 +80,7 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
static void classes_do(KlassClosure* klass_closure);
|
||||
|
||||
// Enhanced class redefinition
|
||||
- static void anonymous_or_hidden_classes_do(KlassClosure* klass_closure);
|
||||
+ static void initialized_classes_do(KlassClosure* klass_closure);
|
||||
|
||||
static void classes_do(void f(Klass* const));
|
||||
static void methods_do(void f(Method*));
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 4d145f30100..8615806ac98 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -2170,17 +2170,12 @@ jvmtiError VM_EnhancedRedefineClasses::find_sorted_affected_classes(TRAPS) {
|
||||
{
|
||||
MutexLocker mcld(ClassLoaderDataGraph_lock);
|
||||
|
||||
- // 0. we can't use ClassLoaderDataGraph::classes_do since classes can be uninitialized in cld,
|
||||
- // fully initialized class is in system dictionary
|
||||
+ // We can't use ClassLoaderDataGraph::classes_do since classes can be uninitialized in cld,
|
||||
+ // fully initialized class is in system dictionary, but hidden classes are excluded. Therefore
|
||||
+ // we use special method iterating over initialized classes only
|
||||
// ClassLoaderDataGraph::classes_do(&closure);
|
||||
|
||||
- // 1. Scan over dictionaries
|
||||
- ClassLoaderDataGraph::dictionary_classes_do(&closure);
|
||||
-
|
||||
- // 2. Anonymous or hidden class is not in dictionary, we have to iterate anonymous cld directly, but there is race cond...
|
||||
- // TODO: review ... anonymous class is added to cld before InstanceKlass initialization,
|
||||
- // find out how to check if the InstanceKlass is initialized
|
||||
- ClassLoaderDataGraph::anonymous_or_hidden_classes_do(&closure);
|
||||
+ ClassLoaderDataGraph::initialized_classes_do(&closure);
|
||||
}
|
||||
|
||||
log_trace(redefine, class, load)("%d classes affected", _affected_klasses->length());
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From 3e62ad1914f202d2d3fe907036924e181cd60fcb Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Wed, 30 Jun 2021 18:58:47 +0200
|
||||
Subject: [PATCH 38/45] Fix compilation issue
|
||||
|
||||
---
|
||||
src/hotspot/share/interpreter/linkResolver.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
index 78c9624a18b..28dccd0face 100644
|
||||
--- a/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
+++ b/src/hotspot/share/interpreter/linkResolver.cpp
|
||||
@@ -562,8 +562,8 @@ void LinkResolver::check_method_accessability(Klass* ref_klass,
|
||||
// We'll check for the method name first, as that's most likely
|
||||
// to be false (so we'll short-circuit out of these tests).
|
||||
if (sel_method->name() == vmSymbols::clone_name() &&
|
||||
- ( !AllowEnhancedClassRedefinition && sel_klass == vmClasses::Object_klass() ||
|
||||
- AllowEnhancedClassRedefinition && sel_klass->newest_version() == vmClasses::Object_klass()->newest_version()) &&
|
||||
+ ( (!AllowEnhancedClassRedefinition && sel_klass == vmClasses::Object_klass()) ||
|
||||
+ (AllowEnhancedClassRedefinition && sel_klass->newest_version() == vmClasses::Object_klass()->newest_version()) ) &&
|
||||
resolved_klass->is_array_klass()) {
|
||||
// We need to change "protected" to "public".
|
||||
assert(flags.is_protected(), "clone not protected?");
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
From 4cfb8eb8caa9b13f54f21cdd34b4d761b2b488cc Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Tue, 27 Jul 2021 21:32:51 +0200
|
||||
Subject: [PATCH 39/45] Remove duplicated lambdaFormInvokers.cpp
|
||||
|
||||
---
|
||||
.../share/classfile/lambdaFormInvokers.cpp | 152 ------------------
|
||||
1 file changed, 152 deletions(-)
|
||||
delete mode 100644 src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
|
||||
diff --git a/src/hotspot/share/classfile/lambdaFormInvokers.cpp b/src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
deleted file mode 100644
|
||||
index 281de58b482..00000000000
|
||||
--- a/src/hotspot/share/classfile/lambdaFormInvokers.cpp
|
||||
+++ /dev/null
|
||||
@@ -1,152 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
- *
|
||||
- * This code is free software; you can redistribute it and/or modify it
|
||||
- * under the terms of the GNU General Public License version 2 only, as
|
||||
- * published by the Free Software Foundation.
|
||||
- *
|
||||
- * This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
- * version 2 for more details (a copy is included in the LICENSE file that
|
||||
- * accompanied this code).
|
||||
- *
|
||||
- * You should have received a copy of the GNU General Public License version
|
||||
- * 2 along with this work; if not, write to the Free Software Foundation,
|
||||
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
- *
|
||||
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
- * or visit www.oracle.com if you need additional information or have any
|
||||
- * questions.
|
||||
- *
|
||||
- */
|
||||
-
|
||||
-#include "precompiled.hpp"
|
||||
-#include "classfile/classLoadInfo.hpp"
|
||||
-#include "classfile/classFileStream.hpp"
|
||||
-#include "classfile/javaClasses.inline.hpp"
|
||||
-#include "classfile/klassFactory.hpp"
|
||||
-#include "classfile/lambdaFormInvokers.hpp"
|
||||
-#include "classfile/symbolTable.hpp"
|
||||
-#include "classfile/systemDictionary.hpp"
|
||||
-#include "classfile/systemDictionaryShared.hpp"
|
||||
-#include "classfile/vmClasses.hpp"
|
||||
-#include "classfile/vmSymbols.hpp"
|
||||
-#include "logging/log.hpp"
|
||||
-#include "memory/oopFactory.hpp"
|
||||
-#include "memory/metaspaceShared.hpp"
|
||||
-#include "memory/resourceArea.hpp"
|
||||
-#include "oops/instanceKlass.hpp"
|
||||
-#include "oops/klass.hpp"
|
||||
-#include "oops/objArrayKlass.hpp"
|
||||
-#include "oops/objArrayOop.hpp"
|
||||
-#include "oops/oop.inline.hpp"
|
||||
-#include "oops/typeArrayOop.inline.hpp"
|
||||
-#include "runtime/handles.inline.hpp"
|
||||
-#include "runtime/javaCalls.hpp"
|
||||
-
|
||||
-GrowableArray<char*>* LambdaFormInvokers::_lambdaform_lines = NULL;
|
||||
-
|
||||
-void LambdaFormInvokers::append(char* line) {
|
||||
- if (_lambdaform_lines == NULL) {
|
||||
- _lambdaform_lines = new GrowableArray<char*>(100);
|
||||
- }
|
||||
- _lambdaform_lines->append(line);
|
||||
-}
|
||||
-
|
||||
-void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
|
||||
- assert(_lambdaform_lines != NULL, "Bad List");
|
||||
- ResourceMark rm(THREAD);
|
||||
-
|
||||
- Symbol* cds_name = vmSymbols::jdk_internal_misc_CDS();
|
||||
- Klass* cds_klass = SystemDictionary::resolve_or_null(cds_name, THREAD);
|
||||
- guarantee(cds_klass != NULL, "jdk/internal/misc/CDS must exist!");
|
||||
-
|
||||
- int len = _lambdaform_lines->length();
|
||||
- objArrayHandle list_lines = oopFactory::new_objArray_handle(vmClasses::String_klass(), len, CHECK);
|
||||
- for (int i = 0; i < len; i++) {
|
||||
- Handle h_line = java_lang_String::create_from_str(_lambdaform_lines->at(i), CHECK);
|
||||
- list_lines->obj_at_put(i, h_line());
|
||||
- }
|
||||
-
|
||||
- //
|
||||
- // Object[] CDS.generateLambdaFormHolderClasses(String[] lines)
|
||||
- // the returned Object[] layout:
|
||||
- // name, byte[], name, byte[] ....
|
||||
- Symbol* method = vmSymbols::generateLambdaFormHolderClasses();
|
||||
- Symbol* signrs = vmSymbols::generateLambdaFormHolderClasses_signature();
|
||||
-
|
||||
- JavaValue result(T_OBJECT);
|
||||
- JavaCalls::call_static(&result, cds_klass, method, signrs, list_lines, THREAD);
|
||||
-
|
||||
- if (HAS_PENDING_EXCEPTION) {
|
||||
- log_info(cds)("%s: %s", THREAD->pending_exception()->klass()->external_name(),
|
||||
- java_lang_String::as_utf8_string(java_lang_Throwable::message(THREAD->pending_exception())));
|
||||
- CLEAR_PENDING_EXCEPTION;
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- objArrayHandle h_array(THREAD, (objArrayOop)result.get_oop());
|
||||
- int sz = h_array->length();
|
||||
- assert(sz % 2 == 0 && sz >= 2, "Must be even size of length");
|
||||
- for (int i = 0; i < sz; i+= 2) {
|
||||
- Handle h_name(THREAD, h_array->obj_at(i));
|
||||
- typeArrayHandle h_bytes(THREAD, (typeArrayOop)h_array->obj_at(i+1));
|
||||
- assert(h_name != NULL, "Class name is NULL");
|
||||
- assert(h_bytes != NULL, "Class bytes is NULL");
|
||||
-
|
||||
- char *class_name = java_lang_String::as_utf8_string(h_name());
|
||||
- int len = h_bytes->length();
|
||||
- // make a copy of class bytes so GC will not affect us.
|
||||
- char *buf = resource_allocate_bytes(THREAD, len);
|
||||
- memcpy(buf, (char*)h_bytes->byte_at_addr(0), len);
|
||||
- ClassFileStream st((u1*)buf, len, NULL, ClassFileStream::verify);
|
||||
-
|
||||
- reload_class(class_name, st, THREAD);
|
||||
- // free buf
|
||||
- resource_free_bytes(buf, len);
|
||||
-
|
||||
- if (HAS_PENDING_EXCEPTION) {
|
||||
- log_info(cds)("Exception happened: %s", PENDING_EXCEPTION->klass()->name()->as_C_string());
|
||||
- log_info(cds)("Could not create InstanceKlass for class %s", class_name);
|
||||
- CLEAR_PENDING_EXCEPTION;
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-// class_handle - the class name, bytes_handle - the class bytes
|
||||
-void LambdaFormInvokers::reload_class(char* name, ClassFileStream& st, TRAPS) {
|
||||
- Symbol* class_name = SymbolTable::new_symbol((const char*)name);
|
||||
- // the class must exist
|
||||
- Klass* klass = SystemDictionary::resolve_or_null(class_name, THREAD);
|
||||
- if (klass == NULL) {
|
||||
- log_info(cds)("Class %s not present, skip", name);
|
||||
- return;
|
||||
- }
|
||||
- assert(klass->is_instance_klass(), "Should be");
|
||||
-
|
||||
- ClassLoaderData* cld = ClassLoaderData::the_null_class_loader_data();
|
||||
- Handle protection_domain;
|
||||
- ClassLoadInfo cl_info(protection_domain);
|
||||
-
|
||||
- InstanceKlass* result = KlassFactory::create_from_stream(&st,
|
||||
- class_name,
|
||||
- cld,
|
||||
- cl_info,
|
||||
- false,
|
||||
- CHECK);
|
||||
-
|
||||
- {
|
||||
- MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
|
||||
- SystemDictionary::add_to_hierarchy(result);
|
||||
- }
|
||||
- // new class not linked yet.
|
||||
- MetaspaceShared::try_link_class(THREAD, result);
|
||||
- assert(!HAS_PENDING_EXCEPTION, "Invariant");
|
||||
-
|
||||
- // exclude the existing class from dump
|
||||
- SystemDictionaryShared::set_excluded(InstanceKlass::cast(klass));
|
||||
- log_info(cds, lambda)("Replaced class %s, old: %p new: %p", name, klass, result);
|
||||
-}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
From 92651c5d109896613e14792aa96ed5226a797f9b Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sun, 10 Oct 2021 20:25:30 +0200
|
||||
Subject: [PATCH 40/45] JBR-3867 - update keys of jvmti TAG map after
|
||||
redefinition
|
||||
|
||||
jdwp keeps relation class_ptr->class_ref in jvmti tag. class_ptr is used
|
||||
as a tag key, tag value is refnode. There are new class_ptrs after
|
||||
redefinition, therefore jdwp redefinition method update all affected
|
||||
keys in the tag map.
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiExtensions.cpp | 24 ++++++++++++++
|
||||
.../share/native/libjdwp/VirtualMachineImpl.c | 20 +++++++++++
|
||||
.../share/native/libjdwp/commonRef.c | 29 ++++++++++++++++
|
||||
.../share/native/libjdwp/commonRef.h | 2 ++
|
||||
.../share/native/libjdwp/util.c | 33 +++++++++++++++++++
|
||||
.../share/native/libjdwp/util.h | 3 ++
|
||||
6 files changed, 111 insertions(+)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiExtensions.cpp b/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
index a3fc430e1d1..ab2e663b95d 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
@@ -49,6 +49,15 @@ static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, ...) {
|
||||
return JVMTI_ERROR_NONE;
|
||||
}
|
||||
|
||||
+// extension function
|
||||
+static jvmtiError JNICALL IsEnhancedClassRedefinitionEnabled(const jvmtiEnv* env, jboolean* enabled, ...) {
|
||||
+ if (enabled == NULL) {
|
||||
+ return JVMTI_ERROR_NULL_POINTER;
|
||||
+ }
|
||||
+ *enabled = (jboolean)AllowEnhancedClassRedefinition;
|
||||
+ return JVMTI_ERROR_NONE;
|
||||
+}
|
||||
+
|
||||
// register extension functions and events. In this implementation we
|
||||
// have a single extension function (to prove the API) that tests if class
|
||||
// unloading is enabled or disabled. We also have a single extension event
|
||||
@@ -88,6 +97,21 @@ void JvmtiExtensions::register_extensions() {
|
||||
event_params
|
||||
};
|
||||
_ext_events->append(&ext_event);
|
||||
+
|
||||
+ static jvmtiParamInfo func_params_enh_redef[] = {
|
||||
+ { (char*)"IsEnhancedClassRedefinitionEnabled", JVMTI_KIND_OUT, JVMTI_TYPE_JBOOLEAN, JNI_FALSE }
|
||||
+
|
||||
+ };
|
||||
+ static jvmtiExtensionFunctionInfo ext_func_enh_redef = {
|
||||
+ (jvmtiExtensionFunction)IsEnhancedClassRedefinitionEnabled,
|
||||
+ (char*)"com.sun.hotspot.functions.IsEnhancedClassRedefinitionEnabled",
|
||||
+ (char*)"Tell if enhanced class redefinition is enabled (-noclassgc)",
|
||||
+ sizeof(func_params_enh_redef)/sizeof(func_params_enh_redef[0]),
|
||||
+ func_params_enh_redef,
|
||||
+ 0, // no non-universal errors
|
||||
+ NULL
|
||||
+ };
|
||||
+ _ext_functions->append(&ext_func_enh_redef);
|
||||
}
|
||||
|
||||
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c b/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
index c07bdac2922..7e3070d7d1d 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
@@ -477,6 +477,14 @@ redefineClasses(PacketInputStream *in, PacketOutputStream *out)
|
||||
if (ok == JNI_TRUE) {
|
||||
jvmtiError error;
|
||||
|
||||
+ jlong classIds[classCount];
|
||||
+
|
||||
+ if (gdata->isEnhancedClassRedefinitionEnabled) {
|
||||
+ for (i = 0; i < classCount; ++i) {
|
||||
+ classIds[i] = commonRef_refToID(env, classDefs[i].klass);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
error = JVMTI_FUNC_PTR(gdata->jvmti,RedefineClasses)
|
||||
(gdata->jvmti, classCount, classDefs);
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
@@ -486,6 +494,18 @@ redefineClasses(PacketInputStream *in, PacketOutputStream *out)
|
||||
for ( i = 0 ; i < classCount; i++ ) {
|
||||
eventHandler_freeClassBreakpoints(classDefs[i].klass);
|
||||
}
|
||||
+
|
||||
+ if (gdata->isEnhancedClassRedefinitionEnabled) {
|
||||
+ /* Update tags in jvmti to use new classes */
|
||||
+ for ( i = 0 ; i < classCount; i++ ) {
|
||||
+ /* pointer in classIds[i] is updated by advanced redefinition to a new class */
|
||||
+ error = commonRef_updateTags(env, classIds[i]);
|
||||
+ if (error != JVMTI_ERROR_NONE) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c b/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c
|
||||
index bc7ddb660bf..f8cb8e36f17 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c
|
||||
@@ -712,3 +712,32 @@ commonRef_unlock(void)
|
||||
{
|
||||
debugMonitorExit(gdata->refLock);
|
||||
}
|
||||
+
|
||||
+/*
|
||||
+ * Update JVMTI tags, used from enhanced redefinition
|
||||
+ */
|
||||
+jvmtiError
|
||||
+commonRef_updateTags(JNIEnv *env, jlong id)
|
||||
+{
|
||||
+ jvmtiError error;
|
||||
+
|
||||
+ error = JVMTI_ERROR_NONE;
|
||||
+
|
||||
+ if (id == NULL_OBJECT_ID) {
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+ debugMonitorEnter(gdata->refLock); {
|
||||
+ RefNode *node;
|
||||
+
|
||||
+ node = findNodeByID(env, id);
|
||||
+ if (node != NULL) {
|
||||
+ error = JVMTI_FUNC_PTR(gdata->jvmti, SetTag)
|
||||
+ (gdata->jvmti, node->ref, ptr_to_jlong(node));
|
||||
+ } else {
|
||||
+ printf("Node not found\n");
|
||||
+ }
|
||||
+ } debugMonitorExit(gdata->refLock);
|
||||
+
|
||||
+ return error;
|
||||
+}
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.h b/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.h
|
||||
index c3700f8c743..35c77e4adbf 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.h
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.h
|
||||
@@ -43,4 +43,6 @@ void commonRef_compact(void);
|
||||
void commonRef_lock(void);
|
||||
void commonRef_unlock(void);
|
||||
|
||||
+jvmtiError commonRef_updateTags(JNIEnv *env, jlong id);
|
||||
+
|
||||
#endif
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/util.c b/src/jdk.jdwp.agent/share/native/libjdwp/util.c
|
||||
index 2403c5273ba..b4a5ad183e0 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.c
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.c
|
||||
@@ -43,6 +43,7 @@ BackendGlobalData *gdata = NULL;
|
||||
static jboolean isInterface(jclass clazz);
|
||||
static jboolean isArrayClass(jclass clazz);
|
||||
static char * getPropertyUTF8(JNIEnv *env, char *propertyName);
|
||||
+static jboolean isEnhancedClassRedefinitionEnabled(JNIEnv *env);
|
||||
|
||||
/* Save an object reference for use later (create a NewGlobalRef) */
|
||||
void
|
||||
@@ -285,6 +286,8 @@ util_initialize(JNIEnv *env)
|
||||
}
|
||||
}
|
||||
|
||||
+ gdata->isEnhancedClassRedefinitionEnabled = isEnhancedClassRedefinitionEnabled(env);
|
||||
+
|
||||
} END_WITH_LOCAL_REFS(env);
|
||||
|
||||
}
|
||||
@@ -1701,6 +1704,36 @@ getPropertyUTF8(JNIEnv *env, char *propertyName)
|
||||
return value;
|
||||
}
|
||||
|
||||
+static jboolean
|
||||
+isEnhancedClassRedefinitionEnabled(JNIEnv *env)
|
||||
+{
|
||||
+ jvmtiError error;
|
||||
+ jint count, i;
|
||||
+ jvmtiExtensionFunctionInfo* ext_funcs;
|
||||
+
|
||||
+ error = JVMTI_FUNC_PTR(gdata->jvmti,GetExtensionFunctions)
|
||||
+ (gdata->jvmti, &count, &ext_funcs);
|
||||
+ if (error != JVMTI_ERROR_NONE) {
|
||||
+ return JNI_FALSE;
|
||||
+ }
|
||||
+
|
||||
+ for (i=0; i<count; i++) {
|
||||
+ if (strcmp(ext_funcs[i].id, (char*)"com.sun.hotspot.functions.IsEnhancedClassRedefinitionEnabled") == 0) {
|
||||
+ jboolean enabled;
|
||||
+ error = (*ext_funcs[i].func)(gdata->jvmti, &enabled);
|
||||
+
|
||||
+ if (error != JVMTI_ERROR_NONE) {
|
||||
+ return JNI_FALSE;
|
||||
+ } else {
|
||||
+ return enabled;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return JNI_FALSE;
|
||||
+}
|
||||
+
|
||||
+
|
||||
jboolean
|
||||
isMethodObsolete(jmethodID method)
|
||||
{
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
|
||||
index f62b5c409f0..6de8f17bb23 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h
|
||||
@@ -133,6 +133,9 @@ typedef struct {
|
||||
int objectsByIDsize;
|
||||
int objectsByIDcount;
|
||||
|
||||
+ /* true if enhanced class redefinition is enabled */
|
||||
+ jboolean isEnhancedClassRedefinitionEnabled;
|
||||
+
|
||||
/* Indication that the agent has been loaded */
|
||||
jboolean isLoaded;
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From 7cfd70e1e43bca677b9827a5a7643bb604e6ae38 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Mon, 11 Oct 2021 20:22:26 +0200
|
||||
Subject: [PATCH 41/45] JBR-3867 - fix msvc compilation issue with non const
|
||||
array on stack
|
||||
|
||||
---
|
||||
.../share/native/libjdwp/VirtualMachineImpl.c | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c b/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
index 7e3070d7d1d..669fac7cb5b 100644
|
||||
--- a/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c
|
||||
@@ -477,11 +477,16 @@ redefineClasses(PacketInputStream *in, PacketOutputStream *out)
|
||||
if (ok == JNI_TRUE) {
|
||||
jvmtiError error;
|
||||
|
||||
- jlong classIds[classCount];
|
||||
+ jlong* classIds = NULL;
|
||||
|
||||
if (gdata->isEnhancedClassRedefinitionEnabled) {
|
||||
- for (i = 0; i < classCount; ++i) {
|
||||
- classIds[i] = commonRef_refToID(env, classDefs[i].klass);
|
||||
+ classIds = jvmtiAllocate(classCount*(int)sizeof(jlong));
|
||||
+ if (classIds == NULL) {
|
||||
+ outStream_setError(out, JDWP_ERROR(OUT_OF_MEMORY));
|
||||
+ return JNI_TRUE;
|
||||
+ }
|
||||
+ for (i = 0; i < classCount; i++) {
|
||||
+ classIds[i] = commonRef_refToID(env, classDefs[i].klass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +500,7 @@ redefineClasses(PacketInputStream *in, PacketOutputStream *out)
|
||||
eventHandler_freeClassBreakpoints(classDefs[i].klass);
|
||||
}
|
||||
|
||||
- if (gdata->isEnhancedClassRedefinitionEnabled) {
|
||||
+ if (gdata->isEnhancedClassRedefinitionEnabled && classIds != NULL) {
|
||||
/* Update tags in jvmti to use new classes */
|
||||
for ( i = 0 ; i < classCount; i++ ) {
|
||||
/* pointer in classIds[i] is updated by advanced redefinition to a new class */
|
||||
@@ -504,6 +509,7 @@ redefineClasses(PacketInputStream *in, PacketOutputStream *out)
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ jvmtiDeallocate((void*) classIds);
|
||||
}
|
||||
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From d41ca807dcf4f192bc730c577acb5d2bff0aa3f7 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Tue, 19 Oct 2021 17:02:35 +0200
|
||||
Subject: [PATCH 42/45] Attempt to fix JBR-3887
|
||||
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiExtensions.cpp | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiExtensions.cpp b/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
index ab2e663b95d..698d32a7228 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiExtensions.cpp
|
||||
@@ -50,7 +50,13 @@ static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, ...) {
|
||||
}
|
||||
|
||||
// extension function
|
||||
-static jvmtiError JNICALL IsEnhancedClassRedefinitionEnabled(const jvmtiEnv* env, jboolean* enabled, ...) {
|
||||
+static jvmtiError JNICALL IsEnhancedClassRedefinitionEnabled(const jvmtiEnv* env, ...) {
|
||||
+ jboolean* enabled = NULL;
|
||||
+ va_list ap;
|
||||
+
|
||||
+ va_start(ap, env);
|
||||
+ enabled = va_arg(ap, jboolean *);
|
||||
+ va_end(ap);
|
||||
if (enabled == NULL) {
|
||||
return JVMTI_ERROR_NULL_POINTER;
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
From 91534f381bf08471b7e6e5064d561fb75e2890c6 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Mon, 1 Nov 2021 19:00:41 +0100
|
||||
Subject: [PATCH 43/45] JBR-3937 Fix crashes in C1/C2 compilers
|
||||
|
||||
There is a race condition in enhanced redefinition with C1/C2. Therefore
|
||||
the patch stops C1/C2 compilation before redefinition and release after
|
||||
redefinition finishing. There is no performance impact since dcevm
|
||||
flushes all code cache.
|
||||
---
|
||||
src/hotspot/share/compiler/compileBroker.cpp | 38 ++++++++++++++++++--
|
||||
src/hotspot/share/compiler/compileBroker.hpp | 6 ++++
|
||||
src/hotspot/share/prims/jvmtiEnv.cpp | 7 ++++
|
||||
src/hotspot/share/runtime/mutexLocker.cpp | 3 ++
|
||||
src/hotspot/share/runtime/mutexLocker.hpp | 1 +
|
||||
5 files changed, 53 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
index aaf8e4b1f1e..878bc265d2f 100644
|
||||
--- a/src/hotspot/share/compiler/compileBroker.cpp
|
||||
+++ b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
@@ -140,6 +140,8 @@ CompileLog** CompileBroker::_compiler2_logs = NULL;
|
||||
// These counters are used to assign an unique ID to each compilation.
|
||||
volatile jint CompileBroker::_compilation_id = 0;
|
||||
volatile jint CompileBroker::_osr_compilation_id = 0;
|
||||
+volatile bool CompileBroker::_compilation_stopped = false;
|
||||
+volatile int CompileBroker::_active_compilations = 0;
|
||||
|
||||
// Performance counters
|
||||
PerfCounter* CompileBroker::_perf_total_compilation = NULL;
|
||||
@@ -2320,8 +2322,19 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
|
||||
locker.wait();
|
||||
}
|
||||
}
|
||||
- comp->compile_method(&ci_env, target, osr_bci, true, directive);
|
||||
-
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ {
|
||||
+ MonitorLocker locker(DcevmCompilation_lock, Mutex::_no_safepoint_check_flag);
|
||||
+ while (_compilation_stopped) {
|
||||
+ locker.wait();
|
||||
+ }
|
||||
+ Atomic::add(&_active_compilations, 1);
|
||||
+ }
|
||||
+ comp->compile_method(&ci_env, target, osr_bci, true, directive);
|
||||
+ Atomic::sub(&_active_compilations, 1);
|
||||
+ } else {
|
||||
+ comp->compile_method(&ci_env, target, osr_bci, true, directive);
|
||||
+ }
|
||||
/* Repeat compilation without installing code for profiling purposes */
|
||||
int repeat_compilation_count = directive->RepeatCompilationOption;
|
||||
while (repeat_compilation_count > 0) {
|
||||
@@ -2329,6 +2342,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
|
||||
comp->compile_method(&ci_env, target, osr_bci, false , directive);
|
||||
repeat_compilation_count--;
|
||||
}
|
||||
+
|
||||
}
|
||||
|
||||
if (!ci_env.failing() && task->code() == NULL) {
|
||||
@@ -2942,3 +2956,23 @@ void CompileBroker::print_heapinfo(outputStream* out, const char* function, size
|
||||
}
|
||||
out->print_cr("\n__ CodeHeapStateAnalytics total duration %10.3f seconds _________\n", ts_total.seconds());
|
||||
}
|
||||
+
|
||||
+void CompileBroker::stopCompilationBeforeEnhancedRedefinition() {
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ MonitorLocker locker(DcevmCompilation_lock, Mutex::_no_safepoint_check_flag);
|
||||
+ _compilation_stopped = true;
|
||||
+ while (_active_compilations > 0) {
|
||||
+ VM_ThreadsSuspendJVMTI tsj; // force safepoint to run C1/C2 VM op
|
||||
+ VMThread::execute(&tsj);
|
||||
+ locker.wait(10);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void CompileBroker::releaseCompilationAfterEnhancedRedefinition() {
|
||||
+ if (AllowEnhancedClassRedefinition) {
|
||||
+ MonitorLocker locker(DcevmCompilation_lock, Mutex::_no_safepoint_check_flag);
|
||||
+ _compilation_stopped = false;
|
||||
+ locker.notify_all();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp
|
||||
index 0b721f83121..f146ff5c93d 100644
|
||||
--- a/src/hotspot/share/compiler/compileBroker.hpp
|
||||
+++ b/src/hotspot/share/compiler/compileBroker.hpp
|
||||
@@ -175,6 +175,9 @@ class CompileBroker: AllStatic {
|
||||
static volatile jint _compilation_id;
|
||||
static volatile jint _osr_compilation_id;
|
||||
|
||||
+ static volatile bool _compilation_stopped;
|
||||
+ static volatile int _active_compilations;
|
||||
+
|
||||
static CompileQueue* _c2_compile_queue;
|
||||
static CompileQueue* _c1_compile_queue;
|
||||
|
||||
@@ -423,6 +426,9 @@ public:
|
||||
// CodeHeap State Analytics.
|
||||
static void print_info(outputStream *out);
|
||||
static void print_heapinfo(outputStream *out, const char* function, size_t granularity);
|
||||
+
|
||||
+ static void stopCompilationBeforeEnhancedRedefinition();
|
||||
+ static void releaseCompilationAfterEnhancedRedefinition();
|
||||
};
|
||||
|
||||
#endif // SHARE_COMPILER_COMPILEBROKER_HPP
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp
|
||||
index 8970d7991b7..9ca8e660197 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnv.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "gc/shared/collectedHeap.hpp"
|
||||
+#include "compiler/compileBroker.hpp"
|
||||
#include "interpreter/bytecodeStream.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
@@ -458,8 +459,11 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) {
|
||||
|
||||
if (AllowEnhancedClassRedefinition) {
|
||||
MutexLocker sd_mutex(EnhancedRedefineClasses_lock);
|
||||
+ // Stop compilation to avoid compilator race condition (crashes) with advanced redefinition
|
||||
+ CompileBroker::stopCompilationBeforeEnhancedRedefinition();
|
||||
VM_EnhancedRedefineClasses op(class_count, class_definitions, jvmti_class_load_kind_retransform);
|
||||
VMThread::execute(&op);
|
||||
+ CompileBroker::releaseCompilationAfterEnhancedRedefinition();
|
||||
op_id = op.id();
|
||||
error = (op.check_error());
|
||||
} else {
|
||||
@@ -489,8 +493,11 @@ JvmtiEnv::RedefineClasses(jint class_count, const jvmtiClassDefinition* class_de
|
||||
|
||||
if (AllowEnhancedClassRedefinition) {
|
||||
MutexLocker sd_mutex(EnhancedRedefineClasses_lock);
|
||||
+ // Stop compilation to avoid compilator race condition (crashes) with advanced redefinition
|
||||
+ CompileBroker::stopCompilationBeforeEnhancedRedefinition();
|
||||
VM_EnhancedRedefineClasses op(class_count, class_definitions, jvmti_class_load_kind_redefine);
|
||||
VMThread::execute(&op);
|
||||
+ CompileBroker::releaseCompilationAfterEnhancedRedefinition();
|
||||
op_id = op.id();
|
||||
error = (op.check_error());
|
||||
} else {
|
||||
diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp
|
||||
index 83982382e6f..beb36ebc177 100644
|
||||
--- a/src/hotspot/share/runtime/mutexLocker.cpp
|
||||
+++ b/src/hotspot/share/runtime/mutexLocker.cpp
|
||||
@@ -84,6 +84,7 @@ Mutex* Compile_lock = NULL;
|
||||
Monitor* MethodCompileQueue_lock = NULL;
|
||||
Monitor* CompileThread_lock = NULL;
|
||||
Monitor* Compilation_lock = NULL;
|
||||
+Monitor* DcevmCompilation_lock = NULL;
|
||||
Mutex* CompileTaskAlloc_lock = NULL;
|
||||
Mutex* CompileStatistics_lock = NULL;
|
||||
Mutex* DirectivesStack_lock = NULL;
|
||||
@@ -318,6 +319,8 @@ void mutex_init() {
|
||||
def(Compilation_lock , PaddedMonitor, leaf, false, _safepoint_check_never);
|
||||
}
|
||||
|
||||
+ def(DcevmCompilation_lock , PaddedMonitor, nonleaf+1, false, _safepoint_check_never);
|
||||
+
|
||||
#if INCLUDE_JFR
|
||||
def(JfrMsg_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
|
||||
def(JfrBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
|
||||
diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp
|
||||
index 65a6366bbfb..4333bd51464 100644
|
||||
--- a/src/hotspot/share/runtime/mutexLocker.hpp
|
||||
+++ b/src/hotspot/share/runtime/mutexLocker.hpp
|
||||
@@ -80,6 +80,7 @@ extern Mutex* Compile_lock; // a lock held when Compilation
|
||||
extern Monitor* MethodCompileQueue_lock; // a lock held when method compilations are enqueued, dequeued
|
||||
extern Monitor* CompileThread_lock; // a lock held by compile threads during compilation system initialization
|
||||
extern Monitor* Compilation_lock; // a lock used to pause compilation
|
||||
+extern Monitor* DcevmCompilation_lock; // a lock used to pause compilation from dcevm
|
||||
extern Mutex* CompileTaskAlloc_lock; // a lock held when CompileTasks are allocated
|
||||
extern Mutex* CompileStatistics_lock; // a lock held when updating compilation statistics
|
||||
extern Mutex* DirectivesStack_lock; // a lock held when mutating the dirstack and ref counting directives
|
||||
--
|
||||
2.23.0
|
||||
|
||||
111
jb/project/tools/patches/dcevm/0044-G1-fixes-code-cleanup.patch
Normal file
111
jb/project/tools/patches/dcevm/0044-G1-fixes-code-cleanup.patch
Normal file
@@ -0,0 +1,111 @@
|
||||
From c45eb681e77d16b7e873c8e4dbd19f98879a102a Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Sat, 6 Nov 2021 19:47:08 +0100
|
||||
Subject: [PATCH 44/45] G1 fixes, code cleanup
|
||||
|
||||
---
|
||||
src/hotspot/share/compiler/compileBroker.cpp | 2 ++
|
||||
src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp | 4 +---
|
||||
src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp | 4 ++++
|
||||
src/hotspot/share/gc/shared/gcConfig.cpp | 6 +++---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 3 ++-
|
||||
5 files changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
index 878bc265d2f..d8275508f9b 100644
|
||||
--- a/src/hotspot/share/compiler/compileBroker.cpp
|
||||
+++ b/src/hotspot/share/compiler/compileBroker.cpp
|
||||
@@ -2958,6 +2958,8 @@ void CompileBroker::print_heapinfo(outputStream* out, const char* function, size
|
||||
}
|
||||
|
||||
void CompileBroker::stopCompilationBeforeEnhancedRedefinition() {
|
||||
+ // There are hard to fix C1/C2 race conditions with dcevm. The easiest solution
|
||||
+ // is to stop compilation.
|
||||
if (AllowEnhancedClassRedefinition) {
|
||||
MonitorLocker locker(DcevmCompilation_lock, Mutex::_no_safepoint_check_flag);
|
||||
_compilation_stopped = true;
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
index 765630a9826..c5bffc9bc49 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp
|
||||
@@ -140,7 +140,6 @@ void G1FullGCCompactTask::compact_region_dcevm(HeapRegion* hr, GrowableArray<Hea
|
||||
hr->apply_to_marked_objects(collector()->mark_bitmap(), &compact);
|
||||
// Once all objects have been moved the liveness information
|
||||
// needs be cleared.
|
||||
- collector()->mark_bitmap()->clear_region(hr);
|
||||
if (G1VerifyBitmaps) {
|
||||
collector()->mark_bitmap()->clear_region(hr);
|
||||
}
|
||||
@@ -150,8 +149,7 @@ void G1FullGCCompactTask::compact_region_dcevm(HeapRegion* hr, GrowableArray<Hea
|
||||
void G1FullGCCompactTask::serial_compaction_dcevm() {
|
||||
GCTraceTime(Debug, gc, phases) tm("Phase 4: Serial Compaction", collector()->scope()->timer());
|
||||
|
||||
- // compact remaining, not parallel compacted rescued oops using serial compact point
|
||||
-
|
||||
+ // Clear allocated resources at compact points now, since all rescued oops are copied to destination.
|
||||
for (uint i = 0; i < collector()->workers(); i++) {
|
||||
G1FullGCCompactionPoint* cp = collector()->compaction_point(i);
|
||||
DcevmSharedGC::clear_rescued_objects_heap(cp->rescued_oops_values());
|
||||
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
index 93c066383a1..aa199f57dd7 100644
|
||||
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
|
||||
@@ -146,6 +146,9 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::should_compact(HeapRegion*
|
||||
if (hr->is_pinned()) {
|
||||
return false;
|
||||
}
|
||||
+ if (Universe::is_redefining_gc_run()) {
|
||||
+ return true;
|
||||
+ }
|
||||
size_t live_words = _collector->live_words(hr->hrm_index());
|
||||
size_t live_words_threshold = _collector->scope()->region_compaction_threshold();
|
||||
// High live ratio region will not be compacted.
|
||||
@@ -324,6 +327,7 @@ bool G1FullGCPrepareTask::G1PrepareCompactLiveClosureDcevm::must_rescue(oop old_
|
||||
int new_size = old_obj->size_given_klass(oop(old_obj)->klass()->new_version());
|
||||
int original_size = old_obj->size();
|
||||
|
||||
+ // what if old_obj > new_obj ?
|
||||
bool overlap = (cast_from_oop<HeapWord*>(old_obj) + original_size < cast_from_oop<HeapWord*>(new_obj) + new_size);
|
||||
|
||||
return overlap;
|
||||
diff --git a/src/hotspot/share/gc/shared/gcConfig.cpp b/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
index 8e78696bef5..f8365f94214 100644
|
||||
--- a/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
+++ b/src/hotspot/share/gc/shared/gcConfig.cpp
|
||||
@@ -96,9 +96,9 @@ void GCConfig::fail_if_non_included_gc_is_selected() {
|
||||
}
|
||||
|
||||
void GCConfig::select_gc_ergonomically() {
|
||||
- if (AllowEnhancedClassRedefinition && !UseG1GC) {
|
||||
- // (DCEVM) Enhanced class redefinition only supports serial GC at the moment
|
||||
- FLAG_SET_ERGO(UseSerialGC, true);
|
||||
+ if (AllowEnhancedClassRedefinition && !UseSerialGC) {
|
||||
+ // (DCEVM) use G1 as default GC in Enhanced class redefinition
|
||||
+ FLAG_SET_ERGO(UseG1GC, true);
|
||||
} else if (os::is_server_class_machine()) {
|
||||
#if INCLUDE_G1GC
|
||||
FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 8615806ac98..32e0fcbe62b 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -385,7 +385,7 @@ class ChangePointersOopClosure : public BasicOopIterateClosure {
|
||||
bool oop_updated = false;
|
||||
if (obj->is_instance() && InstanceKlass::cast(obj->klass())->is_mirror_instance_klass()) {
|
||||
Klass* klass = java_lang_Class::as_Klass(obj);
|
||||
- if (klass != NULL && klass->is_instance_klass()) {
|
||||
+ if (klass != NULL && klass->is_instance_klass() && klass->new_version() != NULL) {
|
||||
assert(obj == InstanceKlass::cast(klass)->java_mirror(), "just checking");
|
||||
if (klass->new_version() != NULL) {
|
||||
obj = InstanceKlass::cast(klass->new_version())->java_mirror();
|
||||
@@ -578,6 +578,7 @@ void VM_EnhancedRedefineClasses::doit() {
|
||||
if (log_is_enabled(Info, redefine, class, timer)) {
|
||||
_timer_heap_iterate.start();
|
||||
}
|
||||
+ // returns after the iteration is finished
|
||||
G1CollectedHeap::heap()->object_par_iterate(&objectClosure);
|
||||
_timer_heap_iterate.stop();
|
||||
} else {
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From bb7c41e91326eaa90e25e02e13a2559adf41ae9e Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Dvorak <vladimir.dvorak@jetbrains.com>
|
||||
Date: Mon, 8 Nov 2021 19:51:41 +0100
|
||||
Subject: [PATCH 45/45] JBR-3867 - fix dcevm redefinition stops due the not
|
||||
updated weak oops
|
||||
|
||||
Dcevm must update also oops in weak storage using WeakProcessor. Oops
|
||||
storage is new concept in java17.
|
||||
---
|
||||
src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
index 32e0fcbe62b..35dfc1a66d1 100644
|
||||
--- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
+++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp
|
||||
@@ -67,6 +67,7 @@
|
||||
#include "gc/shared/dcevmSharedGC.hpp"
|
||||
#include "gc/shared/scavengableNMethods.hpp"
|
||||
#include "gc/shared/oopStorageSet.inline.hpp"
|
||||
+#include "gc/shared/weakProcessor.hpp"
|
||||
#include "ci/ciObjectFactory.hpp"
|
||||
|
||||
Array<Method*>* VM_EnhancedRedefineClasses::_old_methods = NULL;
|
||||
@@ -250,6 +251,7 @@ void VM_EnhancedRedefineClasses::root_oops_do(OopClosure *oopClosure) {
|
||||
|
||||
Threads::oops_do(oopClosure, NULL);
|
||||
OopStorageSet::strong_oops_do(oopClosure);
|
||||
+ WeakProcessor::oops_do(oopClosure);
|
||||
|
||||
CodeBlobToOopClosure blobClosure(oopClosure, CodeBlobToOopClosure::FixRelocations);
|
||||
CodeCache::blobs_do(&blobClosure);
|
||||
--
|
||||
2.23.0
|
||||
|
||||
4
jb/project/tools/test/perfcmp.sh
Executable file → Normal file
4
jb/project/tools/test/perfcmp.sh
Executable file → Normal file
@@ -49,7 +49,7 @@ echo $refFile
|
||||
echo $resFile
|
||||
|
||||
curValues=`cat "$curFile" | cut -f 2 | tr -d '\t'`
|
||||
if [ -z $noHeaders ]; then
|
||||
if [ -z noHeaders ]; then
|
||||
curValuesHeader=`echo "$curValues" | head -n +1`_cur
|
||||
header=`cat "$refFile" | head -n +1 | awk -F'\t' -v x=$curValuesHeader '{print " "$1"\t"$2"_ref\t"x"\tratio"}'`
|
||||
testContent=`paste -d '\t' $refFile <(echo "$curValues") | tail -n +2`
|
||||
@@ -58,7 +58,7 @@ else
|
||||
fi
|
||||
|
||||
testContent=`echo "$testContent" | awk -F'\t' '{ if ($3>$2+$2*0.1) {print "* "$1"\t"$2"\t"$3"\t"(($2==0)?"-":$3/$2)} else {print " "$1"\t"$2"\t"$3"\t"(($2==0)?"-":$3/$2)} }'`
|
||||
if [ -z $noHeaders ]; then
|
||||
if [ -z noHeaders ]; then
|
||||
echo "$header" > $resFile
|
||||
fi
|
||||
echo "$testContent" >> $resFile
|
||||
|
||||
@@ -84,6 +84,12 @@ case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=0
|
||||
;;
|
||||
"dcevm")
|
||||
HEAD_REVISION=$(git rev-parse HEAD)
|
||||
git am jb/project/tools/patches/dcevm/*.patch || do_exit $?
|
||||
do_reset_dcevm=0
|
||||
do_reset_changes=0
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
;;
|
||||
@@ -114,7 +120,7 @@ JSDK=$IMAGES_DIR/jdk
|
||||
JSDK_MODS_DIR=$IMAGES_DIR/jmods
|
||||
JBRSDK_BUNDLE=jbrsdk
|
||||
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ]; then
|
||||
git apply -p0 < jb/project/tools/patches/add_jcef_module.patch || do_exit $?
|
||||
update_jsdk_mods "$JSDK" "$JCEF_PATH"/jmods "$JSDK"/jmods "$JSDK_MODS_DIR" || do_exit $?
|
||||
cp $JCEF_PATH/jmods/* ${JSDK_MODS_DIR} # $JSDK/jmods is not unchanged
|
||||
@@ -128,7 +134,7 @@ create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" ||
|
||||
|
||||
# create sdk image bundle
|
||||
modules=$(cat ${JSDK}/release | grep MODULES | sed s/MODULES=//g | sed s/' '/','/g | sed s/\"//g | sed s/\\r//g | sed s/\\n//g)
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "dcevm" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type" == "$JBRSDK_BUNDLE" ]; then
|
||||
modules=${modules},$(get_mods_list "$JCEF_PATH"/jmods)
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" "$JBRSDK_BUNDLE" "$JSDK_MODS_DIR" "$modules" || do_exit $?
|
||||
|
||||
@@ -221,26 +221,6 @@ else
|
||||
JMOD_FLAGS += --exclude '**{_the.*,_*.marker*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM}'
|
||||
endif
|
||||
|
||||
# For reproducible builds specify the jmod --date using SOURCE_DATE in ISO-8601
|
||||
ifeq ($(ENABLE_REPRODUCIBLE_BUILD), true)
|
||||
JMOD_SOURCE_DATE := --date $(SOURCE_DATE_ISO_8601)
|
||||
else
|
||||
JMOD_SOURCE_DATE :=
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_REPRODUCIBLE_BUILD), true)
|
||||
ifeq ($(MODULE), java.base)
|
||||
JAR_FILE_TO_FIX := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jrt-fs.jar
|
||||
$(eval $(call SetupExecute, fixup_jrtfs_jar, \
|
||||
WARN := Fixing timestamps in modules_libs/java.base/jrt-fs.jar, \
|
||||
DEPS := $(JAR_FILE_TO_FIX) $(JDK_OUTPUTDIR)/bin/jar, \
|
||||
OUTPUT_DIR := $(JMODS_SUPPORT_DIR), \
|
||||
COMMAND := $(FIXPATH) $(JDK_OUTPUTDIR)/bin/jar --date $(SOURCE_DATE_ISO_8601) --update --file $(JAR_FILE_TO_FIX) @$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/_the.jrt-fs.jar_contents, \
|
||||
))
|
||||
DEPS += $(fixup_jrtfs_jar_TARGET)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Create jmods in the support dir and then move them into place to keep the
|
||||
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
|
||||
$(eval $(call SetupExecute, create_$(JMOD_FILE), \
|
||||
@@ -252,7 +232,6 @@ $(eval $(call SetupExecute, create_$(JMOD_FILE), \
|
||||
COMMAND := $(JMOD) create --module-version $(VERSION_SHORT) \
|
||||
--target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
|
||||
--module-path $(JMODS_DIR) $(JMOD_FLAGS) \
|
||||
$(JMOD_SOURCE_DATE) \
|
||||
$(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
|
||||
POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
|
||||
))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@@ -313,15 +313,6 @@ else # $(HAS_SPEC)=true
|
||||
SOURCE_DATE := $$(shell $$(DATE) +"%s")
|
||||
endif
|
||||
export SOURCE_DATE_EPOCH := $$(SOURCE_DATE)
|
||||
ifeq ($$(IS_GNU_DATE), yes)
|
||||
export SOURCE_DATE_ISO_8601 := $$(shell $$(DATE) --utc \
|
||||
--date="@$$(SOURCE_DATE_EPOCH)" \
|
||||
+"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null)
|
||||
else
|
||||
export SOURCE_DATE_ISO_8601 := $$(shell $$(DATE) -u \
|
||||
-j -f "%s" "$$(SOURCE_DATE_EPOCH)" \
|
||||
+"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null)
|
||||
endif
|
||||
endef
|
||||
|
||||
# Parse COMPARE_BUILD into COMPARE_BUILD_*
|
||||
|
||||
@@ -18,19 +18,18 @@ include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include JavaCompilation.gmk
|
||||
|
||||
JBR_API_ROOT_DIR := $(TOPDIR)/src/jetbrains.api
|
||||
JBR_API_TOOLS_DIR := $(JBR_API_ROOT_DIR)/tools
|
||||
JBR_API_SRC_DIR := $(JBR_API_ROOT_DIR)/src
|
||||
JBR_API_ROOT_DIR := $(TOPDIR)/src/jetbrains.api
|
||||
JBR_API_GENSRC_TEMPLATES := $(JBR_API_ROOT_DIR)/templates
|
||||
JBR_API_SRC_DIR := $(JBR_API_ROOT_DIR)/src
|
||||
JBR_API_OUTPUT_DIR := $(OUTPUTDIR)/jbr-api
|
||||
JBR_API_GENSRC_DIR := $(JBR_API_OUTPUT_DIR)/gensrc
|
||||
JBR_API_BIN_DIR := $(JBR_API_OUTPUT_DIR)/bin
|
||||
JBR_API_VERSION_PROPERTIES := $(JBR_API_ROOT_DIR)/version.properties
|
||||
JBR_API_VERSION_GENSRC := $(JBR_API_OUTPUT_DIR)/jbr-api.version
|
||||
JBR_API_GENSRC_BATCH := $(JBR_API_VERSION_GENSRC)
|
||||
|
||||
JBR_API_GENSRC_SOURCES := $(call FindFiles, $(JBR_API_GENSRC_TEMPLATES))
|
||||
JBR_API_GENSRC_FILES := $(foreach f, $(call FindFiles, $(JBR_API_GENSRC_TEMPLATES)/com), \
|
||||
$(JBR_API_GENSRC_DIR)/$(call RelativePath, $f, $(JBR_API_GENSRC_TEMPLATES)))
|
||||
JBR_API_SRC_FILES := $(call FindFiles, $(JBR_API_SRC_DIR))
|
||||
JBR_API_GENSRC_FILES := $(foreach f, $(call FindFiles, $(JBR_API_SRC_DIR)), \
|
||||
$(JBR_API_GENSRC_DIR)/$(call RelativePath, $f, $(JBR_API_SRC_DIR)))
|
||||
|
||||
ifeq ($(JBR_API_JBR_VERSION),)
|
||||
JBR_API_JBR_VERSION := <DEVELOPMENT>
|
||||
@@ -44,30 +43,27 @@ ARCHIVE_BUILD_JBR_API_BIN := $(JBR_API_BIN_DIR)
|
||||
$(eval $(call SetupJavaCompilation, BUILD_JBR_API, \
|
||||
SMALL_JAVA := true, \
|
||||
COMPILER := bootjdk, \
|
||||
SRC := $(JBR_API_GENSRC_DIR), \
|
||||
SRC := $(JBR_API_GENSRC_DIR) $(JBR_API_SRC_DIR), \
|
||||
EXTRA_FILES := $(JBR_API_GENSRC_FILES), \
|
||||
BIN := $(JBR_API_BIN_DIR), \
|
||||
JAR := $(JBR_API_OUTPUT_DIR)/jbr-api.jar, \
|
||||
))
|
||||
|
||||
$(eval $(call SetupJarArchive, BUILD_JBR_API_SOURCES_JAR, \
|
||||
DEPENDENCIES := $(JBR_API_GENSRC_FILES), \
|
||||
SRCS := $(JBR_API_GENSRC_DIR), \
|
||||
DEPENDENCIES := $(JBR_API_GENSRC_FILES) $(JBR_API_SRC_FILES), \
|
||||
SRCS := $(JBR_API_GENSRC_DIR) $(JBR_API_SRC_DIR), \
|
||||
JAR := $(JBR_API_OUTPUT_DIR)/jbr-api-sources.jar, \
|
||||
SUFFIXES := .java, \
|
||||
BIN := $(JBR_API_BIN_DIR), \
|
||||
))
|
||||
|
||||
# Grouped targets may not be supported, so hack dependencies: sources -> version file -> generated sources
|
||||
$(JBR_API_VERSION_GENSRC): $(JBR_API_SRC_FILES) $(JBR_API_VERSION_PROPERTIES) $(JBR_API_TOOLS_DIR)/Gensrc.java
|
||||
$(JBR_API_GENSRC_FILES): $(JBR_API_GENSRC_SOURCES) $(JBR_API_SRC_FILES) $(JBR_API_VERSION_PROPERTIES)
|
||||
$(ECHO) Generating sources for JBR API
|
||||
$(JAVA_CMD) $(JAVA_FLAGS_SMALL) "$(JBR_API_TOOLS_DIR)/Gensrc.java" \
|
||||
$(JAVA_CMD) $(JAVA_FLAGS_SMALL) "$(JBR_API_GENSRC_TEMPLATES)/Gensrc.java" \
|
||||
"$(TOPDIR)/src" "$(JBR_API_OUTPUT_DIR)" "$(JBR_API_JBR_VERSION)"
|
||||
$(JBR_API_GENSRC_FILES): $(JBR_API_VERSION_GENSRC)
|
||||
$(TOUCH) $@
|
||||
|
||||
jbr-api-check-version: $(JBR_API_GENSRC_FILES) $(JBR_API_VERSION_PROPERTIES)
|
||||
$(JAVA_CMD) $(JAVA_FLAGS_SMALL) "$(JBR_API_TOOLS_DIR)/CheckVersion.java" \
|
||||
jbr-api-check-version: $(JBR_API_GENSRC_FILES) $(JBR_API_SRC_FILES) $(JBR_API_VERSION_PROPERTIES)
|
||||
$(JAVA_CMD) $(JAVA_FLAGS_SMALL) "$(JBR_API_GENSRC_TEMPLATES)/CheckVersion.java" \
|
||||
"$(JBR_API_ROOT_DIR)" "$(JBR_API_GENSRC_DIR)" "$(JBR_API_FAIL_ON_HASH_MISMATCH)"
|
||||
|
||||
jbr-api: $(BUILD_JBR_API) $(BUILD_JBR_API_SOURCES_JAR) jbr-api-check-version
|
||||
@@ -76,7 +72,7 @@ jbr-api: $(BUILD_JBR_API) $(BUILD_JBR_API_SOURCES_JAR) jbr-api-check-version
|
||||
|
||||
ifneq ($(JBR_API_CONF_FILE),)
|
||||
$(JBR_API_CONF_FILE): $(JBR_API_GENSRC_FILES)
|
||||
$(ECHO) "VERSION=`$(CAT) $(JBR_API_VERSION_GENSRC)`" > $(JBR_API_CONF_FILE)
|
||||
$(ECHO) "VERSION=`$(CAT) $(JBR_API_OUTPUT_DIR)/jbr-api.version`" > $(JBR_API_CONF_FILE)
|
||||
$(ECHO) "JAR=$(JBR_API_OUTPUT_DIR)/jbr-api.jar" >> $(JBR_API_CONF_FILE)
|
||||
$(ECHO) "SOURCES_JAR=$(JBR_API_OUTPUT_DIR)/jbr-api-sources.jar" >> $(JBR_API_CONF_FILE)
|
||||
jbr-api: $(JBR_API_CONF_FILE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@@ -356,17 +356,13 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
|
||||
fi
|
||||
AC_SUBST(IS_GNU_TIME)
|
||||
|
||||
# Check if it's a GNU date compatible version
|
||||
AC_MSG_CHECKING([if date is a GNU compatible version])
|
||||
check_date=`$DATE --version 2>&1 | $GREP "GNU\|BusyBox"`
|
||||
# Check if it's GNU date
|
||||
check_date=`$DATE --version 2>&1 | $GREP GNU`
|
||||
if test "x$check_date" != x; then
|
||||
AC_MSG_RESULT([yes])
|
||||
IS_GNU_DATE=yes
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
IS_GNU_DATE=no
|
||||
fi
|
||||
AC_SUBST(IS_GNU_DATE)
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
|
||||
UTIL_REQUIRE_PROGS(DSYMUTIL, dsymutil)
|
||||
|
||||
@@ -357,16 +357,6 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
|
||||
|
||||
# Finally, set some other options...
|
||||
|
||||
# Determine if the boot jdk jar supports the --date option
|
||||
if $JAR --help 2>&1 | $GREP -q "\-\-date=TIMESTAMP"; then
|
||||
BOOT_JDK_JAR_SUPPORTS_DATE=true
|
||||
else
|
||||
BOOT_JDK_JAR_SUPPORTS_DATE=false
|
||||
fi
|
||||
AC_MSG_CHECKING([if Boot JDK jar supports --date=TIMESTAMP])
|
||||
AC_MSG_RESULT([$BOOT_JDK_JAR_SUPPORTS_DATE])
|
||||
AC_SUBST(BOOT_JDK_JAR_SUPPORTS_DATE)
|
||||
|
||||
# When compiling code to be executed by the Boot JDK, force compatibility with the
|
||||
# oldest supported bootjdk.
|
||||
OLDEST_BOOT_JDK=`$ECHO $DEFAULT_ACCEPTABLE_BOOT_VERSIONS \
|
||||
|
||||
@@ -778,8 +778,6 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
||||
FILE_MACRO_CFLAGS=
|
||||
]
|
||||
)
|
||||
# -fdebug-prefix-map is supported by all modern versions of gcc/clang
|
||||
DEBUG_PREFIX_CFLAGS=" -fdebug-prefix-map=${workspace_root_trailing_slash}="
|
||||
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft &&
|
||||
test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then
|
||||
# There is a known issue with the pathmap if the mapping is made to the
|
||||
@@ -812,12 +810,12 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
||||
$TOOLCHAIN_CFLAGS_JVM ${$1_TOOLCHAIN_CFLAGS_JVM} \
|
||||
$OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
|
||||
$WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG $FILE_MACRO_CFLAGS \
|
||||
$REPRODUCIBLE_CFLAGS $DEBUG_PREFIX_CFLAGS"
|
||||
$REPRODUCIBLE_CFLAGS"
|
||||
|
||||
CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
|
||||
$OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
|
||||
$WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
|
||||
$FILE_MACRO_CFLAGS $REPRODUCIBLE_CFLAGS $DEBUG_PREFIX_CFLAGS"
|
||||
$FILE_MACRO_CFLAGS $REPRODUCIBLE_CFLAGS"
|
||||
|
||||
# Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
|
||||
# (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
|
||||
|
||||
@@ -82,14 +82,6 @@ AC_DEFUN([FLAGS_SETUP_ASFLAGS],
|
||||
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
||||
BASIC_ASFLAGS="-nologo -c"
|
||||
fi
|
||||
|
||||
if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
|
||||
workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
|
||||
BASIC_ASFLAGS+=" -fdebug-prefix-map=${workspace_root_trailing_slash}="
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(BASIC_ASFLAGS)
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
|
||||
@@ -364,9 +364,6 @@ BUILD_JDK:=@BUILD_JDK@
|
||||
CREATE_BUILDJDK:=@CREATE_BUILDJDK@
|
||||
EXTERNAL_BUILDJDK:=@EXTERNAL_BUILDJDK@
|
||||
|
||||
# Whether the boot jdk jar supports --date=TIMESTAMP
|
||||
BOOT_JDK_JAR_SUPPORTS_DATE:=@BOOT_JDK_JAR_SUPPORTS_DATE@
|
||||
|
||||
# When compiling Java source to be run by the boot jdk
|
||||
# use these extra flags, eg -source 6 -target 6
|
||||
BOOT_JDK_SOURCETARGET:=@BOOT_JDK_SOURCETARGET@
|
||||
@@ -710,7 +707,6 @@ CODESIGN:=@CODESIGN@
|
||||
CP:=@CP@
|
||||
CUT:=@CUT@
|
||||
DATE:=@DATE@
|
||||
IS_GNU_DATE:=@IS_GNU_DATE@
|
||||
DIFF:=@DIFF@
|
||||
DIRNAME:=@DIRNAME@
|
||||
DSYMUTIL:=@DSYMUTIL@
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@@ -236,15 +236,13 @@ AC_DEFUN([UTIL_GET_MATCHING_VALUES],
|
||||
# $2: input date/time string
|
||||
AC_DEFUN([UTIL_GET_EPOCH_TIMESTAMP],
|
||||
[
|
||||
if test "x$IS_GNU_DATE" = xyes; then
|
||||
# GNU date
|
||||
timestamp=$($DATE --utc --date=$2 +"%s" 2> /dev/null)
|
||||
else
|
||||
# BSD date
|
||||
timestamp=$($DATE -u -j -f "%F %T" "$2" "+%s" 2> /dev/null)
|
||||
timestamp=$($DATE --utc --date=$2 +"%s" 2> /dev/null)
|
||||
if test "x$timestamp" = x; then
|
||||
# GNU date format did not work, try BSD date options
|
||||
timestamp=$($DATE -j -f "%F %T" "$2" "+%s" 2> /dev/null)
|
||||
if test "x$timestamp" = x; then
|
||||
# Perhaps the time was missing
|
||||
timestamp=$($DATE -u -j -f "%F %T" "$2 00:00:00" "+%s" 2> /dev/null)
|
||||
timestamp=$($DATE -j -f "%F %T" "$2 00:00:00" "+%s" 2> /dev/null)
|
||||
# If this did not work, we give up and return the empty string
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Default version, product, and vendor information to use,
|
||||
# unless overridden by configure
|
||||
|
||||
DEFAULT_VERSION_FEATURE=15
|
||||
DEFAULT_VERSION_INTERIM=0
|
||||
DEFAULT_VERSION_UPDATE=0
|
||||
DEFAULT_VERSION_PATCH=0
|
||||
DEFAULT_VERSION_EXTRA1=0
|
||||
DEFAULT_VERSION_EXTRA2=0
|
||||
DEFAULT_VERSION_EXTRA3=0
|
||||
DEFAULT_VERSION_DATE=2020-09-15
|
||||
DEFAULT_VERSION_CLASSFILE_MAJOR=59 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
|
||||
DEFAULT_VERSION_CLASSFILE_MINOR=0
|
||||
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="14 15"
|
||||
DEFAULT_JDK_SOURCE_TARGET_VERSION=15
|
||||
DEFAULT_PROMOTED_VERSION_PRE=
|
||||
|
||||
LAUNCHER_NAME=openjdk
|
||||
PRODUCT_NAME=OpenJDK
|
||||
PRODUCT_SUFFIX="Runtime Environment"
|
||||
JDK_RC_PLATFORM_NAME=Platform
|
||||
COMPANY_NAME=N/A
|
||||
HOTSPOT_VM_DISTRO="Dynamic Code Evolution"
|
||||
VENDOR_URL=https://openjdk.java.net/
|
||||
VENDOR_URL_BUG=https://bugreport.java.com/bugreport/
|
||||
VENDOR_URL_VM_BUG=https://bugreport.java.com/bugreport/crash.jsp
|
||||
|
||||
# Might need better names for these
|
||||
MACOSX_BUNDLE_NAME_BASE="OpenJDK"
|
||||
MACOSX_BUNDLE_ID_BASE="net.java.openjdk"
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@@ -193,7 +193,7 @@ define SetupJarArchiveBody
|
||||
$1_UPDATE_CONTENTS=\
|
||||
if [ "`$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'`" -gt "0" ]; then \
|
||||
$(ECHO) " updating" `$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
|
||||
$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents; \
|
||||
$$($1_JAR_CMD) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents; \
|
||||
fi $$(NEWLINE)
|
||||
# The s-variants of the above macros are used when the jar is created from scratch.
|
||||
# NOTICE: please leave the parentheses space separated otherwise the AIX build will break!
|
||||
@@ -212,27 +212,25 @@ define SetupJarArchiveBody
|
||||
| $(SED) 's|$$(src)/|-C $$(src) |g' >> \
|
||||
$$($1_BIN)/_the.$$($1_JARNAME)_contents) $$(NEWLINE) )
|
||||
endif
|
||||
$1_SUPDATE_CONTENTS=$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE)
|
||||
$1_SUPDATE_CONTENTS=$$($1_JAR_CMD) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE)
|
||||
|
||||
# Use a slightly shorter name for logging, but with enough path to identify this jar.
|
||||
$1_NAME:=$$(subst $$(OUTPUTDIR)/,,$$($1_JAR))
|
||||
|
||||
# If reproducible build and the boot jdk jar supports --date option
|
||||
# then specify the --date using SOURCE_DATE in ISO-8601
|
||||
$1_JAR_OPTIONS :=
|
||||
ifeq ($$(ENABLE_REPRODUCIBLE_BUILD), true)
|
||||
ifeq ($$(BOOT_JDK_JAR_SUPPORTS_DATE), true)
|
||||
$1_JAR_OPTIONS += --date $(SOURCE_DATE_ISO_8601)
|
||||
endif
|
||||
endif
|
||||
ifneq (,$$($1_CHECK_COMPRESS_JAR))
|
||||
ifneq ($(COMPRESS_JARS), true)
|
||||
$1_JAR_OPTIONS += --no-compress
|
||||
$1_JAR_CREATE_OPTIONS := c0fm
|
||||
$1_JAR_UPDATE_OPTIONS := u0f
|
||||
ifeq ($(COMPRESS_JARS), true)
|
||||
$1_JAR_CREATE_OPTIONS := cfm
|
||||
$1_JAR_UPDATE_OPTIONS := uf
|
||||
endif
|
||||
else
|
||||
$1_JAR_CREATE_OPTIONS := cfm
|
||||
$1_JAR_UPDATE_OPTIONS := uf
|
||||
endif
|
||||
|
||||
# Include all variables of significance in the vardeps file
|
||||
$1_VARDEPS := $$($1_JAR_CMD) $$($1_JAR_OPTIONS) $$($1_MANIFEST) \
|
||||
$1_VARDEPS := $$($1_JAR_CMD) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) \
|
||||
$$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR) $$($1_ORIG_DEPS) $$($1_SRCS) \
|
||||
$$($1_INCLUDES) $$($1_EXCLUDES) $$($1_EXCLUDE_FILES) $$($1_EXTRA_FILES)
|
||||
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$$($1_JARNAME).vardeps)
|
||||
@@ -257,7 +255,7 @@ define SetupJarArchiveBody
|
||||
$$(if $$($1_EXTRA_MANIFEST_ATTR), \
|
||||
$(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \
|
||||
$(ECHO) Creating $$($1_NAME) $$(NEWLINE) \
|
||||
$$($1_JAR_CMD) --create $$($1_JAR_OPTIONS) --file $$@ --manifest $$($1_MANIFEST_FILE) $$(NEWLINE) \
|
||||
$$($1_JAR_CMD) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
|
||||
$$($1_SCAPTURE_CONTENTS) \
|
||||
$$($1_SCAPTURE_METAINF) \
|
||||
$$($1_SUPDATE_CONTENTS) \
|
||||
|
||||
@@ -34,22 +34,18 @@ import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Generate a zip file in a "reproducible" manner from the input zip file.
|
||||
* Standard zip tools rely on OS file list querying whose ordering can vary
|
||||
* by platform architecture, this class ensures the zip entries are ordered
|
||||
* and also supports SOURCE_DATE_EPOCH timestamps which will set the ZipEntry
|
||||
* local time in UTC.
|
||||
* and also supports SOURCE_DATE_EPOCH timestamps.
|
||||
*/
|
||||
public class MakeZipReproducible {
|
||||
String input_file = null;
|
||||
String fname = null;
|
||||
String zname = "";
|
||||
LocalDateTime timestamp = null;
|
||||
long timestamp = -1L;
|
||||
boolean verbose = false;
|
||||
|
||||
// Keep a sorted Set of ZipEntrys to be processed, so that the zip is reproducible
|
||||
@@ -121,9 +117,7 @@ public class MakeZipReproducible {
|
||||
break;
|
||||
case 't':
|
||||
// SOURCE_DATE_EPOCH timestamp specified
|
||||
long epochSeconds = Long.parseLong(args[++count]);
|
||||
Instant instant = Instant.ofEpochSecond(epochSeconds);
|
||||
timestamp = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
|
||||
timestamp = Long.parseLong(args[++count]) * 1000;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = true;
|
||||
@@ -200,8 +194,8 @@ public class MakeZipReproducible {
|
||||
}
|
||||
|
||||
// Set to specified timestamp if set otherwise leave as original lastModified time
|
||||
if (timestamp != null) {
|
||||
entry.setTimeLocal(timestamp);
|
||||
if (timestamp != -1L) {
|
||||
entry.setTime(timestamp);
|
||||
}
|
||||
|
||||
zos.putNextEntry(entry);
|
||||
|
||||
@@ -31,7 +31,6 @@ jdk.httpserver,
|
||||
jdk.internal.ed,
|
||||
jdk.internal.le,
|
||||
jdk.internal.vm.ci,
|
||||
jdk.javadoc,
|
||||
jdk.jdi,
|
||||
jdk.jdwp.agent,
|
||||
jdk.jfr,
|
||||
@@ -47,7 +46,6 @@ jdk.sctp,
|
||||
jdk.security.auth,
|
||||
jdk.security.jgss,
|
||||
jdk.unsupported,
|
||||
jdk.unsupported.desktop,
|
||||
jdk.xml.dom,
|
||||
jdk.zipfs,
|
||||
jdk.hotspot.agent,
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#define CFUNC(x) _##x
|
||||
|
||||
.file "copy_bsd_aarch64.S"
|
||||
.global CFUNC(_Copy_conjoint_words)
|
||||
.global CFUNC(_Copy_disjoint_words)
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#define ELF_TYPE(name, description) .type name,description
|
||||
#endif
|
||||
|
||||
.file "bsd_x86_32.S"
|
||||
.globl SYMBOL(fixcw)
|
||||
|
||||
# NOTE WELL! The _Copy functions are called directly
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#define ELF_TYPE(name, description) .type name,description
|
||||
#endif
|
||||
|
||||
.file "bsd_x86_64.S"
|
||||
# NOTE WELL! The _Copy functions are called directly
|
||||
# from server-compiler-generated code via CallLeafNoFP,
|
||||
# which means that they *must* either not use floating
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// or visit www.oracle.com if you need additional information or have any
|
||||
// questions.
|
||||
|
||||
.file "atomic_linux_aarch64.S"
|
||||
|
||||
|
||||
.text
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
.file "copy_linux_aarch64.S"
|
||||
|
||||
.global _Copy_conjoint_words
|
||||
.global _Copy_disjoint_words
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
// or visit www.oracle.com if you need additional information or have any
|
||||
// questions.
|
||||
|
||||
.file "threadLS_linux_aarch64.S"
|
||||
|
||||
// JavaThread::aarch64_get_thread_helper()
|
||||
//
|
||||
// Return the current thread pointer in x0.
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
.file "linux_arm_32.S"
|
||||
|
||||
# NOTE WELL! The _Copy functions are called directly
|
||||
# from server-compiler-generated code via CallLeafNoFP,
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#
|
||||
|
||||
|
||||
.file "linux_x86_32.S"
|
||||
|
||||
# NOTE WELL! The _Copy functions are called directly
|
||||
# from server-compiler-generated code via CallLeafNoFP,
|
||||
# which means that they *must* either not use floating
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
.file "linux_x86_64.S"
|
||||
|
||||
# NOTE WELL! The _Copy functions are called directly
|
||||
# from server-compiler-generated code via CallLeafNoFP,
|
||||
|
||||
@@ -837,10 +837,18 @@ bool BlockBegin::try_merge(ValueStack* new_state) {
|
||||
existing_state->invalidate_local(index);
|
||||
TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
|
||||
}
|
||||
}
|
||||
|
||||
if (existing_value != new_state->local_at(index) && existing_value->as_Phi() == NULL) {
|
||||
TRACE_PHI(tty->print_cr("required phi for local %d is missing, irreducible loop?", index));
|
||||
return false; // BAILOUT in caller
|
||||
for_each_stack_value(existing_state, index, existing_value) {
|
||||
if ( !(existing_value->as_Phi() != NULL && existing_value->as_Phi()->block() == this)) {
|
||||
TRACE_PHI(tty->print_cr("Re-entered loop head without existing phi for stack - bailout"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for_each_local_value(existing_state, index, existing_value) {
|
||||
if (!(existing_value == new_state->local_at(index) || (existing_value->as_Phi() != NULL && existing_value->as_Phi()->as_Phi()->block() == this))) {
|
||||
TRACE_PHI(tty->print_cr("Re-entered loop head without existing phi for modified local - bailout"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,6 @@ void LambdaFormInvokers::reload_class(char* name, ClassFileStream& st, TRAPS) {
|
||||
class_name,
|
||||
cld,
|
||||
cl_info,
|
||||
false, // pick_newest
|
||||
CHECK);
|
||||
|
||||
{
|
||||
|
||||
@@ -129,7 +129,6 @@ public:
|
||||
void print_name_on(outputStream* st);
|
||||
|
||||
const char* external_name() const;
|
||||
Klass* new_version() { return get_Klass()->new_version(); }
|
||||
};
|
||||
|
||||
#endif // SHARE_CI_CIKLASS_HPP
|
||||
|
||||
@@ -74,10 +74,7 @@ GrowableArray<ciMetadata*>* ciObjectFactory::_shared_ci_metadata = NULL;
|
||||
ciSymbol* ciObjectFactory::_shared_ci_symbols[vmSymbols::number_of_symbols()];
|
||||
int ciObjectFactory::_shared_ident_limit = 0;
|
||||
volatile bool ciObjectFactory::_initialized = false;
|
||||
volatile bool ciObjectFactory::_reinitialize_vm_klasses = false;
|
||||
|
||||
// TODO: review...
|
||||
Arena* ciObjectFactory::_initial_arena = NULL;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciObjectFactory::ciObjectFactory
|
||||
@@ -113,7 +110,6 @@ void ciObjectFactory::initialize() {
|
||||
// compiler thread that initializes the initial ciObjectFactory which
|
||||
// creates the shared ciObjects that all later ciObjectFactories use.
|
||||
Arena* arena = new (mtCompiler) Arena(mtCompiler);
|
||||
ciObjectFactory::_initial_arena = arena;
|
||||
ciEnv initial(arena);
|
||||
ciEnv* env = ciEnv::current();
|
||||
env->_factory->init_shared_objects();
|
||||
@@ -122,36 +118,6 @@ void ciObjectFactory::initialize() {
|
||||
|
||||
}
|
||||
|
||||
// (DCEVM) vm classes could be modified
|
||||
void ciObjectFactory::reinitialize_vm_classes() {
|
||||
ASSERT_IN_VM;
|
||||
JavaThread* thread = JavaThread::current();
|
||||
HandleMark handle_mark(thread);
|
||||
|
||||
// This Arena is long lived and exists in the resource mark of the
|
||||
// compiler thread that initializes the initial ciObjectFactory which
|
||||
// creates the shared ciObjects that all later ciObjectFactories use.
|
||||
// Arena* arena = new (mtCompiler) Arena(mtCompiler);
|
||||
ciEnv initial(ciObjectFactory::_initial_arena);
|
||||
ciEnv* env = ciEnv::current();
|
||||
env->_factory->do_reinitialize_vm_classes();
|
||||
_reinitialize_vm_klasses = false;
|
||||
}
|
||||
|
||||
// (DCEVM) vm classes could be modified
|
||||
void ciObjectFactory::do_reinitialize_vm_classes() {
|
||||
#define VM_CLASS_DEFN(name, ignore_s) \
|
||||
if (ciEnv::_##name != NULL && ciEnv::_##name->new_version() != NULL) { \
|
||||
int old_ident = ciEnv::_##name->ident(); \
|
||||
ciEnv::_##name = get_metadata(vmClasses::name())->as_instance_klass(); \
|
||||
ciEnv::_##name->compute_nonstatic_fields(); \
|
||||
ciEnv::_##name->set_ident(old_ident); \
|
||||
}
|
||||
|
||||
VM_CLASSES_DO(VM_CLASS_DEFN)
|
||||
#undef VM_CLASS_DEFN
|
||||
}
|
||||
|
||||
void ciObjectFactory::init_shared_objects() {
|
||||
|
||||
_next_ident = 1; // start numbering CI objects at 1
|
||||
@@ -750,28 +716,3 @@ void ciObjectFactory::print() {
|
||||
_unloaded_instances.length(),
|
||||
_unloaded_klasses.length());
|
||||
}
|
||||
|
||||
|
||||
int ciObjectFactory::compare_cimetadata(ciMetadata** a, ciMetadata** b) {
|
||||
Metadata* am = (*a)->constant_encoding();
|
||||
Metadata* bm = (*b)->constant_encoding();
|
||||
return ((am > bm) ? 1 : ((am == bm) ? 0 : -1));
|
||||
}
|
||||
|
||||
// FIXME: review... Resoring the ciObject arrays after class redefinition
|
||||
void ciObjectFactory::resort_shared_ci_metadata() {
|
||||
if (_shared_ci_metadata == NULL) return;
|
||||
_shared_ci_metadata->sort(ciObjectFactory::compare_cimetadata);
|
||||
|
||||
#ifdef ASSERT
|
||||
if (CIObjectFactoryVerify) {
|
||||
Metadata* last = NULL;
|
||||
for (int j = 0; j< _shared_ci_metadata->length(); j++) {
|
||||
Metadata* o = _shared_ci_metadata->at(j)->constant_encoding();
|
||||
assert(last < o, "out of order");
|
||||
last = o;
|
||||
}
|
||||
}
|
||||
#endif // ASSERT
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,9 @@ class ciObjectFactory : public ResourceObj {
|
||||
|
||||
private:
|
||||
static volatile bool _initialized;
|
||||
static volatile bool _reinitialize_vm_klasses;
|
||||
static GrowableArray<ciMetadata*>* _shared_ci_metadata;
|
||||
static ciSymbol* _shared_ci_symbols[];
|
||||
static int _shared_ident_limit;
|
||||
static Arena* _initial_arena;
|
||||
|
||||
Arena* _arena;
|
||||
GrowableArray<ciMetadata*> _ci_metadata;
|
||||
@@ -91,15 +89,10 @@ private:
|
||||
|
||||
ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
|
||||
|
||||
static int compare_cimetadata(ciMetadata** a, ciMetadata** b);
|
||||
void do_reinitialize_vm_classes();
|
||||
public:
|
||||
static bool is_initialized() { return _initialized; }
|
||||
static bool is_reinitialize_vm_klasses() { return _reinitialize_vm_klasses; }
|
||||
static void set_reinitialize_vm_klasses() { _reinitialize_vm_klasses = true; }
|
||||
|
||||
static void initialize();
|
||||
static void reinitialize_vm_classes();
|
||||
void init_shared_objects();
|
||||
void remove_symbols();
|
||||
|
||||
@@ -152,8 +145,6 @@ public:
|
||||
|
||||
void print_contents();
|
||||
void print();
|
||||
|
||||
static void resort_shared_ci_metadata();
|
||||
};
|
||||
|
||||
#endif // SHARE_CI_CIOBJECTFACTORY_HPP
|
||||
|
||||
@@ -852,9 +852,6 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream,
|
||||
CHECK);
|
||||
}
|
||||
|
||||
// (DCEVM) pick newest
|
||||
interf = (Klass *) maybe_newest(interf);
|
||||
|
||||
if (!interf->is_interface()) {
|
||||
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
|
||||
err_msg("class %s can not implement %s, because it is not an interface (%s)",
|
||||
@@ -4020,8 +4017,7 @@ const InstanceKlass* ClassFileParser::parse_super_class(ConstantPool* const cp,
|
||||
// However, make sure it is not an array type.
|
||||
bool is_array = false;
|
||||
if (cp->tag_at(super_class_index).is_klass()) {
|
||||
// (DCEVM) pick newest
|
||||
super_klass = InstanceKlass::cast(maybe_newest(cp->resolved_klass_at(super_class_index)));
|
||||
super_klass = InstanceKlass::cast(cp->resolved_klass_at(super_class_index));
|
||||
if (need_verify)
|
||||
is_array = super_klass->is_array_klass();
|
||||
} else if (need_verify) {
|
||||
@@ -4161,10 +4157,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) {
|
||||
if (!_has_empty_finalizer) {
|
||||
if (_has_finalizer ||
|
||||
(super != NULL && super->has_finalizer())) {
|
||||
// FIXME - (DCEVM) this is condition from previous DCEVM version, however after reload a new finalize() method is not active
|
||||
if (ik->old_version() == NULL || ik->old_version()->has_finalizer()) {
|
||||
ik->set_has_finalizer();
|
||||
}
|
||||
ik->set_has_finalizer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5511,7 +5504,6 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
|
||||
ClassLoaderData* loader_data,
|
||||
const ClassLoadInfo* cl_info,
|
||||
Publicity pub_level,
|
||||
const bool pick_newest,
|
||||
TRAPS) :
|
||||
_stream(stream),
|
||||
_class_name(NULL),
|
||||
@@ -5570,8 +5562,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
|
||||
_has_finalizer(false),
|
||||
_has_empty_finalizer(false),
|
||||
_has_vanilla_constructor(false),
|
||||
_max_bootstrap_specifier_index(-1),
|
||||
_pick_newest(pick_newest) {
|
||||
_max_bootstrap_specifier_index(-1) {
|
||||
|
||||
_class_name = name != NULL ? name : vmSymbols::unknown_class_name();
|
||||
_class_name->increment_refcount();
|
||||
@@ -5970,15 +5961,14 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
|
||||
CHECK);
|
||||
}
|
||||
Handle loader(THREAD, _loader_data->class_loader());
|
||||
const Klass* super_klass =
|
||||
_super_klass = (const InstanceKlass*)
|
||||
SystemDictionary::resolve_super_or_fail(_class_name,
|
||||
super_class_name,
|
||||
loader,
|
||||
_protection_domain,
|
||||
true,
|
||||
CHECK);
|
||||
_super_klass = (const InstanceKlass*) maybe_newest(super_klass);
|
||||
}
|
||||
}
|
||||
|
||||
if (_super_klass != NULL) {
|
||||
if (_super_klass->has_nonstatic_concrete_methods()) {
|
||||
|
||||
@@ -198,9 +198,6 @@ class ClassFileParser {
|
||||
bool _has_vanilla_constructor;
|
||||
int _max_bootstrap_specifier_index; // detects BSS values
|
||||
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
const bool _pick_newest;
|
||||
|
||||
void parse_stream(const ClassFileStream* const stream, TRAPS);
|
||||
|
||||
void mangle_hidden_class_name(InstanceKlass* const ik);
|
||||
@@ -528,8 +525,6 @@ class ClassFileParser {
|
||||
TRAPS);
|
||||
|
||||
void update_class_name(Symbol* new_name);
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
inline const Klass* maybe_newest(const Klass* klass) const { return klass != NULL && _pick_newest ? klass->newest_version() : klass; }
|
||||
|
||||
public:
|
||||
ClassFileParser(ClassFileStream* stream,
|
||||
@@ -537,7 +532,6 @@ class ClassFileParser {
|
||||
ClassLoaderData* loader_data,
|
||||
const ClassLoadInfo* cl_info,
|
||||
Publicity pub_level,
|
||||
const bool pick_newest,
|
||||
TRAPS);
|
||||
|
||||
~ClassFileParser();
|
||||
@@ -563,7 +557,6 @@ class ClassFileParser {
|
||||
ClassLoaderData* loader_data() const { return _loader_data; }
|
||||
const Symbol* class_name() const { return _class_name; }
|
||||
const InstanceKlass* super_klass() const { return _super_klass; }
|
||||
Array<InstanceKlass*>* local_interfaces() const { return _local_interfaces; }
|
||||
|
||||
ReferenceType reference_type() const { return _rt; }
|
||||
AccessFlags access_flags() const { return _access_flags; }
|
||||
|
||||
@@ -1223,7 +1223,6 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
|
||||
name,
|
||||
loader_data,
|
||||
cl_info,
|
||||
false, // pick_newest
|
||||
CHECK_NULL);
|
||||
result->set_classpath_index(classpath_index);
|
||||
return result;
|
||||
|
||||
@@ -337,16 +337,6 @@ void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoaderData::initialized_classes_do(KlassClosure* klass_closure) {
|
||||
// Lock-free access requires load_acquire
|
||||
for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
||||
if (k->is_instance_klass() && InstanceKlass::cast(k)->is_initialized()) {
|
||||
klass_closure->do_klass(k);
|
||||
}
|
||||
assert(k != k->next_link(), "no loops!");
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoaderData::classes_do(void f(Klass * const)) {
|
||||
// Lock-free access requires load_acquire
|
||||
for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
||||
@@ -609,15 +599,6 @@ Dictionary* ClassLoaderData::create_dictionary() {
|
||||
return new Dictionary(this, size, resizable);
|
||||
}
|
||||
|
||||
void ClassLoaderData::exchange_holders(ClassLoaderData* cld) {
|
||||
oop holder_oop = _holder.peek();
|
||||
_holder.replace(cld->_holder.peek());
|
||||
cld->_holder.replace(holder_oop);
|
||||
WeakHandle exchange = _holder;
|
||||
_holder = cld->_holder;
|
||||
cld->_holder = exchange;
|
||||
}
|
||||
|
||||
// Tell the GC to keep this klass alive while iterating ClassLoaderDataGraph
|
||||
oop ClassLoaderData::holder_phantom() const {
|
||||
// A klass that was previously considered dead can be looked up in the
|
||||
|
||||
@@ -175,7 +175,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
|
||||
oop holder_no_keepalive() const;
|
||||
oop holder_phantom() const;
|
||||
void exchange_holders(ClassLoaderData* cld);
|
||||
|
||||
private:
|
||||
void unload();
|
||||
bool keep_alive() const { return _keep_alive > 0; }
|
||||
@@ -272,7 +272,6 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
void oops_do(OopClosure* f, int claim_value, bool clear_modified_oops = false);
|
||||
|
||||
void classes_do(KlassClosure* klass_closure);
|
||||
void initialized_classes_do(KlassClosure* klass_closure);
|
||||
Klass* klasses() { return _klasses; }
|
||||
|
||||
JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
|
||||
|
||||
@@ -361,13 +361,6 @@ void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoaderDataGraph::initialized_classes_do(KlassClosure* klass_closure) {
|
||||
ClassLoaderDataGraphIterator iter;
|
||||
while (ClassLoaderData* cld = iter.get_next()) {
|
||||
cld->initialized_classes_do(klass_closure);
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoaderDataGraph::classes_do(void f(Klass* const)) {
|
||||
ClassLoaderDataGraphIterator iter;
|
||||
while (ClassLoaderData* cld = iter.get_next()) {
|
||||
@@ -448,29 +441,6 @@ void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*, TRAPS),
|
||||
}
|
||||
}
|
||||
|
||||
// (DCEVM) - iterate over dict classes
|
||||
void ClassLoaderDataGraph::dictionary_classes_do(KlassClosure* klass_closure) {
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
cld->dictionary()->classes_do(klass_closure);
|
||||
}
|
||||
}
|
||||
|
||||
// (DCEVM) rollback redefined classes
|
||||
void ClassLoaderDataGraph::rollback_redefinition() {
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
cld->dictionary()->rollback_redefinition();
|
||||
}
|
||||
}
|
||||
|
||||
// (DCEVM) - iterate over all classes in all dictionaries
|
||||
bool ClassLoaderDataGraph::dictionary_classes_do_update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass) {
|
||||
bool ok = false;
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
ok = cld->dictionary()->update_klass(name, k, old_klass) || ok;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void ClassLoaderDataGraph::verify_dictionary() {
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
cld->dictionary()->verify();
|
||||
|
||||
@@ -78,10 +78,6 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
// for redefinition. These classes are removed during the next class unloading.
|
||||
// Walking the ClassLoaderDataGraph also includes hidden classes.
|
||||
static void classes_do(KlassClosure* klass_closure);
|
||||
|
||||
// Enhanced class redefinition
|
||||
static void initialized_classes_do(KlassClosure* klass_closure);
|
||||
|
||||
static void classes_do(void f(Klass* const));
|
||||
static void methods_do(void f(Method*));
|
||||
static void modules_do(void f(ModuleEntry*));
|
||||
@@ -107,14 +103,6 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||
// Added for initialize_itable_for_klass to handle exceptions.
|
||||
static void dictionary_classes_do(void f(InstanceKlass*, TRAPS), TRAPS);
|
||||
|
||||
static void dictionary_classes_do(KlassClosure* klass_closure);
|
||||
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
static void rollback_redefinition();
|
||||
|
||||
// Enhanced class redefinition
|
||||
static bool dictionary_classes_do_update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass);
|
||||
|
||||
// VM_CounterDecay iteration support
|
||||
static InstanceKlass* try_get_next_class();
|
||||
static void adjust_saved_class(ClassLoaderData* cld);
|
||||
|
||||
@@ -290,7 +290,6 @@ InstanceKlass* ClassLoaderExt::load_class(Symbol* name, const char* path, TRAPS)
|
||||
name,
|
||||
loader_data,
|
||||
cl_info,
|
||||
false,
|
||||
CHECK_NULL);
|
||||
return k;
|
||||
}
|
||||
|
||||
@@ -225,21 +225,6 @@ void Dictionary::classes_do(void f(InstanceKlass*)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// (DCEVM) iterate over dict entry
|
||||
void Dictionary::classes_do(KlassClosure* closure) {
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
for (DictionaryEntry* probe = bucket(index);
|
||||
probe != NULL;
|
||||
probe = probe->next()) {
|
||||
InstanceKlass* k = probe->instance_klass();
|
||||
if (loader_data() == k->class_loader_data()) {
|
||||
closure->do_klass(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Added for initialize_itable_for_klass to handle exceptions
|
||||
// Just the classes from defining class loaders
|
||||
void Dictionary::classes_do(void f(InstanceKlass*, TRAPS), TRAPS) {
|
||||
@@ -321,35 +306,6 @@ DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// (DCEVM) replace old_class by new class in dictionary
|
||||
bool Dictionary::update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass) {
|
||||
// There are several entries for the same class in the dictionary: One extra entry for each parent classloader of the classloader of the class.
|
||||
bool found = false;
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
for (DictionaryEntry* entry = bucket(index); entry != NULL; entry = entry->next()) {
|
||||
if (entry->instance_klass() == old_klass) {
|
||||
entry->set_literal(k);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// (DCEVM) rollback redefinition
|
||||
void Dictionary::rollback_redefinition() {
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
for (DictionaryEntry* entry = bucket(index);
|
||||
entry != NULL;
|
||||
entry = entry->next()) {
|
||||
if (entry->instance_klass()->is_redefining()) {
|
||||
entry->set_literal((InstanceKlass*) entry->instance_klass()->old_version());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
InstanceKlass* Dictionary::find(unsigned int hash, Symbol* name,
|
||||
@@ -359,7 +315,7 @@ InstanceKlass* Dictionary::find(unsigned int hash, Symbol* name,
|
||||
int index = hash_to_index(hash);
|
||||
DictionaryEntry* entry = get_entry(index, hash, name);
|
||||
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
|
||||
return old_if_redefining(entry->instance_klass());
|
||||
return entry->instance_klass();
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -373,7 +329,7 @@ InstanceKlass* Dictionary::find_class(unsigned int hash,
|
||||
assert (index == index_for(name), "incorrect index?");
|
||||
|
||||
DictionaryEntry* entry = get_entry(index, hash, name);
|
||||
return old_if_redefining((entry != NULL) ? entry->instance_klass() : NULL);
|
||||
return (entry != NULL) ? entry->instance_klass() : NULL;
|
||||
}
|
||||
|
||||
void Dictionary::add_protection_domain(int index, unsigned int hash,
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
InstanceKlass* find_class(unsigned int hash, Symbol* name);
|
||||
|
||||
void classes_do(void f(InstanceKlass*));
|
||||
void classes_do(KlassClosure* closure);
|
||||
void classes_do(void f(InstanceKlass*, TRAPS), TRAPS);
|
||||
void all_entries_do(KlassClosure* closure);
|
||||
void classes_do(MetaspaceClosure* it);
|
||||
@@ -82,11 +81,6 @@ public:
|
||||
void print_on(outputStream* st) const;
|
||||
void verify();
|
||||
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
bool update_klass(Symbol* name, InstanceKlass* k, InstanceKlass* old_klass);
|
||||
|
||||
void rollback_redefinition();
|
||||
|
||||
private:
|
||||
DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass);
|
||||
|
||||
@@ -107,11 +101,6 @@ public:
|
||||
void add_protection_domain(int index, unsigned int hash,
|
||||
InstanceKlass* klass,
|
||||
Handle protection_domain);
|
||||
|
||||
// (DCEVM) return old class if redefining in AllowEnhancedClassRedefinition, otherwise return "k"
|
||||
static InstanceKlass* old_if_redefining(InstanceKlass* k) {
|
||||
return (k != NULL && k->is_redefining()) ? ((InstanceKlass* )k->old_version()) : k;
|
||||
}
|
||||
};
|
||||
|
||||
// An entry in the class loader data dictionaries, this describes a class as
|
||||
|
||||
@@ -2594,8 +2594,6 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand
|
||||
skip_throwableInit_check = true;
|
||||
}
|
||||
}
|
||||
// (DCEVM): Line numbers from newest version must be used for EMCP-swapped methods
|
||||
method = method->newest_version();
|
||||
if (method->is_hidden()) {
|
||||
if (skip_hidden) {
|
||||
if (total_count == 0) {
|
||||
@@ -3809,62 +3807,6 @@ void java_lang_invoke_DirectMethodHandle::serialize_offsets(SerializeClosure* f)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Support for java_lang_invoke_DirectMethodHandle$StaticAccessor
|
||||
|
||||
int java_lang_invoke_DirectMethodHandle_StaticAccessor::_static_offset_offset;
|
||||
|
||||
long java_lang_invoke_DirectMethodHandle_StaticAccessor::static_offset(oop dmh) {
|
||||
assert(_static_offset_offset != 0, "");
|
||||
return dmh->long_field(_static_offset_offset);
|
||||
}
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_StaticAccessor::set_static_offset(oop dmh, long static_offset) {
|
||||
assert(_static_offset_offset != 0, "");
|
||||
dmh->long_field_put(_static_offset_offset, static_offset);
|
||||
}
|
||||
|
||||
#define DIRECTMETHODHANDLE_STATIC_ACCESSOR_FIELDS_DO(macro) \
|
||||
macro(_static_offset_offset, k, vmSymbols::static_offset_name(), long_signature, false)
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_StaticAccessor::compute_offsets() {
|
||||
InstanceKlass* k = vmClasses::DirectMethodHandle_StaticAccessor_klass();
|
||||
DIRECTMETHODHANDLE_STATIC_ACCESSOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void java_lang_invoke_DirectMethodHandle_StaticAccessor::serialize_offsets(SerializeClosure* f) {
|
||||
DIRECTMETHODHANDLE_STATIC_ACCESSOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Support for java_lang_invoke_DirectMethodHandle$Accessor
|
||||
|
||||
int java_lang_invoke_DirectMethodHandle_Accessor::_field_offset_offset;
|
||||
|
||||
int java_lang_invoke_DirectMethodHandle_Accessor::field_offset(oop dmh) {
|
||||
assert(_field_offset_offset != 0, "");
|
||||
return dmh->int_field(_field_offset_offset);
|
||||
}
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_Accessor::set_field_offset(oop dmh, int field_offset) {
|
||||
assert(_field_offset_offset != 0, "");
|
||||
dmh->int_field_put(_field_offset_offset, field_offset);
|
||||
}
|
||||
|
||||
#define DIRECTMETHODHANDLE_ACCESSOR_FIELDS_DO(macro) \
|
||||
macro(_field_offset_offset, k, vmSymbols::field_offset_name(), int_signature, false)
|
||||
|
||||
void java_lang_invoke_DirectMethodHandle_Accessor::compute_offsets() {
|
||||
InstanceKlass* k = vmClasses::DirectMethodHandle_Accessor_klass();
|
||||
DIRECTMETHODHANDLE_ACCESSOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void java_lang_invoke_DirectMethodHandle_Accessor::serialize_offsets(SerializeClosure* f) {
|
||||
DIRECTMETHODHANDLE_ACCESSOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Support for java_lang_invoke_MethodHandle
|
||||
|
||||
int java_lang_invoke_MethodHandle::_type_offset;
|
||||
|
||||
@@ -59,8 +59,6 @@ class RecordComponent;
|
||||
f(java_lang_invoke_MethodType) \
|
||||
f(java_lang_invoke_CallSite) \
|
||||
f(java_lang_invoke_ConstantCallSite) \
|
||||
f(java_lang_invoke_DirectMethodHandle_StaticAccessor) \
|
||||
f(java_lang_invoke_DirectMethodHandle_Accessor) \
|
||||
f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
|
||||
f(java_security_AccessControlContext) \
|
||||
f(java_lang_reflect_AccessibleObject) \
|
||||
@@ -295,9 +293,7 @@ class java_lang_Class : AllStatic {
|
||||
static void set_init_lock(oop java_class, oop init_lock);
|
||||
static void set_protection_domain(oop java_class, oop protection_domain);
|
||||
static void set_class_loader(oop java_class, oop class_loader);
|
||||
public: // DCEVM
|
||||
static void set_component_mirror(oop java_class, oop comp_mirror);
|
||||
private:
|
||||
static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
|
||||
Handle classData, TRAPS);
|
||||
static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
|
||||
@@ -1012,55 +1008,6 @@ class java_lang_invoke_DirectMethodHandle: AllStatic {
|
||||
static int member_offset() { CHECK_INIT(_member_offset); }
|
||||
};
|
||||
|
||||
// Interface to java.lang.invoke.DirectMethodHandle$StaticAccessor objects
|
||||
|
||||
class java_lang_invoke_DirectMethodHandle_StaticAccessor: AllStatic {
|
||||
friend class JavaClasses;
|
||||
|
||||
private:
|
||||
static int _static_offset_offset; // offset to static field
|
||||
|
||||
static void compute_offsets();
|
||||
|
||||
public:
|
||||
// Accessors
|
||||
static long static_offset(oop dmh);
|
||||
static void set_static_offset(oop dmh, long value);
|
||||
|
||||
// Testers
|
||||
static bool is_subclass(Klass* klass) {
|
||||
return klass->is_subclass_of(vmClasses::DirectMethodHandle_StaticAccessor_klass());
|
||||
}
|
||||
static bool is_instance(oop obj);
|
||||
|
||||
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
|
||||
};
|
||||
|
||||
// Interface to java.lang.invoke.DirectMethodHandle$Accessor objects
|
||||
|
||||
class java_lang_invoke_DirectMethodHandle_Accessor: AllStatic {
|
||||
friend class JavaClasses;
|
||||
|
||||
private:
|
||||
static int _field_offset_offset; // offset to field
|
||||
|
||||
static void compute_offsets();
|
||||
|
||||
public:
|
||||
// Accessors
|
||||
static int field_offset(oop dmh);
|
||||
static void set_field_offset(oop dmh, int value);
|
||||
|
||||
// Testers
|
||||
static bool is_subclass(Klass* klass) {
|
||||
return klass->is_subclass_of(vmClasses::DirectMethodHandle_Accessor_klass());
|
||||
}
|
||||
static bool is_instance(oop obj);
|
||||
|
||||
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
|
||||
};
|
||||
|
||||
|
||||
// Interface to java.lang.invoke.LambdaForm objects
|
||||
// (These are a private interface for managing adapter code generation.)
|
||||
|
||||
|
||||
@@ -272,14 +272,6 @@ inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) {
|
||||
return obj != NULL && is_subclass(obj->klass());
|
||||
}
|
||||
|
||||
inline bool java_lang_invoke_DirectMethodHandle_StaticAccessor::is_instance(oop obj) {
|
||||
return obj != NULL && is_subclass(obj->klass());
|
||||
}
|
||||
|
||||
inline bool java_lang_invoke_DirectMethodHandle_Accessor::is_instance(oop obj) {
|
||||
return obj != NULL && is_subclass(obj->klass());
|
||||
}
|
||||
|
||||
inline bool java_lang_Module::is_instance(oop obj) {
|
||||
return obj != NULL && obj->klass() == vmClasses::Module_klass();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook(
|
||||
loader_data,
|
||||
&cl_info,
|
||||
ClassFileParser::BROADCAST, // publicity level
|
||||
false,
|
||||
CHECK_NULL);
|
||||
const ClassInstanceInfo* cl_inst_info = cl_info.class_hidden_info_ptr();
|
||||
InstanceKlass* new_ik = parser.create_instance_klass(true, // changed_by_loadhook
|
||||
@@ -168,7 +167,6 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,
|
||||
Symbol* name,
|
||||
ClassLoaderData* loader_data,
|
||||
const ClassLoadInfo& cl_info,
|
||||
const bool pick_newest,
|
||||
TRAPS) {
|
||||
assert(stream != NULL, "invariant");
|
||||
assert(loader_data != NULL, "invariant");
|
||||
@@ -198,7 +196,6 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,
|
||||
loader_data,
|
||||
&cl_info,
|
||||
ClassFileParser::BROADCAST, // publicity level
|
||||
pick_newest,
|
||||
CHECK_NULL);
|
||||
|
||||
const ClassInstanceInfo* cl_inst_info = cl_info.class_hidden_info_ptr();
|
||||
|
||||
@@ -64,7 +64,6 @@ class KlassFactory : AllStatic {
|
||||
Symbol* name,
|
||||
ClassLoaderData* loader_data,
|
||||
const ClassLoadInfo& cl_info,
|
||||
const bool pick_newest,
|
||||
TRAPS);
|
||||
static InstanceKlass* check_shared_class_file_load_hook(
|
||||
InstanceKlass* ik,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation) replace old_class by new class in dictionary.
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
@@ -92,20 +92,6 @@ LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
|
||||
return pp;
|
||||
}
|
||||
|
||||
// (DCEVM) update constraint entries to new classes, called from dcevm redefinition code only
|
||||
void LoaderConstraintTable::update_after_redefinition() {
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
LoaderConstraintEntry** p = bucket_addr(index);
|
||||
while(*p) {
|
||||
LoaderConstraintEntry* probe = *p;
|
||||
if (probe->klass() != NULL) {
|
||||
// We swap the class with the newest version with an assumption that the hash will be the same
|
||||
probe->set_klass((InstanceKlass*) probe->klass()->newest_version());
|
||||
}
|
||||
p = probe->next_addr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoaderConstraintTable::purge_loader_constraints() {
|
||||
assert_locked_or_safepoint(SystemDictionary_lock);
|
||||
@@ -460,7 +446,7 @@ void LoaderConstraintTable::verify(PlaceholderTable* placeholders) {
|
||||
if (k != NULL) {
|
||||
// We found the class in the dictionary, so we should
|
||||
// make sure that the Klass* matches what we already have.
|
||||
guarantee(k == probe->klass()->newest_version(), "klass should be in dictionary");
|
||||
guarantee(k == probe->klass(), "klass should be in dictionary");
|
||||
} else {
|
||||
// If we don't find the class in the dictionary, it
|
||||
// has to be in the placeholders table.
|
||||
|
||||
@@ -55,9 +55,6 @@ public:
|
||||
return (LoaderConstraintEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i);
|
||||
}
|
||||
|
||||
// (DCEVM) update all klasses with newest version
|
||||
void update_after_redefinition();
|
||||
|
||||
// Check class loader constraints
|
||||
bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1,
|
||||
InstanceKlass* klass2, Handle loader2);
|
||||
|
||||
@@ -229,7 +229,7 @@ void verify_dictionary_entry(Symbol* class_name, InstanceKlass* k) {
|
||||
assert(class_name == k->name(), "Must be the same");
|
||||
unsigned int name_hash = dictionary->compute_hash(class_name);
|
||||
InstanceKlass* kk = dictionary->find_class(name_hash, class_name);
|
||||
assert((kk == k && !k->is_redefining()) || (k->is_redefining() && kk == k->old_version()), "should be present in the dictionary");
|
||||
assert(kk == k, "should be present in dictionary");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -266,7 +266,6 @@ Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader
|
||||
if (HAS_PENDING_EXCEPTION || klass == NULL) {
|
||||
handle_resolution_exception(class_name, throw_error, CHECK_NULL);
|
||||
}
|
||||
assert(klass == NULL || klass->new_version() == NULL || klass->newest_version()->is_redefining(), "must be");
|
||||
return klass;
|
||||
}
|
||||
|
||||
@@ -825,14 +824,11 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream(
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS) {
|
||||
|
||||
EventClassLoad class_load_start_event;
|
||||
ClassLoaderData* loader_data;
|
||||
|
||||
bool is_redefining = (old_klass != NULL);
|
||||
|
||||
// - for hidden classes that are not strong: create a new CLD that has a class holder and
|
||||
// whose loader is the Lookup class's loader.
|
||||
// - for hidden class: add the class to the Lookup class's loader's CLD.
|
||||
@@ -848,13 +844,8 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream(
|
||||
class_name,
|
||||
loader_data,
|
||||
cl_info,
|
||||
is_redefining, // pick_newest
|
||||
CHECK_NULL);
|
||||
assert(k != NULL, "no klass created");
|
||||
if (is_redefining && k != NULL) {
|
||||
k->set_redefining(true);
|
||||
k->set_old_version(old_klass);
|
||||
}
|
||||
|
||||
// Hidden classes that are not strong must update ClassLoaderData holder
|
||||
// so that they can be unloaded when the mirror is no longer referenced.
|
||||
@@ -893,12 +884,10 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream(
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS) {
|
||||
|
||||
HandleMark hm(THREAD);
|
||||
|
||||
bool is_redefining = (old_klass != NULL);
|
||||
ClassLoaderData* loader_data = register_loader(class_loader);
|
||||
|
||||
// Classloaders that support parallelism, e.g. bootstrap classloader,
|
||||
@@ -913,7 +902,6 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream(
|
||||
InstanceKlass* k = NULL;
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// FIXME: (DCEVM) what to do during redefinition?
|
||||
if (!DumpSharedSpaces) {
|
||||
k = SystemDictionaryShared::lookup_from_stream(class_name,
|
||||
class_loader,
|
||||
@@ -924,12 +912,7 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream(
|
||||
#endif
|
||||
|
||||
if (k == NULL) {
|
||||
k = KlassFactory::create_from_stream(st, class_name, loader_data, cl_info, is_redefining, CHECK_NULL);
|
||||
}
|
||||
|
||||
if (is_redefining && k != NULL) {
|
||||
k->set_redefining(true);
|
||||
k->set_old_version(old_klass);
|
||||
k = KlassFactory::create_from_stream(st, class_name, loader_data, cl_info, CHECK_NULL);
|
||||
}
|
||||
|
||||
assert(k != NULL, "no klass created");
|
||||
@@ -940,10 +923,10 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream(
|
||||
// If a class loader supports parallel classloading, handle parallel define requests.
|
||||
// find_or_define_instance_class may return a different InstanceKlass,
|
||||
// in which case the old k would be deallocated
|
||||
if (is_parallelCapable(class_loader) && !is_redefining) {
|
||||
if (is_parallelCapable(class_loader)) {
|
||||
k = find_or_define_instance_class(h_name, class_loader, k, CHECK_NULL);
|
||||
} else {
|
||||
define_instance_class(k, old_klass, class_loader, THREAD);
|
||||
define_instance_class(k, class_loader, THREAD);
|
||||
|
||||
// If defining the class throws an exception register 'k' for cleanup.
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
@@ -963,12 +946,11 @@ InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS) {
|
||||
if (cl_info.is_hidden()) {
|
||||
return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, old_klass, CHECK_NULL);
|
||||
return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
|
||||
} else {
|
||||
return resolve_class_from_stream(st, class_name, class_loader, cl_info, old_klass, CHECK_NULL);
|
||||
return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,11 +1392,10 @@ static void post_class_define_event(InstanceKlass* k, const ClassLoaderData* def
|
||||
}
|
||||
}
|
||||
|
||||
void SystemDictionary::define_instance_class(InstanceKlass* k, InstanceKlass* old_klass, Handle class_loader, TRAPS) {
|
||||
void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS) {
|
||||
|
||||
ClassLoaderData* loader_data = k->class_loader_data();
|
||||
assert(loader_data->class_loader() == class_loader(), "they must be the same");
|
||||
bool is_redefining = (old_klass != NULL);
|
||||
|
||||
// Bootstrap and other parallel classloaders don't acquire a lock,
|
||||
// they use placeholder token.
|
||||
@@ -1438,17 +1419,8 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, InstanceKlass* ol
|
||||
// which will require a token to perform the define class
|
||||
Symbol* name_h = k->name();
|
||||
Dictionary* dictionary = loader_data->dictionary();
|
||||
|
||||
unsigned int name_hash = dictionary->compute_hash(name_h);
|
||||
if (is_redefining) {
|
||||
// Update all dictionaries containing old_class to new_class
|
||||
// outcome must be same as result of standard redefinition, that does not create a new Klass
|
||||
ClassLoaderDataGraph_lock->lock();
|
||||
bool ok = ClassLoaderDataGraph::dictionary_classes_do_update_klass(name_h, k, old_klass);
|
||||
ClassLoaderDataGraph_lock->unlock();
|
||||
assert (ok, "must have found old class and updated!");
|
||||
}
|
||||
check_constraints(name_hash, k, class_loader, !is_redefining, CHECK);
|
||||
check_constraints(name_hash, k, class_loader, true, CHECK);
|
||||
|
||||
// Register class just loaded with class loader (placed in ArrayList)
|
||||
// Note we do this before updating the dictionary, as this can
|
||||
@@ -1477,7 +1449,7 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, InstanceKlass* ol
|
||||
k->eager_initialize(THREAD);
|
||||
|
||||
// notify jvmti
|
||||
if (!is_redefining && JvmtiExport::should_post_class_load()) {
|
||||
if (JvmtiExport::should_post_class_load()) {
|
||||
JvmtiExport::post_class_load(THREAD, k);
|
||||
}
|
||||
post_class_define_event(k, loader_data);
|
||||
@@ -1552,7 +1524,7 @@ InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handl
|
||||
}
|
||||
}
|
||||
|
||||
define_instance_class(k, NULL, class_loader, THREAD);
|
||||
define_instance_class(k, class_loader, THREAD);
|
||||
|
||||
// definer must notify any waiting threads
|
||||
{
|
||||
@@ -1615,19 +1587,6 @@ void SystemDictionary::add_to_hierarchy(InstanceKlass* k) {
|
||||
}
|
||||
}
|
||||
|
||||
// (DCEVM) - remove from klass hierarchy
|
||||
void SystemDictionary::remove_from_hierarchy(InstanceKlass* k) {
|
||||
assert(k != NULL, "just checking");
|
||||
|
||||
// remove receiver from sibling list
|
||||
k->remove_from_sibling_list();
|
||||
}
|
||||
|
||||
// (DCEVM)
|
||||
void SystemDictionary::update_constraints_after_redefinition() {
|
||||
constraints()->update_after_redefinition();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GC support
|
||||
|
||||
@@ -1728,7 +1687,7 @@ void SystemDictionary::check_constraints(unsigned int name_hash,
|
||||
// else - ok, class loaded by a different thread in parallel.
|
||||
// We should only have found it if it was done loading and ok to use.
|
||||
|
||||
if ((defining == true) || (k != check && (!AllowEnhancedClassRedefinition || k->old_version() != check))) {
|
||||
if ((defining == true) || (k != check)) {
|
||||
throwException = true;
|
||||
ss.print("loader %s", loader_data->loader_name_and_id());
|
||||
ss.print(" attempted duplicate %s definition for %s. (%s)",
|
||||
|
||||
@@ -124,7 +124,6 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS);
|
||||
|
||||
// Resolve a class from stream (called by jni_DefineClass and JVM_DefineClass)
|
||||
@@ -133,7 +132,6 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS);
|
||||
|
||||
public:
|
||||
@@ -142,7 +140,6 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
const ClassLoadInfo& cl_info,
|
||||
InstanceKlass* old_klass,
|
||||
TRAPS);
|
||||
|
||||
// Lookup an already loaded class. If not found NULL is returned.
|
||||
@@ -205,10 +202,6 @@ class SystemDictionary : AllStatic {
|
||||
// Initialization
|
||||
static void initialize(TRAPS);
|
||||
|
||||
// (DCEVM) Enhanced class redefinition
|
||||
static void remove_from_hierarchy(InstanceKlass* k);
|
||||
static void update_constraints_after_redefinition();
|
||||
|
||||
protected:
|
||||
// Returns the class loader data to be used when looking up/updating the
|
||||
// system dictionary.
|
||||
@@ -343,7 +336,7 @@ private:
|
||||
Handle lockObject,
|
||||
bool* throw_circularity_error);
|
||||
|
||||
static void define_instance_class(InstanceKlass* k, InstanceKlass* old_klass, Handle class_loader, TRAPS);
|
||||
static void define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS);
|
||||
static InstanceKlass* find_or_define_helper(Symbol* class_name,
|
||||
Handle class_loader,
|
||||
InstanceKlass* k, TRAPS);
|
||||
|
||||
@@ -270,7 +270,7 @@ bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_ve
|
||||
Symbol* name = klass->name();
|
||||
Klass* refl_magic_klass = vmClasses::reflect_MagicAccessorImpl_klass();
|
||||
|
||||
bool is_reflect = refl_magic_klass != NULL && (klass->is_subtype_of(refl_magic_klass) || klass->is_subtype_of(refl_magic_klass->newest_version()));
|
||||
bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass);
|
||||
|
||||
return (should_verify_for(klass->class_loader(), should_verify_class) &&
|
||||
// return if the class is a bootstrapping class
|
||||
|
||||
@@ -375,7 +375,6 @@ class ClassVerifier : public StackObj {
|
||||
|
||||
VerificationType object_type() const;
|
||||
|
||||
InstanceKlass* _klass_to_verify;
|
||||
InstanceKlass* _klass; // the class being verified
|
||||
methodHandle _method; // current method being verified
|
||||
VerificationType _this_type; // the verification type of the current class
|
||||
|
||||
@@ -109,8 +109,6 @@
|
||||
\
|
||||
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
|
||||
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
|
||||
do_klass(DirectMethodHandle_StaticAccessor_klass, java_lang_invoke_DirectMethodHandle_StaticAccessor ) \
|
||||
do_klass(DirectMethodHandle_Accessor_klass, java_lang_invoke_DirectMethodHandle_Accessor ) \
|
||||
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle ) \
|
||||
do_klass(VarHandle_klass, java_lang_invoke_VarHandle ) \
|
||||
do_klass(MemberName_klass, java_lang_invoke_MemberName ) \
|
||||
|
||||
@@ -259,13 +259,3 @@ BasicType vmClasses::box_klass_type(Klass* k) {
|
||||
}
|
||||
return T_OBJECT;
|
||||
}
|
||||
|
||||
bool vmClasses::update_vm_klass(InstanceKlass* old_klass, InstanceKlass* new_klass) {
|
||||
for (int id = static_cast<int>(vmClassID::FIRST); id < static_cast<int>(vmClassID::LIMIT); id++) {
|
||||
if (_klasses[id] == old_klass) {
|
||||
_klasses[id] = new_klass;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user