# HG changeset patch # User Tom Rodriguez # Date 1446765690 28800 # Node ID eada427470a3aa671dd7f4fdce5197b60d1e4351 # Parent 2d21c13d7829a3457eeea3ba597e6b92b2fd0710 Use proper GC barriers when clearing _jvmci_installed_code diff -r 2d21c13d7829 -r eada427470a3 src/share/vm/code/nmethod.cpp --- a/src/share/vm/code/nmethod.cpp Thu Nov 05 15:18:36 2015 -0800 +++ b/src/share/vm/code/nmethod.cpp Thu Nov 05 15:21:30 2015 -0800 @@ -1978,9 +1978,7 @@ if (_jvmci_installed_code != NULL) { if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { if (!is_alive->do_object_b(_jvmci_installed_code)) { - bs->write_ref_nmethod_pre(&_jvmci_installed_code, this); - _jvmci_installed_code = NULL; - bs->write_ref_nmethod_post(&_jvmci_installed_code, this); + clear_jvmci_installed_code(); } } else { if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { @@ -2109,27 +2107,6 @@ unloading_occurred = true; } -#if INCLUDE_JVMCI - // Follow JVMCI method - if (_jvmci_installed_code != NULL) { - if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { - if (!is_alive->do_object_b(_jvmci_installed_code)) { - _jvmci_installed_code = NULL; - } - } else { - if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { - return false; - } - } - } - - if (_speculation_log != NULL) { - if (!is_alive->do_object_b(_speculation_log)) { - _speculation_log = NULL; - } - } -#endif - // When class redefinition is used all metadata in the CodeCache has to be recorded, // so that unused "previous versions" can be purged. Since walking the CodeCache can // be expensive, the "mark on stack" is piggy-backed on this parallel unloading code. @@ -2204,9 +2181,7 @@ if (_jvmci_installed_code != NULL) { if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { if (!is_alive->do_object_b(_jvmci_installed_code)) { - bs->write_ref_nmethod_pre(&_jvmci_installed_code, this); - _jvmci_installed_code = NULL; - bs->write_ref_nmethod_post(&_jvmci_installed_code, this); + clear_jvmci_installed_code(); } } else { if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { @@ -3542,6 +3517,14 @@ } #if INCLUDE_JVMCI +void nmethod::clear_jvmci_installed_code() { + // This must be done carefully to maintain nmethod remembered sets properly + BarrierSet* bs = Universe::heap()->barrier_set(); + bs->write_ref_nmethod_pre(&_jvmci_installed_code, this); + _jvmci_installed_code = NULL; + bs->write_ref_nmethod_post(&_jvmci_installed_code, this); +} + void nmethod::maybe_invalidate_installed_code() { if (_jvmci_installed_code != NULL) { if (!is_alive()) { @@ -3551,7 +3534,7 @@ // might want to invalidate all existing activations. InstalledCode::set_address(_jvmci_installed_code, 0); InstalledCode::set_entryPoint(_jvmci_installed_code, 0); - _jvmci_installed_code = NULL; + clear_jvmci_installed_code(); } else if (is_not_entrant()) { InstalledCode::set_entryPoint(_jvmci_installed_code, 0); } diff -r 2d21c13d7829 -r eada427470a3 src/share/vm/code/nmethod.hpp --- a/src/share/vm/code/nmethod.hpp Thu Nov 05 15:18:36 2015 -0800 +++ b/src/share/vm/code/nmethod.hpp Thu Nov 05 15:21:30 2015 -0800 @@ -629,7 +629,7 @@ #if INCLUDE_JVMCI oop jvmci_installed_code() { return _jvmci_installed_code ; } char* jvmci_installed_code_name(char* buf, size_t buflen); - void set_jvmci_installed_code(oop installed_code) { _jvmci_installed_code = installed_code; } + void clear_jvmci_installed_code(); void maybe_invalidate_installed_code(); oop speculation_log() { return _speculation_log ; } void set_speculation_log(oop speculation_log) { _speculation_log = speculation_log; }