8274401: C2: GraphKit::load_array_element bypasses Access API

Reviewed-by: kvn, goetz, thartmann
This commit is contained in:
Martin Doerr 2021-09-30 08:41:03 +00:00
parent dfc557cbea
commit a8210c53e7
4 changed files with 7 additions and 6 deletions

View File

@ -1748,14 +1748,15 @@ Node* GraphKit::array_element_address(Node* ary, Node* idx, BasicType elembt,
}
//-------------------------load_array_element-------------------------
Node* GraphKit::load_array_element(Node* ctl, Node* ary, Node* idx, const TypeAryPtr* arytype) {
Node* GraphKit::load_array_element(Node* ary, Node* idx, const TypeAryPtr* arytype, bool set_ctrl) {
const Type* elemtype = arytype->elem();
BasicType elembt = elemtype->array_element_basic_type();
Node* adr = array_element_address(ary, idx, elembt, arytype->size());
if (elembt == T_NARROWOOP) {
elembt = T_OBJECT; // To satisfy switch in LoadNode::make()
}
Node* ld = make_load(ctl, adr, elemtype, elembt, arytype, MemNode::unordered);
Node* ld = access_load_at(ary, adr, arytype, elemtype, elembt,
IN_HEAP | IS_ARRAY | (set_ctrl ? C2_CONTROL_DEPENDENT_LOAD : 0));
return ld;
}
@ -4258,7 +4259,7 @@ void GraphKit::inflate_string_slow(Node* src, Node* dst, Node* start, Node* coun
record_for_igvn(mem);
set_control(head);
set_memory(mem, TypeAryPtr::BYTES);
Node* ch = load_array_element(control(), src, i_byte, TypeAryPtr::BYTES);
Node* ch = load_array_element(src, i_byte, TypeAryPtr::BYTES, /* set_ctrl */ true);
Node* st = store_to_memory(control(), array_element_address(dst, i_char, T_BYTE),
AndI(ch, intcon(0xff)), T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
false, false, true /* mismatched */);

View File

@ -660,7 +660,7 @@ class GraphKit : public Phase {
Node* ctrl = NULL);
// Return a load of array element at idx.
Node* load_array_element(Node* ctl, Node* ary, Node* idx, const TypeAryPtr* arytype);
Node* load_array_element(Node* ary, Node* idx, const TypeAryPtr* arytype, bool set_ctrl);
//---------------- Dtrace support --------------------
void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);

View File

@ -6205,7 +6205,7 @@ Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object)
if (objSessionK == NULL) {
return (Node *) NULL;
}
Node* objAESCryptKey = load_array_element(control(), objSessionK, intcon(0), TypeAryPtr::OOPS);
Node* objAESCryptKey = load_array_element(objSessionK, intcon(0), TypeAryPtr::OOPS, /* set_ctrl */ true);
#else
Node* objAESCryptKey = load_field_from_object(aescrypt_object, "K", "[I");
#endif // PPC64

View File

@ -1244,7 +1244,7 @@ Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) {
kit.set_control(loop);
Node* sizeTable = fetch_static_field(kit, size_table_field);
Node* value = kit.load_array_element(NULL, sizeTable, index, TypeAryPtr::INTS);
Node* value = kit.load_array_element(sizeTable, index, TypeAryPtr::INTS, /* set_ctrl */ false);
C->record_for_igvn(value);
Node* limit = __ CmpI(phi, value);
Node* limitb = __ Bool(limit, BoolTest::le);