1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
29 // - cleanup inline caches |
29 // - cleanup inline caches |
30 // - reclamation of unreferences zombie nmethods |
30 // - reclamation of unreferences zombie nmethods |
31 // |
31 // |
32 |
32 |
33 class NMethodSweeper : public AllStatic { |
33 class NMethodSweeper : public AllStatic { |
34 static long _traversals; // Stack traversal count |
34 static long _traversals; // Stack scan count, also sweep ID. |
35 static nmethod* _current; // Current nmethod |
35 static nmethod* _current; // Current nmethod |
36 static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache |
36 static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache |
|
37 static int _flushed_count; // Nof. nmethods flushed in current sweep |
|
38 static int _zombified_count; // Nof. nmethods made zombie in current sweep |
|
39 static int _marked_count; // Nof. nmethods marked for reclaim in current sweep |
37 |
40 |
38 static volatile int _invocations; // No. of invocations left until we are completed with this pass |
41 static volatile int _invocations; // No. of invocations left until we are completed with this pass |
39 static volatile int _sweep_started; // Flag to control conc sweeper |
42 static volatile int _sweep_started; // Flag to control conc sweeper |
40 |
43 |
41 //The following are reset in scan_stacks and synchronized by the safepoint |
44 //The following are reset in scan_stacks and synchronized by the safepoint |
51 |
54 |
52 // These are synchronized by the _sweep_started token |
55 // These are synchronized by the _sweep_started token |
53 static int _highest_marked; // highest compile id dumped at last emergency unloading |
56 static int _highest_marked; // highest compile id dumped at last emergency unloading |
54 static int _dead_compile_ids; // number of compile ids that where not in the cache last flush |
57 static int _dead_compile_ids; // number of compile ids that where not in the cache last flush |
55 |
58 |
|
59 // Stat counters |
|
60 static int _number_of_flushes; // Total of full traversals caused by full cache |
|
61 static int _total_nof_methods_reclaimed; // Accumulated nof methods flushed |
|
62 static jlong _total_time_sweeping; // Accumulated time sweeping |
|
63 static jlong _total_time_this_sweep; // Total time this sweep |
|
64 static jlong _peak_sweep_time; // Peak time for a full sweep |
|
65 static jlong _peak_sweep_fraction_time; // Peak time sweeping one fraction |
|
66 static jlong _total_disconnect_time; // Total time cleaning code mem |
|
67 static jlong _peak_disconnect_time; // Peak time cleaning code mem |
|
68 |
56 static void process_nmethod(nmethod *nm); |
69 static void process_nmethod(nmethod *nm); |
57 static void release_nmethod(nmethod* nm); |
70 static void release_nmethod(nmethod* nm); |
58 |
71 |
59 static void log_sweep(const char* msg, const char* format = NULL, ...); |
72 static void log_sweep(const char* msg, const char* format = NULL, ...); |
60 static bool sweep_in_progress(); |
73 static bool sweep_in_progress(); |
61 |
74 |
62 public: |
75 public: |
63 static long traversal_count() { return _traversals; } |
76 static long traversal_count() { return _traversals; } |
|
77 static int number_of_flushes() { return _number_of_flushes; } |
|
78 static int total_nof_methods_reclaimed() { return _total_nof_methods_reclaimed; } |
|
79 static jlong total_time_sweeping() { return _total_time_sweeping; } |
|
80 static jlong peak_sweep_time() { return _peak_sweep_time; } |
|
81 static jlong peak_sweep_fraction_time() { return _peak_sweep_fraction_time; } |
|
82 static jlong total_disconnect_time() { return _total_disconnect_time; } |
|
83 static jlong peak_disconnect_time() { return _peak_disconnect_time; } |
64 |
84 |
65 #ifdef ASSERT |
85 #ifdef ASSERT |
66 // Keep track of sweeper activity in the ring buffer |
86 // Keep track of sweeper activity in the ring buffer |
67 static void record_sweep(nmethod* nm, int line); |
87 static void record_sweep(nmethod* nm, int line); |
68 static void report_events(int id, address entry); |
88 static void report_events(int id, address entry); |