-
Notifications
You must be signed in to change notification settings - Fork 144
8375441: [lworld] C2: assert(is_instance()) failed: bad cast #1923
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
base: lworld
Are you sure you want to change the base?
Conversation
|
👋 Welcome back mchevalier! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
| type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load); | ||
|
|
||
| if (con.is_valid() && // not a mismatched access | ||
| !con.is_null_or_zero()) { // not a default value |
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.
This is incorrect, the value is not constant if the element of the array is null, not if the field we retrieved is null.
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.
I think you're correct. While being sound, we might miss opportunities where the value is actually constant but we discard it. con.is_value() already is enough to make sure the array element is not null (and constant).
| } | ||
|
|
||
| ciConstant ciFlatArray::field_value(int index, ciField* field) { | ||
| auto get_field_from_object_constant = [field](const ciConstant& v) -> ciConstant { |
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.
I don't really agree with this fix, ciFlatArray::field_value should be dumber, it is the caller who knows that we do not fold the load if the element is null, the callee should just return the field as it is.
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.
I fear I don't understand. Let's say, I have a flat array MyValue[] arr where MyValue is a value class with a single field f. Let's also assume arr[0] == null, arr.field_value(0, f) (assuming the ci... versions of it with matching names) tries to get the constant value of the field f of arr[0], and arr[0].f is not null, it's rather undefined. It's not about stability and folding. On the other hand, if arr[0] is not null, but arr[0].f is null, arr.field_value(0, f) already returns null (the ciConstant that means that).
Am I missing something?
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.
That is only true from the Java perspective. From the VM perspective, a flat array would be something like (C++ pseudocode):
class MyValuePayload {
oop* f;
bool null_marker;
};
MyValuePayload* arr = new MyValuePayload[n];
Then, it is clear that even if arr[0].null_marker == false, arr[0].f is still defined and has a value (which should be nullptr).
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.
As discussed offline, I'm trying change that.
Some code added by JDK-8372700 can compute the constant value of a field of a (flatten) element in a flat array. We get a crash when the element of the array is known to be
null, and so the field doesn't exist.So, let's just check in
ciConstant ciFlatArray::field_value(int index, ciField* field)whether we get a null constant before interpreting it as aciInstanceand trying to retrieve a field from there. This should be enough since aciObjectis (directly) derived byciNullObject,ciInstanceandciArray. Since we are looking up a value of a flat array, an element cannot be aciArray(arrays have identities and can't be contained in a flat array). After looking up whether the flat array element is null, theobj->as_instance()cast acts as an assert, should we ever add another derived class fromciObject.In case of a null array element,
field_valuesimply returns an invalidciConstant.Tested with tier1,tier2,tier3,hs-precheckin-comp,hs-comp-stress,valhalla-comp-stress. Looks good.
Thanks,
Marc
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1923/head:pull/1923$ git checkout pull/1923Update a local copy of the PR:
$ git checkout pull/1923$ git pull https://git.openjdk.org/valhalla.git pull/1923/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1923View PR using the GUI difftool:
$ git pr show -t 1923Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1923.diff
Using Webrev
Link to Webrev Comment