You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jvmti-lockRedefine-java8.patch 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. diff --git a/src/share/vm/prims/jvmtiEnv.cpp b/src/share/vm/prims/jvmtiEnv.cpp
  2. index 9cafbd1..e24f8c9 100644
  3. --- a/src/share/vm/prims/jvmtiEnv.cpp
  4. +++ b/src/share/vm/prims/jvmtiEnv.cpp
  5. @@ -298,10 +298,12 @@
  6. //TODO: add locking
  7. if (AllowEnhancedClassRedefinition) {
  8. VM_EnhancedRedefineClasses op(class_count, class_definitions, jvmti_class_load_kind_redefine);
  9. + MutexLocker sd_mutex(RedefineClasses_lock);
  10. VMThread::execute(&op);
  11. return (op.check_error());
  12. }
  13. VM_RedefineClasses op(class_count, class_definitions, jvmti_class_load_kind_redefine);
  14. + MutexLocker sd_mutex(RedefineClasses_lock);
  15. VMThread::execute(&op);
  16. return (op.check_error());
  17. } /* end RedefineClasses */
  18. diff --git a/src/share/vm/runtime/mutexLocker.cpp b/src/share/vm/runtime/mutexLocker.cpp
  19. index f358c75..02377a4 100644
  20. --- a/src/share/vm/runtime/mutexLocker.cpp
  21. +++ b/src/share/vm/runtime/mutexLocker.cpp
  22. @@ -38,6 +38,7 @@
  23. // Consider using GCC's __read_mostly.
  24. Mutex* Patching_lock = NULL;
  25. +Mutex* RedefineClasses_lock = NULL;
  26. Monitor* SystemDictionary_lock = NULL;
  27. Mutex* PackageTable_lock = NULL;
  28. Mutex* CompiledIC_lock = NULL;
  29. @@ -279,6 +280,7 @@
  30. def(ProfileVM_lock , Monitor, special, false); // used for profiling of the VMThread
  31. def(CompileThread_lock , Monitor, nonleaf+5, false );
  32. def(PeriodicTask_lock , Monitor, nonleaf+5, true);
  33. + def(RedefineClasses_lock , Mutex , nonleaf+7, false ); // for ensuring that class redefinition is not done in parallel
  34. #ifdef INCLUDE_TRACE
  35. def(JfrMsg_lock , Monitor, leaf, true);
  36. diff --git a/src/share/vm/runtime/mutexLocker.hpp b/src/share/vm/runtime/mutexLocker.hpp
  37. index be86bac..a77f546 100644
  38. --- a/src/share/vm/runtime/mutexLocker.hpp
  39. +++ b/src/share/vm/runtime/mutexLocker.hpp
  40. @@ -46,6 +46,7 @@
  41. // Mutexes used in the VM.
  42. extern Mutex* Patching_lock; // a lock used to guard code patching of compiled code
  43. +extern Mutex* RedefineClasses_lock; // a lock on class redefinition
  44. extern Monitor* SystemDictionary_lock; // a lock on the system dictonary
  45. extern Mutex* PackageTable_lock; // a lock on the class loader package table
  46. extern Mutex* CompiledIC_lock; // a lock used to guard compiled IC patching and access
  47. diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
  48. index 0dc86d9..9f4c2e9 100644
  49. --- a/src/share/vm/runtime/thread.cpp
  50. +++ b/src/share/vm/runtime/thread.cpp
  51. @@ -910,6 +910,15 @@
  52. return false;
  53. }
  54. +bool Thread::owns_locks_but_redefine_classes_lock() const {
  55. + for(Monitor *cur = _owned_locks; cur; cur = cur->next()) {
  56. + if (cur != RedefineClasses_lock && cur->rank() != Mutex::redefine_classes) {
  57. + return true;
  58. + }
  59. + }
  60. + return false;
  61. +}
  62. +
  63. #endif
  64. diff --git a/src/share/vm/runtime/thread.hpp b/src/share/vm/runtime/thread.hpp
  65. index 1117c87..77b716c 100644
  66. --- a/src/share/vm/runtime/thread.hpp
  67. +++ b/src/share/vm/runtime/thread.hpp
  68. @@ -211,11 +211,14 @@
  69. void enter_signal_handler() { _num_nested_signal++; }
  70. void leave_signal_handler() { _num_nested_signal--; }
  71. bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
  72. + Mutex* redefine_classes_mutex() { return _redefine_classes_mutex; }
  73. private:
  74. // Debug tracing
  75. static void trace(const char* msg, const Thread* const thread) PRODUCT_RETURN;
  76. + Mutex* _redefine_classes_mutex;
  77. +
  78. // Active_handles points to a block of handles
  79. JNIHandleBlock* _active_handles;
  80. @@ -585,6 +588,7 @@
  81. void print_owned_locks() const { print_owned_locks_on(tty); }
  82. Monitor* owned_locks() const { return _owned_locks; }
  83. bool owns_locks() const { return owned_locks() != NULL; }
  84. + bool owns_locks_but_redefine_classes_lock() const;
  85. bool owns_locks_but_compiled_lock() const;
  86. // Deadlock detection