author | pliden |
Fri, 11 Apr 2014 12:29:24 +0200 | |
changeset 24094 | 5dbf1f44de18 |
parent 22872 | b6902ee5bc8d |
child 24351 | 61b33cc6d3cf |
permissions | -rw-r--r-- |
1 | 1 |
/* |
18025 | 2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "code/codeCache.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
27 |
#include "code/compiledIC.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
28 |
#include "code/icBuffer.hpp" |
7397 | 29 |
#include "code/nmethod.hpp" |
30 |
#include "compiler/compileBroker.hpp" |
|
31 |
#include "memory/resourceArea.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
32 |
#include "oops/method.hpp" |
7397 | 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" |
|
18025 | 39 |
#include "trace/tracing.hpp" |
7397 | 40 |
#include "utilities/events.hpp" |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
41 |
#include "utilities/ticks.inline.hpp" |
7397 | 42 |
#include "utilities/xmlstream.hpp" |
1 | 43 |
|
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
44 |
#ifdef ASSERT |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
45 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
46 |
#define SWEEP(nm) record_sweep(nm, __LINE__) |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
47 |
// Sweeper logging code |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
48 |
class SweeperRecord { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
49 |
public: |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
50 |
int traversal; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
51 |
int invocation; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
52 |
int compile_id; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
53 |
long traversal_mark; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
54 |
int state; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
55 |
const char* kind; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
56 |
address vep; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
57 |
address uep; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
58 |
int line; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
59 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
60 |
void print() { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
61 |
tty->print_cr("traversal = %d invocation = %d compile_id = %d %s uep = " PTR_FORMAT " vep = " |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
62 |
PTR_FORMAT " state = %d traversal_mark %d line = %d", |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
63 |
traversal, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
64 |
invocation, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
65 |
compile_id, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
66 |
kind == NULL ? "" : kind, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
67 |
uep, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
68 |
vep, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
69 |
state, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
70 |
traversal_mark, |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
71 |
line); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
72 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
73 |
}; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
74 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
75 |
static int _sweep_index = 0; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
76 |
static SweeperRecord* _records = NULL; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
77 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
78 |
void NMethodSweeper::report_events(int id, address entry) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
79 |
if (_records != NULL) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
80 |
for (int i = _sweep_index; i < SweeperLogEntries; i++) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
81 |
if (_records[i].uep == entry || |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
82 |
_records[i].vep == entry || |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
83 |
_records[i].compile_id == id) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
84 |
_records[i].print(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
85 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
86 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
87 |
for (int i = 0; i < _sweep_index; i++) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
88 |
if (_records[i].uep == entry || |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
89 |
_records[i].vep == entry || |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
90 |
_records[i].compile_id == id) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
91 |
_records[i].print(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
92 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
93 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
94 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
95 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
96 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
97 |
void NMethodSweeper::report_events() { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
98 |
if (_records != NULL) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
99 |
for (int i = _sweep_index; i < SweeperLogEntries; i++) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
100 |
// skip empty records |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
101 |
if (_records[i].vep == NULL) continue; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
102 |
_records[i].print(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
103 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
104 |
for (int i = 0; i < _sweep_index; i++) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
105 |
// skip empty records |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
106 |
if (_records[i].vep == NULL) continue; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
107 |
_records[i].print(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
108 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
109 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
110 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
111 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
112 |
void NMethodSweeper::record_sweep(nmethod* nm, int line) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
113 |
if (_records != NULL) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
114 |
_records[_sweep_index].traversal = _traversals; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
115 |
_records[_sweep_index].traversal_mark = nm->_stack_traversal_mark; |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
116 |
_records[_sweep_index].invocation = _sweep_fractions_left; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
117 |
_records[_sweep_index].compile_id = nm->compile_id(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
118 |
_records[_sweep_index].kind = nm->compile_kind(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
119 |
_records[_sweep_index].state = nm->_state; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
120 |
_records[_sweep_index].vep = nm->verified_entry_point(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
121 |
_records[_sweep_index].uep = nm->entry_point(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
122 |
_records[_sweep_index].line = line; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
123 |
_sweep_index = (_sweep_index + 1) % SweeperLogEntries; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
124 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
125 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
126 |
#else |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
127 |
#define SWEEP(nm) |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
128 |
#endif |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
129 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
130 |
nmethod* NMethodSweeper::_current = NULL; // Current nmethod |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
131 |
long NMethodSweeper::_traversals = 0; // Stack scan count, also sweep ID. |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
132 |
long NMethodSweeper::_total_nof_code_cache_sweeps = 0; // Total number of full sweeps of the code cache |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
133 |
long NMethodSweeper::_time_counter = 0; // Virtual time used to periodically invoke sweeper |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
134 |
long NMethodSweeper::_last_sweep = 0; // Value of _time_counter when the last sweep happened |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
135 |
int NMethodSweeper::_seen = 0; // Nof. nmethod we have currently processed in current pass of CodeCache |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
136 |
int NMethodSweeper::_flushed_count = 0; // Nof. nmethods flushed in current sweep |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
137 |
int NMethodSweeper::_zombified_count = 0; // Nof. nmethods made zombie in current sweep |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
138 |
int NMethodSweeper::_marked_for_reclamation_count = 0; // Nof. nmethods marked for reclaim in current sweep |
1 | 139 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
140 |
volatile bool NMethodSweeper::_should_sweep = true; // Indicates if we should invoke the sweeper |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
141 |
volatile int NMethodSweeper::_sweep_fractions_left = 0; // Nof. invocations left until we are completed with this pass |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
142 |
volatile int NMethodSweeper::_sweep_started = 0; // Flag to control conc sweeper |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
143 |
volatile int NMethodSweeper::_bytes_changed = 0; // Counts the total nmethod size if the nmethod changed from: |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
144 |
// 1) alive -> not_entrant |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
145 |
// 2) not_entrant -> zombie |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
146 |
// 3) zombie -> marked_for_reclamation |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
147 |
int NMethodSweeper::_hotness_counter_reset_val = 0; |
1 | 148 |
|
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
149 |
long NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
150 |
long NMethodSweeper::_total_nof_c2_methods_reclaimed = 0; // Accumulated nof methods flushed |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
151 |
size_t NMethodSweeper::_total_flushed_size = 0; // Total number of bytes flushed from the code cache |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
152 |
Tickspan NMethodSweeper::_total_time_sweeping; // Accumulated time sweeping |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
153 |
Tickspan NMethodSweeper::_total_time_this_sweep; // Total time this sweep |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
154 |
Tickspan NMethodSweeper::_peak_sweep_time; // Peak time for a full sweep |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
155 |
Tickspan NMethodSweeper::_peak_sweep_fraction_time; // Peak time sweeping one fraction |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
156 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
157 |
|
18025 | 158 |
|
3908 | 159 |
class MarkActivationClosure: public CodeBlobClosure { |
160 |
public: |
|
161 |
virtual void do_code_blob(CodeBlob* cb) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
162 |
if (cb->is_nmethod()) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
163 |
nmethod* nm = (nmethod*)cb; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
164 |
nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
165 |
// If we see an activation belonging to a non_entrant nmethod, we mark it. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
166 |
if (nm->is_not_entrant()) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
167 |
nm->mark_as_seen_on_stack(); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
168 |
} |
3908 | 169 |
} |
170 |
} |
|
171 |
}; |
|
172 |
static MarkActivationClosure mark_activation_closure; |
|
173 |
||
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
174 |
class SetHotnessClosure: public CodeBlobClosure { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
175 |
public: |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
176 |
virtual void do_code_blob(CodeBlob* cb) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
177 |
if (cb->is_nmethod()) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
178 |
nmethod* nm = (nmethod*)cb; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
179 |
nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
180 |
} |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
181 |
} |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
182 |
}; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
183 |
static SetHotnessClosure set_hotness_closure; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
184 |
|
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
185 |
|
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
186 |
int NMethodSweeper::hotness_counter_reset_val() { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
187 |
if (_hotness_counter_reset_val == 0) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
188 |
_hotness_counter_reset_val = (ReservedCodeCacheSize < M) ? 1 : (ReservedCodeCacheSize / M) * 2; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
189 |
} |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
190 |
return _hotness_counter_reset_val; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
191 |
} |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
192 |
bool NMethodSweeper::sweep_in_progress() { |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
193 |
return (_current != NULL); |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
194 |
} |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
195 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
196 |
// Scans the stacks of all Java threads and marks activations of not-entrant methods. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
197 |
// No need to synchronize access, since 'mark_active_nmethods' is always executed at a |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
198 |
// safepoint. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
199 |
void NMethodSweeper::mark_active_nmethods() { |
1 | 200 |
assert(SafepointSynchronize::is_at_safepoint(), "must be executed at a safepoint"); |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
201 |
// If we do not want to reclaim not-entrant or zombie methods there is no need |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
202 |
// to scan stacks |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
203 |
if (!MethodFlushing) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
204 |
return; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
205 |
} |
1 | 206 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
207 |
// Increase time so that we can estimate when to invoke the sweeper again. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
208 |
_time_counter++; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
209 |
|
1 | 210 |
// Check for restart |
211 |
assert(CodeCache::find_blob_unsafe(_current) == _current, "Sweeper nmethod cached state invalid"); |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
212 |
if (!sweep_in_progress()) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
213 |
_seen = 0; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
214 |
_sweep_fractions_left = NmethodSweepFraction; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
215 |
_current = CodeCache::first_nmethod(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
216 |
_traversals += 1; |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
217 |
_total_time_this_sweep = Tickspan(); |
18025 | 218 |
|
1 | 219 |
if (PrintMethodFlushing) { |
220 |
tty->print_cr("### Sweep: stack traversal %d", _traversals); |
|
221 |
} |
|
3908 | 222 |
Threads::nmethods_do(&mark_activation_closure); |
1 | 223 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
224 |
} else { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
225 |
// Only set hotness counter |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
226 |
Threads::nmethods_do(&set_hotness_closure); |
1 | 227 |
} |
228 |
||
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
229 |
OrderAccess::storestore(); |
1 | 230 |
} |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
231 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
232 |
* This function invokes the sweeper if at least one of the three conditions is met: |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
233 |
* (1) The code cache is getting full |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
234 |
* (2) There are sufficient state changes in/since the last sweep. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
235 |
* (3) We have not been sweeping for 'some time' |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
236 |
*/ |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
237 |
void NMethodSweeper::possibly_sweep() { |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
238 |
assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); |
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21575
diff
changeset
|
239 |
// Only compiler threads are allowed to sweep |
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21575
diff
changeset
|
240 |
if (!MethodFlushing || !sweep_in_progress() || !Thread::current()->is_Compiler_thread()) { |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
241 |
return; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
242 |
} |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
243 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
244 |
// If there was no state change while nmethod sweeping, 'should_sweep' will be false. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
245 |
// This is one of the two places where should_sweep can be set to true. The general |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
246 |
// idea is as follows: If there is enough free space in the code cache, there is no |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
247 |
// need to invoke the sweeper. The following formula (which determines whether to invoke |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
248 |
// the sweeper or not) depends on the assumption that for larger ReservedCodeCacheSizes |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
249 |
// we need less frequent sweeps than for smaller ReservedCodecCacheSizes. Furthermore, |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
250 |
// the formula considers how much space in the code cache is currently used. Here are |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
251 |
// some examples that will (hopefully) help in understanding. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
252 |
// |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
253 |
// Small ReservedCodeCacheSizes: (e.g., < 16M) We invoke the sweeper every time, since |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
254 |
// the result of the division is 0. This |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
255 |
// keeps the used code cache size small |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
256 |
// (important for embedded Java) |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
257 |
// Large ReservedCodeCacheSize : (e.g., 256M + code cache is 10% full). The formula |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
258 |
// computes: (256 / 16) - 1 = 15 |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
259 |
// As a result, we invoke the sweeper after |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
260 |
// 15 invocations of 'mark_active_nmethods. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
261 |
// Large ReservedCodeCacheSize: (e.g., 256M + code Cache is 90% full). The formula |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
262 |
// computes: (256 / 16) - 10 = 6. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
263 |
if (!_should_sweep) { |
22208
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
264 |
const int time_since_last_sweep = _time_counter - _last_sweep; |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
265 |
// ReservedCodeCacheSize has an 'unsigned' type. We need a 'signed' type for max_wait_time, |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
266 |
// since 'time_since_last_sweep' can be larger than 'max_wait_time'. If that happens using |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
267 |
// an unsigned type would cause an underflow (wait_until_next_sweep becomes a large positive |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
268 |
// value) that disables the intended periodic sweeps. |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
269 |
const int max_wait_time = ReservedCodeCacheSize / (16 * M); |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
270 |
double wait_until_next_sweep = max_wait_time - time_since_last_sweep - CodeCache::reverse_free_ratio(); |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
271 |
assert(wait_until_next_sweep <= (double)max_wait_time, "Calculation of code cache sweeper interval is incorrect"); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
272 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
273 |
if ((wait_until_next_sweep <= 0.0) || !CompileBroker::should_compile_new_jobs()) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
274 |
_should_sweep = true; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
275 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
276 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
277 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
278 |
if (_should_sweep && _sweep_fractions_left > 0) { |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
279 |
// Only one thread at a time will sweep |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
280 |
jint old = Atomic::cmpxchg( 1, &_sweep_started, 0 ); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
281 |
if (old != 0) { |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
282 |
return; |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
283 |
} |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
284 |
#ifdef ASSERT |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
285 |
if (LogSweeper && _records == NULL) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
286 |
// Create the ring buffer for the logging code |
13195 | 287 |
_records = NEW_C_HEAP_ARRAY(SweeperRecord, SweeperLogEntries, mtGC); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
288 |
memset(_records, 0, sizeof(SweeperRecord) * SweeperLogEntries); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
289 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
290 |
#endif |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
291 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
292 |
if (_sweep_fractions_left > 0) { |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
293 |
sweep_code_cache(); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
294 |
_sweep_fractions_left--; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
295 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
296 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
297 |
// We are done with sweeping the code cache once. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
298 |
if (_sweep_fractions_left == 0) { |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
299 |
_total_nof_code_cache_sweeps++; |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
300 |
_last_sweep = _time_counter; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
301 |
// Reset flag; temporarily disables sweeper |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
302 |
_should_sweep = false; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
303 |
// If there was enough state change, 'possibly_enable_sweeper()' |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
304 |
// sets '_should_sweep' to true |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
305 |
possibly_enable_sweeper(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
306 |
// Reset _bytes_changed only if there was enough state change. _bytes_changed |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
307 |
// can further increase by calls to 'report_state_change'. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
308 |
if (_should_sweep) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
309 |
_bytes_changed = 0; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
310 |
} |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
311 |
} |
22859
7b88983393b7
8029396: PPC64 (part 212): Several memory ordering fixes in C-code.
goetz
parents:
21767
diff
changeset
|
312 |
// Release work, because another compiler thread could continue. |
7b88983393b7
8029396: PPC64 (part 212): Several memory ordering fixes in C-code.
goetz
parents:
21767
diff
changeset
|
313 |
OrderAccess::release_store((int*)&_sweep_started, 0); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
314 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
315 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
316 |
|
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
317 |
void NMethodSweeper::sweep_code_cache() { |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
318 |
Ticks sweep_start_counter = Ticks::now(); |
18025 | 319 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
320 |
_flushed_count = 0; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
321 |
_zombified_count = 0; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
322 |
_marked_for_reclamation_count = 0; |
18025 | 323 |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
324 |
if (PrintMethodFlushing && Verbose) { |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
325 |
tty->print_cr("### Sweep at %d out of %d. Invocations left: %d", _seen, CodeCache::nof_nmethods(), _sweep_fractions_left); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
326 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
327 |
|
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
328 |
if (!CompileBroker::should_compile_new_jobs()) { |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
329 |
// If we have turned off compilations we might as well do full sweeps |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
330 |
// in order to reach the clean state faster. Otherwise the sleeping compiler |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
331 |
// threads will slow down sweeping. |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
332 |
_sweep_fractions_left = 1; |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
333 |
} |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
334 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
335 |
// We want to visit all nmethods after NmethodSweepFraction |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
336 |
// invocations so divide the remaining number of nmethods by the |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
337 |
// remaining number of invocations. This is only an estimate since |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
338 |
// the number of nmethods changes during the sweep so the final |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
339 |
// stage must iterate until it there are no more nmethods. |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
340 |
int todo = (CodeCache::nof_nmethods() - _seen) / _sweep_fractions_left; |
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
341 |
int swept_count = 0; |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
342 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
343 |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
344 |
assert(!SafepointSynchronize::is_at_safepoint(), "should not be in safepoint when we get here"); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
345 |
assert(!CodeCache_lock->owned_by_self(), "just checking"); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
346 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
347 |
int freed_memory = 0; |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
348 |
{ |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
349 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
350 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
351 |
// The last invocation iterates until there are no more nmethods |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
352 |
for (int i = 0; (i < todo || _sweep_fractions_left == 1) && _current != NULL; i++) { |
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
353 |
swept_count++; |
11789
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
354 |
if (SafepointSynchronize::is_synchronizing()) { // Safepoint request |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
355 |
if (PrintMethodFlushing && Verbose) { |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
356 |
tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _sweep_fractions_left); |
11789
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
357 |
} |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
358 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
359 |
|
11789
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
360 |
assert(Thread::current()->is_Java_thread(), "should be java thread"); |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
361 |
JavaThread* thread = (JavaThread*)Thread::current(); |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
362 |
ThreadBlockInVM tbivm(thread); |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
363 |
thread->java_suspend_self(); |
2ff80dcfc1cf
7145345: Code cache sweeper must cooperate with safepoints
iveresov
parents:
9942
diff
changeset
|
364 |
} |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
365 |
// Since we will give up the CodeCache_lock, always skip ahead |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
366 |
// to the next nmethod. Other blobs can be deleted by other |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
367 |
// threads but nmethods are only reclaimed by the sweeper. |
5895
7127e98012e3
6956958: assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted() || is_optimized() || is_megam
never
parents:
5547
diff
changeset
|
368 |
nmethod* next = CodeCache::next_nmethod(_current); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
369 |
|
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
370 |
// Now ready to process nmethod and give up CodeCache_lock |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
371 |
{ |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
372 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
373 |
freed_memory += process_nmethod(_current); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
374 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
375 |
_seen++; |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
376 |
_current = next; |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
377 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
378 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
379 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
380 |
assert(_sweep_fractions_left > 1 || _current == NULL, "must have scanned the whole cache"); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
381 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
382 |
const Ticks sweep_end_counter = Ticks::now(); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
383 |
const Tickspan sweep_time = sweep_end_counter - sweep_start_counter; |
18025 | 384 |
_total_time_sweeping += sweep_time; |
385 |
_total_time_this_sweep += sweep_time; |
|
386 |
_peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); |
|
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
387 |
_total_flushed_size += freed_memory; |
18025 | 388 |
_total_nof_methods_reclaimed += _flushed_count; |
389 |
||
390 |
EventSweepCodeCache event(UNTIMED); |
|
391 |
if (event.should_commit()) { |
|
392 |
event.set_starttime(sweep_start_counter); |
|
393 |
event.set_endtime(sweep_end_counter); |
|
394 |
event.set_sweepIndex(_traversals); |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
395 |
event.set_sweepFractionIndex(NmethodSweepFraction - _sweep_fractions_left + 1); |
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
396 |
event.set_sweptCount(swept_count); |
18025 | 397 |
event.set_flushedCount(_flushed_count); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
398 |
event.set_markedCount(_marked_for_reclamation_count); |
18025 | 399 |
event.set_zombifiedCount(_zombified_count); |
400 |
event.commit(); |
|
401 |
} |
|
402 |
||
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
403 |
#ifdef ASSERT |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
404 |
if(PrintMethodFlushing) { |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
405 |
tty->print_cr("### sweeper: sweep time(%d): " |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
406 |
INT64_FORMAT, _sweep_fractions_left, (jlong)sweep_time.value()); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
407 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
408 |
#endif |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
409 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
410 |
if (_sweep_fractions_left == 1) { |
18025 | 411 |
_peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
412 |
log_sweep("finished"); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
413 |
} |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
414 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
415 |
// Sweeper is the only case where memory is released, check here if it |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
416 |
// is time to restart the compiler. Only checking if there is a certain |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
417 |
// amount of free memory in the code cache might lead to re-enabling |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
418 |
// compilation although no memory has been released. For example, there are |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
419 |
// cases when compilation was disabled although there is 4MB (or more) free |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
420 |
// memory in the code cache. The reason is code cache fragmentation. Therefore, |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
421 |
// it only makes sense to re-enable compilation if we have actually freed memory. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
422 |
// Note that typically several kB are released for sweeping 16MB of the code |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
423 |
// cache. As a result, 'freed_memory' > 0 to restart the compiler. |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
424 |
if (!CompileBroker::should_compile_new_jobs() && (freed_memory > 0)) { |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
425 |
CompileBroker::set_should_compile_new_jobs(CompileBroker::run_compilation); |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
426 |
log_sweep("restart_compiler"); |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
427 |
} |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
428 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
429 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
430 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
431 |
* This function updates the sweeper statistics that keep track of nmethods |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
432 |
* state changes. If there is 'enough' state change, the sweeper is invoked |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
433 |
* as soon as possible. There can be data races on _bytes_changed. The data |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
434 |
* races are benign, since it does not matter if we loose a couple of bytes. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
435 |
* In the worst case we call the sweeper a little later. Also, we are guaranteed |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
436 |
* to invoke the sweeper if the code cache gets full. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
437 |
*/ |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
438 |
void NMethodSweeper::report_state_change(nmethod* nm) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
439 |
_bytes_changed += nm->total_size(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
440 |
possibly_enable_sweeper(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
441 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
442 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
443 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
444 |
* Function determines if there was 'enough' state change in the code cache to invoke |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
445 |
* the sweeper again. Currently, we determine 'enough' as more than 1% state change in |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
446 |
* the code cache since the last sweep. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
447 |
*/ |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
448 |
void NMethodSweeper::possibly_enable_sweeper() { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
449 |
double percent_changed = ((double)_bytes_changed / (double)ReservedCodeCacheSize) * 100; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
450 |
if (percent_changed > 1.0) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
451 |
_should_sweep = true; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
452 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
453 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
454 |
|
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
455 |
class NMethodMarker: public StackObj { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
456 |
private: |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
457 |
CompilerThread* _thread; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
458 |
public: |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
459 |
NMethodMarker(nmethod* nm) { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
460 |
_thread = CompilerThread::current(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
461 |
if (!nm->is_zombie() && !nm->is_unloaded()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
462 |
// Only expose live nmethods for scanning |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
463 |
_thread->set_scanned_nmethod(nm); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
464 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
465 |
} |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
466 |
~NMethodMarker() { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
467 |
_thread->set_scanned_nmethod(NULL); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
468 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
469 |
}; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
470 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
471 |
void NMethodSweeper::release_nmethod(nmethod *nm) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
472 |
// Clean up any CompiledICHolders |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
473 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
474 |
ResourceMark rm; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
475 |
MutexLocker ml_patch(CompiledIC_lock); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
476 |
RelocIterator iter(nm); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
477 |
while (iter.next()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
478 |
if (iter.type() == relocInfo::virtual_call_type) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
479 |
CompiledIC::cleanup_call_site(iter.virtual_call_reloc()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
480 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
481 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
482 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
483 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
484 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
485 |
nm->flush(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
486 |
} |
1 | 487 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
488 |
int NMethodSweeper::process_nmethod(nmethod *nm) { |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
489 |
assert(!CodeCache_lock->owned_by_self(), "just checking"); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
490 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
491 |
int freed_memory = 0; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
492 |
// Make sure this nmethod doesn't get unloaded during the scan, |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
493 |
// since safepoints may happen during acquired below locks. |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
494 |
NMethodMarker nmm(nm); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
495 |
SWEEP(nm); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
496 |
|
1 | 497 |
// Skip methods that are currently referenced by the VM |
498 |
if (nm->is_locked_by_vm()) { |
|
499 |
// But still remember to clean-up inline caches for alive nmethods |
|
500 |
if (nm->is_alive()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
501 |
// Clean inline caches that point to zombie/non-entrant methods |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
502 |
MutexLocker cl(CompiledIC_lock); |
1 | 503 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
504 |
SWEEP(nm); |
1 | 505 |
} |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
506 |
return freed_memory; |
1 | 507 |
} |
508 |
||
509 |
if (nm->is_zombie()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
510 |
// If it is the first time we see nmethod then we mark it. Otherwise, |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
511 |
// we reclaim it. When we have seen a zombie method twice, we know that |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
512 |
// there are no inline caches that refer to it. |
1 | 513 |
if (nm->is_marked_for_reclamation()) { |
514 |
assert(!nm->is_locked_by_vm(), "must not flush locked nmethods"); |
|
3696 | 515 |
if (PrintMethodFlushing && Verbose) { |
4750 | 516 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), nm); |
3696 | 517 |
} |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
518 |
freed_memory = nm->total_size(); |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
519 |
if (nm->is_compiled_by_c2()) { |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
520 |
_total_nof_c2_methods_reclaimed++; |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
521 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
522 |
release_nmethod(nm); |
18025 | 523 |
_flushed_count++; |
1 | 524 |
} else { |
3696 | 525 |
if (PrintMethodFlushing && Verbose) { |
4750 | 526 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), nm); |
3696 | 527 |
} |
1 | 528 |
nm->mark_for_reclamation(); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
529 |
// Keep track of code cache state change |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
530 |
_bytes_changed += nm->total_size(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
531 |
_marked_for_reclamation_count++; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
532 |
SWEEP(nm); |
1 | 533 |
} |
534 |
} else if (nm->is_not_entrant()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
535 |
// If there are no current activations of this method on the |
1 | 536 |
// stack we can safely convert it to a zombie method |
537 |
if (nm->can_not_entrant_be_converted()) { |
|
3696 | 538 |
if (PrintMethodFlushing && Verbose) { |
4750 | 539 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), nm); |
3696 | 540 |
} |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
541 |
// Code cache state change is tracked in make_zombie() |
1 | 542 |
nm->make_zombie(); |
18025 | 543 |
_zombified_count++; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
544 |
SWEEP(nm); |
1 | 545 |
} else { |
546 |
// Still alive, clean up its inline caches |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
547 |
MutexLocker cl(CompiledIC_lock); |
1 | 548 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
549 |
SWEEP(nm); |
1 | 550 |
} |
551 |
} else if (nm->is_unloaded()) { |
|
552 |
// Unloaded code, just make it a zombie |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
553 |
if (PrintMethodFlushing && Verbose) { |
4750 | 554 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), nm); |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
555 |
} |
3696 | 556 |
if (nm->is_osr_method()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
557 |
SWEEP(nm); |
1 | 558 |
// No inline caches will ever point to osr methods, so we can just remove it |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
559 |
freed_memory = nm->total_size(); |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
560 |
if (nm->is_compiled_by_c2()) { |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
561 |
_total_nof_c2_methods_reclaimed++; |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
562 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
563 |
release_nmethod(nm); |
18025 | 564 |
_flushed_count++; |
1 | 565 |
} else { |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
566 |
// Code cache state change is tracked in make_zombie() |
1 | 567 |
nm->make_zombie(); |
18025 | 568 |
_zombified_count++; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
569 |
SWEEP(nm); |
1 | 570 |
} |
571 |
} else { |
|
4750 | 572 |
if (UseCodeCacheFlushing) { |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
573 |
if (!nm->is_locked_by_vm() && !nm->is_osr_method() && !nm->is_native_method()) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
574 |
// Do not make native methods and OSR-methods not-entrant |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
575 |
nm->dec_hotness_counter(); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
576 |
// Get the initial value of the hotness counter. This value depends on the |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
577 |
// ReservedCodeCacheSize |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
578 |
int reset_val = hotness_counter_reset_val(); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
579 |
int time_since_reset = reset_val - nm->hotness_counter(); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
580 |
double threshold = -reset_val + (CodeCache::reverse_free_ratio() * NmethodSweepActivity); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
581 |
// The less free space in the code cache we have - the bigger reverse_free_ratio() is. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
582 |
// I.e., 'threshold' increases with lower available space in the code cache and a higher |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
583 |
// NmethodSweepActivity. If the current hotness counter - which decreases from its initial |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
584 |
// value until it is reset by stack walking - is smaller than the computed threshold, the |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
585 |
// corresponding nmethod is considered for removal. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
586 |
if ((NmethodSweepActivity > 0) && (nm->hotness_counter() < threshold) && (time_since_reset > 10)) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
587 |
// A method is marked as not-entrant if the method is |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
588 |
// 1) 'old enough': nm->hotness_counter() < threshold |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
589 |
// 2) The method was in_use for a minimum amount of time: (time_since_reset > 10) |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
590 |
// The second condition is necessary if we are dealing with very small code cache |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
591 |
// sizes (e.g., <10m) and the code cache size is too small to hold all hot methods. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
592 |
// The second condition ensures that methods are not immediately made not-entrant |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
593 |
// after compilation. |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
594 |
nm->make_not_entrant(); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
595 |
// Code cache state change is tracked in make_not_entrant() |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
596 |
if (PrintMethodFlushing && Verbose) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
597 |
tty->print_cr("### Nmethod %d/" PTR_FORMAT "made not-entrant: hotness counter %d/%d threshold %f", |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
598 |
nm->compile_id(), nm, nm->hotness_counter(), reset_val, threshold); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
599 |
} |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
600 |
} |
4750 | 601 |
} |
602 |
} |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
603 |
// Clean-up all inline caches that point to zombie/non-reentrant methods |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
604 |
MutexLocker cl(CompiledIC_lock); |
1 | 605 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
606 |
SWEEP(nm); |
1 | 607 |
} |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
608 |
return freed_memory; |
4750 | 609 |
} |
610 |
||
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
611 |
// Print out some state information about the current sweep and the |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
612 |
// state of the code cache if it's requested. |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
613 |
void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
614 |
if (PrintMethodFlushing) { |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
615 |
stringStream s; |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
616 |
// Dump code cache state into a buffer before locking the tty, |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
617 |
// because log_state() will use locks causing lock conflicts. |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
618 |
CodeCache::log_state(&s); |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
619 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
620 |
ttyLocker ttyl; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
621 |
tty->print("### sweeper: %s ", msg); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
622 |
if (format != NULL) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
623 |
va_list ap; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
624 |
va_start(ap, format); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
625 |
tty->vprint(format, ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
626 |
va_end(ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
627 |
} |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
628 |
tty->print_cr(s.as_string()); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
629 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
630 |
|
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
631 |
if (LogCompilation && (xtty != NULL)) { |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
632 |
stringStream s; |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
633 |
// Dump code cache state into a buffer before locking the tty, |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
634 |
// because log_state() will use locks causing lock conflicts. |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
635 |
CodeCache::log_state(&s); |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
636 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
637 |
ttyLocker ttyl; |
5926 | 638 |
xtty->begin_elem("sweeper state='%s' traversals='" INTX_FORMAT "' ", msg, (intx)traversal_count()); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
639 |
if (format != NULL) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
640 |
va_list ap; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
641 |
va_start(ap, format); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
642 |
xtty->vprint(format, ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
643 |
va_end(ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
644 |
} |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
645 |
xtty->print(s.as_string()); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
646 |
xtty->stamp(); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
647 |
xtty->end_elem(); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
648 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
649 |
} |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
650 |
|
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
651 |
void NMethodSweeper::print() { |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
652 |
ttyLocker ttyl; |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
653 |
tty->print_cr("Code cache sweeper statistics:"); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
654 |
tty->print_cr(" Total sweep time: %1.0lfms", (double)_total_time_sweeping.value()/1000000); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
655 |
tty->print_cr(" Total number of full sweeps: %ld", _total_nof_code_cache_sweeps); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
656 |
tty->print_cr(" Total number of flushed methods: %ld(%ld C2 methods)", _total_nof_methods_reclaimed, |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
657 |
_total_nof_c2_methods_reclaimed); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
658 |
tty->print_cr(" Total size of flushed methods: " SIZE_FORMAT "kB", _total_flushed_size/K); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
659 |
} |