Skip to content
Permalink
Browse files
8274401: C2: GraphKit::load_array_element bypasses Access API
Reviewed-by: kvn, goetz, thartmann
  • Loading branch information
TheRealMDoerr committed Sep 30, 2021
1 parent dfc557c commit a8210c53e7af1cb558251fcb420de1b8a5461b25
Showing with 7 additions and 6 deletions.
  1. +4 −3 src/hotspot/share/opto/graphKit.cpp
  2. +1 −1 src/hotspot/share/opto/graphKit.hpp
  3. +1 −1 src/hotspot/share/opto/library_call.cpp
  4. +1 −1 src/hotspot/share/opto/stringopts.cpp
@@ -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 */);
@@ -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);
@@ -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
@@ -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);

3 comments on commit a8210c5

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot replied Sep 30, 2021

@TheRealMDoerr

This comment has been minimized.

Copy link
Contributor Author

@TheRealMDoerr TheRealMDoerr replied Oct 15, 2021

/backport jdk17u

@openjdk

This comment has been minimized.

Copy link

@openjdk openjdk bot replied Oct 15, 2021

@TheRealMDoerr @TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-a8210c53 in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit a8210c53 from the openjdk/jdk repository.

The commit being backported was authored by Martin Doerr on 30 Sep 2021 and was reviewed by Vladimir Kozlov, Goetz Lindenmaier and Tobias Hartmann.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u TheRealMDoerr-backport-a8210c53:TheRealMDoerr-backport-a8210c53
$ git checkout TheRealMDoerr-backport-a8210c53
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u TheRealMDoerr-backport-a8210c53
Please sign in to comment.