Skip to content

Commit 48d2acb

Browse files
committed
8356783: CompilerTask hot_method is redundant
Reviewed-by: kvn, cslucas
1 parent de10644 commit 48d2acb

File tree

8 files changed

+15
-62
lines changed

8 files changed

+15
-62
lines changed

src/hotspot/share/ci/ciReplay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ class CompileReplay : public StackObj {
806806
}
807807
replay_state = this;
808808
CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,
809-
methodHandle(), 0, CompileTask::Reason_Replay, THREAD);
809+
0, CompileTask::Reason_Replay, THREAD);
810810
replay_state = nullptr;
811811
}
812812

src/hotspot/share/compiler/compilationPolicy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void CompilationPolicy::compile_if_required(const methodHandle& m, TRAPS) {
104104
if (PrintTieredEvents) {
105105
print_event(COMPILE, m(), m(), InvocationEntryBci, level);
106106
}
107-
CompileBroker::compile_method(m, InvocationEntryBci, level, methodHandle(), 0, CompileTask::Reason_MustBeCompiled, THREAD);
107+
CompileBroker::compile_method(m, InvocationEntryBci, level, 0, CompileTask::Reason_MustBeCompiled, THREAD);
108108
}
109109
}
110110

@@ -812,7 +812,7 @@ void CompilationPolicy::compile(const methodHandle& mh, int bci, CompLevel level
812812
}
813813
int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
814814
update_rate(nanos_to_millis(os::javaTimeNanos()), mh);
815-
CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, THREAD);
815+
CompileBroker::compile_method(mh, bci, level, hot_count, CompileTask::Reason_Tiered, THREAD);
816816
}
817817
}
818818

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ CompileTask* CompileQueue::get(CompilerThread* thread) {
398398
// save methods from RedefineClasses across safepoint
399399
// across MethodCompileQueue_lock below.
400400
methodHandle save_method;
401-
methodHandle save_hot_method;
402401

403402
MonitorLocker locker(MethodCompileQueue_lock);
404403
// If _first is null we have no more compile jobs. There are two reasons for
@@ -453,7 +452,6 @@ CompileTask* CompileQueue::get(CompilerThread* thread) {
453452
// the compilation queue, which is walked during RedefineClasses.
454453
Thread* thread = Thread::current();
455454
save_method = methodHandle(thread, task->method());
456-
save_hot_method = methodHandle(thread, task->hot_method());
457455

458456
remove(task);
459457
}
@@ -1154,7 +1152,6 @@ void CompileBroker::mark_on_stack() {
11541152
void CompileBroker::compile_method_base(const methodHandle& method,
11551153
int osr_bci,
11561154
int comp_level,
1157-
const methodHandle& hot_method,
11581155
int hot_count,
11591156
CompileTask::CompileReason compile_reason,
11601157
bool blocking,
@@ -1173,13 +1170,8 @@ void CompileBroker::compile_method_base(const methodHandle& method,
11731170
tty->print(" osr_bci: %d", osr_bci);
11741171
}
11751172
tty->print(" level: %d comment: %s count: %d", comp_level, CompileTask::reason_name(compile_reason), hot_count);
1176-
if (!hot_method.is_null()) {
1177-
tty->print(" hot: ");
1178-
if (hot_method() != method()) {
1179-
hot_method->print_short_name(tty);
1180-
} else {
1181-
tty->print("yes");
1182-
}
1173+
if (hot_count > 0) {
1174+
tty->print(" hot: yes");
11831175
}
11841176
tty->cr();
11851177
}
@@ -1326,7 +1318,7 @@ void CompileBroker::compile_method_base(const methodHandle& method,
13261318
task = create_compile_task(queue,
13271319
compile_id, method,
13281320
osr_bci, comp_level,
1329-
hot_method, hot_count, compile_reason,
1321+
hot_count, compile_reason,
13301322
blocking);
13311323
}
13321324

@@ -1337,7 +1329,7 @@ void CompileBroker::compile_method_base(const methodHandle& method,
13371329

13381330
nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
13391331
int comp_level,
1340-
const methodHandle& hot_method, int hot_count,
1332+
int hot_count,
13411333
CompileTask::CompileReason compile_reason,
13421334
TRAPS) {
13431335
// Do nothing if compilebroker is not initialized or compiles are submitted on level none
@@ -1357,14 +1349,14 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
13571349

13581350
DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
13591351
// CompileBroker::compile_method can trap and can have pending async exception.
1360-
nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, directive, THREAD);
1352+
nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_count, compile_reason, directive, THREAD);
13611353
DirectivesStack::release(directive);
13621354
return nm;
13631355
}
13641356

13651357
nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
13661358
int comp_level,
1367-
const methodHandle& hot_method, int hot_count,
1359+
int hot_count,
13681360
CompileTask::CompileReason compile_reason,
13691361
DirectiveSet* directive,
13701362
TRAPS) {
@@ -1460,7 +1452,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
14601452
return nullptr;
14611453
}
14621454
bool is_blocking = !directive->BackgroundCompilationOption || ReplayCompiles;
1463-
compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, is_blocking, THREAD);
1455+
compile_method_base(method, osr_bci, comp_level, hot_count, compile_reason, is_blocking, THREAD);
14641456
}
14651457

