Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected void setTotalHeapSize(long totalHeapSize) {
this.totalHeapSize = totalHeapSize;
}

protected void calculate(BeforeImageWriteAccessImpl access) {
protected void calculate(BeforeImageWriteAccessImpl access, boolean resourcesAreReachable) {
HostedMetaAccess metaAccess = access.getHostedMetaAccess();
ObjectLayout objectLayout = ImageSingletons.lookup(ObjectLayout.class);

Expand Down Expand Up @@ -160,10 +160,13 @@ protected void calculate(BeforeImageWriteAccessImpl access) {
addEntry(entries, byteArrayEntry, new HeapBreakdownEntry(BYTE_ARRAY_PREFIX, "reflection metadata", "#glossary-reflection-metadata"), metadataSize, 1);
}
ProgressReporter reporter = ProgressReporter.singleton();
/* GR-57350: This condition can be removed once resources are adapted for Layered Images */
if (!ImageLayerBuildingSupport.buildingExtensionLayer()) {
long resourcesByteArraySize = 0;
/*
* GR-57350: The first part of this condition can be removed once resources are adapted for
* Layered Images.
*/
if (!ImageLayerBuildingSupport.buildingExtensionLayer() && resourcesAreReachable) {
/* Extract byte[] for resources. */
long resourcesByteArraySize = 0;
int resourcesByteArrayCount = 0;
for (ConditionalRuntimeValue<ResourceStorageEntryBase> resourceList : Resources.currentLayer().resources()) {
if (resourceList.getValueUnconditionally().hasData()) {
Expand All @@ -173,11 +176,11 @@ protected void calculate(BeforeImageWriteAccessImpl access) {
}
}
}
reporter.recordJsonMetric(ImageDetailKey.RESOURCE_SIZE_BYTES, resourcesByteArraySize);
if (resourcesByteArraySize > 0) {
addEntry(entries, byteArrayEntry, new HeapBreakdownEntry(BYTE_ARRAY_PREFIX, "embedded resources", "#glossary-embedded-resources"), resourcesByteArraySize, resourcesByteArrayCount);
}
}
reporter.recordJsonMetric(ImageDetailKey.RESOURCE_SIZE_BYTES, resourcesByteArraySize);
/* Extract byte[] for graph encodings. */
if (graphEncodingByteLength >= 0) {
long graphEncodingSize = objectLayout.getArraySize(JavaKind.Byte, graphEncodingByteLength, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem;
import com.oracle.svm.core.jni.access.JNIAccessibleClass;
import com.oracle.svm.core.jni.access.JNIReflectionDictionary;
import com.oracle.svm.hosted.FeatureImpl.AfterCompilationAccessImpl;
Expand All @@ -51,6 +52,7 @@
@AutomaticallyRegisteredFeature
public class ProgressReporterFeature implements InternalFeature {
protected final ProgressReporter reporter = ProgressReporter.singleton();
private boolean resourcesAreReachable;

@Override
public void duringSetup(DuringSetupAccess access) {
Expand All @@ -71,10 +73,15 @@ public void afterCompilation(AfterCompilationAccess access) {
}
}

@Override
public void afterAnalysis(AfterAnalysisAccess access) {
resourcesAreReachable = access.isReachable(NativeImageResourceFileSystem.class);
}

@Override
public void beforeImageWrite(BeforeImageWriteAccess access) {
if (SubstrateOptions.BuildOutputBreakdowns.getValue()) {
HeapBreakdownProvider.singleton().calculate(((BeforeImageWriteAccessImpl) access));
HeapBreakdownProvider.singleton().calculate(((BeforeImageWriteAccessImpl) access), resourcesAreReachable);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class WebImageJSHeapBreakdownProvider extends HeapBreakdownProvider {
* of bytes used if they were laid out in binary without alignment gaps.
*/
@Override
protected void calculate(FeatureImpl.BeforeImageWriteAccessImpl access) {
protected void calculate(FeatureImpl.BeforeImageWriteAccessImpl access, boolean resourcesAreReachable) {
long totalByteSize = 0;
WebImageJSProviders providers = (WebImageJSProviders) ImageSingletons.lookup(WebImageProviders.class);
ConstantIdentityMapping identityMapping = providers.typeControl().getConstantMap().identityMapping;
Expand Down
Loading