8214352: C1: Unnecessary "compilation bailout: block join failed" with JVMTI

Invalidate Phi functions for conflicting types and avoid bailout.

Reviewed-by: kvn, iveresov
This commit is contained in:
Martin Doerr 2018-12-14 09:59:08 +01:00
parent 2932598566
commit b83df1e1fc
4 changed files with 17 additions and 10 deletions

View file

@ -827,9 +827,16 @@ bool BlockBegin::try_merge(ValueStack* new_state) {
for_each_local_value(existing_state, index, existing_value) { for_each_local_value(existing_state, index, existing_value) {
Value new_value = new_state->local_at(index); Value new_value = new_state->local_at(index);
if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) { if (new_value == NULL || new_value->type()->tag() != existing_value->type()->tag()) {
// The old code invalidated the phi function here Phi* existing_phi = existing_value->as_Phi();
// Because dead locals are replaced with NULL, this is a very rare case now, so simply bail out if (existing_phi == NULL) {
return false; // BAILOUT in caller return false; // BAILOUT in caller
}
// Invalidate the phi function here. This case is very rare except for
// JVMTI capability "can_access_local_variables".
// In really rare cases we will bail out in LIRGenerator::move_to_phi.
existing_phi->make_illegal();
existing_state->invalidate_local(index);
TRACE_PHI(tty->print_cr("invalidating local %d because of type mismatch", index));
} }
} }

View file

@ -1113,7 +1113,7 @@ void LIRGenerator::do_ExceptionObject(ExceptionObject* x) {
// no moves are created for phi functions at the begin of exception // no moves are created for phi functions at the begin of exception
// handlers, so assign operands manually here // handlers, so assign operands manually here
for_each_phi_fun(block(), phi, for_each_phi_fun(block(), phi,
operand_for_instruction(phi)); if (!phi->is_illegal()) { operand_for_instruction(phi); });
LIR_Opr thread_reg = getThreadPointer(); LIR_Opr thread_reg = getThreadPointer();
__ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT), __ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT),

View file

@ -574,7 +574,7 @@ void LinearScan::compute_local_live_sets() {
// Phi functions at the begin of an exception handler are // Phi functions at the begin of an exception handler are
// implicitly defined (= killed) at the beginning of the block. // implicitly defined (= killed) at the beginning of the block.
for_each_phi_fun(block, phi, for_each_phi_fun(block, phi,
live_kill.set_bit(phi->operand()->vreg_number()) if (!phi->is_illegal()) { live_kill.set_bit(phi->operand()->vreg_number()); }
); );
} }
@ -1904,7 +1904,7 @@ void LinearScan::resolve_exception_entry(BlockBegin* block, MoveResolver &move_r
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately // the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
for_each_phi_fun(block, phi, for_each_phi_fun(block, phi,
resolve_exception_entry(block, phi->operand()->vreg_number(), move_resolver) if (!phi->is_illegal()) { resolve_exception_entry(block, phi->operand()->vreg_number(), move_resolver); }
); );
if (move_resolver.has_mappings()) { if (move_resolver.has_mappings()) {
@ -1978,7 +1978,7 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, M
// the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately // the live_in bits are not set for phi functions of the xhandler entry, so iterate them separately
for_each_phi_fun(block, phi, for_each_phi_fun(block, phi,
resolve_exception_edge(handler, throwing_op_id, phi->operand()->vreg_number(), phi, move_resolver) if (!phi->is_illegal()) { resolve_exception_edge(handler, throwing_op_id, phi->operand()->vreg_number(), phi, move_resolver); }
); );
if (move_resolver.has_mappings()) { if (move_resolver.has_mappings()) {

View file

@ -299,7 +299,7 @@ class ValueStack: public CompilationResourceObj {
} }
// Macro definition for simple iteration of all phif functions of a block, i.e all // Macro definition for simple iteration of all phi functions of a block, i.e all
// phi functions of the ValueStack where the block matches. // phi functions of the ValueStack where the block matches.
// Use the following code pattern to iterate all phi functions of a block: // Use the following code pattern to iterate all phi functions of a block:
// //
@ -315,7 +315,7 @@ class ValueStack: public CompilationResourceObj {
Value value; \ Value value; \
{ \ { \
for_each_stack_value(cur_state, cur_index, value) { \ for_each_stack_value(cur_state, cur_index, value) { \
Phi* v_phi = value->as_Phi(); \ Phi* v_phi = value->as_Phi(); \
if (v_phi != NULL && v_phi->block() == v_block) { \ if (v_phi != NULL && v_phi->block() == v_block) { \
v_code; \ v_code; \
} \ } \
@ -323,7 +323,7 @@ class ValueStack: public CompilationResourceObj {
} \ } \
{ \ { \
for_each_local_value(cur_state, cur_index, value) { \ for_each_local_value(cur_state, cur_index, value) { \
Phi* v_phi = value->as_Phi(); \ Phi* v_phi = value->as_Phi(); \
if (v_phi != NULL && v_phi->block() == v_block) { \ if (v_phi != NULL && v_phi->block() == v_block) { \
v_code; \ v_code; \
} \ } \