Skip to content

Commit

Permalink
Rename support for SVM runtime compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
teshull committed Sep 20, 2022
1 parent c0eaabb commit 43f9aba
Show file tree
Hide file tree
Showing 20 changed files with 818 additions and 731 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.UserError.UserException;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.graal.hosted.GraalFeature;
import com.oracle.svm.graal.hosted.RuntimeCompilationFeature;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl;
import com.oracle.svm.hosted.ImageClassLoader;
Expand Down Expand Up @@ -195,7 +195,7 @@ public boolean isInConfiguration(IsInConfigurationAccess access) {

@Override
public List<Class<? extends Feature>> getRequiredFeatures() {
return Arrays.asList(JNIFeature.class, GraalFeature.class, ReflectionFeature.class);
return Arrays.asList(JNIFeature.class, RuntimeCompilationFeature.class, ReflectionFeature.class);
}

public static final class IsEnabled implements BooleanSupplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@
import com.oracle.svm.core.option.HostedOptionValues;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.graal.hosted.FieldsOffsetsFeature;
import com.oracle.svm.graal.hosted.GraalFeature;
import com.oracle.svm.graal.hosted.RuntimeCompilationFeature;
import com.oracle.svm.graal.meta.SubstrateMethod;
import com.oracle.svm.util.ReflectionUtil;

import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.meta.ResolvedJavaMethod;

@TargetClass(value = org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
final class Target_org_graalvm_compiler_nodes_graphbuilderconf_InvocationPlugins {

@Alias//
Expand All @@ -98,7 +98,7 @@ private void flushDeferrables() {
}
}

@TargetClass(value = org.graalvm.compiler.phases.common.inlining.info.elem.InlineableGraph.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.phases.common.inlining.info.elem.InlineableGraph.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
@SuppressWarnings({"unused"})
final class Target_org_graalvm_compiler_phases_common_inlining_info_elem_InlineableGraph {

Expand All @@ -112,7 +112,7 @@ private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTie
}
}

@TargetClass(value = org.graalvm.compiler.phases.common.inlining.walker.ComputeInliningRelevance.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.phases.common.inlining.walker.ComputeInliningRelevance.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
@SuppressWarnings({"static-method", "unused"})
final class Target_org_graalvm_compiler_phases_common_inlining_walker_ComputeInliningRelevance {

Expand All @@ -130,11 +130,11 @@ public double getRelevance(Invoke invoke) {
}
}

@TargetClass(value = DebugContext.class, innerClass = "Invariants", onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = DebugContext.class, innerClass = "Invariants", onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_debug_DebugContext_Invariants {
}

@TargetClass(value = DebugContext.class, innerClass = "Immutable", onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = DebugContext.class, innerClass = "Immutable", onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_debug_DebugContext_Immutable {
static class ClearImmutableCache implements FieldValueTransformer {
@Override
Expand Down Expand Up @@ -163,7 +163,7 @@ public Object transform(Object receiver, Object originalValue) {
private static Target_org_graalvm_compiler_debug_DebugContext_Immutable[] CACHE;
}

@TargetClass(value = DebugHandlersFactory.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = DebugHandlersFactory.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_debug_DebugHandlersFactory {
static class CachedFactories implements FieldValueTransformer {
@Override
Expand All @@ -180,22 +180,22 @@ public Object transform(Object receiver, Object originalValue) {
private static Iterable<DebugHandlersFactory> LOADER;
}

@TargetClass(value = TimeSource.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = TimeSource.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_debug_TimeSource {
// Checkstyle: stop
@Alias @RecomputeFieldValue(kind = FromAlias)//
private static boolean USING_THREAD_CPU_TIME = false;
// Checkstyle: resume
}

@TargetClass(value = org.graalvm.compiler.debug.TTY.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.debug.TTY.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
final class Target_org_graalvm_compiler_debug_TTY {

@Alias @RecomputeFieldValue(kind = FromAlias)//
private static PrintStream out = Log.logStream();
}

@TargetClass(className = "org.graalvm.compiler.serviceprovider.IsolateUtil", onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(className = "org.graalvm.compiler.serviceprovider.IsolateUtil", onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_serviceprovider_IsolateUtil {

@Substitute
Expand All @@ -213,7 +213,7 @@ public static long getIsolateID() {
* The following substitutions replace methods where reflection is used in the Graal code.
*/

@TargetClass(value = org.graalvm.compiler.debug.KeyRegistry.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.debug.KeyRegistry.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_debug_KeyRegistry {

@Alias @RecomputeFieldValue(kind = FromAlias)//
Expand All @@ -223,7 +223,7 @@ final class Target_org_graalvm_compiler_debug_KeyRegistry {
private static List<MetricKey> keys = new ArrayList<>();
}

@TargetClass(value = org.graalvm.compiler.core.match.MatchRuleRegistry.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.core.match.MatchRuleRegistry.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_core_match_MatchRuleRegistry {

@Substitute
Expand All @@ -237,7 +237,7 @@ public static EconomicMap<Class<? extends Node>, List<MatchStatement>> lookup(Cl
}
}

@TargetClass(value = org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
@SuppressWarnings({"unused", "static-method"})
final class Target_org_graalvm_compiler_replacements_nodes_BinaryMathIntrinsicNode {

Expand All @@ -253,7 +253,7 @@ void generate(NodeLIRBuilderTool nodeValueMap, ArithmeticLIRGeneratorTool gen) {
}
}

@TargetClass(value = org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.class, onlyWith = GraalFeature.IsEnabledAndNotLibgraal.class)
@TargetClass(value = org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.class, onlyWith = RuntimeCompilationFeature.IsEnabledAndNotLibgraal.class)
@SuppressWarnings({"unused", "static-method"})
final class Target_org_graalvm_compiler_replacements_nodes_UnaryMathIntrinsicNode {

Expand All @@ -263,7 +263,7 @@ void generate(NodeLIRBuilderTool nodeValueMap, ArithmeticLIRGeneratorTool gen) {
}
}

@TargetClass(value = org.graalvm.compiler.phases.BasePhase.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.phases.BasePhase.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_phases_BasePhase {

@Substitute
Expand All @@ -276,7 +276,7 @@ static BasePhase.BasePhaseStatistics getBasePhaseStatistics(Class<?> clazz) {
}
}

@TargetClass(value = org.graalvm.compiler.lir.phases.LIRPhase.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.lir.phases.LIRPhase.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_lir_phases_LIRPhase {

@Substitute
Expand All @@ -289,7 +289,7 @@ static LIRPhase.LIRPhaseStatistics getLIRPhaseStatistics(Class<?> clazz) {
}
}

@TargetClass(value = org.graalvm.compiler.graph.NodeClass.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.graph.NodeClass.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_graph_NodeClass {

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = FieldsOffsetsFeature.InputsIterationMaskRecomputation.class)//
Expand Down Expand Up @@ -319,7 +319,7 @@ public String shortName() {
}
}

@TargetClass(value = org.graalvm.compiler.lir.LIRInstructionClass.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.lir.LIRInstructionClass.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_lir_LIRInstructionClass {

@Substitute
Expand All @@ -334,7 +334,7 @@ public static LIRInstructionClass<?> get(Class<? extends LIRInstruction> clazz)
}
}

@TargetClass(value = org.graalvm.compiler.lir.CompositeValueClass.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.lir.CompositeValueClass.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_lir_CompositeValueClass {

@Substitute
Expand All @@ -356,7 +356,7 @@ final class Target_org_graalvm_compiler_printer_NoDeadCodeVerifyHandler {
private static Map<String, Boolean> discovered;
}

@TargetClass(value = org.graalvm.compiler.nodes.NamedLocationIdentity.class, innerClass = "DB", onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = org.graalvm.compiler.nodes.NamedLocationIdentity.class, innerClass = "DB", onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_nodes_NamedLocationIdentity_DB {
@Alias//
@RecomputeFieldValue(kind = FromAlias, declClass = EconomicMap.class)//
Expand All @@ -369,7 +369,7 @@ final class Target_org_graalvm_compiler_nodes_NamedLocationIdentity_DB {
* created just once during the image build and accessed via {@link ConfigurationValues} and
* {@link ImageSingletons} from many locations.
*/
@TargetClass(value = TargetDescription.class, onlyWith = GraalFeature.IsEnabled.class)
@TargetClass(value = TargetDescription.class, onlyWith = RuntimeCompilationFeature.IsEnabled.class)
final class Target_jdk_vm_ci_code_TargetDescription {
@Alias @InjectAccessors(value = InlineObjectsAccessor.class) //
boolean inlineObjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
*
* It is mainly used to replace the Hosted* meta data with the Substrate* meta data.
*/
public class GraalObjectReplacer implements Function<Object, Object> {
public class GraalGraphObjectReplacer implements Function<Object, Object> {

private final AnalysisUniverse aUniverse;
private final AnalysisMetaAccess aMetaAccess;
Expand All @@ -103,7 +103,7 @@ public class GraalObjectReplacer implements Function<Object, Object> {
private final HashMap<FieldLocationIdentity, SubstrateFieldLocationIdentity> fieldLocationIdentities = new HashMap<>();
private final HashMap<AnalysisType, SubstrateType> types = new HashMap<>();
private final HashMap<Signature, SubstrateSignature> signatures = new HashMap<>();
private final GraalProviderObjectReplacements providerReplacements;
private final SubstrateProviders sProviders;
private SubstrateGraalRuntime sGraalRuntime;

private final HostedStringDeduplication stringTable;
Expand All @@ -116,10 +116,10 @@ public class GraalObjectReplacer implements Function<Object, Object> {
private final Field substrateMethodImplementationsField;
private final Field substrateMethodAnnotationsEncodingField;

public GraalObjectReplacer(AnalysisUniverse aUniverse, AnalysisMetaAccess aMetaAccess, GraalProviderObjectReplacements providerReplacements) {
public GraalGraphObjectReplacer(AnalysisUniverse aUniverse, AnalysisMetaAccess aMetaAccess, SubstrateProviders sProviders) {
this.aUniverse = aUniverse;
this.aMetaAccess = aMetaAccess;
this.providerReplacements = providerReplacements;
this.sProviders = sProviders;
this.stringTable = HostedStringDeduplication.singleton();
substrateFieldAnnotationsEncodingField = ReflectionUtil.lookupField(SubstrateField.class, "annotationsEncoding");
substrateFieldTypeField = ReflectionUtil.lookupField(SubstrateField.class, "type");
Expand Down Expand Up @@ -152,7 +152,7 @@ public Object apply(Object source) {
return source;
}
if (source instanceof MetaAccessProvider) {
dest = providerReplacements.getMetaAccessProvider();
dest = sProviders.getMetaAccessProvider();
} else if (source instanceof HotSpotJVMCIRuntime) {
throw new UnsupportedFeatureException("HotSpotJVMCIRuntime should not appear in the image: " + source);
} else if (source instanceof GraalHotSpotVMConfig) {
Expand All @@ -166,13 +166,13 @@ public Object apply(Object source) {
} else if (source instanceof GraalRuntime) {
dest = sGraalRuntime;
} else if (source instanceof AnalysisConstantReflectionProvider) {
dest = providerReplacements.getConstantReflectionProvider();
dest = sProviders.getConstantReflectionProvider();
} else if (source instanceof AnalysisConstantFieldProvider) {
dest = providerReplacements.getConstantFieldProvider();
dest = sProviders.getConstantFieldProvider();
} else if (source instanceof ForeignCallsProvider) {
dest = providerReplacements.getForeignCallsProvider();
dest = sProviders.getForeignCallsProvider();
} else if (source instanceof SnippetReflectionProvider) {
dest = providerReplacements.getSnippetReflectionProvider();
dest = sProviders.getSnippetReflectionProvider();

} else if (source instanceof MetricKey) {
/* Ensure lazily initialized name fields are computed. */
Expand Down
Loading

0 comments on commit 43f9aba

Please sign in to comment.