Skip to content

Commit 19fae97

Browse files
peter-hofercstancu
authored andcommitted
[GR-57826] Layered images binary snapshot format.
PullRequest: graal/19374
2 parents 50a7fe1 + a7b8627 commit 19fae97

19 files changed

+6146
-1513
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,3 +2455,57 @@ def svm_libcontainer_namespace(args):
24552455
libcontainer_project = mx.project("com.oracle.svm.native.libcontainer")
24562456
for src_dir in libcontainer_project.source_dirs():
24572457
mx.command_function("svm_namespace")(args + ["--directory", src_dir , "--namespace", "svm_container"])
2458+
2459+
@mx.command(suite, 'capnp-compile', usage_msg="Compile Cap'n Proto schema files to source code.")
2460+
def capnp_compile(args):
2461+
capnpcjava_home = os.environ.get('CAPNPROTOJAVA_HOME')
2462+
if capnpcjava_home is None or not exists(capnpcjava_home + '/capnpc-java'):
2463+
mx.abort('Clone and build capnproto/capnproto-java from GitHub and point CAPNPROTOJAVA_HOME to its path.')
2464+
srcdir = 'src/com.oracle.svm.hosted/resources/'
2465+
outdir = 'src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/'
2466+
command = ['capnp', 'compile',
2467+
'--import-path=' + capnpcjava_home + '/compiler/src/main/schema/',
2468+
'--output=' + capnpcjava_home + '/capnpc-java:' + outdir,
2469+
'--src-prefix=' + srcdir,
2470+
srcdir + 'SharedLayerSnapshotCapnProtoSchema.capnp']
2471+
mx.run(command)
2472+
# Remove huge unused schema chunks from generated code
2473+
outpath = outdir + 'SharedLayerSnapshotCapnProtoSchemaHolder.java' # name specified in schema
2474+
with open(outpath, 'r') as f:
2475+
lines = f.readlines()
2476+
with open(outpath, 'w') as f:
2477+
f.write(
2478+
"""/*
2479+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
2480+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2481+
*
2482+
* This code is free software; you can redistribute it and/or modify it
2483+
* under the terms of the GNU General Public License version 2 only, as
2484+
* published by the Free Software Foundation. Oracle designates this
2485+
* particular file as subject to the "Classpath" exception as provided
2486+
* by Oracle in the LICENSE file that accompanied this code.
2487+
*
2488+
* This code is distributed in the hope that it will be useful, but WITHOUT
2489+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2490+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2491+
* version 2 for more details (a copy is included in the LICENSE file that
2492+
* accompanied this code).
2493+
*
2494+
* You should have received a copy of the GNU General Public License version
2495+
* 2 along with this work; if not, write to the Free Software Foundation,
2496+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2497+
*
2498+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2499+
* or visit www.oracle.com if you need additional information or have any
2500+
* questions.
2501+
*/
2502+
//@formatter:off
2503+
//Checkstyle: stop
2504+
""")
2505+
for line in lines:
2506+
if line.startswith("public final class "):
2507+
f.write('@SuppressWarnings("all")\n')
2508+
if 'public static final class Schemas {' in line:
2509+
break
2510+
f.write(line)
2511+
f.write('}\n')

substratevm/mx.substratevm/suite.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@
202202
"path": "mx.substratevm/jar-with-space-in-resource-dir.jar",
203203
"digest": "sha512:270bffd158c92b04b16db147f4ef336dcb4d830bf3503cc25be1227b351597a3254544b3c4a5183dcc53f2f3ab10b282722dbf7f1b5e9d9a2741878a7057eb40",
204204
},
205+
206+
"CAPNPROTO_RUNTIME": {
207+
"digest" : "sha512:94a7776511c344da60a1acdc346c133522a43c239d067d0d5d86c21291e0252a19bd4fa74e4b1d3a93e75dadd41af6557a5d118a1584e39d34c092485ce065b2",
208+
"maven" : {
209+
"groupId" : "org.capnproto",
210+
"artifactId" : "runtime",
211+
"version" : "0.1.16",
212+
},
213+
},
205214
},
206215

207216
"projects": {
@@ -537,6 +546,7 @@
537546
"sourceDirs": ["src"],
538547
"dependencies": [
539548
"com.oracle.svm.common",
549+
"CAPNPROTO_RUNTIME"
540550
],
541551
"requires" : [
542552
"jdk.internal.vm.ci"
@@ -1656,6 +1666,9 @@
16561666
"java.management": [
16571667
"sun.management",
16581668
],
1669+
"org.graalvm.nativeimage.pointsto": [
1670+
"org.capnproto"
1671+
]
16591672
},
16601673
},
16611674
"noMavenJavadoc": True,
@@ -2089,6 +2102,7 @@
20892102
"NATIVE_IMAGE_BASE",
20902103
],
20912104
"exclude": [
2105+
# "CAPNPROTO_RUNTIME",
20922106
],
20932107
"moduleInfo" : {
20942108
"name" : "org.graalvm.nativeimage.pointsto",

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageHeapConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
@Platforms(Platform.HOSTED_ONLY.class)
5353
public abstract class ImageHeapConstant implements JavaConstant, TypedConstant, CompressibleConstant, VMConstant {
5454

55-
private static final AtomicInteger currentId = new AtomicInteger(0);
55+
private static final AtomicInteger currentId = new AtomicInteger(1);
5656

5757
public static final VarHandle isReachableHandle = ReflectionUtil.unreflectField(ConstantData.class, "isReachable", MethodHandles.lookup());
5858

0 commit comments

Comments
 (0)