Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 7000:bf2ea3ed3bce
Fixed nmethod not being unloaded after their classloader has been unloaded by initializing _graal_installed_code in an nmethod's constructor
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 21 Nov 2012 23:33:43 +0100 |
parents | e3ada110d3cf |
children | 74f0207b82f5 |
comparison
equal
deleted
inserted
replaced
6999:679e6584c177 | 7000:bf2ea3ed3bce |
---|---|
772 Handle compResultHandle = JNIHandles::resolve(compResult); | 772 Handle compResultHandle = JNIHandles::resolve(compResult); |
773 nmethod* nm = NULL; | 773 nmethod* nm = NULL; |
774 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(compResult)); | 774 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(compResult)); |
775 Arena arena; | 775 Arena arena; |
776 ciEnv env(&arena); | 776 ciEnv env(&arena); |
777 bool bind_to_method = installed_code == NULL; | 777 Handle installed_code_handle = JNIHandles::resolve(installed_code); |
778 CodeInstaller installer(compResultHandle, method, nm, bind_to_method); | 778 CodeInstaller installer(compResultHandle, method, nm, installed_code_handle); |
779 | 779 |
780 if (info != NULL) { | 780 if (info != NULL) { |
781 arrayOop codeCopy = oopFactory::new_byteArray(nm->code_size(), CHECK_0); | 781 arrayOop codeCopy = oopFactory::new_byteArray(nm->code_size(), CHECK_0); |
782 memcpy(codeCopy->base(T_BYTE), nm->code_begin(), nm->code_size()); | 782 memcpy(codeCopy->base(T_BYTE), nm->code_begin(), nm->code_size()); |
783 HotSpotCodeInfo::set_code(info, codeCopy); | 783 HotSpotCodeInfo::set_code(info, codeCopy); |
784 HotSpotCodeInfo::set_start(info, (jlong) nm->code_begin()); | 784 HotSpotCodeInfo::set_start(info, (jlong) nm->code_begin()); |
785 } | 785 } |
786 | 786 |
787 if (installed_code != NULL && nm != NULL) { | 787 if (!installed_code_handle.is_null()) { |
788 Handle obj = JNIHandles::resolve(installed_code); | 788 assert(installed_code_handle->is_a(HotSpotInstalledCode::klass()), "wrong type"); |
789 assert(obj->is_a(HotSpotInstalledCode::klass()), "wrong type"); | 789 HotSpotInstalledCode::set_nmethod(installed_code_handle, (jlong) nm); |
790 HotSpotInstalledCode::set_nmethod(obj, (jlong) nm); | 790 HotSpotInstalledCode::set_method(installed_code_handle, HotSpotCompilationResult::method(compResult)); |
791 HotSpotInstalledCode::set_method(obj, HotSpotCompilationResult::method(compResult)); | 791 assert(nm == NULL || !installed_code_handle->is_scavengable() || nm->on_scavenge_root_list(), "nm should be scavengable if installed_code is scavengable"); |
792 nm->set_graal_installed_code(obj()); | 792 return installed_code; |
793 assert(nm->graal_installed_code() == obj(), "must be"); | |
794 if (!nm->on_scavenge_root_list()) { | |
795 // Since the nmethod now contains a normal oop (i.e. installed_code) it must | |
796 // be on the list of nmethods scavenged for oops. | |
797 // Must hold the code cache lock when adding to the scavenger list | |
798 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
799 CodeCache::add_scavenge_root_nmethod(nm); | |
800 assert(nm->on_scavenge_root_list(), "must be"); | |
801 } | |
802 return JNIHandles::make_local(obj()); | |
803 } else { | 793 } else { |
804 return NULL; | 794 return NULL; |
805 } | 795 } |
806 C2V_END | 796 C2V_END |
807 | 797 |