Mercurial > hg > graal-jvmci-8
diff src/share/vm/jvmci/jvmciCompilerToVM.cpp @ 22736:2dea101cdfe9
Fix assertion failures with G1 barrier logic and guard InstalledCode updates
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 13 Nov 2015 09:31:04 -0800 |
parents | 24fd08e99b35 |
children | d57508b1bcb5 |
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Nov 13 14:09:57 2015 +0100 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Nov 13 09:31:04 2015 -0800 @@ -82,20 +82,6 @@ return NULL; } -void CompilerToVM::invalidate_installed_code(Handle installedCode) { - jlong nativeMethod = InstalledCode::address(installedCode); - nmethod* nm = (nmethod*)nativeMethod; - if (nm != NULL && nm->is_alive()) { - // The nmethod state machinery maintains the link between the - // HotSpotInstalledCode and nmethod* so as long as the nmethod appears to be - // alive assume there is work to do and deoptimize the nmethod. - nm->mark_for_deoptimization(); - VM_Deoptimize op; - VMThread::execute(&op); - } - InstalledCode::set_address(installedCode, 0); -} - C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *, jobject, jobject config)) VMStructs::initHotSpotVMConfig(JNIHandles::resolve(config)); C2V_END @@ -612,18 +598,22 @@ } else { if (!installed_code_handle.is_null()) { assert(installed_code_handle->is_a(InstalledCode::klass()), "wrong type"); - CompilerToVM::invalidate_installed_code(installed_code_handle); - InstalledCode::set_address(installed_code_handle, (jlong) cb); - InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1); - if (cb->is_nmethod()) { - InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->as_nmethod_or_null()->verified_entry_point()); - } else { - InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->code_begin()); - } - if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { - HotSpotInstalledCode::set_size(installed_code_handle, cb->size()); - HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin()); - HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size()); + nmethod::invalidate_installed_code(installed_code_handle, CHECK_0); + { + // Ensure that all updates to the InstalledCode fields are consistent. + MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); + InstalledCode::set_address(installed_code_handle, (jlong) cb); + InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1); + if (cb->is_nmethod()) { + InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->as_nmethod_or_null()->verified_entry_point()); + } else { + InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->code_begin()); + } + if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { + HotSpotInstalledCode::set_size(installed_code_handle, cb->size()); + HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin()); + HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size()); + } } nmethod* nm = cb->as_nmethod_or_null(); if (nm != NULL && installed_code_handle->is_scavengable()) { @@ -833,7 +823,7 @@ C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject installed_code)) Handle installed_code_handle = JNIHandles::resolve(installed_code); - CompilerToVM::invalidate_installed_code(installed_code_handle); + nmethod::invalidate_installed_code(installed_code_handle, CHECK); C2V_END C2V_VMENTRY(jobject, readUncompressedOop, (JNIEnv*, jobject, jlong addr))