Skip to content

Commit

Permalink
Record activity when generating debuginfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 31, 2023
1 parent e7203d7 commit db31b1a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
Path filePath = debugTypeInfo.filePath();
addTypeEntry(idType, typeName, fileName, filePath, byteSize, typeKind);
}));
debugInfoProvider.recordActivity();

/* Now we can cross reference static and instance field details. */
debugInfoProvider.typeInfoProvider().forEach(debugTypeInfo -> debugTypeInfo.debugContext((debugContext) -> {
Expand All @@ -310,6 +311,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
TypeEntry typeEntry = (idType != null ? lookupTypeEntry(idType) : lookupHeaderType());
typeEntry.addDebugInfo(this, debugTypeInfo, debugContext);
}));
debugInfoProvider.recordActivity();

debugInfoProvider.codeInfoProvider().forEach(debugCodeInfo -> debugCodeInfo.debugContext((debugContext) -> {
/*
Expand All @@ -336,6 +338,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
EconomicMap<DebugLocationInfo, SubRange> subRangeIndex = EconomicMap.create();
debugCodeInfo.locationInfoProvider().forEach(debugLocationInfo -> addSubrange(debugLocationInfo, primaryRange, classEntry, subRangeIndex, debugContext));
}));
debugInfoProvider.recordActivity();

debugInfoProvider.dataInfoProvider().forEach(debugDataInfo -> debugDataInfo.debugContext((debugContext) -> {
if (debugContext.isLogEnabled(DebugContext.INFO_LEVEL)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,6 @@ enum Type {
Stream<DebugDataInfo> dataInfoProvider();

Path getCachePath();

void recordActivity();
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public void beforeImageWrite(BeforeImageWriteAccess access) {
var accessImpl = (FeatureImpl.BeforeImageWriteAccessImpl) access;
var image = accessImpl.getImage();
var debugContext = new DebugContext.Builder(HostedOptionValues.singleton(), new GraalDebugHandlersFactory(GraalAccess.getOriginalSnippetReflection())).build();
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debugContext, image.getCodeCache(), image.getHeap(), image.getNativeLibs(), accessImpl.getHostedMetaAccess());
DebugInfoProvider provider = new NativeImageDebugInfoProvider(debugContext, image.getCodeCache(), image.getHeap(), image.getNativeLibs(), accessImpl.getHostedMetaAccess(),
accessImpl.getImageClassLoader().watchdog::recordActivity);
var objectFile = image.getObjectFile();
objectFile.installDebugInfo(provider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@
class NativeImageDebugInfoProvider extends NativeImageDebugInfoProviderBase implements DebugInfoProvider {
private final DebugContext debugContext;
private final Set<HostedMethod> allOverrides;
private final Runnable heartbeatCallback;

NativeImageDebugInfoProvider(DebugContext debugContext, NativeImageCodeCache codeCache, NativeImageHeap heap, NativeLibraries nativeLibs, HostedMetaAccess metaAccess) {
NativeImageDebugInfoProvider(DebugContext debugContext, NativeImageCodeCache codeCache, NativeImageHeap heap, NativeLibraries nativeLibs, HostedMetaAccess metaAccess, Runnable heartbeatCallback) {
super(codeCache, heap, nativeLibs, metaAccess);
this.debugContext = debugContext;
/* Calculate the set of all HostedMethods that are overrides. */
Expand All @@ -129,6 +130,7 @@ class NativeImageDebugInfoProvider extends NativeImageDebugInfoProviderBase impl
.flatMap(m -> Arrays.stream(m.getImplementations())
.filter(Predicate.not(m::equals)))
.collect(Collectors.toSet());
this.heartbeatCallback = heartbeatCallback;
}

@Override
Expand Down Expand Up @@ -2704,4 +2706,9 @@ private boolean acceptObjectInfo(ObjectInfo objectInfo) {
private DebugDataInfo createDebugDataInfo(ObjectInfo objectInfo) {
return new NativeImageDebugDataInfo(objectInfo);
}

@Override
public void recordActivity() {
heartbeatCallback.run();
}
}

0 comments on commit db31b1a

Please sign in to comment.