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.

light-jdk8u66-b17-deopt-cp.patch 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp
  2. index fa7986b..0910a7d 100644
  3. --- a/src/share/vm/classfile/classFileParser.cpp
  4. +++ b/src/share/vm/classfile/classFileParser.cpp
  5. @@ -4264,6 +4264,30 @@
  6. }
  7. }
  8. + if (this_klass->external_name() != NULL && HotswapDeoptClassPath != NULL) {
  9. + const char* deopt_path = HotswapDeoptClassPath;
  10. + const char* const end = deopt_path + strlen(deopt_path);
  11. + bool deopt_found = false;
  12. + while (!deopt_found && deopt_path < end) {
  13. + const char* tmp_end = strchr(deopt_path, ',');
  14. + if (tmp_end == NULL) {
  15. + tmp_end = end;
  16. + }
  17. + char* deopt_segm_path = NEW_C_HEAP_ARRAY(char, tmp_end - deopt_path + 1, mtInternal);
  18. + memcpy(deopt_segm_path, deopt_path, tmp_end - deopt_path);
  19. + deopt_segm_path[tmp_end - deopt_path] = '\0';
  20. + if (strstr(this_klass->external_name(), deopt_segm_path) != NULL) {
  21. + if (TraceRedefineClasses > 0) {
  22. + tty->print_cr("Including in deoptimization : %s", this_klass->external_name());
  23. + }
  24. + this_klass->set_deoptimization_incl(true);
  25. + deopt_found = true;
  26. + }
  27. + FREE_C_HEAP_ARRAY(char, deopt_segm_path, mtInternal);
  28. + deopt_path = tmp_end + 1;
  29. + }
  30. + }
  31. +
  32. if (TraceClassResolution) {
  33. ResourceMark rm;
  34. // print out the superclass.
  35. diff --git a/src/share/vm/classfile/systemDictionary.cpp b/src/share/vm/classfile/systemDictionary.cpp
  36. index e40b061..588e0e5 100644
  37. --- a/src/share/vm/classfile/systemDictionary.cpp
  38. +++ b/src/share/vm/classfile/systemDictionary.cpp
  39. @@ -1255,6 +1255,31 @@
  40. ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh));
  41. }
  42. + if (HotswapDeoptClassPath != NULL) {
  43. + const char* deopt_path = HotswapDeoptClassPath;
  44. + const char* const end = deopt_path + strlen(deopt_path);
  45. + bool deopt_found = false;
  46. + while (!deopt_found && deopt_path < end) {
  47. + const char* tmp_end = strchr(deopt_path, ',');
  48. + if (tmp_end == NULL) {
  49. + tmp_end = end;
  50. + }
  51. + char* deopt_segm_path = NEW_C_HEAP_ARRAY(char, tmp_end - deopt_path + 1, mtInternal);
  52. + memcpy(deopt_segm_path, deopt_path, tmp_end - deopt_path);
  53. + deopt_segm_path[tmp_end - deopt_path] = '\0';
  54. + if (strstr(ik->external_name(), deopt_segm_path) != NULL) {
  55. + if (TraceRedefineClasses > 0) {
  56. + tty->print_cr("Including in deoptimization : %s", ik->external_name());
  57. + }
  58. + ik->set_deoptimization_incl(true);
  59. + deopt_found = true;
  60. + }
  61. + FREE_C_HEAP_ARRAY(char, deopt_segm_path, mtInternal);
  62. + deopt_path = tmp_end + 1;
  63. + }
  64. + }
  65. +
  66. +
  67. if (TraceClassLoading) {
  68. ResourceMark rm;
  69. tty->print("[Loaded %s", ik->external_name());
  70. diff --git a/src/share/vm/code/codeCache.cpp b/src/share/vm/code/codeCache.cpp
  71. index c9059d7..af10381 100644
  72. --- a/src/share/vm/code/codeCache.cpp
  73. +++ b/src/share/vm/code/codeCache.cpp
  74. @@ -709,6 +709,13 @@
  75. }
  76. #endif // HOTSWAP
  77. +// Deoptimize all methods having deopt-include flag
  78. +void CodeCache::mark_all_incl_nmethods_for_deoptimization() {
  79. + MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
  80. + FOR_ALL_ALIVE_NMETHODS(nm) {
  81. + nm->mark_for_deoptimization_incl();
  82. + }
  83. +}
  84. // Deoptimize all methods
  85. void CodeCache::mark_all_nmethods_for_deoptimization() {
  86. diff --git a/src/share/vm/code/codeCache.hpp b/src/share/vm/code/codeCache.hpp
  87. index f098284..d4a1363 100644
  88. --- a/src/share/vm/code/codeCache.hpp
  89. +++ b/src/share/vm/code/codeCache.hpp
  90. @@ -184,6 +184,7 @@
  91. // tells how many nmethods have dependencies
  92. static int number_of_nmethods_with_dependencies();
  93. + static void mark_all_incl_nmethods_for_deoptimization();
  94. static int get_codemem_full_count() { return _codemem_full_count; }
  95. };
  96. diff --git a/src/share/vm/code/nmethod.cpp b/src/share/vm/code/nmethod.cpp
  97. index 6ea39ae..bf2db7e 100644
  98. --- a/src/share/vm/code/nmethod.cpp
  99. +++ b/src/share/vm/code/nmethod.cpp
  100. @@ -476,6 +476,7 @@
  101. _lazy_critical_native = 0;
  102. _has_wide_vectors = 0;
  103. _marked_for_deoptimization = 0;
  104. + _deoptimization_incl = false;
  105. _lock_count = 0;
  106. _stack_traversal_mark = 0;
  107. _unload_reported = false; // jvmti state
  108. @@ -688,6 +689,7 @@
  109. _dependencies_offset = _scopes_pcs_offset;
  110. _handler_table_offset = _dependencies_offset;
  111. _nul_chk_table_offset = _handler_table_offset;
  112. +
  113. _nmethod_end_offset = _nul_chk_table_offset;
  114. _compile_id = compile_id;
  115. _comp_level = CompLevel_none;
  116. @@ -697,6 +699,8 @@
  117. _exception_cache = NULL;
  118. _pc_desc_cache.reset_to(NULL);
  119. _hotness_counter = NMethodSweeper::hotness_counter_reset_val();
  120. + if (method != NULL)
  121. + _deoptimization_incl = method->method_holder()->is_deoptimization_incl();
  122. code_buffer->copy_values_to(this);
  123. if (ScavengeRootsInCode) {
  124. @@ -772,6 +776,7 @@
  125. _metadata_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize);
  126. _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize);
  127. _scopes_pcs_offset = _scopes_data_offset;
  128. +
  129. _dependencies_offset = _scopes_pcs_offset;
  130. _handler_table_offset = _dependencies_offset;
  131. _nul_chk_table_offset = _handler_table_offset;
  132. @@ -784,6 +789,8 @@
  133. _exception_cache = NULL;
  134. _pc_desc_cache.reset_to(NULL);
  135. _hotness_counter = NMethodSweeper::hotness_counter_reset_val();
  136. + if (method != NULL)
  137. + _deoptimization_incl = method->method_holder()->is_deoptimization_incl();
  138. code_buffer->copy_values_to(this);
  139. if (ScavengeRootsInCode) {
  140. @@ -900,6 +907,9 @@
  141. _exception_cache = NULL;
  142. _pc_desc_cache.reset_to(scopes_pcs_begin());
  143. + if (method != NULL)
  144. + _deoptimization_incl = method->method_holder()->is_deoptimization_incl();
  145. +
  146. // Copy contents of ScopeDescRecorder to nmethod
  147. code_buffer->copy_values_to(this);
  148. debug_info->copy_to(this);
  149. diff --git a/src/share/vm/code/nmethod.hpp b/src/share/vm/code/nmethod.hpp
  150. index b7d6890..3de4757 100644
  151. --- a/src/share/vm/code/nmethod.hpp
  152. +++ b/src/share/vm/code/nmethod.hpp
  153. @@ -184,6 +184,8 @@
  154. bool _marked_for_reclamation; // Used by NMethodSweeper (set only by sweeper)
  155. bool _marked_for_deoptimization; // Used for stack deoptimization
  156. + bool _deoptimization_incl;
  157. +
  158. // used by jvmti to track if an unload event has been posted for this nmethod.
  159. bool _unload_reported;
  160. @@ -470,6 +472,11 @@
  161. bool is_marked_for_deoptimization() const { return _marked_for_deoptimization; }
  162. void mark_for_deoptimization() { _marked_for_deoptimization = true; }
  163. + bool is_deoptimization_incl() const { return _deoptimization_incl; }
  164. + void set_deoptimization_incl(bool z) { _deoptimization_incl = z; }
  165. +
  166. + void mark_for_deoptimization_incl() { if (_deoptimization_incl) _marked_for_deoptimization = true; }
  167. +
  168. void make_unloaded(BoolObjectClosure* is_alive, oop cause);
  169. bool has_dependencies() { return dependencies_size() != 0; }
  170. diff --git a/src/share/vm/oops/klass.cpp b/src/share/vm/oops/klass.cpp
  171. index 2e3d192..a889458 100644
  172. --- a/src/share/vm/oops/klass.cpp
  173. +++ b/src/share/vm/oops/klass.cpp
  174. @@ -188,6 +188,7 @@
  175. set_redefinition_flags(Klass::NoRedefinition);
  176. set_redefining(false);
  177. + set_deoptimization_incl(false);
  178. set_new_version(NULL);
  179. set_old_version(NULL);
  180. set_redefinition_index(-1);
  181. @@ -236,6 +237,8 @@
  182. if (FastSuperclassLimit == 0) {
  183. // None of the other machinery matters.
  184. set_super(k);
  185. + if (k != NULL && k->is_deoptimization_incl())
  186. + set_deoptimization_incl(true);
  187. return;
  188. }
  189. if (k == NULL) {
  190. @@ -247,6 +250,8 @@
  191. "initialize this only once to a non-trivial value");
  192. set_super(k);
  193. Klass* sup = k;
  194. + if (sup->is_deoptimization_incl())
  195. + set_deoptimization_incl(true);
  196. int sup_depth = sup->super_depth();
  197. juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
  198. if (!can_be_primary_super_slow())
  199. diff --git a/src/share/vm/oops/klass.hpp b/src/share/vm/oops/klass.hpp
  200. index e3fc3bd..c5fc46d 100644
  201. --- a/src/share/vm/oops/klass.hpp
  202. +++ b/src/share/vm/oops/klass.hpp
  203. @@ -177,6 +177,7 @@
  204. bool _original_field_offsets_changed; // Did the original field offsets of this class change during class redefinition?
  205. int * _update_information; // Update information
  206. bool _is_redefining;
  207. + bool _deoptimization_incl; // True if class methods are included in deoptimization
  208. // Biased locking implementation and statistics
  209. // (the 64-bit chunk goes first, to avoid some fragmentation)
  210. @@ -263,6 +264,9 @@
  211. int *update_information() const { return _update_information; }
  212. void set_update_information(int *info) { _update_information = info; }
  213. + bool is_deoptimization_incl() const { return _deoptimization_incl; }
  214. + void set_deoptimization_incl(bool z) { _deoptimization_incl = z; }
  215. +
  216. // Revision number for redefined classes, -1 for originally loaded classes
  217. bool was_redefined() const { return _revision_number != -1; }
  218. jint revision_number() const { return _revision_number; }
  219. diff --git a/src/share/vm/prims/jvmtiRedefineClasses2.cpp b/src/share/vm/prims/jvmtiRedefineClasses2.cpp
  220. index f545b98..4fad1cb 100644
  221. --- a/src/share/vm/prims/jvmtiRedefineClasses2.cpp
  222. +++ b/src/share/vm/prims/jvmtiRedefineClasses2.cpp
  223. @@ -443,6 +443,8 @@
  224. new_class->set_redefinition_flags(redefinition_flags);
  225. + new_class->set_deoptimization_incl(true);
  226. +
  227. _max_redefinition_flags = _max_redefinition_flags | redefinition_flags;
  228. if ((redefinition_flags & Klass::ModifyInstances) != 0) {
  229. @@ -1572,7 +1574,10 @@
  230. if (0 && JvmtiExport::all_dependencies_are_recorded()) {
  231. Universe::flush_evol_dependents_on(k_h);
  232. } else {
  233. - CodeCache::mark_all_nmethods_for_deoptimization();
  234. + if (HotswapDeoptClassPath == NULL)
  235. + CodeCache::mark_all_nmethods_for_deoptimization();
  236. + else
  237. + CodeCache::mark_all_incl_nmethods_for_deoptimization();
  238. ResourceMark rm(THREAD);
  239. DeoptimizationMarker dm;
  240. diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
  241. index 9a51218..b8ca7bb 100644
  242. --- a/src/share/vm/runtime/globals.hpp
  243. +++ b/src/share/vm/runtime/globals.hpp
  244. @@ -3962,7 +3962,16 @@
  245. \
  246. product_pd(bool, PreserveFramePointer, \
  247. "Use the FP register for holding the frame pointer " \
  248. - "and not as a general purpose register.")
  249. + "and not as a general purpose register.") \
  250. + \
  251. + product(ccstr, HotswapDeoptClassPath, NULL, \
  252. + "Comma separated list of packages containing classes that are " \
  253. + "expected to be redefined. If com.sun.proxy is used by " \
  254. + "application and proxied class is redefined, then this option " \
  255. + "should contain 'com.sun.proxy'. If the option is not defined, " \
  256. + "then all classes will be deoptimized on hotswap. Using this " \
  257. + "option improves hotswap performance. ")
  258. +
  259. /*
  260. * Macros for factoring of globals