-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8347006: LoadRangeNode floats above array guard in arraycopy intrinsic #22967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
425bbb6
5c0292a
3b465a4
0a1fe38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -5917,11 +5917,14 @@ bool LibraryCallKit::inline_arraycopy() { | |
| // (1) src and dest are arrays. | ||
| // Keep track of the information that src/dest are arrays to prevent below array specific accesses from floating above. | ||
| generate_non_array_guard(load_object_klass(src), slow_region); | ||
| const Type* tary = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::BOTTOM, TypeInt::POS), nullptr, false, Type::OffsetBot); | ||
| src = _gvn.transform(new CheckCastPPNode(control(), src, tary)); | ||
| if (!stopped()) { | ||
| src = _gvn.transform(new CheckCastPPNode(control(), src, TypeAryPtr::BOTTOM)); | ||
|
||
| } | ||
|
|
||
| generate_non_array_guard(load_object_klass(dest), slow_region); | ||
| dest = _gvn.transform(new CheckCastPPNode(control(), dest, tary)); | ||
| if (!stopped()) { | ||
| dest = _gvn.transform(new CheckCastPPNode(control(), dest, TypeAryPtr::BOTTOM)); | ||
| } | ||
|
|
||
| // (2) src and dest arrays must have elements of the same BasicType | ||
| // done at macro expansion or at Ideal transformation time | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -1473,6 +1473,7 @@ class TypeAryPtr : public TypeOopPtr { | |
| virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const; | ||
|
|
||
| // Convenience common pre-built types. | ||
| static const TypeAryPtr* BOTTOM; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you are here it may be better to change the other constant to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, done. |
||
| static const TypeAryPtr *RANGE; | ||
| static const TypeAryPtr *OOPS; | ||
| static const TypeAryPtr *NARROWOOPS; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we simply return then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we need to set up the
slow_regionpath, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By that you mean have the
slow_regionfeed into the uncommon trap that's only created later. It does feel weird that we know we have reached a dead end and we keep trying to add stuff, but ok then.The other thing is shouldn't the cast be added in
generate_non_array_guard()? I see it's used elsewhere (LibraryCallKit::inline_native_getLength()): couldn't the same bug occur there?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. It's a bit weird but probably still the best solution in terms of complexity. The trap will lead to recompilation and then the
too_many_trapscheck will trigger.Right, good catch. I think the use in
LibraryCallKit::inline_native_getLengthhas the same problem. We can't easily put the cast intogenerate_non_array_guardthough because it operates on the Klass and not on the object. The othergenerate*array*guardmethods potentially have the same issue but current uses look good. I guess it's best to fix theLibraryCallKit::inline_native_getLengthas well, i.e., make it the caller's responsibility to add a cast. What do you think?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe
inline_getObjectSizeis affected as well:jdk/src/hotspot/share/opto/library_call.cpp
Lines 8535 to 8543 in afe5434
And
LibraryCallKit::inline_native_cloneas well:jdk/src/hotspot/share/opto/library_call.cpp
Lines 5257 to 5262 in afe5434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the methods need to take an extra parameter (the object to cast)?
Having the cast in the method would lead to less code duplication and a lower risk of forgetting the cast when new calls of the method are added so that's what I would go with unless it's really a pain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll give that a try.