Skip to content

Commit 09a1552

Browse files
[GR-65020] [GR-65327] Fixes for java.specification.maintenance.version and reference constants in large images.
PullRequest: graal/20915
2 parents 17fe52a + 594fce8 commit 09a1552

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,32 @@
2323
* questions.
2424
*/
2525

26-
package com.oracle.graal.pointsto.heap;
26+
package com.oracle.svm.core.graal.nodes;
2727

2828
import java.util.Objects;
2929

30+
import com.oracle.svm.core.hub.DynamicHub;
31+
3032
import jdk.vm.ci.meta.JavaConstant;
3133
import jdk.vm.ci.meta.JavaKind;
3234
import jdk.vm.ci.meta.VMConstant;
3335

3436
/**
3537
* An {@code TLABObjectHeaderConstant} is a constant representing the content of the header of a
36-
* newly created object. It is computed from the address of the type object and needs patching in
37-
* after compilation.
38+
* newly created object. It is computed from the address of the {@link DynamicHub} and needs
39+
* patching after compilation and relocations at run-time.
3840
*/
3941
public final class TLABObjectHeaderConstant implements JavaConstant, VMConstant {
40-
private final ImageHeapInstance hub;
42+
private final JavaConstant hub;
4143
private final int size;
4244

43-
public TLABObjectHeaderConstant(ImageHeapInstance hub, int size) {
45+
public TLABObjectHeaderConstant(JavaConstant hub, int size) {
4446
assert size == Integer.BYTES || size == Long.BYTES : size;
4547
this.hub = hub;
4648
this.size = size;
4749
}
4850

49-
public ImageHeapInstance hub() {
51+
public JavaConstant hub() {
5052
return hub;
5153
}
5254

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ObjectHeader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ protected ObjectHeader() {
8080

8181
/**
8282
* If we should constant-fold the header calculation when initializing new objects, this method
83-
* returns the size of the header, else it returns -1. This method should be in sync with
84-
* {@link #readHeaderFromObject(Object)}.
83+
* returns the size of the header, else it returns -1.
8584
*/
8685
public abstract int constantHeaderSize();
8786

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
import java.util.concurrent.ConcurrentHashMap;
3737
import java.util.function.Supplier;
3838

39-
import com.oracle.svm.core.SubstrateOptions;
4039
import org.graalvm.nativeimage.ImageInfo;
4140
import org.graalvm.nativeimage.ImageSingletons;
4241
import org.graalvm.nativeimage.Platform;
4342
import org.graalvm.nativeimage.Platforms;
4443
import org.graalvm.nativeimage.hosted.RuntimeSystemProperties;
4544
import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport;
4645

46+
import com.oracle.svm.core.SubstrateOptions;
4747
import com.oracle.svm.core.SubstrateUtil;
4848
import com.oracle.svm.core.VM;
4949
import com.oracle.svm.core.c.locale.LocaleSupport;
@@ -69,6 +69,15 @@ public abstract class SystemPropertiesSupport implements RuntimeSystemProperties
6969
private static final String[] HOSTED_PROPERTIES = {
7070
"java.version",
7171
"java.version.date",
72+
"java.class.version",
73+
"java.runtime.version",
74+
"java.specification.name",
75+
"java.specification.vendor",
76+
"java.specification.version",
77+
"java.specification.maintenance.version",
78+
"java.vm.specification.name",
79+
"java.vm.specification.vendor",
80+
"java.vm.specification.version",
7281
ImageInfo.PROPERTY_IMAGE_KIND_KEY,
7382
/*
7483
* We do not support cross-compilation for now. Separators might also be cached
@@ -83,14 +92,6 @@ public abstract class SystemPropertiesSupport implements RuntimeSystemProperties
8392
"native.encoding",
8493
"stdout.encoding",
8594
"stderr.encoding",
86-
"java.class.version",
87-
"java.runtime.version",
88-
"java.specification.name",
89-
"java.specification.vendor",
90-
"java.specification.version",
91-
"java.vm.specification.name",
92-
"java.vm.specification.vendor",
93-
"java.vm.specification.version"
9495
};
9596

9697
/** System properties that are computed at run time on first access. */

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
import org.graalvm.nativeimage.c.type.CTypedef;
6262
import org.graalvm.nativeimage.c.type.CUnsigned;
6363

64-
import com.oracle.graal.pointsto.heap.ImageHeapInstance;
65-
import com.oracle.graal.pointsto.heap.TLABObjectHeaderConstant;
6664
import com.oracle.graal.pointsto.meta.AnalysisMethod;
6765
import com.oracle.graal.pointsto.meta.AnalysisType;
6866
import com.oracle.objectfile.BasicProgbitsSectionImpl;
@@ -93,6 +91,7 @@
9391
import com.oracle.svm.core.graal.code.CGlobalDataBasePointer;
9492
import com.oracle.svm.core.graal.code.CGlobalDataInfo;
9593
import com.oracle.svm.core.graal.code.CGlobalDataReference;
94+
import com.oracle.svm.core.graal.nodes.TLABObjectHeaderConstant;
9695
import com.oracle.svm.core.heap.Heap;
9796
import com.oracle.svm.core.image.ImageHeapLayoutInfo;
9897
import com.oracle.svm.core.image.ImageHeapPartition;
@@ -749,7 +748,7 @@ private void markDataRelocationSiteFromText(RelocatableBuffer buffer, final Prog
749748
// The value of the hub pointer in the header of an object
750749
VMError.guarantee(constant instanceof TLABObjectHeaderConstant, "must be an EncodedHubPointerConstant: %s", constant);
751750
TLABObjectHeaderConstant hpc = (TLABObjectHeaderConstant) constant;
752-
ImageHeapInstance hub = hpc.hub();
751+
JavaConstant hub = hpc.hub();
753752
long hubOffsetFromHeapBase = heap.getConstantInfo(hub).getOffset();
754753
VMError.guarantee(hubOffsetFromHeapBase != 0, "hub must be non-null: %s", hub);
755754
targetValue = Heap.getHeap().getObjectHeader().encodeAsTLABObjectHeader(hubOffsetFromHeapBase);
@@ -762,13 +761,12 @@ private void markDataRelocationSiteFromText(RelocatableBuffer buffer, final Prog
762761
if (info.getRelocationSize() == Long.BYTES) {
763762
bufferBytes.putLong(offset, targetValue);
764763
} else if (info.getRelocationSize() == Integer.BYTES) {
765-
bufferBytes.putInt(offset, NumUtil.safeToInt(targetValue));
764+
bufferBytes.putInt(offset, NumUtil.safeToUInt(targetValue));
766765
} else {
767-
new Exception().printStackTrace();
768-
shouldNotReachHere("Unsupported object reference size: " + info.getRelocationSize());
766+
throw shouldNotReachHere("Unsupported object reference size: " + info.getRelocationSize());
769767
}
770768
} else if (arch instanceof AArch64) {
771-
int patchValue = 0;
769+
int patchValue;
772770
switch (info.getRelocationKind()) {
773771
case AARCH64_R_MOVW_UABS_G0:
774772
case AARCH64_R_MOVW_UABS_G0_NC:

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
import com.oracle.graal.pointsto.AbstractAnalysisEngine;
5959
import com.oracle.graal.pointsto.BigBang;
60-
import com.oracle.graal.pointsto.heap.TLABObjectHeaderConstant;
60+
import com.oracle.svm.core.graal.nodes.TLABObjectHeaderConstant;
6161
import com.oracle.graal.pointsto.infrastructure.WrappedElement;
6262
import com.oracle.graal.pointsto.meta.AnalysisField;
6363
import com.oracle.graal.pointsto.meta.AnalysisMethod;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/HostedSnippetReflectionProvider.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929

3030
import com.oracle.graal.pointsto.ObjectScanner.OtherReason;
3131
import com.oracle.graal.pointsto.heap.ImageHeapConstant;
32-
import com.oracle.graal.pointsto.heap.ImageHeapInstance;
3332
import com.oracle.graal.pointsto.heap.ImageHeapScanner;
34-
import com.oracle.graal.pointsto.heap.TLABObjectHeaderConstant;
3533
import com.oracle.svm.core.deopt.DeoptimizationSupport;
34+
import com.oracle.svm.core.graal.nodes.TLABObjectHeaderConstant;
3635
import com.oracle.svm.core.heap.Heap;
3736
import com.oracle.svm.core.hub.DynamicHub;
3837
import com.oracle.svm.core.meta.SubstrateObjectConstant;
@@ -88,7 +87,7 @@ public ValueNode forTLABObjectHeader(Object hub, StructuredGraph graph) {
8887
return null;
8988
}
9089

91-
JavaConstant constant = new TLABObjectHeaderConstant((ImageHeapInstance) forObject(hub), constantHeaderSize);
90+
JavaConstant constant = new TLABObjectHeaderConstant(forObject(hub), constantHeaderSize);
9291
ValueNode res = NonFoldingConstantNode.create(constant, graph);
9392
if (constantHeaderSize == Integer.BYTES) {
9493
res = graph.addOrUniqueWithInputs(ZeroExtendNode.create(res, Long.SIZE, NodeView.DEFAULT));

0 commit comments

Comments
 (0)