author | coleenp |
Wed, 28 Oct 2015 09:47:23 -0400 | |
changeset 33611 | 9abd65805e19 |
parent 33148 | 68fa8b6c4340 |
child 34158 | 1f8d643b02d5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, 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" |
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24445
diff
changeset
|
33 |
#include "runtime/atomic.inline.hpp" |
7397 | 34 |
#include "runtime/compilationPolicy.hpp" |
35 |
#include "runtime/mutexLocker.hpp" |
|
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
22872
diff
changeset
|
36 |
#include "runtime/orderAccess.inline.hpp" |
7397 | 37 |
#include "runtime/os.hpp" |
38 |
#include "runtime/sweeper.hpp" |
|
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
22872
diff
changeset
|
39 |
#include "runtime/thread.inline.hpp" |
7397 | 40 |
#include "runtime/vm_operations.hpp" |
18025 | 41 |
#include "trace/tracing.hpp" |
7397 | 42 |
#include "utilities/events.hpp" |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
43 |
#include "utilities/ticks.inline.hpp" |
7397 | 44 |
#include "utilities/xmlstream.hpp" |
1 | 45 |
|
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
46 |
#ifdef ASSERT |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
47 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
48 |
#define SWEEP(nm) record_sweep(nm, __LINE__) |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
49 |
// Sweeper logging code |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
50 |
class SweeperRecord { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
51 |
public: |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
52 |
int traversal; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
53 |
int compile_id; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
54 |
long traversal_mark; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
55 |
int state; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
56 |
const char* kind; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
57 |
address vep; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
58 |
address uep; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
59 |
int line; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
60 |
|
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
61 |
void print() { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
62 |
tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = " |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
63 |
PTR_FORMAT " state = %d traversal_mark %ld line = %d", |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
64 |
traversal, |
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, |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
67 |
p2i(uep), |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
68 |
p2i(vep), |
9942
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; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
116 |
_records[_sweep_index].compile_id = nm->compile_id(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
117 |
_records[_sweep_index].kind = nm->compile_kind(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
118 |
_records[_sweep_index].state = nm->_state; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
119 |
_records[_sweep_index].vep = nm->verified_entry_point(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
120 |
_records[_sweep_index].uep = nm->entry_point(); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
121 |
_records[_sweep_index].line = line; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
122 |
_sweep_index = (_sweep_index + 1) % SweeperLogEntries; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
123 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
124 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
125 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
126 |
void NMethodSweeper::init_sweeper_log() { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
127 |
if (LogSweeper && _records == NULL) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
128 |
// Create the ring buffer for the logging code |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
129 |
_records = NEW_C_HEAP_ARRAY(SweeperRecord, SweeperLogEntries, mtGC); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
130 |
memset(_records, 0, sizeof(SweeperRecord) * SweeperLogEntries); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
131 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
132 |
} |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
133 |
#else |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
134 |
#define SWEEP(nm) |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
135 |
#endif |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
136 |
|
26796 | 137 |
NMethodIterator NMethodSweeper::_current; // Current nmethod |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
int NMethodSweeper::_seen = 0; // Nof. nmethod we have currently processed in current pass of CodeCache |
1 | 143 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
144 |
volatile bool NMethodSweeper::_should_sweep = true; // Indicates if we should invoke the sweeper |
30205 | 145 |
volatile bool NMethodSweeper::_force_sweep = false;// Indicates if we should force a sweep |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
146 |
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
|
147 |
// 1) alive -> not_entrant |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
148 |
// 2) not_entrant -> zombie |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
149 |
// 3) zombie -> marked_for_reclamation |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
150 |
int NMethodSweeper::_hotness_counter_reset_val = 0; |
1 | 151 |
|
26796 | 152 |
long NMethodSweeper::_total_nof_methods_reclaimed = 0; // Accumulated nof methods flushed |
153 |
long NMethodSweeper::_total_nof_c2_methods_reclaimed = 0; // Accumulated nof methods flushed |
|
154 |
size_t NMethodSweeper::_total_flushed_size = 0; // Total number of bytes flushed from the code cache |
|
155 |
Tickspan NMethodSweeper::_total_time_sweeping; // Accumulated time sweeping |
|
156 |
Tickspan NMethodSweeper::_total_time_this_sweep; // Total time this sweep |
|
157 |
Tickspan NMethodSweeper::_peak_sweep_time; // Peak time for a full sweep |
|
158 |
Tickspan NMethodSweeper::_peak_sweep_fraction_time; // Peak time sweeping one fraction |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
159 |
|
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
27917
diff
changeset
|
160 |
Monitor* NMethodSweeper::_stat_lock = new Monitor(Mutex::special, "Sweeper::Statistics", true, Monitor::_safepoint_check_sometimes); |
18025 | 161 |
|
3908 | 162 |
class MarkActivationClosure: public CodeBlobClosure { |
163 |
public: |
|
164 |
virtual void do_code_blob(CodeBlob* cb) { |
|
26796 | 165 |
assert(cb->is_nmethod(), "CodeBlob should be nmethod"); |
166 |
nmethod* nm = (nmethod*)cb; |
|
167 |
nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
|
168 |
// If we see an activation belonging to a non_entrant nmethod, we mark it. |
|
169 |
if (nm->is_not_entrant()) { |
|
170 |
nm->mark_as_seen_on_stack(); |
|
3908 | 171 |
} |
172 |
} |
|
173 |
}; |
|
174 |
static MarkActivationClosure mark_activation_closure; |
|
175 |
||
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
176 |
class SetHotnessClosure: public CodeBlobClosure { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
177 |
public: |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
178 |
virtual void do_code_blob(CodeBlob* cb) { |
26796 | 179 |
assert(cb->is_nmethod(), "CodeBlob should be nmethod"); |
180 |
nmethod* nm = (nmethod*)cb; |
|
181 |
nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
|
20290
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 |
}; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
184 |
static SetHotnessClosure set_hotness_closure; |
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 |
|
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
187 |
int NMethodSweeper::hotness_counter_reset_val() { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
188 |
if (_hotness_counter_reset_val == 0) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
189 |
_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
|
190 |
} |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
191 |
return _hotness_counter_reset_val; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
192 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
193 |
bool NMethodSweeper::wait_for_stack_scanning() { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
194 |
return _current.end(); |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
195 |
} |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
196 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
197 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
198 |
* Scans the stacks of all Java threads and marks activations of not-entrant methods. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
199 |
* No need to synchronize access, since 'mark_active_nmethods' is always executed at a |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
200 |
* safepoint. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
201 |
*/ |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
202 |
void NMethodSweeper::mark_active_nmethods() { |
1 | 203 |
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
|
204 |
// 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
|
205 |
// to scan stacks |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
206 |
if (!MethodFlushing) { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
207 |
return; |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
208 |
} |
1 | 209 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
210 |
// 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
|
211 |
_time_counter++; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
212 |
|
1 | 213 |
// Check for restart |
26796 | 214 |
assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid"); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
215 |
if (wait_for_stack_scanning()) { |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
216 |
_seen = 0; |
26796 | 217 |
_current = NMethodIterator(); |
218 |
// Initialize to first nmethod |
|
219 |
_current.next(); |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
220 |
_traversals += 1; |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
221 |
_total_time_this_sweep = Tickspan(); |
18025 | 222 |
|
1 | 223 |
if (PrintMethodFlushing) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
224 |
tty->print_cr("### Sweep: stack traversal %ld", _traversals); |
1 | 225 |
} |
3908 | 226 |
Threads::nmethods_do(&mark_activation_closure); |
1 | 227 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
228 |
} else { |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
229 |
// Only set hotness counter |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
230 |
Threads::nmethods_do(&set_hotness_closure); |
1 | 231 |
} |
232 |
||
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
233 |
OrderAccess::storestore(); |
1 | 234 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
235 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
236 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
237 |
* This function triggers a VM operation that does stack scanning of active |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
238 |
* methods. Stack scanning is mandatory for the sweeper to make progress. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
239 |
*/ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
240 |
void NMethodSweeper::do_stack_scanning() { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
241 |
assert(!CodeCache_lock->owned_by_self(), "just checking"); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
242 |
if (wait_for_stack_scanning()) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
243 |
VM_MarkActiveNMethods op; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
244 |
VMThread::execute(&op); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
245 |
_should_sweep = true; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
246 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
247 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
248 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
249 |
void NMethodSweeper::sweeper_loop() { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
250 |
bool timeout; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
251 |
while (true) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
252 |
{ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
253 |
ThreadBlockInVM tbivm(JavaThread::current()); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
254 |
MutexLockerEx waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
255 |
const long wait_time = 60*60*24 * 1000; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
256 |
timeout = CodeCache_lock->wait(Mutex::_no_safepoint_check_flag, wait_time); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
257 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
258 |
if (!timeout) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
259 |
possibly_sweep(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
260 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
261 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
262 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
263 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
264 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
265 |
* Wakes up the sweeper thread to possibly sweep. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
266 |
*/ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
267 |
void NMethodSweeper::notify(int code_blob_type) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
268 |
// Makes sure that we do not invoke the sweeper too often during startup. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
269 |
double start_threshold = 100.0 / (double)StartAggressiveSweepingAt; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
270 |
double aggressive_sweep_threshold = MIN2(start_threshold, 1.1); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
271 |
if (CodeCache::reverse_free_ratio(code_blob_type) >= aggressive_sweep_threshold) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
272 |
assert_locked_or_safepoint(CodeCache_lock); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
273 |
CodeCache_lock->notify(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
274 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
275 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
276 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
277 |
/** |
30205 | 278 |
* Wakes up the sweeper thread and forces a sweep. Blocks until it finished. |
279 |
*/ |
|
280 |
void NMethodSweeper::force_sweep() { |
|
281 |
ThreadBlockInVM tbivm(JavaThread::current()); |
|
282 |
MutexLockerEx waiter(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
283 |
// Request forced sweep |
|
284 |
_force_sweep = true; |
|
285 |
while (_force_sweep) { |
|
286 |
// Notify sweeper that we want to force a sweep and wait for completion. |
|
287 |
// In case a sweep currently takes place we timeout and try again because |
|
288 |
// we want to enforce a full sweep. |
|
289 |
CodeCache_lock->notify(); |
|
290 |
CodeCache_lock->wait(Mutex::_no_safepoint_check_flag, 1000); |
|
291 |
} |
|
292 |
} |
|
293 |
||
294 |
/** |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
295 |
* Handle a safepoint request |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
296 |
*/ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
297 |
void NMethodSweeper::handle_safepoint_request() { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
298 |
if (SafepointSynchronize::is_synchronizing()) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
299 |
if (PrintMethodFlushing && Verbose) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
300 |
tty->print_cr("### Sweep at %d out of %d, yielding to safepoint", _seen, CodeCache::nof_nmethods()); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
301 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
302 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
303 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
304 |
JavaThread* thread = JavaThread::current(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
305 |
ThreadBlockInVM tbivm(thread); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
306 |
thread->java_suspend_self(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
307 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
308 |
} |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
309 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
310 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
311 |
* 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
|
312 |
* (1) The code cache is getting full |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
313 |
* (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
|
314 |
* (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
|
315 |
*/ |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
316 |
void NMethodSweeper::possibly_sweep() { |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
317 |
assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
318 |
// 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
|
319 |
// 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
|
320 |
// 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
|
321 |
// 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
|
322 |
// 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
|
323 |
// 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
|
324 |
// 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
|
325 |
// some examples that will (hopefully) help in understanding. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
326 |
// |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
327 |
// 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
|
328 |
// the result of the division is 0. This |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
329 |
// keeps the used code cache size small |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
330 |
// (important for embedded Java) |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
331 |
// 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
|
332 |
// computes: (256 / 16) - 1 = 15 |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
333 |
// As a result, we invoke the sweeper after |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
334 |
// 15 invocations of 'mark_active_nmethods. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
335 |
// 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
|
336 |
// computes: (256 / 16) - 10 = 6. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
337 |
if (!_should_sweep) { |
22208
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
338 |
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
|
339 |
// 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
|
340 |
// 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
|
341 |
// 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
|
342 |
// value) that disables the intended periodic sweeps. |
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
343 |
const int max_wait_time = ReservedCodeCacheSize / (16 * M); |
26796 | 344 |
double wait_until_next_sweep = max_wait_time - time_since_last_sweep - |
345 |
MAX2(CodeCache::reverse_free_ratio(CodeBlobType::MethodProfiled), |
|
346 |
CodeCache::reverse_free_ratio(CodeBlobType::MethodNonProfiled)); |
|
22208
fb1e20bd389f
8029091: Bug in calculation of code cache sweeping interval
anoll
parents:
21767
diff
changeset
|
347 |
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
|
348 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
349 |
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
|
350 |
_should_sweep = true; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
351 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
352 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
353 |
|
30205 | 354 |
// Remember if this was a forced sweep |
355 |
bool forced = _force_sweep; |
|
356 |
||
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
357 |
// Force stack scanning if there is only 10% free space in the code cache. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
358 |
// We force stack scanning only non-profiled code heap gets full, since critical |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
359 |
// allocation go to the non-profiled heap and we must be make sure that there is |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
360 |
// enough space. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
361 |
double free_percent = 1 / CodeCache::reverse_free_ratio(CodeBlobType::MethodNonProfiled) * 100; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
362 |
if (free_percent <= StartAggressiveSweepingAt) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
363 |
do_stack_scanning(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
364 |
} |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
365 |
|
30205 | 366 |
if (_should_sweep || forced) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
367 |
init_sweeper_log(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
368 |
sweep_code_cache(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
369 |
} |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
370 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
371 |
// We are done with sweeping the code cache once. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
372 |
_total_nof_code_cache_sweeps++; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
373 |
_last_sweep = _time_counter; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
374 |
// Reset flag; temporarily disables sweeper |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
375 |
_should_sweep = false; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
376 |
// If there was enough state change, 'possibly_enable_sweeper()' |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
377 |
// sets '_should_sweep' to true |
30205 | 378 |
possibly_enable_sweeper(); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
379 |
// Reset _bytes_changed only if there was enough state change. _bytes_changed |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
380 |
// can further increase by calls to 'report_state_change'. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
381 |
if (_should_sweep) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
382 |
_bytes_changed = 0; |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
383 |
} |
30205 | 384 |
|
385 |
if (forced) { |
|
386 |
// Notify requester that forced sweep finished |
|
387 |
assert(_force_sweep, "Should be a forced sweep"); |
|
388 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
389 |
_force_sweep = false; |
|
390 |
CodeCache_lock->notify(); |
|
391 |
} |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
392 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
393 |
|
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
394 |
void NMethodSweeper::sweep_code_cache() { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
395 |
ResourceMark rm; |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
396 |
Ticks sweep_start_counter = Ticks::now(); |
18025 | 397 |
|
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
398 |
int flushed_count = 0; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
399 |
int zombified_count = 0; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
400 |
int marked_for_reclamation_count = 0; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
401 |
int flushed_c2_count = 0; |
18025 | 402 |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
403 |
if (PrintMethodFlushing && Verbose) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
404 |
tty->print_cr("### Sweep at %d out of %d", _seen, CodeCache::nof_nmethods()); |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
405 |
} |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
406 |
|
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
407 |
int swept_count = 0; |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
408 |
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
|
409 |
assert(!CodeCache_lock->owned_by_self(), "just checking"); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
410 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
411 |
int freed_memory = 0; |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
412 |
{ |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
413 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
414 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
415 |
while (!_current.end()) { |
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
416 |
swept_count++; |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
417 |
// 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
|
418 |
// 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
|
419 |
// threads but nmethods are only reclaimed by the sweeper. |
26796 | 420 |
nmethod* nm = _current.method(); |
421 |
_current.next(); |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
422 |
|
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
423 |
// Now ready to process nmethod and give up CodeCache_lock |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
424 |
{ |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
425 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
426 |
int size = nm->total_size(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
427 |
bool is_c2_method = nm->is_compiled_by_c2(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
428 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
429 |
MethodStateChange type = process_nmethod(nm); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
430 |
switch (type) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
431 |
case Flushed: |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
432 |
freed_memory += size; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
433 |
++flushed_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
434 |
if (is_c2_method) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
435 |
++flushed_c2_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
436 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
437 |
break; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
438 |
case MarkedForReclamation: |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
439 |
++marked_for_reclamation_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
440 |
break; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
441 |
case MadeZombie: |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
442 |
++zombified_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
443 |
break; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
444 |
case None: |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
445 |
break; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
446 |
default: |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
447 |
ShouldNotReachHere(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
448 |
} |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
449 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
450 |
_seen++; |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
451 |
handle_safepoint_request(); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
452 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
453 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
454 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
455 |
assert(_current.end(), "must have scanned the whole cache"); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
456 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21727
diff
changeset
|
457 |
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
|
458 |
const Tickspan sweep_time = sweep_end_counter - sweep_start_counter; |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
459 |
{ |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
460 |
MutexLockerEx mu(_stat_lock, Mutex::_no_safepoint_check_flag); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
461 |
_total_time_sweeping += sweep_time; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
462 |
_total_time_this_sweep += sweep_time; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
463 |
_peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
464 |
_total_flushed_size += freed_memory; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
465 |
_total_nof_methods_reclaimed += flushed_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
466 |
_total_nof_c2_methods_reclaimed += flushed_c2_count; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
467 |
_peak_sweep_time = MAX2(_peak_sweep_time, _total_time_this_sweep); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
468 |
} |
18025 | 469 |
EventSweepCodeCache event(UNTIMED); |
470 |
if (event.should_commit()) { |
|
471 |
event.set_starttime(sweep_start_counter); |
|
472 |
event.set_endtime(sweep_end_counter); |
|
473 |
event.set_sweepIndex(_traversals); |
|
20019
3e9220f93c61
8022883: Assertion failed: sweptCount >= flushedCount + markedCount + zombifiedCount
anoll
parents:
18025
diff
changeset
|
474 |
event.set_sweptCount(swept_count); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
475 |
event.set_flushedCount(flushed_count); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
476 |
event.set_markedCount(marked_for_reclamation_count); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
477 |
event.set_zombifiedCount(zombified_count); |
18025 | 478 |
event.commit(); |
479 |
} |
|
480 |
||
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
481 |
#ifdef ASSERT |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
482 |
if(PrintMethodFlushing) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
483 |
tty->print_cr("### sweeper: sweep time(" JLONG_FORMAT "): ", sweep_time.value()); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
484 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
485 |
#endif |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
486 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
487 |
log_sweep("finished"); |
17132
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
488 |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
489 |
// 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
|
490 |
// 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
|
491 |
// 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
|
492 |
// 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
|
493 |
// 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
|
494 |
// 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
|
495 |
// 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
|
496 |
// 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
|
497 |
// 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
|
498 |
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
|
499 |
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
|
500 |
log_sweep("restart_compiler"); |
dffd513b2a8c
8012547: Code cache flushing can get stuck reclaming of memory
neliasso
parents:
13728
diff
changeset
|
501 |
} |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
502 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
503 |
|
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
504 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
505 |
* 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
|
506 |
* 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
|
507 |
* 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
|
508 |
* 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
|
509 |
* 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
|
510 |
* 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
|
511 |
*/ |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
512 |
void NMethodSweeper::report_state_change(nmethod* nm) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
513 |
_bytes_changed += nm->total_size(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
514 |
possibly_enable_sweeper(); |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
515 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
516 |
|
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
517 |
/** |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
518 |
* 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
|
519 |
* 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
|
520 |
* the code cache since the last sweep. |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
521 |
*/ |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
522 |
void NMethodSweeper::possibly_enable_sweeper() { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
523 |
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
|
524 |
if (percent_changed > 1.0) { |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
525 |
_should_sweep = true; |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
526 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
527 |
} |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
528 |
|
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
529 |
class NMethodMarker: public StackObj { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
530 |
private: |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
531 |
CodeCacheSweeperThread* _thread; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
532 |
public: |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
533 |
NMethodMarker(nmethod* nm) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
534 |
JavaThread* current = JavaThread::current(); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
535 |
assert (current->is_Code_cache_sweeper_thread(), "Must be"); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
536 |
_thread = (CodeCacheSweeperThread*)JavaThread::current(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
537 |
if (!nm->is_zombie() && !nm->is_unloaded()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
538 |
// Only expose live nmethods for scanning |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
539 |
_thread->set_scanned_nmethod(nm); |
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
540 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
541 |
} |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
542 |
~NMethodMarker() { |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
543 |
_thread->set_scanned_nmethod(NULL); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
544 |
} |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
545 |
}; |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
546 |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27017
diff
changeset
|
547 |
void NMethodSweeper::release_nmethod(nmethod* nm) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
548 |
// Clean up any CompiledICHolders |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
549 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
550 |
ResourceMark rm; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
551 |
MutexLocker ml_patch(CompiledIC_lock); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
552 |
RelocIterator iter(nm); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
553 |
while (iter.next()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
554 |
if (iter.type() == relocInfo::virtual_call_type) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
555 |
CompiledIC::cleanup_call_site(iter.virtual_call_reloc()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
556 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
557 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
558 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
559 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
560 |
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
|
561 |
nm->flush(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
562 |
} |
1 | 563 |
|
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
564 |
NMethodSweeper::MethodStateChange NMethodSweeper::process_nmethod(nmethod* nm) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
565 |
assert(nm != NULL, "sanity"); |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
566 |
assert(!CodeCache_lock->owned_by_self(), "just checking"); |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
567 |
|
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
568 |
MethodStateChange result = None; |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
569 |
// 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
|
570 |
// since safepoints may happen during acquired below locks. |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
571 |
NMethodMarker nmm(nm); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
572 |
SWEEP(nm); |
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
573 |
|
1 | 574 |
// Skip methods that are currently referenced by the VM |
575 |
if (nm->is_locked_by_vm()) { |
|
576 |
// But still remember to clean-up inline caches for alive nmethods |
|
577 |
if (nm->is_alive()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
578 |
// Clean inline caches that point to zombie/non-entrant methods |
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
579 |
MutexLocker cl(CompiledIC_lock); |
1 | 580 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
581 |
SWEEP(nm); |
1 | 582 |
} |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
583 |
return result; |
1 | 584 |
} |
585 |
||
586 |
if (nm->is_zombie()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
587 |
// 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
|
588 |
// 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
|
589 |
// there are no inline caches that refer to it. |
1 | 590 |
if (nm->is_marked_for_reclamation()) { |
591 |
assert(!nm->is_locked_by_vm(), "must not flush locked nmethods"); |
|
3696 | 592 |
if (PrintMethodFlushing && Verbose) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
593 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (marked for reclamation) being flushed", nm->compile_id(), p2i(nm)); |
3696 | 594 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
595 |
release_nmethod(nm); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
596 |
assert(result == None, "sanity"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
597 |
result = Flushed; |
1 | 598 |
} else { |
3696 | 599 |
if (PrintMethodFlushing && Verbose) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
600 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (zombie) being marked for reclamation", nm->compile_id(), p2i(nm)); |
3696 | 601 |
} |
1 | 602 |
nm->mark_for_reclamation(); |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
603 |
// Keep track of code cache state change |
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
604 |
_bytes_changed += nm->total_size(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
605 |
SWEEP(nm); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
606 |
assert(result == None, "sanity"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
607 |
result = MarkedForReclamation; |
1 | 608 |
} |
609 |
} else if (nm->is_not_entrant()) { |
|
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
610 |
// If there are no current activations of this method on the |
1 | 611 |
// stack we can safely convert it to a zombie method |
32466
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
612 |
if (nm->can_convert_to_zombie()) { |
26912
19021f626ad2
8058737: CodeCache::find_blob fails with 'unsafe access to zombie method'
thartmann
parents:
26799
diff
changeset
|
613 |
// Clear ICStubs to prevent back patching stubs of zombie or unloaded |
19021f626ad2
8058737: CodeCache::find_blob fails with 'unsafe access to zombie method'
thartmann
parents:
26799
diff
changeset
|
614 |
// nmethods during the next safepoint (see ICStub::finalize). |
27017
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
615 |
{ |
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
616 |
MutexLocker cl(CompiledIC_lock); |
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
617 |
nm->clear_ic_stubs(); |
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
618 |
} |
32401
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
619 |
if (PrintMethodFlushing && Verbose) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
620 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (not entrant) being made zombie", nm->compile_id(), p2i(nm)); |
27017
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
621 |
} |
32401
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
622 |
// Code cache state change is tracked in make_zombie() |
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
623 |
nm->make_zombie(); |
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
624 |
SWEEP(nm); |
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
625 |
assert(result == None, "sanity"); |
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31348
diff
changeset
|
626 |
result = MadeZombie; |
27017
bae5d661dd4b
8059735: make_not_entrant_or_zombie sees zombies
thartmann
parents:
26912
diff
changeset
|
627 |
assert(nm->is_zombie(), "nmethod must be zombie"); |
1 | 628 |
} else { |
629 |
// Still alive, clean up its inline caches |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
4750
diff
changeset
|
630 |
MutexLocker cl(CompiledIC_lock); |
1 | 631 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
632 |
SWEEP(nm); |
1 | 633 |
} |
634 |
} else if (nm->is_unloaded()) { |
|
635 |
// 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
|
636 |
if (PrintMethodFlushing && Verbose) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
637 |
tty->print_cr("### Nmethod %3d/" PTR_FORMAT " (unloaded) being made zombie", nm->compile_id(), p2i(nm)); |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
638 |
} |
3696 | 639 |
if (nm->is_osr_method()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
640 |
SWEEP(nm); |
1 | 641 |
// No inline caches will ever point to osr methods, so we can just remove it |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
642 |
release_nmethod(nm); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
643 |
assert(result == None, "sanity"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
644 |
result = Flushed; |
1 | 645 |
} else { |
32466
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
646 |
{ |
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
647 |
// Clean ICs of unloaded nmethods as well because they may reference other |
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
648 |
// unloaded nmethods that may be flushed earlier in the sweeper cycle. |
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
649 |
MutexLocker cl(CompiledIC_lock); |
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
650 |
nm->cleanup_inline_caches(); |
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
651 |
} |
21575
6a9645992cee
8027593: performance drop with constrained codecache starting with hs25 b111
anoll
parents:
20290
diff
changeset
|
652 |
// Code cache state change is tracked in make_zombie() |
1 | 653 |
nm->make_zombie(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
654 |
SWEEP(nm); |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
655 |
assert(result == None, "sanity"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
656 |
result = MadeZombie; |
1 | 657 |
} |
658 |
} else { |
|
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
659 |
possibly_flush(nm); |
20290
2127dc70bce9
8020151: PSR:PERF Large performance regressions when code cache is filled
anoll
parents:
20019
diff
changeset
|
660 |
// 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
|
661 |
MutexLocker cl(CompiledIC_lock); |
1 | 662 |
nm->cleanup_inline_caches(); |
9942
2e86734ba620
6996747: SIGSEGV in nmethod::cleanup_inline_caches / CompiledIC::verify
never
parents:
9138
diff
changeset
|
663 |
SWEEP(nm); |
1 | 664 |
} |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
27420
diff
changeset
|
665 |
return result; |
4750 | 666 |
} |
667 |
||
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
668 |
|
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
669 |
void NMethodSweeper::possibly_flush(nmethod* nm) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
670 |
if (UseCodeCacheFlushing) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
671 |
if (!nm->is_locked_by_vm() && !nm->is_osr_method() && !nm->is_native_method()) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
672 |
bool make_not_entrant = false; |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
673 |
|
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
674 |
// Do not make native methods and OSR-methods not-entrant |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
675 |
nm->dec_hotness_counter(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
676 |
// Get the initial value of the hotness counter. This value depends on the |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
677 |
// ReservedCodeCacheSize |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
678 |
int reset_val = hotness_counter_reset_val(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
679 |
int time_since_reset = reset_val - nm->hotness_counter(); |
31348
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
30205
diff
changeset
|
680 |
int code_blob_type = CodeCache::get_code_blob_type(nm); |
26796 | 681 |
double threshold = -reset_val + (CodeCache::reverse_free_ratio(code_blob_type) * NmethodSweepActivity); |
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
682 |
// The less free space in the code cache we have - the bigger reverse_free_ratio() is. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
683 |
// I.e., 'threshold' increases with lower available space in the code cache and a higher |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
684 |
// NmethodSweepActivity. If the current hotness counter - which decreases from its initial |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
685 |
// value until it is reset by stack walking - is smaller than the computed threshold, the |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
686 |
// corresponding nmethod is considered for removal. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
687 |
if ((NmethodSweepActivity > 0) && (nm->hotness_counter() < threshold) && (time_since_reset > MinPassesBeforeFlush)) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
688 |
// A method is marked as not-entrant if the method is |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
689 |
// 1) 'old enough': nm->hotness_counter() < threshold |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
690 |
// 2) The method was in_use for a minimum amount of time: (time_since_reset > MinPassesBeforeFlush) |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
691 |
// The second condition is necessary if we are dealing with very small code cache |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
692 |
// sizes (e.g., <10m) and the code cache size is too small to hold all hot methods. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
693 |
// The second condition ensures that methods are not immediately made not-entrant |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
694 |
// after compilation. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
695 |
make_not_entrant = true; |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
696 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
697 |
|
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
698 |
// The stack-scanning low-cost detection may not see the method was used (which can happen for |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
699 |
// flat profiles). Check the age counter for possible data. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
700 |
if (UseCodeAging && make_not_entrant && (nm->is_compiled_by_c2() || nm->is_compiled_by_c1())) { |
26799
0c349e16bbe8
8058564: Tiered compilation performance drop in PIT
iveresov
parents:
26796
diff
changeset
|
701 |
MethodCounters* mc = nm->method()->get_method_counters(Thread::current()); |
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
702 |
if (mc != NULL) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
703 |
// Snapshot the value as it's changed concurrently |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
704 |
int age = mc->nmethod_age(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
705 |
if (MethodCounters::is_nmethod_hot(age)) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
706 |
// The method has gone through flushing, and it became relatively hot that it deopted |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
707 |
// before we could take a look at it. Give it more time to appear in the stack traces, |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
708 |
// proportional to the number of deopts. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
709 |
MethodData* md = nm->method()->method_data(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
710 |
if (md != NULL && time_since_reset > (int)(MinPassesBeforeFlush * (md->tenure_traps() + 1))) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
711 |
// It's been long enough, we still haven't seen it on stack. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
712 |
// Try to flush it, but enable counters the next time. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
713 |
mc->reset_nmethod_age(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
714 |
} else { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
715 |
make_not_entrant = false; |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
716 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
717 |
} else if (MethodCounters::is_nmethod_warm(age)) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
718 |
// Method has counters enabled, and the method was used within |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
719 |
// previous MinPassesBeforeFlush sweeps. Reset the counter. Stay in the existing |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
720 |
// compiled state. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
721 |
mc->reset_nmethod_age(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
722 |
// delay the next check |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
723 |
nm->set_hotness_counter(NMethodSweeper::hotness_counter_reset_val()); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
724 |
make_not_entrant = false; |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
725 |
} else if (MethodCounters::is_nmethod_age_unset(age)) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
726 |
// No counters were used before. Set the counters to the detection |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
727 |
// limit value. If the method is going to be used again it will be compiled |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
728 |
// with counters that we're going to use for analysis the the next time. |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
729 |
mc->reset_nmethod_age(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
730 |
} else { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
731 |
// Method was totally idle for 10 sweeps |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
732 |
// The counter already has the initial value, flush it and may be recompile |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
733 |
// later with counters |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
734 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
735 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
736 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
737 |
|
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
738 |
if (make_not_entrant) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
739 |
nm->make_not_entrant(); |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
740 |
|
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
741 |
// Code cache state change is tracked in make_not_entrant() |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
742 |
if (PrintMethodFlushing && Verbose) { |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
743 |
tty->print_cr("### Nmethod %d/" PTR_FORMAT "made not-entrant: hotness counter %d/%d threshold %f", |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32466
diff
changeset
|
744 |
nm->compile_id(), p2i(nm), nm->hotness_counter(), reset_val, threshold); |
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
745 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
746 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
747 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
748 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
749 |
} |
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
24424
diff
changeset
|
750 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
751 |
// 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
|
752 |
// state of the code cache if it's requested. |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
753 |
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
|
754 |
if (PrintMethodFlushing) { |
29339
f0b1b7788a51
8073257: compiler/codecache/stress/RandomAllocationTest.java + fastdebug + -XX:+LogCompilation, "allocating without ResourceMark"
thartmann
parents:
28163
diff
changeset
|
755 |
ResourceMark rm; |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
756 |
stringStream s; |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
757 |
// 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
|
758 |
// 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
|
759 |
CodeCache::log_state(&s); |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
760 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
761 |
ttyLocker ttyl; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
762 |
tty->print("### sweeper: %s ", msg); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
763 |
if (format != NULL) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
764 |
va_list ap; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
765 |
va_start(ap, format); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
766 |
tty->vprint(format, ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
767 |
va_end(ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
768 |
} |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
769 |
tty->print_cr("%s", s.as_string()); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
770 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
771 |
|
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
772 |
if (LogCompilation && (xtty != NULL)) { |
29339
f0b1b7788a51
8073257: compiler/codecache/stress/RandomAllocationTest.java + fastdebug + -XX:+LogCompilation, "allocating without ResourceMark"
thartmann
parents:
28163
diff
changeset
|
773 |
ResourceMark rm; |
9138
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
774 |
stringStream s; |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
775 |
// 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
|
776 |
// 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
|
777 |
CodeCache::log_state(&s); |
35e4b04eadf4
7036236: VM crashes assert((!inside_attrs()) || is_error_reported()) failed ...
iveresov
parents:
8921
diff
changeset
|
778 |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
779 |
ttyLocker ttyl; |
5926 | 780 |
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
|
781 |
if (format != NULL) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
782 |
va_list ap; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
783 |
va_start(ap, format); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
784 |
xtty->vprint(format, ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
785 |
va_end(ap); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
786 |
} |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
787 |
xtty->print("%s", s.as_string()); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
788 |
xtty->stamp(); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
789 |
xtty->end_elem(); |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
790 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5895
diff
changeset
|
791 |
} |
22210
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
792 |
|
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
793 |
void NMethodSweeper::print() { |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
794 |
ttyLocker ttyl; |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
795 |
tty->print_cr("Code cache sweeper statistics:"); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
796 |
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
|
797 |
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
|
798 |
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
|
799 |
_total_nof_c2_methods_reclaimed); |
b0408ba029f6
8025277: Add -XX: flag to print code cache sweeper statistics
anoll
parents:
22208
diff
changeset
|
800 |
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
|
801 |
} |