-
Notifications
You must be signed in to change notification settings - Fork 729
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
Implement truncated return bytecodes #1831
Conversation
I had a comment on the PR which enabled JIT support before I knew this PR existed here (#1943 (comment)). @dnakamura would it be possible to add some unit tests which generate these new bytecodes to this PR? |
runtime/bcverify/rtverify.c
Outdated
returnType = BCV_BASE_TYPE_INT_BIT; | ||
break; | ||
default: | ||
//TODO mark unreachable |
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.
Can you add an Assert unreachable here?
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.
Do we have a common solution for that? I tried doing a quick search of the code and It looks like its usually a module or function specific tracepoint. Wasn't sure if there was a more generic solution, hence the TODO
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.
usually a module or function specific tracepoint
That's the generic solution :) Most (many?) tdf files have the basic asserts in them at this point. Copying over an existing one if it isn't present already should be fairly straightforward
runtime/stackmap/fixreturns.c
Outdated
break; | ||
default: | ||
if (romMethod->modifiers & J9AccSynchronized) { | ||
return JBsyncReturn0 + (U_8) *returnSlots; |
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 change introduces multiple return points - can we keep it to a single return?
runtime/bcverify/rtverify.c
Outdated
//TODO mark unreachable | ||
break; | ||
} | ||
inconsistentStack |= ( returnType == baseTypeCharConversion[returnChar - 'A']); |
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.
Does this match the RIs behaviour? Some of the primitives can be automatically converted to others as long as the conversion doesn't lose info. ie: byte -> int. Will this fail verification in those cases?
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.
Does this actually matter, since these return bytecodes are only generated internally?
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 right here - the check that the return type is compatible is already handled above this code so all this is doing is validating we put the right bytecode in for the signature.
break; | ||
|
||
case JBreturn1: | ||
case JBsyncReturn1: |
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.
Can you add a comment here that the synchronized {b,c,s,z} will always be handled by JBgenericReturn
? It will make it more obvious to anyone debugging through the verifier that this is correct without requiring them to check how the bytecodes are written
Can you also look into why the copyright check is failing? |
Thanks for fixing the copyright check. There's one remaining review comment and some unit tests required. When do you think this could be completed? |
Hope to get it done by the end of the week, I have a standalone test case that needs to be polished a bit and integrated with the test framework |
Currently hitting an issue with shared classes. I believe the issue is that there is an old shared class cache which has the old bytecodes. |
@pshipton @hangshao0 What's the process for incrementing the SCC version number when the ROMClass format changes? |
In OSCache.hpp, you'll find the following define: #define OSCACHE_CURRENT_CACHE_GEN To add a new generation, increment the OSCACHE_CURRENT_CACHE_GEN by 2. There are 3 case statements which need to be updated with the old generation numbers, search for "case OSCACHE_CURRENT_CACHE_GEN". The cache generation number is appended to the cache file name. The effect of changing the generation number is that the JVM will create a new cache file, rather than trying to open the old one. We'll have to document / release note this, as it leaves a extra file in the file system, until the cache is destroyed (which destroys older generations as well). |
@pshipton Is there any reason the switch statement are not re-structured as |
Re-structure to if...else should be fine. |
@DanHeidinga this should be good to go |
@dnakamura there are some conflicts to be resolved. |
runtime/vm/BytecodeInterpreter.hpp
Outdated
} else if (isConstructor) { | ||
newBytecode = JBreturnFromConstructor; | ||
/* are we dealing with a case where we should use a truncated return bytecode? */ | ||
if(truncatedReturnBytecode != 0){ |
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.
There is a missing space after the if
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.
and also before the curly bracket.
runtime/vm/BytecodeInterpreter.hpp
Outdated
} else if (isConstructor) { | ||
newBytecode = JBreturnFromConstructor; | ||
/* are we dealing with a case where we should use a truncated return bytecode? */ | ||
if (truncatedReturnBytecode != 0){ |
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.
Missing space before the curly bracket here too.
runtime/bcverify/rtverify.c
Outdated
|
||
/* check methods that return char, byte, short, or bool use the right opcode */ | ||
if (BCV_BASE_TYPE_INT == type){ | ||
switch(bc){ |
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.
nitpicks on the spacing here as well. Between the ){
here and line above.
@pshipton looking at the conflicts and comments now. There turned out to be a bug in my earlier code which caused issues with the shared classes cache. However this shouldn't break compatibility, since all returns are converted to the generic return opcode before being put in the cache |
@dnakamura that's backwards actually. We run |
No, this isn't ready to go yet. Some of the review comments haven't been addressed and I believe this will leave The bytecode patching in JBgenericReturn in the interpreter will need to be modified if we're genericreturns in SCC romclasses |
Then it seems it should be removed from the 0.11.0 plan and deferred to 0.12.0 |
a13e67b
to
eec7ffb
Compare
IT looks like I forgot to push the changes to the branch (or maybe pushed them to the wrong branch). Latest changes with fixes for comments should be there
Oh yeah, thats right. I knew there was some issue involving patching generic returns and the shared classes cache. The problem is addressed in these changes |
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.
@smlambert @sophia-guo Can one of you give the tests a look? It looks OK to me
runtime/bcverify/rtverify.c
Outdated
__LINE__); | ||
break; | ||
} | ||
inconsistentStack |= !( returnType == baseTypeCharConversion[returnChar - 'A']); |
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.
Isn't this just inconsistentStack |= (returnType != baseTypeCharConversion[returnChar - 'A']);
or is there some other reason to negate the whole expression?
Jenkins test sanity plinux,win,zlinux jdk8 |
@@ -30,6 +30,7 @@ | |||
<test name="generalTest"> | |||
<classes> | |||
<class name="org.openj9.test.gpu.SortTest" /> | |||
<class name="org.openj9.test.truncatedReturn.TestTruncatedReturn" /> |
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.
We are planning to rename the generalTest to GPUSortTest to be more straightforward. Each testname could indicate kind of its feature just like all other tests. So probably adding a new test naming truncateReturn
would be better.
@@ -27,7 +27,7 @@ | |||
<test> | |||
<testCaseName>generalSanityTest</testCaseName> | |||
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \ | |||
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(Q) \ | |||
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(LIB_DIR)$(D)asm-all.jar$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(Q) \ |
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.
Same as comment for testng.xml. Adding a separate testcase would be better.
@sophia-guo Are you ok with the updated tests? |
Add code which emmits the new bytecodes for truncated return types. See eclipse-openj9#999 Signed-off-by: Devin Nakamura <[email protected]>
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.
LGTM
Jenkins test sanity plinux,xlinux,win jdk8 |
Jenkins test extended xlinux jdk8 |
When new bytecodes were added in eclipse-openj9#1831 for the truncated returns, the SCC generation number wasn't incremented which can lead to crashes. Currently the VM will attempt to destroy and recreate the SCC if the SHA in the header is different but if can't, it will continue to use the cache. The only sure way (today) to prevent this issue is to increment the cache generation. Do this now to prevent VerifyErrors due to unknown bytecodes while we work out the right behaviour. issue: eclipse-openj9#5380 Signed-off-by: Dan Heidinga <[email protected]>
When new bytecodes were added in eclipse-openj9#1831 for the truncated returns, the SCC generation number wasn't incremented which can lead to crashes. Currently the VM will attempt to destroy and recreate the SCC if the SHA in the header is different but if can't, it will continue to use the cache. The only sure way (today) to prevent this issue is to increment the cache generation. Do this now to prevent VerifyErrors due to unknown bytecodes while we work out the right behaviour. issue: eclipse-openj9#5380 Signed-off-by: Dan Heidinga <[email protected]>
Add code which emmits the new bytecodes for truncated return types.
See #999
Signed-off-by: Devin Nakamura [email protected]