-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[GR-32340] Predicated configuration for Native Image. #3606
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
[GR-32340] Predicated configuration for Native Image. #3606
Conversation
2794aff to
cad8fc3
Compare
0f4bbe7 to
59fd6e3
Compare
24bf7f7 to
b52baa0
Compare
fbfcc1d to
3cf466e
Compare
...src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/PredicatedReflectionSupport.java
Outdated
Show resolved
Hide resolved
sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java
Outdated
Show resolved
Hide resolved
3cf466e to
0673858
Compare
...tevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationType.java
Show resolved
Hide resolved
...src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.jni/src/com/oracle/svm/jni/access/JNIAccessFeature.java
Outdated
Show resolved
Hide resolved
bf01286 to
d32b050
Compare
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/PredicatedConfigurationSupport.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/PredicatedConfigurationSupport.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/PredicatedConfigurationSupport.java
Outdated
Show resolved
Hide resolved
de7bc85 to
395a9b2
Compare
...evm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/PredicatedConfigurationRegistry.java
Outdated
Show resolved
Hide resolved
...tevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationType.java
Outdated
Show resolved
Hide resolved
| writer.append("\"predicate\":{"); | ||
| writer.append("\"whenTypeReachable\":\"").append(predicate.getTypeName()).append("\""); | ||
| writer.append("},").newline(); |
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 "predicate": declaration is a part of the type object and should be printed by TypeConfiguration. Only the {"whenTypeReachable":"..."} part should be printed here.
Please use the JsonWriter.quote for readability and safety with special characters.
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.
So you propose to have redundant checks if the printing of predicated should happen? Then we should duplicate that if and the printing of predicate in all different configuration kinds. This is hardly minimal as ConfigurationPredicate will be uniform in all configuration kinds.
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.
Fair enough, we should simply rename the method to printPredicateAttribute then. Also, I meant ConfigurationType (not TypeConfiguration) in my comment above.
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.
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 method is still called ConfigurationPredicatePrintable.printJson in your last commit.
|
I am starting to consider changing {
"predicate" : { "typeReachable" : "io.netty.util.internal.PlatformDependent0" },
"name" : "sun.misc.Unsafe",
"fields" : [
{ "name" : "theUnsafe" }
]
}instead of {
"predicate" : { "whenTypeReachable" : "io.netty.util.internal.PlatformDependent0" },
"name" : "sun.misc.Unsafe",
"fields" : [
{ "name" : "theUnsafe" }
]
}WDYT? |
3f1e7d2 to
2eeabe0
Compare
I think this is better regardless of file size concerns. You could consider changing |
3644e5b to
659fecf
Compare
659fecf to
01a8fa7
Compare
|
Agree, also predicate is something that is evaluated over an argument and yields a boolean. Here the relation to the argument is unclear. So we are left with: {
"condition" : { "typeReachable" : "io.netty.util.internal.PlatformDependent0" },
"name" : "sun.misc.Unsafe",
"fields" : [
{ "name" : "theUnsafe" }
]
}or {
"if" : { "typeReachable" : "io.netty.util.internal.PlatformDependent0" },
"name" : "sun.misc.Unsafe",
"fields" : [
{ "name" : "theUnsafe" }
]
}or {
"when" : { "typeReachable" : "io.netty.util.internal.PlatformDependent0" },
"name" : "sun.misc.Unsafe",
"fields" : [
{ "name" : "theUnsafe" }
]
} |
ce41138 to
fc4db98
Compare
I like |
1f2c9e1 to
70044a1
Compare
|
I like |
f2429f5 to
5b3b8ce
Compare
Introducing conditions for reflection, JNI, and serialization configuration. The condition
can be only a type name. For example,
"condition": {
"typeReachable": "org.graalvm.ReachableClass"
},
will apply configuration only if type "org.graalvm.ReachableClass" is reachable.
The default condition for every reflection entry is "java.lang.Object" and as
such it will not be printed.
The Native Image agent does not emit conditions, but will fuse conditions
accordingly. Instead all config of one type, the fusion will happen by
the condition and the type.
5b3b8ce to
80c9ff8
Compare
See:
https://github.com/oracle/graal/pull/3606/files#diff-ad2f1f5ee9adf56edcef4ff598e2a3c5ddd3f39e07d428ead926b5446c287f19