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
8260473: [vector] ZGC: VectorReshape test produces incorrect results with ZGC enabled #2253
Conversation
Hi @casparcwang, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user casparcwang" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
@casparcwang The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
/signed |
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
/covered |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
Webrevs
|
/cc hotspot-gc |
@casparcwang |
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.
The patch looks good.
Please turn the reproducer into a regression test for this bug. Contact me if you need any help with that.
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.
What about migrating it to GraphKit::access_load_at
instead?
@iwanowww GraphKit::access_load_at is for parse time only. C2OptAccess must be used here. |
The test is part of test/jdk/jdk/incubator/vector/VectorReshapeTests.java. The small test is provided by Stuart Monteith in the JBS. Thanks for providing the test. /contributor add @stooart-mon |
@casparcwang |
/contributor add casparcwang casparcwang@tencent.com |
@casparcwang Could not parse
|
I suggest adding the test under test/hotspot/jtreg/compiler/vectorapi. |
Since 32-bit VM doesn't support ZGC, the test should only for 64-bit. |
I see. That's unfortunate. Actually, |
|
Worth mentioning is that we have optimization-time loads and stores in the arraycopy/clone code. When that was added, it was the only place where we had such accesses, so a little load/store wrapper utility was written in the arraycopy code. But perhaps now that there is more than one place, that utility belongs in a more central place, so the boilerplate can be reduced. I'm okay with doing that in a follow-up RFE though, as it is a refactoring only, and getting the actual bug fix in soon is is of value. |
/* | ||
* @test | ||
* @bug 8260473 | ||
* @modules jdk.incubator.vector |
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 test should have a @requires vm.gc.Z
tag. That will make sure it's only executed on platforms where ZGC is supported (and that ZGC is included in the build).
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.
done
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.
Looks good, but needs some editing.
System.out.println("expect: "+Arrays.toString(expected)); | ||
System.out.println("output: "+Arrays.toString(output)); | ||
// Assert.assertEquals(expected, output); | ||
assert(expected.equals(output)); // SRDM |
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.
"SRDM" are my initials. You can remove this line and replace it with the uncommented line above.
I was structuring this to work outwith the jtreg framework.
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.
done
* -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -Xbatch -Xmx256m VectorReshapeTest | ||
*/ | ||
|
||
public class VectorReshapeTest { |
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 simply has this name as it is a cut-down version of test/jdk/jdk/incubator/vector/VectorReshapeTests.java
The problem was originally intermittent, but was narrowed somewhat down to what we have here. Perhaps this could be renamed?
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.
The test has changed to VectorRebracket128Test.java
* @bug 8260473 | ||
* @modules jdk.incubator.vector | ||
* @modules java.base/jdk.internal.vm.annotation | ||
* @run main/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromByteBuffer |
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.
-XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromByteBuffer restricts the compilation to a single method for diagnostic purposes. The test runs much quicker without it, and still reproduces the issue.
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.
The test is changed to 'testng' mode, remove option compileonly will make the test pass the assert in jtreg test framework. But add the option will make it fail the assert. So the option is left unchanged.
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 accept that - running it away from standalone does change the behaviour sufficiently that the CompileCommand is necessary to run the test (the standalone test was developed without the CompileCommand being necessary).
*/ | ||
|
||
public class VectorReshapeTest { | ||
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); |
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.
The name "jdk.incubator.vector.test.loop-iterations" should probably be "jtreg.compiler.vectorapi.vectorreshapetest.loop-iterations".
In addition, it should be reset to "1000" to ensure the test is compiled and executed with a chance of GCing to occur.
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.
done
My point is since PhaseVector effectively enters the parsing phase (by signaling about the possibility of post-parse inlining), technically I don't see why So far, I took a look at the review thread of 8212243 (which introduced
Considering |
1, require Z gc 2, Use testng Assert 3, Rename the test 4, get the right INVOC_COUNT
/contributor add Wang Chao casparcwang@tencent.com |
@casparcwang |
@@ -0,0 +1,132 @@ | |||
/* | |||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. |
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.
The Copyright should be " Copyright (c) 2021," since it's a new file added in 2021.
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.
The Copyright should be " Copyright (c) 2021," since it's a new file added in 2021.
done
|
As far as I can see, during the parse phase, GraphKit contains the jvm state info which can be used to get the control and memory for creating new nodes. But during optimization, the jvm state info may be missing like the situation in I think a similar api like |
The main thing to make sure you get right, is the aliasing. I'm not sure that will work right after parsing, the way it works now. |
I suggest you keep this CR as it is since 16 is in rampdown and we need to get approval and push it before Feb 4th (and we do want some margin). Open an enhancement on 17 to fix the api. |
vec_field_ld = gvn.transform(vec_field_ld); | ||
Node* vec_field_ld; | ||
{ | ||
DecoratorSet decorators = C2_READ_ACCESS | C2_CONTROL_DEPENDENT_LOAD | IN_HEAP; |
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.
C2_READ_ACCESS will be set by "bs->load_at" so you can skip that.
MO_UNORDERED is missing. That corresponds to "MemNode::unordered" in the original code.
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.
C2_CONTROL_DEPENDENT_LOAD
is also redundant (though original code does that): it's just a plain load from a final instance field).
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.
Fixed in the new pr: openjdk/jdk16#139
I agree. @casparcwang, please, file an RFE. |
JVM state is irrelevant here (otherwise, |
We need this patch to be based on the JDK 16 repository. I will help out with the fix-request and sponsor-ship. |
Thank you for the explanation. @iwanowww
Thank you very much. @neliasso |
Jie Fu @DamonFool has helped to create an RFE. https://bugs.openjdk.java.net/browse/JDK-8260682 |
Thanks @iwanowww @neliasso @pliden @stooart-mo @XiaohongGong @fisk @DamonFool for the reviews and helping. |
https://bugs.openjdk.java.net/browse/JDK-8260473
Function "PhaseVector::expand_vunbox_node" creates a LoadNode, but forgets to make the LoadNode to pass gc barriers.
Testing: all Vector API related tests have passed.
Progress
Issue
Contributors
<smonteith@openjdk.org>
<casparcwang@tencent.com>
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2253/head:pull/2253
$ git checkout pull/2253