Mercurial > hg > truffle
annotate src/share/vm/runtime/sweeper.cpp @ 13046:613e6a6fc328
Merge
author | iveresov |
---|---|
date | Tue, 05 Nov 2013 02:29:41 -0800 |
parents | 510fbd28919c |
children | cefad50507d8 78da3894b86f |
rev | line source |
---|---|
0 | 1 /* |
10405 | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1538
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/codeCache.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
27 #include "code/compiledIC.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
28 #include "code/icBuffer.hpp" |
1972 | 29 #include "code/nmethod.hpp" |
30 #include "compiler/compileBroker.hpp" | |
31 #include "memory/resourceArea.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
32 #include "oops/method.hpp" |
1972 | 33 #include "runtime/atomic.hpp" |
34 #include "runtime/compilationPolicy.hpp" | |
35 #include "runtime/mutexLocker.hpp" | |
36 #include "runtime/os.hpp" | |
37 #include "runtime/sweeper.hpp" | |
38 #include "runtime/vm_operations.hpp" | |
10405 | 39 #include "trace/tracing.hpp" |
1972 | 40 #include "utilities/events.hpp" |
41 #include "utilities/xmlstream.hpp" | |
0 | 42 |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
43 #ifdef ASSERT |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
44 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
45 #define SWEEP(nm) record_sweep(nm, __LINE__) |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
46 // Sweeper logging code |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
47 class SweeperRecord { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
48 public: |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
49 int traversal; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
50 int invocation; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
51 int compile_id; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
52 long traversal_mark; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
53 int state; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
54 const char* kind; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
55 address vep; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
56 address uep; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
57 int line; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
58 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
59 void print() { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
60 tty->print_cr("traversal = %d invocation = %d compile_id = %d %s uep = " PTR_FORMAT " vep = " |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
61 PTR_FORMAT " state = %d traversal_mark %d line = %d", |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
62 traversal, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
63 invocation, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
64 compile_id, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
65 kind == NULL ? "" : kind, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
66 uep, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
67 vep, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
68 state, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
69 traversal_mark, |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
70 line); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
71 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
72 }; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
73 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
74 static int _sweep_index = 0; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
75 static SweeperRecord* _records = NULL; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
76 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
77 void NMethodSweeper::report_events(int id, address entry) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
78 if (_records != NULL) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
79 for (int i = _sweep_index; i < SweeperLogEntries; i++) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
80 if (_records[i].uep == entry || |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
81 _records[i].vep == entry || |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
82 _records[i].compile_id == id) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
83 _records[i].print(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
84 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
85 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
86 for (int i = 0; i < _sweep_index; i++) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
87 if (_records[i].uep == entry || |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
88 _records[i].vep == entry || |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
89 _records[i].compile_id == id) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
90 _records[i].print(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
91 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
92 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
93 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
94 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
95 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
96 void NMethodSweeper::report_events() { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
97 if (_records != NULL) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
98 for (int i = _sweep_index; i < SweeperLogEntries; i++) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
99 // skip empty records |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
100 if (_records[i].vep == NULL) continue; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
101 _records[i].print(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
102 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
103 for (int i = 0; i < _sweep_index; i++) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
104 // skip empty records |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
105 if (_records[i].vep == NULL) continue; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
106 _records[i].print(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
107 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
108 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
109 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
110 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
111 void NMethodSweeper::record_sweep(nmethod* nm, int line) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
112 if (_records != NULL) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
113 _records[_sweep_index].traversal = _traversals; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
114 _records[_sweep_index].traversal_mark = nm->_stack_traversal_mark; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
115 _records[_sweep_index].invocation = _invocations; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
116 _records[_sweep_index].compile_id = nm->compile_id(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
117 _records[_sweep_index].kind = nm->compile_kind(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
118 _records[_sweep_index].state = nm->_state; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
119 _records[_sweep_index].vep = nm->verified_entry_point(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
120 _records[_sweep_index].uep = nm->entry_point(); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
121 _records[_sweep_index].line = line; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
122 |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
123 _sweep_index = (_sweep_index + 1) % SweeperLogEntries; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
124 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
125 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
126 #else |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
127 #define SWEEP(nm) |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
128 #endif |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
129 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
130 nmethod* NMethodSweeper::_current = NULL; // Current nmethod |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
131 long NMethodSweeper::_traversals = 0; // Nof. stack traversals performed |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
132 int NMethodSweeper::_seen = 0; // Nof. nmethods we have currently processed in current pass of CodeCache |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
133 int NMethodSweeper::_flushed_count = 0; // Nof. nmethods flushed in current sweep |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
134 int NMethodSweeper::_zombified_count = 0; // Nof. nmethods made zombie in current sweep |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
135 int NMethodSweeper::_marked_count = 0; // Nof. nmethods marked for reclaim in current sweep |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
136 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
137 volatile int NMethodSweeper::_invocations = 0; // Nof. invocations left until we are completed with this pass |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
138 volatile int NMethodSweeper::_sweep_started = 0; // Whether a sweep is in progress. |
0 | 139 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
140 jint NMethodSweeper::_locked_seen = 0; |
0 | 141 jint NMethodSweeper::_not_entrant_seen_on_stack = 0; |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
142 bool NMethodSweeper::_request_mark_phase = false; |
0 | 143 |
10405 | 144 int NMethodSweeper::_total_nof_methods_reclaimed = 0; |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
145 jlong NMethodSweeper::_total_time_sweeping = 0; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
146 jlong NMethodSweeper::_total_time_this_sweep = 0; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
147 jlong NMethodSweeper::_peak_sweep_time = 0; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
148 jlong NMethodSweeper::_peak_sweep_fraction_time = 0; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
149 int NMethodSweeper::_hotness_counter_reset_val = 0; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
150 |
10405 | 151 |
989 | 152 class MarkActivationClosure: public CodeBlobClosure { |
153 public: | |
154 virtual void do_code_blob(CodeBlob* cb) { | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
155 if (cb->is_nmethod()) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
156 nmethod* nm = (nmethod*)cb; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
157 nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
158 // If we see an activation belonging to a non_entrant nmethod, we mark it. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
159 if (nm->is_not_entrant()) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
160 nm->mark_as_seen_on_stack(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
161 } |
989 | 162 } |
163 } | |
164 }; | |
165 static MarkActivationClosure mark_activation_closure; | |
166 | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
167 class SetHotnessClosure: public CodeBlobClosure { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
168 public: |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
169 virtual void do_code_blob(CodeBlob* cb) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
170 if (cb->is_nmethod()) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
171 nmethod* nm = (nmethod*)cb; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
172 nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
173 } |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
174 } |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
175 }; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
176 static SetHotnessClosure set_hotness_closure; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
177 |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
178 |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
179 int NMethodSweeper::hotness_counter_reset_val() { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
180 if (_hotness_counter_reset_val == 0) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
181 _hotness_counter_reset_val = (ReservedCodeCacheSize < M) ? 1 : (ReservedCodeCacheSize / M) * 2; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
182 } |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
183 return _hotness_counter_reset_val; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
184 } |
10206
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
185 bool NMethodSweeper::sweep_in_progress() { |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
186 return (_current != NULL); |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
187 } |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
188 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
189 // Scans the stacks of all Java threads and marks activations of not-entrant methods. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
190 // No need to synchronize access, since 'mark_active_nmethods' is always executed at a |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
191 // safepoint. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
192 void NMethodSweeper::mark_active_nmethods() { |
0 | 193 assert(SafepointSynchronize::is_at_safepoint(), "must be executed at a safepoint"); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
194 // If we do not want to reclaim not-entrant or zombie methods there is no need |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
195 // to scan stacks |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
196 if (!MethodFlushing) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
197 return; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
198 } |
0 | 199 |
200 // Check for restart | |
201 assert(CodeCache::find_blob_unsafe(_current) == _current, "Sweeper nmethod cached state invalid"); | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
202 if (!sweep_in_progress() && need_marking_phase()) { |
0 | 203 _seen = 0; |
204 _invocations = NmethodSweepFraction; | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
205 _current = CodeCache::first_nmethod(); |
0 | 206 _traversals += 1; |
10405 | 207 _total_time_this_sweep = 0; |
208 | |
0 | 209 if (PrintMethodFlushing) { |
210 tty->print_cr("### Sweep: stack traversal %d", _traversals); | |
211 } | |
989 | 212 Threads::nmethods_do(&mark_activation_closure); |
0 | 213 |
214 // reset the flags since we started a scan from the beginning. | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
215 reset_nmethod_marking(); |
0 | 216 _locked_seen = 0; |
217 _not_entrant_seen_on_stack = 0; | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
218 } else { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
219 // Only set hotness counter |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
220 Threads::nmethods_do(&set_hotness_closure); |
0 | 221 } |
222 | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
223 OrderAccess::storestore(); |
0 | 224 } |
225 | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
226 void NMethodSweeper::possibly_sweep() { |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
227 assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
228 if (!MethodFlushing || !sweep_in_progress()) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
229 return; |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
230 } |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
231 |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
232 if (_invocations > 0) { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
233 // Only one thread at a time will sweep |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
234 jint old = Atomic::cmpxchg( 1, &_sweep_started, 0 ); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
235 if (old != 0) { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
236 return; |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
237 } |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
238 #ifdef ASSERT |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
239 if (LogSweeper && _records == NULL) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
240 // Create the ring buffer for the logging code |
6197 | 241 _records = NEW_C_HEAP_ARRAY(SweeperRecord, SweeperLogEntries, mtGC); |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
242 memset(_records, 0, sizeof(SweeperRecord) * SweeperLogEntries); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
243 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
244 #endif |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
245 if (_invocations > 0) { |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
246 sweep_code_cache(); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
247 _invocations--; |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
248 } |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
249 _sweep_started = 0; |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
250 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
251 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
252 |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
253 void NMethodSweeper::sweep_code_cache() { |
10405 | 254 |
255 jlong sweep_start_counter = os::elapsed_counter(); | |
256 | |
257 _flushed_count = 0; | |
258 _zombified_count = 0; | |
259 _marked_count = 0; | |
260 | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
261 if (PrintMethodFlushing && Verbose) { |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
262 tty->print_cr("### Sweep at %d out of %d. Invocations left: %d", _seen, CodeCache::nof_nmethods(), _invocations); |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
263 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
264 |
10206
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
265 if (!CompileBroker::should_compile_new_jobs()) { |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
266 // If we have turned off compilations we might as well do full sweeps |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
267 // in order to reach the clean state faster. Otherwise the sleeping compiler |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
268 // threads will slow down sweeping. |
10206
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
269 _invocations = 1; |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
270 } |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
271 |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
272 // We want to visit all nmethods after NmethodSweepFraction |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
273 // invocations so divide the remaining number of nmethods by the |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
274 // remaining number of invocations. This is only an estimate since |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
275 // the number of nmethods changes during the sweep so the final |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
276 // stage must iterate until it there are no more nmethods. |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
277 int todo = (CodeCache::nof_nmethods() - _seen) / _invocations; |
12266
ab274453d37f
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
10405
diff
changeset
|
278 int swept_count = 0; |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
279 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
280 |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
281 assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
282 assert(!CodeCache_lock->owned_by_self(), "just checking"); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
283 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
284 int freed_memory = 0; |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
285 { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
286 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
287 |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
288 // The last invocation iterates until there are no more nmethods |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
289 for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { |
12266
ab274453d37f
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
10405
diff
changeset
|
290 swept_count++; |
4945
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
291 if (SafepointSynchronize::is_synchronizing()) { // Safepoint request |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
292 if (PrintMethodFlushing && Verbose) { |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
293 tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
294 } |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
295 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
296 |
4945
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
297 assert(Thread::current()->is_Java_thread(), "should be java thread"); |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
298 JavaThread* thread = (JavaThread*)Thread::current(); |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
299 ThreadBlockInVM tbivm(thread); |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
300 thread->java_suspend_self(); |
cfdfbeac0a5b
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
3384
diff
changeset
|
301 } |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
302 // Since we will give up the CodeCache_lock, always skip ahead |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
303 // to the next nmethod. Other blobs can be deleted by other |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
304 // threads but nmethods are only reclaimed by the sweeper. |
1615
ff38d05ea86f
6956958: assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted() || is_optimized() || is_megam
never
parents:
1552
diff
changeset
|
305 nmethod* next = CodeCache::next_nmethod(_current); |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
306 |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
307 // Now ready to process nmethod and give up CodeCache_lock |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
308 { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
309 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
310 freed_memory += process_nmethod(_current); |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
311 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
312 _seen++; |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
313 _current = next; |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
314 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
315 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
316 |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
317 assert(_invocations > 1 || _current == NULL, "must have scanned the whole cache"); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
318 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
319 if (!sweep_in_progress() && !need_marking_phase() && (_locked_seen || _not_entrant_seen_on_stack)) { |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
320 // we've completed a scan without making progress but there were |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
321 // nmethods we were unable to process either because they were |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
322 // locked or were still on stack. We don't have to aggressively |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
323 // clean them up so just stop scanning. We could scan once more |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
324 // but that complicates the control logic and it's unlikely to |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
325 // matter much. |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
326 if (PrintMethodFlushing) { |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
327 tty->print_cr("### Couldn't make progress on some nmethods so stopping sweep"); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
328 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
329 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
330 |
10405 | 331 jlong sweep_end_counter = os::elapsed_counter(); |
332 jlong sweep_time = sweep_end_counter - sweep_start_counter; | |
333 _total_time_sweeping += sweep_time; | |
334 _total_time_this_sweep += sweep_time; | |
335 _peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); | |
336 _total_nof_methods_reclaimed += _flushed_count; | |
337 | |
338 EventSweepCodeCache event(UNTIMED); | |
339 if (event.should_commit()) { | |
340 event.set_starttime(sweep_start_counter); | |
341 event.set_endtime(sweep_end_counter); | |
342 event.set_sweepIndex(_traversals); | |
343 event.set_sweepFractionIndex(NmethodSweepFraction - _invocations + 1); | |
12266
ab274453d37f
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
10405
diff
changeset
|
344 event.set_sweptCount(swept_count); |
10405 | 345 event.set_flushedCount(_flushed_count); |
346 event.set_markedCount(_marked_count); | |
347 event.set_zombifiedCount(_zombified_count); | |
348 event.commit(); | |
349 } | |
350 | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
351 #ifdef ASSERT |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
352 if(PrintMethodFlushing) { |
10405 | 353 tty->print_cr("### sweeper: sweep time(%d): " INT64_FORMAT, _invocations, (jlong)sweep_time); |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
354 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
355 #endif |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
356 |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
357 if (_invocations == 1) { |
10405 | 358 _peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
359 log_sweep("finished"); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
360 } |
10206
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
361 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
362 // Sweeper is the only case where memory is released, check here if it |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
363 // is time to restart the compiler. Only checking if there is a certain |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
364 // amount of free memory in the code cache might lead to re-enabling |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
365 // compilation although no memory has been released. For example, there are |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
366 // cases when compilation was disabled although there is 4MB (or more) free |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
367 // memory in the code cache. The reason is code cache fragmentation. Therefore, |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
368 // it only makes sense to re-enable compilation if we have actually freed memory. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
369 // Note that typically several kB are released for sweeping 16MB of the code |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
370 // cache. As a result, 'freed_memory' > 0 to restart the compiler. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
371 if (UseCodeCacheFlushing && (!CompileBroker::should_compile_new_jobs() && (freed_memory > 0))) { |
10206
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
372 CompileBroker::set_should_compile_new_jobs(CompileBroker::run_compilation); |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
373 log_sweep("restart_compiler"); |
0cfa93c2fcc4
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
6725
diff
changeset
|
374 } |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
375 } |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
376 |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
377 class NMethodMarker: public StackObj { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
378 private: |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
379 CompilerThread* _thread; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
380 public: |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
381 NMethodMarker(nmethod* nm) { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
382 _thread = CompilerThread::current(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
383 if (!nm->is_zombie() && !nm->is_unloaded()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
384 // Only expose live nmethods for scanning |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
385 _thread->set_scanned_nmethod(nm); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
386 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
387 } |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
388 ~NMethodMarker() { |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
389 _thread->set_scanned_nmethod(NULL); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
390 } |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
391 }; |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
392 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
393 void NMethodSweeper::release_nmethod(nmethod *nm) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
394 // Clean up any CompiledICHolders |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
395 { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
396 ResourceMark rm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
397 MutexLocker ml_patch(CompiledIC_lock); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
398 RelocIterator iter(nm); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
399 while (iter.next()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
400 if (iter.type() == relocInfo::virtual_call_type) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
401 CompiledIC::cleanup_call_site(iter.virtual_call_reloc()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
402 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
403 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
404 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
405 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
406 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
407 nm->flush(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
408 } |
0 | 409 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
410 int NMethodSweeper::process_nmethod(nmethod *nm) { |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
411 assert(!CodeCache_lock->owned_by_self(), "just checking"); |
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
412 |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
413 int freed_memory = 0; |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
414 // Make sure this nmethod doesn't get unloaded during the scan, |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
415 // since safepoints may happen during acquired below locks. |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
416 NMethodMarker nmm(nm); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
417 SWEEP(nm); |
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
418 |
0 | 419 // Skip methods that are currently referenced by the VM |
420 if (nm->is_locked_by_vm()) { | |
421 // But still remember to clean-up inline caches for alive nmethods | |
422 if (nm->is_alive()) { | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
423 // Clean inline caches that point to zombie/non-entrant methods |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
424 MutexLocker cl(CompiledIC_lock); |
0 | 425 nm->cleanup_inline_caches(); |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
426 SWEEP(nm); |
0 | 427 } else { |
428 _locked_seen++; | |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
429 SWEEP(nm); |
0 | 430 } |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
431 return freed_memory; |
0 | 432 } |
433 | |
434 if (nm->is_zombie()) { | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
435 // If it is the first time we see nmethod then we mark it. Otherwise, |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
436 // we reclaim it. When we have seen a zombie method twice, we know that |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
437 // there are no inline caches that refer to it. |
0 | 438 if (nm->is_marked_for_reclamation()) { |
439 assert(!nm->is_locked_by_vm(), "must not flush locked nmethods"); | |
941 | 440 if (PrintMethodFlushing && Verbose) { |
1202 | 441 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), nm); |
941 | 442 } |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
443 freed_memory = nm->total_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
444 release_nmethod(nm); |
10405 | 445 _flushed_count++; |
0 | 446 } else { |
941 | 447 if (PrintMethodFlushing && Verbose) { |
1202 | 448 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm); |
941 | 449 } |
0 | 450 nm->mark_for_reclamation(); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
451 request_nmethod_marking(); |
10405 | 452 _marked_count++; |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
453 SWEEP(nm); |
0 | 454 } |
455 } else if (nm->is_not_entrant()) { | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
456 // If there are no current activations of this method on the |
0 | 457 // stack we can safely convert it to a zombie method |
458 if (nm->can_not_entrant_be_converted()) { | |
941 | 459 if (PrintMethodFlushing && Verbose) { |
1202 | 460 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); |
941 | 461 } |
0 | 462 nm->make_zombie(); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
463 request_nmethod_marking(); |
10405 | 464 _zombified_count++; |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
465 SWEEP(nm); |
0 | 466 } else { |
467 // Still alive, clean up its inline caches | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
468 MutexLocker cl(CompiledIC_lock); |
0 | 469 nm->cleanup_inline_caches(); |
470 // we coudn't transition this nmethod so don't immediately | |
471 // request a rescan. If this method stays on the stack for a | |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
472 // long time we don't want to keep rescanning the code cache. |
0 | 473 _not_entrant_seen_on_stack++; |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
474 SWEEP(nm); |
0 | 475 } |
476 } else if (nm->is_unloaded()) { | |
477 // Unloaded code, just make it a zombie | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
478 if (PrintMethodFlushing && Verbose) { |
1202 | 479 tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm); |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
480 } |
941 | 481 if (nm->is_osr_method()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
482 SWEEP(nm); |
0 | 483 // No inline caches will ever point to osr methods, so we can just remove it |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
484 freed_memory = nm->total_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
485 release_nmethod(nm); |
10405 | 486 _flushed_count++; |
0 | 487 } else { |
488 nm->make_zombie(); | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
489 request_nmethod_marking(); |
10405 | 490 _zombified_count++; |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
491 SWEEP(nm); |
0 | 492 } |
493 } else { | |
1202 | 494 if (UseCodeCacheFlushing) { |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
495 if (!nm->is_locked_by_vm() && !nm->is_osr_method() && !nm->is_native_method()) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
496 // Do not make native methods and OSR-methods not-entrant |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
497 nm->dec_hotness_counter(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
498 // Get the initial value of the hotness counter. This value depends on the |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
499 // ReservedCodeCacheSize |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
500 int reset_val = hotness_counter_reset_val(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
501 int time_since_reset = reset_val - nm->hotness_counter(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
502 double threshold = -reset_val + (CodeCache::reverse_free_ratio() * NmethodSweepActivity); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
503 // The less free space in the code cache we have - the bigger reverse_free_ratio() is. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
504 // I.e., 'threshold' increases with lower available space in the code cache and a higher |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
505 // NmethodSweepActivity. If the current hotness counter - which decreases from its initial |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
506 // value until it is reset by stack walking - is smaller than the computed threshold, the |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
507 // corresponding nmethod is considered for removal. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
508 if ((NmethodSweepActivity > 0) && (nm->hotness_counter() < threshold) && (time_since_reset > 10)) { |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
509 // A method is marked as not-entrant if the method is |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
510 // 1) 'old enough': nm->hotness_counter() < threshold |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
511 // 2) The method was in_use for a minimum amount of time: (time_since_reset > 10) |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
512 // The second condition is necessary if we are dealing with very small code cache |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
513 // sizes (e.g., <10m) and the code cache size is too small to hold all hot methods. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
514 // The second condition ensures that methods are not immediately made not-entrant |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
515 // after compilation. |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
516 nm->make_not_entrant(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
517 request_nmethod_marking(); |
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
518 } |
1202 | 519 } |
520 } | |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
521 // Clean-up all inline caches that point to zombie/non-reentrant methods |
1538
bfe29ec02863
6950075: nmethod sweeper should operate concurrently
never
parents:
1202
diff
changeset
|
522 MutexLocker cl(CompiledIC_lock); |
0 | 523 nm->cleanup_inline_caches(); |
3384
f52ed367b66d
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
2482
diff
changeset
|
524 SWEEP(nm); |
0 | 525 } |
12324
510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
12266
diff
changeset
|
526 return freed_memory; |
1202 | 527 } |
528 | |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
529 // Print out some state information about the current sweep and the |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
530 // state of the code cache if it's requested. |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
531 void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) { |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
532 if (PrintMethodFlushing) { |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
533 stringStream s; |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
534 // Dump code cache state into a buffer before locking the tty, |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
535 // because log_state() will use locks causing lock conflicts. |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
536 CodeCache::log_state(&s); |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
537 |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
538 ttyLocker ttyl; |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
539 tty->print("### sweeper: %s ", msg); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
540 if (format != NULL) { |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
541 va_list ap; |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
542 va_start(ap, format); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
543 tty->vprint(format, ap); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
544 va_end(ap); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
545 } |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
546 tty->print_cr(s.as_string()); |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
547 } |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
548 |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
549 if (LogCompilation && (xtty != NULL)) { |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
550 stringStream s; |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
551 // Dump code cache state into a buffer before locking the tty, |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
552 // because log_state() will use locks causing lock conflicts. |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
553 CodeCache::log_state(&s); |
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
554 |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
555 ttyLocker ttyl; |
1646 | 556 xtty->begin_elem("sweeper state='%s' traversals='" INTX_FORMAT "' ", msg, (intx)traversal_count()); |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
557 if (format != NULL) { |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
558 va_list ap; |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
559 va_start(ap, format); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
560 xtty->vprint(format, ap); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
561 va_end(ap); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
562 } |
2482
dbccacb79c63
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
2426
diff
changeset
|
563 xtty->print(s.as_string()); |
1644
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
564 xtty->stamp(); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
565 xtty->end_elem(); |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
566 } |
2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
never
parents:
1615
diff
changeset
|
567 } |