Skip to content

Commit 1f452cb

Browse files
pejovicatkrodriguez
authored andcommitted
[GR-42220] Support compiling substratevm with JDK 20.
PullRequest: graal/13449
2 parents a7b33dd + 01cfe78 commit 1f452cb

File tree

11 files changed

+47
-43
lines changed

11 files changed

+47
-43
lines changed

substratevm/ci/ci.jsonnet

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,11 @@
5050
},
5151
}),
5252

53-
local linux_amd64_jdk17 = common.linux_amd64 + common.labsjdk17,
54-
local linux_amd64_jdk19 = common.linux_amd64 + common.labsjdk19,
55-
local darwin_jdk17 = common.darwin_amd64 + common.labsjdk17,
56-
local windows_jdk17 = common.windows_amd64 + common.labsjdk17 + common.devkits["windows-jdk17"],
57-
5853
// JDKs
5954
local jdk_name_to_dict = {
6055
"jdk17"+: common.labsjdk17,
6156
"jdk19"+: common.labsjdk19,
57+
"jdk20"+: common.labsjdk20,
6258
},
6359

6460
local default_os_arch = {
@@ -82,23 +78,27 @@
8278
tools.delete_timelimit(jdk_name_to_dict[b.jdk] + default_os_arch[b.os][b.arch])
8379
})),
8480

