Skip to content

Commit 5972fd2

Browse files
committed
[GR-36671] [GR-35917] Re-introduce JDK8OrEarlier/JDK11OrLater and extend build output.
PullRequest: graal/10934
2 parents 58b1a05 + a6065a9 commit 5972fd2

File tree

6 files changed

+102
-19
lines changed

6 files changed

+102
-19
lines changed

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ GraalVM Native Image: Generating 'helloworld'...
3333
13.57MB in total
3434
--------------------------------------------------------------------------------
3535
Top 10 packages in code area: Top 10 object types in image heap:
36-
606.23KB java.util 1.64MB byte[] for general heap data
37-
282.34KB java.lang 715.56KB java.lang.String
38-
222.47KB java.util.regex 549.46KB java.lang.Class
39-
219.55KB java.text 451.79KB byte[] for java.lang.String
40-
193.17KB com.oracle.svm.jni 363.23KB java.util.HashMap$Node
41-
149.80KB java.util.concurrent 192.00KB java.util.HashMap$Node[]
42-
118.07KB java.math 139.83KB java.lang.String[]
43-
103.60KB com.oracle.svm.core.reflect 139.04KB char[]
44-
97.83KB sun.text.normalizer 130.59KB j.u.c.ConcurrentHashMap$Node
45-
88.78KB c.oracle.svm.core.genscavenge 103.92KB s.u.l.LocaleObjec~e$CacheEntry
46-
... 111 additional packages ... 723 additional object types
36+
607.28KB java.util 862.66KB byte[] for general heap data
37+
288.63KB java.lang 834.02KB byte[] for code metadata
38+
223.34KB java.util.regex 723.00KB java.lang.String
39+
220.45KB java.text 534.05KB java.lang.Class
40+
194.21KB com.oracle.svm.jni 457.63KB byte[] for java.lang.String
41+
153.69KB java.util.concurrent 363.75KB java.util.HashMap$Node
42+
118.78KB java.math 192.70KB java.util.HashMap$Node[]
43+
99.00KB com.oracle.svm.core.reflect 140.03KB java.lang.String[]
44+
98.21KB sun.text.normalizer 139.04KB char[]
45+
89.95KB c.oracle.svm.core.genscavenge 132.78KB c.o.s.c.h.DynamicHubCompanion
46+
... 112 additional packages ... 734 additional object types
4747
(use GraalVM Dashboard to see all)
4848
--------------------------------------------------------------------------------
4949
0.9s (5.6% of total time) in 17 GCs | Peak RSS: 3.22GB | CPU load: 10.87
@@ -114,24 +114,28 @@ Debug info is also generated as part of this stage (if requested).
114114
115115
#### <a name="glossary-code-area"></a>Code Area
116116
The code area contains machine code produced by the Graal compiler for all reachable methods.
117-
Therefore, reducing the number of reachable methods also reduces the size of the code area.
117+
Therefore, reducing the number of [reachable methods](#glossary-reachability) also reduces the size of the code area.
118118
119119
#### <a name="glossary-image-heap"></a>Image Heap
120120
The image heap contains reachable objects such as static data, classes initialized at run-time, and `byte[]` for different purposes.
121121
122122
##### <a name="glossary-general-heap-data"></a>General Heap Data Stored in `byte[]`
123-
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [graph encodings](#glossary-graph-encodings), nor [method metadata](#glossary-method-metadata).
124-
This typically dominates
123+
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [code metadata](#glossary-code-metadata), nor [method metadata](#glossary-method-metadata), nor [graph encodings](#glossary-graph-encodings).
124+
Therefore, this can also include `byte[]` objects from application code.
125125
126-
##### <a name="glossary-graph-encodings"></a>Graph Encodings Stored in `byte[]`
127-
The total size of all `byte[]` objects used for graph encodings.
128-
These encodings are a result of [runtime compiled methods](#glossary-runtime-methods).
129-
Therefore, reducing the number of such methods also reduces the size of corresponding graph encodings.
126+
##### <a name="glossary-code-metadata"></a>Code Metadata Stored in `byte[]`
127+
The total size of all `byte[]` objects used for metadata for the [code area](#glossary-code-area).
128+
Therefore, reducing the number of [reachable methods](#glossary-reachability) also reduces the size of this metadata.
130129
131130
##### <a name="glossary-method-metadata"></a>Method Metadata Stored in `byte[]`
132131
The total size of all `byte[]` objects used for method metadata, a type of reflection metadata.
133132
To reduce the amount of method metadata, reduce the number of [classes registered for reflection](#glossary-reflection-classes).
134133
134+
##### <a name="glossary-graph-encodings"></a>Graph Encodings Stored in `byte[]`
135+
The total size of all `byte[]` objects used for graph encodings.
136+
These encodings are a result of [runtime compiled methods](#glossary-runtime-methods).
137+
Therefore, reducing the number of such methods also reduces the size of corresponding graph encodings.
138+
135139
#### <a name="glossary-debug-info"></a>Debug Info
136140
The total size of generated debug information (if enabled).
137141

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This changelog summarizes major changes to GraalVM Native Image.
44

55
## Version 22.1.0
66
* (GR-35898) Improved handling of static synchronized methods: the lock is no longer stored in the secondary monitor map, but in the mutable DynamicHubCompanion object.
7+
* Remove support for JDK8. As a result, `JDK8OrEarlier` and `JDK11OrLater` have been deprecated and will be removed in a future release.
78

89
## Version 22.0.0
910
* (GR-33930) Decouple HostedOptionParser setup from classpath/modulepath scanning (use ServiceLoader for collecting options).

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/ImageCodeInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public HostedImageCodeInfo getHostedImageCodeInfo() {
109109
return hostedImageCodeInfo;
110110
}
111111

112+
public long getTotalByteArraySize() {
113+
return codeInfoIndex.length + codeInfoEncodings.length + referenceMapEncoding.length + frameInfoEncodings.length;
114+
}
115+
112116
/**
113117
* Pure-hosted {@link CodeInfo} to collect and persist image code metadata in
114118
* {@link ImageCodeInfo} and provide accesses during image generation.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.jdk;
26+
27+
import java.util.function.BooleanSupplier;
28+
29+
@Deprecated(since = "22.1.0", forRemoval = true)
30+
public class JDK11OrLater implements BooleanSupplier {
31+
@Override
32+
public boolean getAsBoolean() {
33+
return true;
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.jdk;
26+
27+
import java.util.function.BooleanSupplier;
28+
29+
@Deprecated(since = "22.1.0", forRemoval = true)
30+
public class JDK8OrEarlier implements BooleanSupplier {
31+
@Override
32+
public boolean getAsBoolean() {
33+
return false;
34+
}
35+
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.oracle.svm.core.SubstrateOptions;
6666
import com.oracle.svm.core.VM;
6767
import com.oracle.svm.core.annotate.AutomaticFeature;
68+
import com.oracle.svm.core.code.CodeInfoTable;
6869
import com.oracle.svm.core.option.HostedOptionValues;
6970
import com.oracle.svm.core.reflect.MethodMetadataDecoder;
7071
import com.oracle.svm.core.util.VMError;
@@ -489,6 +490,9 @@ private Map<String, Long> calculateHeapBreakdown(Collection<ObjectInfo> heapObje
489490
long remainingBytes = byteArraySize;
490491
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + "java.lang.String", stringByteLength);
491492
remainingBytes -= stringByteLength;
493+
long codeInfoSize = CodeInfoTable.getImageCodeCache().getTotalByteArraySize();
494+
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + linePrinter.asDocLink("code metadata", "#glossary-code-metadata"), codeInfoSize);
495+
remainingBytes -= codeInfoSize;
492496
long metadataByteLength = ImageSingletons.lookup(MethodMetadataDecoder.class).getMetadataByteLength();
493497
if (metadataByteLength > 0) {
494498
classNameToSize.put(BREAKDOWN_BYTE_ARRAY_PREFIX + linePrinter.asDocLink("method metadata", "#glossary-method-metadata"), metadataByteLength);
@@ -515,7 +519,7 @@ public void printEpilog(String imageName, NativeImageGenerator generator, boolea
515519
l().a(" ").link(p).dim().a(" (").a(artifactType.name().toLowerCase()).a(")").reset().flushln();
516520
}
517521
});
518-
if (ImageBuildStatistics.Options.CollectImageBuildStatistics.getValue(parsedHostedOptions)) {
522+
if (generator.getBigbang() != null && ImageBuildStatistics.Options.CollectImageBuildStatistics.getValue(parsedHostedOptions)) {
519523
l().a(" ").link(reportImageBuildStatistics(imageName, generator.getBigbang())).flushln();
520524
}
521525
l().a(" ").link(reportBuildArtifacts(imageName, generator.getBuildArtifacts())).flushln();

0 commit comments

Comments
 (0)