@@ -1851,6 +1851,9 @@ class ShenandoahEvacUpdateCodeCacheClosure : public NMethodClosure {
1851
1851
void do_nmethod (nmethod* n) {
1852
1852
ShenandoahNMethod* data = ShenandoahNMethod::gc_data (n);
1853
1853
ShenandoahReentrantLocker locker (data->lock ());
1854
+ // Setup EvacOOM scope below reentrant lock to avoid deadlock with
1855
+ // nmethod_entry_barrier
1856
+ ShenandoahEvacOOMScope oom;
1854
1857
data->oops_do (&_cl, true /* fix relocation*/ );
1855
1858
_bs->disarm (n);
1856
1859
}
@@ -1887,20 +1890,23 @@ class ShenandoahConcurrentRootsEvacUpdateTask : public AbstractGangTask {
1887
1890
1888
1891
void work (uint worker_id) {
1889
1892
ShenandoahConcurrentWorkerSession worker_session (worker_id);
1890
- ShenandoahEvacOOMScope oom;
1891
1893
{
1892
- // vm_roots and weak_roots are OopStorage backed roots, concurrent iteration
1893
- // may race against OopStorage::release() calls.
1894
- ShenandoahEvacUpdateOopStorageRootsClosure cl;
1895
- _vm_roots.oops_do <ShenandoahEvacUpdateOopStorageRootsClosure>(&cl, worker_id);
1896
- }
1894
+ ShenandoahEvacOOMScope oom;
1895
+ {
1896
+ // vm_roots and weak_roots are OopStorage backed roots, concurrent iteration
1897
+ // may race against OopStorage::release() calls.
1898
+ ShenandoahEvacUpdateOopStorageRootsClosure cl;
1899
+ _vm_roots.oops_do <ShenandoahEvacUpdateOopStorageRootsClosure>(&cl, worker_id);
1900
+ }
1897
1901
1898
- {
1899
- ShenandoahEvacuateUpdateRootsClosure<> cl;
1900
- CLDToOopClosure clds (&cl, ClassLoaderData::_claim_strong);
1901
- _cld_roots.cld_do (&clds, worker_id);
1902
+ {
1903
+ ShenandoahEvacuateUpdateRootsClosure<> cl;
1904
+ CLDToOopClosure clds (&cl, ClassLoaderData::_claim_strong);
1905
+ _cld_roots.cld_do (&clds, worker_id);
1906
+ }
1902
1907
}
1903
1908
1909
+ // Cannot setup ShenandoahEvacOOMScope here, due to potential deadlock with nmethod_entry_barrier.
1904
1910
if (_process_codecache) {
1905
1911
ShenandoahWorkerTimingsTracker timer (_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
1906
1912
ShenandoahEvacUpdateCodeCacheClosure cl;
0 commit comments