Skip to content

Commit 35916ed

Browse files
author
Vladimir Ivanov
committedMay 31, 2021
8267806: C1: Relax inlining checks for not yet initialized classes
Reviewed-by: roland, thartmann
1 parent 1e29005 commit 35916ed

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎src/hotspot/share/c1/c1_GraphBuilder.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -2030,17 +2030,16 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
20302030
}
20312031

20322032
// check if we could do inlining
2033-
if (!PatchALot && Inline && target->is_loaded() &&
2034-
(klass->is_initialized() || (klass->is_interface() && target->holder()->is_initialized()))
2035-
&& !patch_for_appendix) {
2033+
if (!PatchALot && Inline && target->is_loaded() && callee_holder->is_linked() && !patch_for_appendix) {
20362034
// callee is known => check if we have static binding
2037-
if (code == Bytecodes::_invokestatic ||
2035+
if ((code == Bytecodes::_invokestatic && callee_holder->is_initialized()) || // invokestatic involves an initialization barrier on resolved klass
20382036
code == Bytecodes::_invokespecial ||
20392037
(code == Bytecodes::_invokevirtual && target->is_final_method()) ||
20402038
code == Bytecodes::_invokedynamic) {
2041-
ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target;
20422039
// static binding => check if callee is ok
2043-
bool success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), false, code, better_receiver);
2040+
ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target;
2041+
bool holder_known = (cha_monomorphic_target != NULL) || (exact_target != NULL);
2042+
bool success = try_inline(inline_target, holder_known, false /* ignore_return */, code, better_receiver);
20442043

20452044
CHECK_BAILOUT();
20462045
clear_inline_bailout();
@@ -3758,7 +3757,9 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ign
37583757
!InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
37593758
if (callee->is_synchronized() &&
37603759
!InlineSynchronizedMethods ) INLINE_BAILOUT("callee is synchronized");
3761-
if (!callee->holder()->is_initialized()) INLINE_BAILOUT("callee's klass not initialized yet");
3760+
if (!callee->holder()->is_linked()) INLINE_BAILOUT("callee's klass not linked yet");
3761+
if (bc == Bytecodes::_invokestatic &&
3762+
!callee->holder()->is_initialized()) INLINE_BAILOUT("callee's klass not initialized yet");
37623763
if (!callee->has_balanced_monitors()) INLINE_BAILOUT("callee's monitors do not match");
37633764

37643765
// Proper inlining of methods with jsrs requires a little more work.
@@ -3840,6 +3841,8 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ign
38403841
print_inlining(callee, "inline", /*success*/ true);
38413842
}
38423843

3844+
assert(bc != Bytecodes::_invokestatic || callee->holder()->is_initialized(), "required");
3845+
38433846
// NOTE: Bailouts from this point on, which occur at the
38443847
// GraphBuilder level, do not cause bailout just of the inlining but
38453848
// in fact of the entire compilation.

0 commit comments

Comments
 (0)
Please sign in to comment.