use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class HotSpotGraalCompiler method compile.
public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
StructuredGraph graph = createGraph(method, entryBCI, useProfilingInfo, compilationId, options, debug);
CompilationResult result = new CompilationResult(compilationId);
return compileHelper(CompilationResultBuilderFactory.Default, result, graph, method, entryBCI, useProfilingInfo, options);
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class HotSpotGraalVMEventListener method notifyInstall.
@Override
public void notifyInstall(HotSpotCodeCacheProvider codeCache, InstalledCode installedCode, CompiledCode compiledCode) {
DebugContext debug = DebugContext.forCurrentThread();
if (debug.isDumpEnabled(DebugContext.BASIC_LEVEL)) {
CompilationResult compResult = debug.contextLookup(CompilationResult.class);
assert compResult != null : "can't dump installed code properly without CompilationResult";
debug.dump(DebugContext.BASIC_LEVEL, installedCode, "After code installation");
}
if (debug.isLogEnabled()) {
debug.log("%s", codeCache.disassemble(installedCode));
}
for (HotSpotCodeCacheListener listener : listeners) {
listener.notifyInstall(codeCache, installedCode, compiledCode);
}
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class TruffleCompilerImpl method compilePEGraph.
/**
* Compiles a graph produced by {@link PartialEvaluator#createGraph partial evaluation}.
*
* @param graph a graph resulting from partial evaluation
* @param name the name to be used for the returned {@link CompilationResult#getName() result}
* @param graphBuilderSuite phase suite to be used for creating new graphs during inlining
* @param compilationRequest
* @param listener
*/
@SuppressWarnings("try")
public CompilationResult compilePEGraph(StructuredGraph graph, String name, PhaseSuite<HighTierContext> graphBuilderSuite, CompilableTruffleAST compilable, CompilationRequest compilationRequest, TruffleCompilerListener listener) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("TruffleFinal")) {
debug.dump(DebugContext.BASIC_LEVEL, graph, "After TruffleTier");
} catch (Throwable e) {
throw debug.handle(e);
}
CompilationResult result = null;
try (DebugCloseable a = CompilationTime.start(debug);
DebugContext.Scope s = debug.scope("TruffleGraal.GraalCompiler", graph, providers.getCodeCache());
DebugCloseable c = CompilationMemUse.start(debug)) {
CompilationResult compilationResult = createCompilationResult(name, graph.compilationId());
result = GraalCompiler.compileGraph(graph, graph.method(), providers, backend, graphBuilderSuite, Optimizations, graph.getProfilingInfo(), suites, lirSuites, compilationResult, CompilationResultBuilderFactory.Default);
} catch (Throwable e) {
throw debug.handle(e);
}
if (listener != null) {
listener.onGraalTierFinished(compilable, new GraphInfoImpl(graph));
}
try (DebugCloseable a = CodeInstallationTime.start(debug);
DebugCloseable c = CodeInstallationMemUse.start(debug)) {
InstalledCode installedCode = createInstalledCode(compilable);
backend.createInstalledCode(debug, graph.method(), compilationRequest, result, graph.getSpeculationLog(), installedCode, false);
} catch (Throwable e) {
throw debug.handle(e);
}
return result;
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class HotSpotTruffleCompilerImpl method compileTruffleCallBoundaryMethod.
/**
* Compiles a method denoted as a
* {@linkplain HotSpotTruffleCompilerRuntime#getTruffleCallBoundaryMethods() Truffle call
* boundary}. The compiled code has a special entry point generated by an
* {@link TruffleCallBoundaryInstrumentationFactory}.
*/
private CompilationResult compileTruffleCallBoundaryMethod(ResolvedJavaMethod javaMethod, CompilationIdentifier compilationId, DebugContext debug) {
Suites newSuites = this.suites.copy();
removeInliningPhase(newSuites);
OptionValues options = TruffleCompilerOptions.getOptions();
StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.NO).method(javaMethod).compilationId(compilationId).build();
MetaAccessProvider metaAccess = providers.getMetaAccess();
Plugins plugins = new Plugins(new InvocationPlugins());
HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) providers.getCodeCache();
boolean infoPoints = codeCache.shouldDebugNonSafepoints();
GraphBuilderConfiguration newConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true).withNodeSourcePosition(infoPoints);
new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), newConfig, OptimisticOptimizations.ALL, null).apply(graph);
PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(codeCache, backend.getSuites());
CompilationResultBuilderFactory factory = getTruffleCallBoundaryInstrumentationFactory(backend.getTarget().arch.getName());
return compileGraph(graph, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), newSuites, lirSuites, new CompilationResult(compilationId), factory);
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class BitOpsTest method tzcntlMemTest.
@Test
public void tzcntlMemTest() {
if (tzcntSupported) {
CodeGenTest test = new CodeGenTest() {
@Override
public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
AMD64Assembler asm = new AMD64Assembler(target);
Register ret = registerConfig.getReturnRegister(JavaKind.Int);
try {
Field f = IntField.class.getDeclaredField("x");
AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) UNSAFE.objectFieldOffset(f));
TZCNT.emit(asm, DWORD, ret, arg);
asm.ret(0);
return asm.close(true);
} catch (Exception e) {
throw new RuntimeException("exception while trying to generate field access:", e);
}
}
};
assertReturn("intFieldStub", test, 31, new IntField(0x8000_0000));
}
}
Aggregations