85-
local no_jobs = {
86-
"<all-os>"+: run_spec.exclude,
81+
local all_jobs = {
82+
"windows:aarch64"+: exclude,
83+
},
84+
local no_jobs = all_jobs {
85+
"*"+: exclude,
8786
},
87+
8888
local feature_map = {
8989
libc: {
90-
musl: {
91-
"<all-os>"+: exclude + use_musl,
90+
musl: no_jobs {
91+
"*"+: use_musl,
9292
},
9393
},
9494
optlevel: {
95-
quickbuild: {
96-
"<all-os>"+: exclude + add_quickbuild,
95+
quickbuild: no_jobs {
96+
"*"+: add_quickbuild,
9797
},
9898
},
9999
"java-compiler": {
100-
ecj: {
101-
"<all-os>"+: exclude + sg.use_ecj,
100+
ecj: no_jobs {
101+
"*"+: sg.use_ecj,
102102
},
103103
},
104104
},
@@ -108,10 +108,10 @@
108108

109109
// START MAIN BUILD DEFINITION
110110
local task_dict = {
111-
"style-fullbuild": mxgate("fullbuild,style,nativeimagehelp") + eclipse + jdt + maven + jsonschema + mx_build_exploded + gdb("10.2") + platform_spec(no_jobs) + platform_spec({
112-
"linux:amd64:jdk17": gate + t("30:00"),
111+
"style-fullbuild": mxgate("fullbuild,style,nativeimagehelp") + eclipse + jdt + maven + mx_build_exploded + gdb("10.2") + platform_spec(no_jobs) + platform_spec({
112+
"linux:amd64:jdk20": gate + t("30:00"),
113113
}),
114-
"basics": mxgate("build,helloworld,native_unittests,truffle_unittests,debuginfotest,hellomodule") + maven + platform_spec(no_jobs) + platform_spec({
114+
"basics": mxgate("build,helloworld,native_unittests,truffle_unittests,debuginfotest,hellomodule") + maven + jsonschema + platform_spec(no_jobs) + platform_spec({
115115
"linux:amd64:jdk19": gate + gdb("10.2") + t("55:00"),
116116
"windows:amd64:jdk17": gate + t("1:30:00"),
117117
}) + variants({

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def help_stdout_check(output):
415415
if t:
416416
hellomodule(args.extra_image_builder_arguments)
417417

418-
with Task('Validate JSON build info', tasks, tags=[mx_gate.Tags.style]) as t:
418+
with Task('Validate JSON build info', tasks, tags=[GraalTags.helloworld]) as t:
419419
if t:
420420
import json
421421
try:

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfARangesSectionImpl.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626

2727
package com.oracle.objectfile.elf.dwarf;
2828

29+
import java.util.List;
30+
import java.util.Map;
31+
import java.util.stream.Collectors;
32+
import java.util.stream.Stream;
33+
34+
import org.graalvm.compiler.debug.DebugContext;
35+
2936
import com.oracle.objectfile.LayoutDecision;
3037
import com.oracle.objectfile.LayoutDecisionMap;
3138
import com.oracle.objectfile.ObjectFile;
3239
import com.oracle.objectfile.debugentry.ClassEntry;
3340
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
3441
import com.oracle.objectfile.debugentry.Range;
35-
import org.graalvm.compiler.debug.DebugContext;
36-
37-
import java.util.List;
38-
import java.util.Map;
39-
import java.util.stream.Collectors;
40-
import java.util.stream.Stream;
4142

4243
/**
4344
* Section generator for debug_aranges section.
@@ -119,7 +120,7 @@ private static int deoptEntrySize(ClassEntry classEntry) {
119120
}
120121

121122
private static int entrySize(Stream<CompiledMethodEntry> compiledEntries) {
122-
int size = 0;
123+
long size = 0;
123124
// allow for header data
124125
size += DW_AR_HEADER_SIZE;
125126
// align to 2 * address size.
@@ -128,7 +129,7 @@ private static int entrySize(Stream<CompiledMethodEntry> compiledEntries) {
128129
size += compiledEntries.count() * (2 * 8);
129130
// allow for two trailing zeroes to terminate
130131
size += 2 * 8;
131-
return size;
132+
return Math.toIntExact(size);
132133
}
133134

134135
@Override

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLineSectionImpl.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626

2727
package com.oracle.objectfile.elf.dwarf;
2828

29+
import java.util.Iterator;
30+
import java.util.Map;
31+
32+
import org.graalvm.compiler.debug.DebugContext;
33+
2934
import com.oracle.objectfile.LayoutDecision;
3035
import com.oracle.objectfile.LayoutDecisionMap;
3136
import com.oracle.objectfile.ObjectFile;
3237
import com.oracle.objectfile.debugentry.ClassEntry;
38+
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
3339
import com.oracle.objectfile.debugentry.DirEntry;
3440
import com.oracle.objectfile.debugentry.FileEntry;
35-
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
3641
import com.oracle.objectfile.debugentry.Range;
37-
import org.graalvm.compiler.debug.DebugContext;
38-
39-
import java.util.Iterator;
40-
import java.util.Map;
4142

4243
/**
4344
* Section generator for debug_line section.
@@ -436,7 +437,7 @@ private int writeFileTable(DebugContext context, ClassEntry classEntry, byte[] b
436437
return pos;
437438
}
438439

439-
private int debugLine = 1;
440+
private long debugLine = 1;
440441
private int debugCopyCount = 0;
441442

442443
private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEntry, CompiledMethodEntry compiledEntry, byte[] buffer, int p) {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLocSectionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer,
295295
if (sp < 32) {
296296
// fold the base reg index into the op
297297
stackOp = DwarfDebugInfo.DW_OP_breg0;
298-
stackOp += sp;
298+
stackOp += (byte) sp;
299299
} else {
300300
// pass base reg index as a ULEB operand
301301
stackOp = DwarfDebugInfo.DW_OP_bregx;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/io/AssemblyBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void writeSLEB128(long v) {
180180
if ((vv == 0L && (b & 0x40) == 0) || (vv == -1L && (b & 0x40) == 0x40)) {
181181
more = false;
182182
} else {
183-
b |= 0x80;
183+
b |= (byte) 0x80;
184184
}
185185
writeByte(b);
186186
}

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ private static boolean isProtected(int prot) {
6868
}
6969

7070
@Uninterruptible(reason = "Called from uninterruptible code.")
71-
private static int vmComputeStackGuard(UnsignedWord stackend) {
72-
int guardsize = 0;
71+
private static UnsignedWord vmComputeStackGuardSize(UnsignedWord stackend) {
72+
UnsignedWord guardsize = WordFactory.zero();
7373

7474
WordPointer address = StackValue.get(WordPointer.class);
7575
address.write(stackend);
@@ -85,11 +85,11 @@ private static int vmComputeStackGuard(UnsignedWord stackend) {
8585
count.write(VM_REGION_SUBMAP_INFO_COUNT_64());
8686

8787
if (mach_vm_region(task, address, size, VM_REGION_BASIC_INFO_64(), info, count, dummyobject) != 0) {
88-
return -1;
88+
throw VMError.shouldNotReachHere();
8989
}
9090

9191
if (isProtected(info.protection())) {
92-
guardsize += size.read().rawValue();
92+
guardsize = guardsize.add(size.read());
9393
}
9494

9595
UnsignedWord currentAddress = address.read();
@@ -116,8 +116,8 @@ public void lookupStack(WordPointer stackBasePtr, WordPointer stackEndPtr, Unsig
116116
UnsignedWord stacksize = DarwinPthread.pthread_get_stacksize_np(self);
117117
stackBasePtr.write(stackaddr);
118118

119-
int guardsize = vmComputeStackGuard(stackaddr.subtract(stacksize));
120-
VMError.guarantee(guardsize >= 0 && guardsize < 100 * 1024);
119+
UnsignedWord guardsize = vmComputeStackGuardSize(stackaddr.subtract(stacksize));
120+
VMError.guarantee(guardsize.belowThan(100 * 1024));
121121
VMError.guarantee(stacksize.aboveThan(guardsize));
122122

123123
stacksize = stacksize.subtract(guardsize);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/deopt/Deoptimizer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.nio.ByteOrder;
3333
import java.util.ArrayList;
3434

35+
import org.graalvm.compiler.core.common.NumUtil;
3536
import org.graalvm.compiler.core.common.util.TypeConversion;
3637
import org.graalvm.compiler.options.Option;
3738
import org.graalvm.compiler.word.BarrieredAccess;
@@ -812,7 +813,7 @@ public static void logRecentDeoptimizationEvents(Log log) {
812813
private VirtualFrame constructTargetFrame(CodeInfoQueryResult targetInfo, FrameInfoQueryResult sourceFrame) {
813814
FrameInfoQueryResult targetFrame = targetInfo.getFrameInfo();
814815
int savedBasePointerSize = FrameAccess.singleton().savedBasePointerSize();
815-
long targetFrameSize = targetInfo.getTotalFrameSize() - FrameAccess.returnAddressSize() - savedBasePointerSize;
816+
int targetFrameSize = NumUtil.safeToInt(targetInfo.getTotalFrameSize()) - FrameAccess.returnAddressSize() - savedBasePointerSize;
816817
VirtualFrame result = new VirtualFrame(targetFrame);
817818

818819
if (savedBasePointerSize != 0) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/SubstrateObjectCloneSnippets.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Map;
3131

3232
import org.graalvm.compiler.api.replacements.Snippet;
33+
import org.graalvm.compiler.core.common.NumUtil;
3334
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
3435
import org.graalvm.compiler.graph.Node;
3536
import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
@@ -136,7 +137,7 @@ private static Object doClone(Object original) throws CloneNotSupportedException
136137
long entryStart = referenceMapIndex + InstanceReferenceMapEncoder.MAP_HEADER_SIZE;
137138
for (long idx = entryStart; idx < entryStart + entryCount * InstanceReferenceMapEncoder.MAP_ENTRY_SIZE; idx += InstanceReferenceMapEncoder.MAP_ENTRY_SIZE) {
138139
int objectOffset = NonmovableByteArrayReader.getS4(referenceMapEncoding, idx);
139-
long count = NonmovableByteArrayReader.getU4(referenceMapEncoding, idx + 4);
140+
int count = NumUtil.safeToInt(NonmovableByteArrayReader.getU4(referenceMapEncoding, idx + 4));
140141
assert objectOffset >= firstFieldOffset : "must not overwrite the object header";
141142

142143
// copy non-object data

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/RuntimeCompilationFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ protected final void beforeCompilationHelper() {
405405
try {
406406
/* Strip optional comment string from MaxRuntimeCompileMethods value */
407407
numberStr = value.split("#")[0];
408-
maxMethods += Long.parseLong(numberStr);
408+
maxMethods += Integer.parseInt(numberStr);
409409
} catch (NumberFormatException ex) {
410410
throw UserError.abort("Invalid value for option 'MaxRuntimeCompileMethods': '%s' is not a valid number", numberStr);
411411
}

0 commit comments

Comments
 (0)