Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8266854: LibraryCallKit::inline_preconditions_checkIndex modifies con…
…trol flow even if the intrinsic bailed out

Reviewed-by: kvn, jbhateja, vlivanov
  • Loading branch information
Sandhya Viswanathan committed Jun 23, 2021
1 parent 7e96318 commit b4743143428a3e0c9a6d1d7dcaf73f7a06882e84
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/hotspot/share/opto/library_call.cpp
@@ -1032,17 +1032,18 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) {
Deoptimization::Action_make_not_entrant);
}

if (stopped()) {
// Length is known to be always negative during compilation and the IR graph so far constructed is good so return success
return true;
}

// length is now known postive, add a cast node to make this explicit
jlong upper_bound = _gvn.type(length)->is_integer(bt)->hi_as_long();
Node* casted_length = ConstraintCastNode::make(control(), length, TypeInteger::make(0, upper_bound, Type::WidenMax, bt), bt);
casted_length = _gvn.transform(casted_length);
replace_in_map(length, casted_length);
length = casted_length;

if (stopped()) {
return false;
}

// Use an unsigned comparison for the range check itself
Node* rc_cmp = _gvn.transform(CmpNode::make(index, length, bt, true));
BoolTest::mask btest = BoolTest::lt;
@@ -1061,7 +1062,8 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) {
}

if (stopped()) {
return false;
// Range check is known to always fail during compilation and the IR graph so far constructed is good so return success
return true;
}

// index is now known to be >= 0 and < length, cast it

1 comment on commit b474314

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on b474314 Jun 23, 2021

Please sign in to comment.