Skip to content

Commit 96fdf86

Browse files
committed
Assorted improvements.
1 parent 39151dc commit 96fdf86

File tree

15 files changed

+55
-38
lines changed

15 files changed

+55
-38
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64BigIntegerMulAddOp.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ public AMD64BigIntegerMulAddOp(
128128
};
129129
}
130130

131+
@Override
132+
public boolean modifiesStackPointer() {
133+
return spillR13;
134+
}
135+
131136
@Override
132137
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
133138
GraalError.guarantee(outValue.getPlatformKind().equals(AMD64Kind.QWORD), "Invalid outValue kind: %s", outValue);

substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta
148148
* or sp.
149149
*/
150150
regs.remove(r31);
151-
/*
152-
* If enabled, the heapBaseRegister and threadRegister are r27 and r28, respectively. See
153-
* AArch64ReservedRegisters and ReservedRegisters for more information.
154-
*/
151+
/* Reserved registers: see AArch64ReservedRegisters and ReservedRegisters for details. */
155152
regs.remove(ReservedRegisters.singleton().getHeapBaseRegister());
156153
regs.remove(ReservedRegisters.singleton().getThreadRegister());
157154
regs.remove(ReservedRegisters.singleton().getCodeBaseRegister());

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/ReservedRegisters.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ public Register getCodeBaseRegister() {
9494
public boolean isAllowedInFrameState(JavaValue value) {
9595
if (value instanceof RegisterValue rv) {
9696
Register r = rv.getRegister();
97-
if (r.equals(threadRegister) || r.equals(heapBaseRegister) || r.equals(codeBaseRegister)) {
98-
return true;
99-
}
97+
return r.equals(threadRegister) || r.equals(heapBaseRegister) || r.equals(codeBaseRegister);
10098
}
10199
return false;
102100
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,9 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
891891
log.string("Runtime information:").indent(true);
892892
log.string("Isolate id: ").signed(Isolates.getIsolateId()).newline();
893893
log.string("Heap base: ").zhex(KnownIntrinsics.heapBase()).newline();
894+
if (SubstrateOptions.RelativeCodePointers.getValue()) {
895+
log.string("Code base: ").zhex(KnownIntrinsics.codeBase()).newline();
896+
}
894897
log.string("CGlobalData base: ").zhex(CGlobalDataInfo.CGLOBALDATA_RUNTIME_BASE_ADDRESS.getPointer()).newline();
895898

896899
if (Container.singleton().isContainerized()) {
@@ -1142,6 +1145,11 @@ private static final class ImageCodeLocationInfoPrinter {
11421145
* NOTE: this method may only be called by a single thread.
11431146
*/
11441147
public boolean printLocationInfo(Log log, UnsignedWord value) {
1148+
if (SubstrateOptions.RelativeCodePointers.getValue() && KnownIntrinsics.codeBase().equal(value)) {
1149+
log.string("is the code base");
1150+
return true;
1151+
}
1152+
11451153
CodeInfo imageCodeInfo = CodeInfoTable.getFirstImageCodeInfo();
11461154
while (imageCodeInfo.isNonNull()) {
11471155
if (imageCodeInfo.equal(value)) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,11 @@ private static void validateRelativeCodePointers(HostedOptionKey<Boolean> option
14531453

14541454
UserError.guarantee(Platform.includedIn(PLATFORM_JNI.class) || Platform.includedIn(NATIVE_ONLY.class), "%s is supported only with hardware target platforms.", enabledOption);
14551455

1456-
// Offsets need to be passed on between layer builds rather than using symbol names.
1456+
/*
1457+
* GR-59707: Dispatch tables must potentially be patched at runtime still. Method
1458+
* offsets for dispatch need to be passed on between layer builds rather than using
1459+
* symbol names.
1460+
*/
14571461
UserError.guarantee(!ImageLayerBuildingSupport.buildingImageLayer(), "%s is currently not supported with layered images.", enabledOption);
14581462

14591463
// The concept of a code base would need to be introduced in the LLVM backend first.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/SetThreadAndHeapBasePrologue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.oracle.svm.core.c.function.CEntryPointOptions;
3131

3232
/**
33-
* Required by legacy code. Use {@link InitializeReservedRegistersPrologue} instead.
33+
* GR-64740: required by legacy code. Use {@link InitializeReservedRegistersPrologue} instead.
3434
*/
3535
public class SetThreadAndHeapBasePrologue implements CEntryPointOptions.Prologue {
3636
@Uninterruptible(reason = "prologue")

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.core.graal.snippets;
2626

27+
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
2728
import static com.oracle.svm.core.graal.nodes.WriteCodeBaseNode.writeCurrentVMCodeBase;
2829
import static com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode.writeCurrentVMThread;
2930
import static com.oracle.svm.core.graal.nodes.WriteHeapBaseNode.writeCurrentVMHeapBase;
@@ -201,23 +202,27 @@ static boolean hasHeapBase() {
201202
return ImageSingletons.lookup(CompressEncoding.class).hasBase();
202203
}
203204

204-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
205+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
205206
private static void setHeapBase(PointerBase heapBase) {
206207
writeCurrentVMHeapBase(heapBase);
207208
if (MemoryProtectionProvider.isAvailable()) {
208209
MemoryProtectionProvider.singleton().unlockCurrentIsolate();
209210
}
210211
}
211212

212-
@Uninterruptible(reason = "Called from uninterruptible code.")
213+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE)
213214
@NeverInline("Heap base register is set in caller, prevent reads from floating before that.")
214215
private static void initCodeBase() {
215-
ImageCodeInfo imageCodeInfo = MultiLayeredImageSingleton.getForLayer(ImageCodeInfo.class, 0);
216+
ImageCodeInfo imageCodeInfo = MultiLayeredImageSingleton.getForLayer(ImageCodeInfo.class, MultiLayeredImageSingleton.INITIAL_LAYER_NUMBER);
216217
CodePointer codeBase = imageCodeInfo.getCodeStart();
217218
writeCurrentVMCodeBase(codeBase);
218219
}
219220

220-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
221+
/**
222+
* Use {@link #initBaseRegisters} instead. Calling this method is not necessary unless
223+
* heap-relative addressing is needed before the heap is fully set up.
224+
*/
225+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
221226
public static void earlyInitHeapBase(PointerBase heapBase) {
222227
setHeapBase(heapBase);
223228
}
@@ -226,7 +231,7 @@ public static void earlyInitHeapBase(PointerBase heapBase) {
226231
* Sets the heap base register to the provided value. If the code base register is in use,
227232
* initializes it to contain the code base address.
228233
*/
229-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
234+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
230235
public static void initBaseRegisters(PointerBase heapBase) {
231236
setHeapBase(heapBase);
232237
if (SubstrateOptions.useRelativeCodePointers()) {
@@ -235,7 +240,7 @@ public static void initBaseRegisters(PointerBase heapBase) {
235240
}
236241

237242
/** Sets the heap base register, and if in use, the code base register, to the given values. */
238-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
243+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
239244
public static void initBaseRegisters(PointerBase heapBase, PointerBase codeBase) {
240245
setHeapBase(heapBase);
241246
if (SubstrateOptions.useRelativeCodePointers()) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/layeredimagesingleton/MultiLayeredImageSingleton.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public interface MultiLayeredImageSingleton extends LayeredImageSingleton {
3939
*/
4040
int UNUSED_LAYER_NUMBER = -1;
4141
int UNKNOWN_LAYER_NUMBER = 0;
42+
int INITIAL_LAYER_NUMBER = 0;
4243

4344
/**
4445
* Returns an array containing the image singletons installed for {@code key} within all layers.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/MethodOffset.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public final class MethodOffset implements WordBase {
3939
private final ResolvedJavaMethod method;
4040

4141
public MethodOffset(ResolvedJavaMethod method) {
42-
Objects.requireNonNull(method);
43-
this.method = method;
42+
this.method = Objects.requireNonNull(method);
4443
}
4544

4645
public ResolvedJavaMethod getMethod() {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/SubstrateMethodOffsetConstant.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SubstrateMethodOffsetConstant implements VMConstant {
4242
private final MethodOffset offset;
4343

4444
public SubstrateMethodOffsetConstant(MethodOffset offset) {
45-
this.offset = offset;
45+
this.offset = Objects.requireNonNull(offset);
4646
}
4747

4848
public MethodOffset offset() {
@@ -61,7 +61,7 @@ public String toValueString() {
6161

6262
@Override
6363
public String toString() {
64-
return "method offset: " + ((offset == null) ? "null" : offset.getMethod().format("%H.%n"));
64+
return "method offset: " + offset.getMethod().format("%H.%n");
6565
}
6666

6767
@Override
@@ -74,6 +74,6 @@ public boolean equals(Object obj) {
7474

7575
@Override
7676
public int hashCode() {
77-
return (offset == null) ? 0 : Objects.hashCode(offset.getMethod());
77+
return Objects.hashCode(offset.getMethod());
7878
}
7979
}

0 commit comments

Comments
 (0)