-
Notifications
You must be signed in to change notification settings - Fork 738
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
Adds static and dynamic verification for ConstantDynamic Entry #1858
Conversation
17d7184
to
6a33f5d
Compare
6afd1d0
to
c49779d
Compare
@ChengJin01 can you take a look please |
runtime/bcverify/staticverify.c
Outdated
} else if (('D' == constantDynamicSignature->bytes[0]) | ||
|| ('J' == constantDynamicSignature->bytes[0]) | ||
) { | ||
ldcErrorType = J9NLS_CFR_ERR_BC_LDC_CONSTANT_DYNAMIC_RETURNS_LONG_OR_DOUBLE; |
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.
Should it be "J9NLS_CFR_ERR_BC_LDC_CONSTANT_DYNAMIC_RETURNS_LONG_OR_DOUBLE__ID" ?
runtime/bcverify/staticverify.c
Outdated
if (CFR_CONSTANT_Dynamic == tag) { | ||
J9CfrConstantPoolInfo *constantDynamicSignature = &classfile->constantPool[classfile->constantPool[info->slot2].slot2]; | ||
if ( ((flags & BCT_MajorClassFileVersionMask) < BCT_Java11MajorVersionShifted) | ||
&& ((flags & BCT_MajorClassFileVersionMask) != 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.
Please indent against the coding guide for if statement. I recall it should be:
if ((..)
&& ()
) {....
runtime/bcverify/staticverify.c
Outdated
default: | ||
ldcErrorType = J9NLS_CFR_ERR_BC_LDC_NOT_CONSTANT_OR_CONSTANT_DYNAMIC__ID; | ||
} | ||
if (0 != ldcErrorType) { |
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 no need to introduce a new local variable ldcErrorType as errorType has been initialized to 0 at the very beginning of the function.
7aadb82
to
3809173
Compare
fixed code format, @ChengJin01 please take a look, thanks |
runtime/bcverify/staticverify.c
Outdated
if (CFR_CONSTANT_Dynamic == tag) { | ||
J9CfrConstantPoolInfo *constantDynamicSignature = &classfile->constantPool[classfile->constantPool[info->slot2].slot2]; | ||
if (((flags & BCT_MajorClassFileVersionMask) < BCT_Java11MajorVersionShifted) | ||
&& (0 != (flags & BCT_MajorClassFileVersionMask)) |
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.
Better use J9_ARE_ANY_BITS_SET() for (0 != (flags & BCT_MajorClassFileVersionMask) and other similar 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.
fixed
f89c939
to
11ca45e
Compare
per discussion with @DanHeidinga, removed the zero major version check on constant dynamic as cfdumper no longer sets default classfile version to zero. |
lgtm |
Senior reviewer: @DanHeidinga please take a look |
runtime/bcverify/staticverify.c
Outdated
break; | ||
case CFR_CONSTANT_Class: | ||
if (((flags & BCT_MajorClassFileVersionMask) < BCT_Java5MajorVersionShifted) | ||
&& (J9_ARE_ANY_BITS_SET(flags, BCT_MajorClassFileVersionMask)) |
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.
given the way this has been rewritten, it makes sense to just remove the && (J9_ARE_ANY_BITS_SET(flags, BCT_MajorClassFileVersionMask))
as I don't believe it's required anymore.
Previously, cfdump used it.
runtime/nls/cfre/cfrerr.nls
Outdated
# END NON-TRANSLATABLE | ||
|
||
#ldc and ldc_w are not translatable | ||
J9NLS_CFR_ERR_BC_LDC_NOT_CONSTANT_OR_CONSTANT_DYNAMIC=The ldc and ldc_2 bytecodes must reference a constant or a constant dynamic |
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.
constant dynamic
-> constant_dynamic
runtime/nls/cfre/cfrerr.nls
Outdated
#ldc and ldc_w are not translatable | ||
J9NLS_CFR_ERR_BC_LDC_NOT_CONSTANT_OR_CONSTANT_DYNAMIC=The ldc and ldc_2 bytecodes must reference a constant or a constant dynamic | ||
# START NON-TRANSLATABLE | ||
J9NLS_CFR_ERR_BC_LDC_NOT_CONSTANT_OR_CONSTANT_DYNAMIC.explanation=An 'ldc' or 'ldc_w' bytecode can only reference constant values or a constant dynamic entry. |
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 here
runtime/nls/cfre/cfrerr.nls
Outdated
# END NON-TRANSLATABLE | ||
|
||
#ldc2_w is not translatable | ||
J9NLS_CFR_ERR_BC_LDC2W_NOT_CONSTANT_OR_CONSTANT_DYNAMIC=The ldc2_w bytecode must reference a constant or a constant dynamic |
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
runtime/nls/cfre/cfrerr.nls
Outdated
# END NON-TRANSLATABLE | ||
|
||
#ldc and ldc_w are not translatable | ||
J9NLS_CFR_ERR_BC_LDC_CONSTANT_DYNAMIC_RETURNS_LONG_OR_DOUBLE=Constant dynamic entries referenced by the ldc and ldc_w bytecodes must not return long or double |
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. Might be better to use Constant_Dynamic
runtime/nls/cfre/cfrerr.nls
Outdated
# END NON-TRANSLATABLE | ||
|
||
#ldc2_w is not translatable | ||
J9NLS_CFR_ERR_BC_LDC2W_CONSTANT_DYNAMIC_NOT_LONG_OR_DOUBLE=Constant dynamic entries referenced by the ldc2_w bytecode must return long or double |
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
- Add validation to ldc ldc_w and ldc2_w for ConstantDynamic entry - Check that the Condy return type matches the bytecode - Refactor ldc with more informative error messages - Update description comments on pushLdcType(...) - Update pushLdcType to expect a constant dynamic to provide a field - Refactor ldc error codes Code by Talia McCormick from eclipse-openj9#1631 Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- fixed constant pool item access macro names - corrected Java majorVersion checks in static verifier - update NLS messages Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
- Removed legacy check condition that no longer apply - Updated wording of the error message to be more clear Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
11ca45e
to
b9ad8a5
Compare
removed the legacy check condition, changed nls to use |
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. @ChengJin01 Any other comments on this?
Jenkins test sanity xlinux jdk8,jdk11 |
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 am OK with the latest update.
Jenkins line endings check |
The extended test failures are the jdk11 issues we're still working through. Not related to this PR |
Replaces: #1631
Close: #1278
Signed-off-by: Jack Lu Jack.S.Lu@ibm.com