14661458
// return requested nmethod
@@ -1607,13 +1599,12 @@ CompileTask* CompileBroker::create_compile_task(CompileQueue* queue,
16071599
const methodHandle& method,
16081600
int osr_bci,
16091601
int comp_level,
1610-
const methodHandle& hot_method,
16111602
int hot_count,
16121603
CompileTask::CompileReason compile_reason,
16131604
bool blocking) {
16141605
CompileTask* new_task = CompileTask::allocate();
16151606
new_task->initialize(compile_id, method, osr_bci, comp_level,
1616-
hot_method, hot_count, compile_reason,
1607+
hot_count, compile_reason,
16171608
blocking);
16181609
queue->add(new_task);
16191610
return new_task;

src/hotspot/share/compiler/compileBroker.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ class CompileBroker: AllStatic {
267267
const methodHandle& method,
268268
int osr_bci,
269269
int comp_level,
270-
const methodHandle& hot_method,
271270
int hot_count,
272271
CompileTask::CompileReason compile_reason,
273272
bool blocking);
@@ -288,7 +287,6 @@ class CompileBroker: AllStatic {
288287
static void compile_method_base(const methodHandle& method,
289288
int osr_bci,
290289
int comp_level,
291-
const methodHandle& hot_method,
292290
int hot_count,
293291
CompileTask::CompileReason compile_reason,
294292
bool blocking,
@@ -322,7 +320,6 @@ class CompileBroker: AllStatic {
322320
static nmethod* compile_method(const methodHandle& method,
323321
int osr_bci,
324322
int comp_level,
325-
const methodHandle& hot_method,
326323
int hot_count,
327324
CompileTask::CompileReason compile_reason,
328325
TRAPS);
@@ -333,7 +330,6 @@ class CompileBroker: AllStatic {
333330
static nmethod* compile_method(const methodHandle& method,
334331
int osr_bci,
335332
int comp_level,
336-
const methodHandle& hot_method,
337333
int hot_count,
338334
CompileTask::CompileReason compile_reason,
339335
DirectiveSet* directive,

src/hotspot/share/compiler/compileTask.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,10 @@ void CompileTask::free(CompileTask* task) {
6666
MutexLocker locker(CompileTaskAlloc_lock);
6767
if (!task->is_free()) {
6868
assert(!task->lock()->is_locked(), "Should not be locked when freed");
69-
if ((task->_method_holder != nullptr && JNIHandles::is_weak_global_handle(task->_method_holder)) ||
70-
(task->_hot_method_holder != nullptr && JNIHandles::is_weak_global_handle(task->_hot_method_holder))) {
69+
if ((task->_method_holder != nullptr && JNIHandles::is_weak_global_handle(task->_method_holder))) {
7170
JNIHandles::destroy_weak_global(task->_method_holder);
72-
JNIHandles::destroy_weak_global(task->_hot_method_holder);
7371
} else {
7472
JNIHandles::destroy_global(task->_method_holder);
75-
JNIHandles::destroy_global(task->_hot_method_holder);
7673
}
7774
if (task->_failure_reason_on_C_heap && task->_failure_reason != nullptr) {
7875
os::free((void*) task->_failure_reason);
@@ -90,7 +87,6 @@ void CompileTask::initialize(int compile_id,
9087
const methodHandle& method,
9188
int osr_bci,
9289
int comp_level,
93-
const methodHandle& hot_method,
9490
int hot_count,
9591
CompileTask::CompileReason compile_reason,
9692
bool is_blocking) {
@@ -112,8 +108,6 @@ void CompileTask::initialize(int compile_id,
112108
_is_complete = false;
113109
_is_success = false;
114110

115-
_hot_method = nullptr;
116-
_hot_method_holder = nullptr;
117111
_hot_count = hot_count;
118112
_time_queued = os::elapsed_counter();
119113
_time_started = 0;
@@ -127,18 +121,6 @@ void CompileTask::initialize(int compile_id,
127121
_failure_reason_on_C_heap = false;
128122
_arena_bytes = 0;
129123

130-
if (LogCompilation) {
131-
if (hot_method.not_null()) {
132-
if (hot_method == method) {
133-
_hot_method = _method;
134-
} else {
135-
_hot_method = hot_method();
136-
// only add loader or mirror if different from _method_holder
137-
_hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder()));
138-
}
139-
}
140-
}
141-
142124
_next = nullptr;
143125
}
144126

@@ -159,11 +141,7 @@ CompileTask* CompileTask::select_for_compilation() {
159141
assert(_method->method_holder()->is_loader_alive(), "should be alive");
160142
Handle method_holder(thread, _method->method_holder()->klass_holder());
161143
JNIHandles::destroy_weak_global(_method_holder);
162-
JNIHandles::destroy_weak_global(_hot_method_holder);
163144
_method_holder = JNIHandles::make_global(method_holder);
164-
if (_hot_method != nullptr) {
165-
_hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
166-
}
167145
return this;
168146
}
169147

@@ -173,9 +151,6 @@ void CompileTask::mark_on_stack() {
173151
}
174152
// Mark these methods as something redefine classes cannot remove.
175153
_method->set_on_stack(true);
176-
if (_hot_method != nullptr) {
177-
_hot_method->set_on_stack(true);
178-
}
179154
}
180155

181156
bool CompileTask::is_unloaded() const {
@@ -188,9 +163,6 @@ void CompileTask::metadata_do(MetadataClosure* f) {
188163
return;
189164
}
190165
f->do_metadata(method());
191-
if (hot_method() != nullptr && hot_method() != method()) {
192-
f->do_metadata(hot_method());
193-
}
194166
}
195167

196168
// ------------------------------------------------------------------
@@ -329,9 +301,6 @@ void CompileTask::log_task_queued() {
329301
assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values");
330302
xtty->print(" comment='%s'", reason_name(_compile_reason));
331303

332-
if (_hot_method != nullptr && _hot_method != _method) {
333-
xtty->method(_hot_method);
334-
}
335304
if (_hot_count != 0) {
336305
xtty->print(" hot_count='%d'", _hot_count);
337306
}

src/hotspot/share/compiler/compileTask.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ class CompileTask : public CHeapObj<mtCompiler> {
106106
// Fields used for logging why the compilation was initiated:
107107
jlong _time_queued; // time when task was enqueued
108108
jlong _time_started; // time when compilation started
109-
Method* _hot_method; // which method actually triggered this task
110-
jobject _hot_method_holder;
111109
int _hot_count; // information about its invocation counter
112110
CompileReason _compile_reason; // more info about the task
113111
const char* _failure_reason;
@@ -122,15 +120,14 @@ class CompileTask : public CHeapObj<mtCompiler> {
122120
}
123121

124122
void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level,
125-
const methodHandle& hot_method, int hot_count,
123+
int hot_count,
126124
CompileTask::CompileReason compile_reason, bool is_blocking);
127125

128126
static CompileTask* allocate();
129127
static void free(CompileTask* task);
130128

131129
int compile_id() const { return _compile_id; }
132130
Method* method() const { return _method; }
133-
Method* hot_method() const { return _hot_method; }
134131
int osr_bci() const { return _osr_bci; }
135132
bool is_complete() const { return _is_complete; }
136133
bool is_blocking() const { return _is_blocking; }

src/hotspot/share/jvmci/jvmciCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void JVMCICompiler::bootstrap(TRAPS) {
8989
if (!mh->is_native() && !mh->is_static() && !mh->is_object_initializer() && !mh->is_static_initializer()) {
9090
ResourceMark rm;
9191
int hot_count = 10; // TODO: what's the appropriate value?
92-
CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, CHECK);
92+
CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, hot_count, CompileTask::Reason_Bootstrap, CHECK);
9393
}
9494
}
9595

src/hotspot/share/prims/whitebox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ bool WhiteBox::compile_method(Method* method, int comp_level, int bci, JavaThrea
11241124
DirectivesStack::release(directive);
11251125

11261126
// Compile method and check result
1127-
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), CompileTask::Reason_Whitebox, CHECK_false);
1127+
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh->invocation_count(), CompileTask::Reason_Whitebox, CHECK_false);
11281128
MutexLocker mu(THREAD, Compile_lock);
11291129
bool is_queued = mh->queued_for_compilation();
11301130
if ((!is_blocking && is_queued) || nm != nullptr) {

0 commit comments

Comments
 (0)