use of com.oracle.svm.core.util.Counter in project graal by oracle.
the class NativeImageCodeCache method layoutMethods.
@SuppressWarnings("try")
public void layoutMethods(DebugContext debug) {
try (Indent indent = debug.logAndIndent("layout methods")) {
// Assign a location to all methods.
assert codeCacheSize == 0;
HostedMethod firstMethod = null;
for (Entry<HostedMethod, CompilationResult> entry : compilations.entrySet()) {
HostedMethod method = entry.getKey();
if (firstMethod == null) {
firstMethod = method;
}
CompilationResult compilation = entry.getValue();
compilationsByStart.put(codeCacheSize, compilation);
method.setCodeAddressOffset(codeCacheSize);
codeCacheSize = ObjectLayout.roundUp(codeCacheSize + compilation.getTargetCodeSize(), CODE_ALIGNMENT);
}
// Build run-time metadata.
FrameInfoCustomization frameInfoCustomization = new FrameInfoCustomization();
CodeInfoEncoder codeInfoEncoder = new CodeInfoEncoder(frameInfoCustomization, null);
for (Entry<HostedMethod, CompilationResult> entry : compilations.entrySet()) {
final HostedMethod method = entry.getKey();
final CompilationResult compilation = entry.getValue();
codeInfoEncoder.addMethod(method, compilation, method.getCodeAddressOffset());
}
if (NativeImageOptions.PrintMethodHistogram.getValue()) {
System.out.println("encoded deopt entry points ; " + frameInfoCustomization.numDeoptEntryPoints);
System.out.println("encoded during call entry points ; " + frameInfoCustomization.numDuringCallEntryPoints);
}
ImageCodeInfo imageCodeInfo = CodeInfoTable.getImageCodeCache();
codeInfoEncoder.encodeAll();
codeInfoEncoder.install(imageCodeInfo);
imageCodeInfo.setData(MethodPointer.factory(firstMethod), WordFactory.unsigned(codeCacheSize));
if (CodeInfoEncoder.Options.CodeInfoEncoderCounters.getValue()) {
for (Counter counter : ImageSingletons.lookup(CodeInfoEncoder.Counters.class).group.getCounters()) {
System.out.println(counter.getName() + " ; " + counter.getValue());
}
}
if (Options.VerifyDeoptimizationEntryPoints.getValue()) {
/*
* Missing deoptimization entry points lead to hard-to-debug transient failures, so
* we want the verification on all the time and not just when assertions are on.
*/
verifyDeoptEntries(imageCodeInfo);
}
assert verifyMethods(codeInfoEncoder);
}
}
Aggregations