use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.
the class DeoptimizationFeature method beforeCompilation.
@Override
public void beforeCompilation(BeforeCompilationAccess a) {
CompilationAccessImpl config = (CompilationAccessImpl) a;
HostedMetaAccess metaAccess = config.getMetaAccess();
DeoptimizationSupport.setDeoptStubPointer(MethodPointer.factory(metaAccess.lookupJavaMethod(deoptStubMethod)));
}
use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.
the class FieldsOffsetsFeature method beforeCompilation.
@Override
public void beforeCompilation(BeforeCompilationAccess a) {
CompilationAccessImpl config = (CompilationAccessImpl) a;
HostedMetaAccess hMetaAccess = config.getMetaAccess();
for (FieldsOffsetsReplacement replacement : getReplacements().values()) {
Fields fields = replacement.fields;
long[] newOffsets = new long[fields.getCount()];
for (int i = 0; i < newOffsets.length; i++) {
Field field = findField(fields, i);
assert UnsafeAccess.UNSAFE.objectFieldOffset(field) == fields.getOffsets()[i];
newOffsets[i] = hMetaAccess.lookupJavaField(field).getLocation();
}
replacement.newOffsets = newOffsets;
if (fields instanceof Edges) {
Edges edges = (Edges) fields;
replacement.newIterationInitMask = NodeClass.computeIterationMask(edges.type(), edges.getDirectCount(), newOffsets);
}
replacement.newValuesAvailable = true;
}
}
use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.
the class RuntimeStrengthenStampsPhase method beforeCompilation.
@Override
@SuppressWarnings("try")
public void beforeCompilation(BeforeCompilationAccess c) {
CompilationAccessImpl config = (CompilationAccessImpl) c;
if (Options.PrintRuntimeCompileMethods.getValue()) {
printCallTree();
}
System.out.println(methods.size() + " method(s) included for runtime compilation");
if (Options.PrintStaticTruffleBoundaries.getValue()) {
printStaticTruffleBoundaries();
}
Integer maxMethods = Options.MaxRuntimeCompileMethods.getValue();
if (maxMethods != 0 && methods.size() > maxMethods) {
printDeepestLevelPath();
throw VMError.shouldNotReachHere("Number of methods for runtime compilation exceeds the allowed limit: " + methods.size() + " > " + maxMethods);
}
HostedMetaAccess hMetaAccess = config.getMetaAccess();
runtimeConfigBuilder.updateLazyState(hMetaAccess);
/*
* Start fresh with a new GraphEncoder, since we are going to optimize all graphs now that
* the static analysis results are available.
*/
graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
StrengthenStampsPhase strengthenStamps = new RuntimeStrengthenStampsPhase(config.getUniverse(), objectReplacer);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
PhaseContext phaseContext = new PhaseContext(hostedProviders);
for (CallTreeNode node : methods.values()) {
StructuredGraph graph = node.graph;
if (graph != null) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope scope = debug.scope("RuntimeOptimize", graph)) {
removeUnreachableInvokes(node);
strengthenStamps.apply(graph);
canonicalizer.apply(graph, phaseContext);
GraalConfiguration.instance().runAdditionalCompilerPhases(graph, this);
canonicalizer.apply(graph, phaseContext);
graphEncoder.prepare(graph);
} catch (Throwable ex) {
debug.handle(ex);
}
}
}
graphEncoder.finishPrepare();
for (CallTreeNode node : methods.values()) {
if (node.graph != null) {
registerDeoptEntries(node);
long startOffset = graphEncoder.encode(node.graph);
objectReplacer.createMethod(node.implementationMethod).setEncodedGraphStartOffset(startOffset);
/* We do not need the graph anymore, let the GC do it's work. */
node.graph = null;
}
}
GraalSupport.setGraphEncoding(graphEncoder.getEncoding(), graphEncoder.getObjects(), graphEncoder.getNodeClasses());
objectReplacer.updateDataDuringAnalysis((AnalysisMetaAccess) hMetaAccess.getWrapped());
}
use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.
the class RuntimeStrengthenStampsPhase method afterCompilation.
@Override
public void afterCompilation(AfterCompilationAccess a) {
CompilationAccessImpl config = (CompilationAccessImpl) a;
HostedMetaAccess hMetaAccess = config.getMetaAccess();
HostedUniverse hUniverse = (HostedUniverse) hMetaAccess.getUniverse();
objectReplacer.updateSubstrateDataAfterCompilation(hUniverse);
objectReplacer.registerImmutableObjects(config);
GraalSupport.registerImmutableObjects(config);
((SubstrateReplacements) runtimeConfigBuilder.getRuntimeConfig().getProviders().getReplacements()).registerImmutableObjects(config);
}
use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.
the class JNIAccessFeature method beforeCompilation.
@Override
public void beforeCompilation(BeforeCompilationAccess a) {
CompilationAccessImpl access = (CompilationAccessImpl) a;
for (JNIAccessibleClass clazz : JNIReflectionDictionary.singleton().getClasses()) {
for (JNIAccessibleField field : clazz.getFields()) {
field.fillOffset(access);
}
for (JNIAccessibleMethod method : clazz.getMethods()) {
method.resolveJavaCallWrapper(access);
// for constant address to use as identifier
access.registerAsImmutable(method);
}
}
}
Aggregations