43 // called at a safepoint. However, sweep_code_cache() stops executing if |
43 // called at a safepoint. However, sweep_code_cache() stops executing if |
44 // another thread requests a safepoint. Consequently, 'mark_active_nmethods()' |
44 // another thread requests a safepoint. Consequently, 'mark_active_nmethods()' |
45 // and sweep_code_cache() cannot execute at the same time. |
45 // and sweep_code_cache() cannot execute at the same time. |
46 // To reclaim memory, nmethods are first marked as 'not-entrant'. Methods can |
46 // To reclaim memory, nmethods are first marked as 'not-entrant'. Methods can |
47 // be made not-entrant by (i) the sweeper, (ii) deoptimization, (iii) dependency |
47 // be made not-entrant by (i) the sweeper, (ii) deoptimization, (iii) dependency |
48 // invalidation, and (iv) being replaced be a different method version (tiered |
48 // invalidation, and (iv) being replaced by a different method version (tiered |
49 // compilation). Not-entrant nmethod cannot be called by Java threads, but they |
49 // compilation). Not-entrant nmethods cannot be called by Java threads, but they |
50 // can still be active on the stack. To ensure that active nmethod are not reclaimed, |
50 // can still be active on the stack. To ensure that active nmethods are not reclaimed, |
51 // we have to wait until the next marking phase has completed. If a not-entrant |
51 // we have to wait until the next marking phase has completed. If a not-entrant |
52 // nmethod was NOT marked as active, it can be converted to 'zombie' state. To safely |
52 // nmethod was NOT marked as active, it can be converted to 'zombie' state. To safely |
53 // remove the nmethod, all inline caches (IC) that point to the the nmethod must be |
53 // remove the nmethod, all inline caches (IC) that point to the nmethod must be |
54 // cleared. After that, the nmethod can be evicted from the code cache. Each nmethod's |
54 // cleared. After that, the nmethod can be evicted from the code cache. Each nmethod's |
55 // state change happens during separate sweeps. It may take at least 3 sweeps before an |
55 // state change happens during separate sweeps. It may take at least 3 sweeps before an |
56 // nmethod's space is freed. |
56 // nmethod's space is freed. |
57 |
57 |
58 class NMethodSweeper : public AllStatic { |
58 class NMethodSweeper : public AllStatic { |