54 // nmethod's space is freed. |
54 // nmethod's space is freed. |
55 |
55 |
56 class NMethodSweeper : public AllStatic { |
56 class NMethodSweeper : public AllStatic { |
57 friend class WhiteBox; |
57 friend class WhiteBox; |
58 private: |
58 private: |
|
59 enum MethodStateChange { |
|
60 None, |
|
61 MadeZombie, |
|
62 MarkedForReclamation, |
|
63 Flushed |
|
64 }; |
59 static long _traversals; // Stack scan count, also sweep ID. |
65 static long _traversals; // Stack scan count, also sweep ID. |
60 static long _total_nof_code_cache_sweeps; // Total number of full sweeps of the code cache |
66 static long _total_nof_code_cache_sweeps; // Total number of full sweeps of the code cache |
61 static long _time_counter; // Virtual time used to periodically invoke sweeper |
67 static long _time_counter; // Virtual time used to periodically invoke sweeper |
62 static long _last_sweep; // Value of _time_counter when the last sweep happened |
68 static long _last_sweep; // Value of _time_counter when the last sweep happened |
63 static NMethodIterator _current; // Current nmethod |
69 static NMethodIterator _current; // Current nmethod |
64 static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache |
70 static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache |
65 static int _flushed_count; // Nof. nmethods flushed in current sweep |
|
66 static int _zombified_count; // Nof. nmethods made zombie in current sweep |
|
67 static int _marked_for_reclamation_count; // Nof. nmethods marked for reclaim in current sweep |
|
68 |
71 |
69 static volatile int _sweep_started; // Flag to control conc sweeper |
72 static volatile int _sweep_started; // Flag to control conc sweeper |
70 static volatile bool _should_sweep; // Indicates if we should invoke the sweeper |
73 static volatile bool _should_sweep; // Indicates if we should invoke the sweeper |
71 static volatile int _bytes_changed; // Counts the total nmethod size if the nmethod changed from: |
74 static volatile int _bytes_changed; // Counts the total nmethod size if the nmethod changed from: |
72 // 1) alive -> not_entrant |
75 // 1) alive -> not_entrant |
81 static Tickspan _total_time_sweeping; // Accumulated time sweeping |
84 static Tickspan _total_time_sweeping; // Accumulated time sweeping |
82 static Tickspan _total_time_this_sweep; // Total time this sweep |
85 static Tickspan _total_time_this_sweep; // Total time this sweep |
83 static Tickspan _peak_sweep_time; // Peak time for a full sweep |
86 static Tickspan _peak_sweep_time; // Peak time for a full sweep |
84 static Tickspan _peak_sweep_fraction_time; // Peak time sweeping one fraction |
87 static Tickspan _peak_sweep_fraction_time; // Peak time sweeping one fraction |
85 |
88 |
86 static int process_nmethod(nmethod *nm); |
89 static Monitor* _stat_lock; |
87 static void release_nmethod(nmethod* nm); |
90 |
|
91 static MethodStateChange process_nmethod(nmethod *nm); |
|
92 static void release_nmethod(nmethod* nm); |
88 |
93 |
89 static void init_sweeper_log() NOT_DEBUG_RETURN; |
94 static void init_sweeper_log() NOT_DEBUG_RETURN; |
90 static bool wait_for_stack_scanning(); |
95 static bool wait_for_stack_scanning(); |
91 static void sweep_code_cache(); |
96 static void sweep_code_cache(); |
92 static void handle_safepoint_request(); |
97 static void handle_safepoint_request(); |