< prev index next > src/hotspot/share/c1/c1_Optimizer.cpp
Print this page
}
virtual void block_do(BlockBegin* block);
private:
! Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval);
};
void CE_Eliminator::block_do(BlockBegin* block) {
// 1) find conditional expression
// check if block ends with an If
}
virtual void block_do(BlockBegin* block);
private:
! Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+ ValueStack* state_before, bool substitutability_check);
};
void CE_Eliminator::block_do(BlockBegin* block) {
// 1) find conditional expression
// check if block ends with an If
f_value = new Constant(f_const->type());
NOT_PRODUCT(f_value->set_printable_bci(if_->printable_bci()));
cur_end = cur_end->set_next(f_value);
}
! Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value);
assert(result != nullptr, "make_ifop must return a non-null instruction");
if (!result->is_linked() && result->can_be_linked()) {
NOT_PRODUCT(result->set_printable_bci(if_->printable_bci()));
cur_end = cur_end->set_next(result);
}
f_value = new Constant(f_const->type());
NOT_PRODUCT(f_value->set_printable_bci(if_->printable_bci()));
cur_end = cur_end->set_next(f_value);
}
! Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value,
+ if_->state_before(), if_->substitutability_check());
assert(result != nullptr, "make_ifop must return a non-null instruction");
if (!result->is_linked() && result->can_be_linked()) {
NOT_PRODUCT(result->set_printable_bci(if_->printable_bci()));
cur_end = cur_end->set_next(result);
}
_hir->verify_local(blocks_to_verify_later);
#endif // DO_DELAYED_VERIFICATION
}
! Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval) {
if (!OptimizeIfOps) {
! return new IfOp(x, cond, y, tval, fval);
}
tval = tval->subst();
fval = fval->subst();
if (tval == fval) {
_hir->verify_local(blocks_to_verify_later);
#endif // DO_DELAYED_VERIFICATION
}
! Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+ ValueStack* state_before, bool substitutability_check) {
if (!OptimizeIfOps) {
! return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
}
tval = tval->subst();
fval = fval->subst();
if (tval == fval) {
_ifop_count++;
if (new_tval == new_fval) {
return new_tval;
} else {
! return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval);
}
}
}
} else {
Constant* x_const = x->as_Constant();
_ifop_count++;
if (new_tval == new_fval) {
return new_tval;
} else {
! return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval, state_before, substitutability_check);
}
}
}
} else {
Constant* x_const = x->as_Constant();
return x_compare_res == Constant::cond_true ? tval : fval;
}
}
}
}
! return new IfOp(x, cond, y, tval, fval);
}
void Optimizer::eliminate_conditional_expressions() {
// find conditional expressions & replace them with IfOps
CE_Eliminator ce(ir());
return x_compare_res == Constant::cond_true ? tval : fval;
}
}
}
}
! return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
}
void Optimizer::eliminate_conditional_expressions() {
// find conditional expressions & replace them with IfOps
CE_Eliminator ce(ir());
if (!con || !ifop) {
ifop = if_->y()->as_IfOp();
con = if_->x()->as_Constant();
swapped = true;
}
! if (con && ifop) {
Constant* tval = ifop->tval()->as_Constant();
Constant* fval = ifop->fval()->as_Constant();
if (tval && fval) {
// Find the instruction before if_, starting with ifop.
// When if_ and ifop are not in the same block, prev
if (!con || !ifop) {
ifop = if_->y()->as_IfOp();
con = if_->x()->as_Constant();
swapped = true;
}
! if (con && ifop && !ifop->substitutability_check()) {
Constant* tval = ifop->tval()->as_Constant();
Constant* fval = ifop->fval()->as_Constant();
if (tval && fval) {
// Find the instruction before if_, starting with ifop.
// When if_ and ifop are not in the same block, prev
BlockBegin* tblock = tval->compare(cond, con, tsux, fsux);
BlockBegin* fblock = fval->compare(cond, con, tsux, fsux);
if (tblock != fblock && !if_->is_safepoint()) {
If* newif = new If(ifop->x(), ifop->cond(), false, ifop->y(),
! tblock, fblock, if_->state_before(), if_->is_safepoint());
newif->set_state(if_->state()->copy());
assert(prev->next() == if_, "must be guaranteed by above search");
NOT_PRODUCT(newif->set_printable_bci(if_->printable_bci()));
prev->set_next(newif);
BlockBegin* tblock = tval->compare(cond, con, tsux, fsux);
BlockBegin* fblock = fval->compare(cond, con, tsux, fsux);
if (tblock != fblock && !if_->is_safepoint()) {
If* newif = new If(ifop->x(), ifop->cond(), false, ifop->y(),
! tblock, fblock, if_->state_before(), if_->is_safepoint(), ifop->substitutability_check());
newif->set_state(if_->state()->copy());
assert(prev->next() == if_, "must be guaranteed by above search");
NOT_PRODUCT(newif->set_printable_bci(if_->printable_bci()));
prev->set_next(newif);
void do_UnsafeGet (UnsafeGet* x);
void do_UnsafePut (UnsafePut* x);
void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
void do_ProfileCall (ProfileCall* x);
void do_ProfileReturnType (ProfileReturnType* x);
+ void do_ProfileACmpTypes(ProfileACmpTypes* x);
void do_ProfileInvoke (ProfileInvoke* x);
void do_RuntimeCall (RuntimeCall* x);
void do_MemBar (MemBar* x);
void do_RangeCheckPredicate(RangeCheckPredicate* x);
#ifdef ASSERT
void handle_Intrinsic (Intrinsic* x);
void handle_ExceptionObject (ExceptionObject* x);
void handle_Phi (Phi* x);
void handle_ProfileCall (ProfileCall* x);
void handle_ProfileReturnType (ProfileReturnType* x);
+ void handle_ProfileACmpTypes(ProfileACmpTypes* x);
void handle_Constant (Constant* x);
void handle_IfOp (IfOp* x);
};
void NullCheckVisitor::do_UnsafeGetAndSet(UnsafeGetAndSet* x) {}
void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_last_explicit_null_check();
nce()->handle_ProfileCall(x); }
void NullCheckVisitor::do_ProfileReturnType (ProfileReturnType* x) { nce()->handle_ProfileReturnType(x); }
void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {}
+ void NullCheckVisitor::do_ProfileACmpTypes(ProfileACmpTypes* x) { nce()->handle_ProfileACmpTypes(x); }
void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {}
void NullCheckVisitor::do_MemBar (MemBar* x) {}
void NullCheckVisitor::do_RangeCheckPredicate(RangeCheckPredicate* x) {}
#ifdef ASSERT
void NullCheckVisitor::do_Assert (Assert* x) {}
void NullCheckEliminator::handle_ProfileReturnType(ProfileReturnType* x) {
x->set_needs_null_check(!set_contains(x->ret()));
}
+ void NullCheckEliminator::handle_ProfileACmpTypes(ProfileACmpTypes* x) {
+ x->set_left_maybe_null(!set_contains(x->left()));
+ x->set_right_maybe_null(!set_contains(x->right()));
+ }
+
void NullCheckEliminator::handle_Constant(Constant *x) {
ObjectType* ot = x->type()->as_ObjectType();
if (ot != nullptr && ot->is_loaded()) {
ObjectConstant* oc = ot->as_ObjectConstant();
if (oc == nullptr || !oc->value()->is_null_object()) {
< prev index next >