Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ protected LoopScope processNextNode(MethodScope ms, LoopScope loopScope) {
return super.processNextNode(methodScope, loopScope);
}

protected MethodCallTargetNode createCallTargetNode(ResolvedMethodHandleCallTargetNode t) {
return new MethodCallTargetNode(t.invokeKind(), t.targetMethod(), t.arguments().toArray(ValueNode.EMPTY_ARRAY), t.returnStamp(), t.getTypeProfile());
}

@Override
protected LoopScope handleMethodHandle(MethodScope s, LoopScope loopScope, InvokableData<MethodHandleWithExceptionNode> invokableData) {
MethodHandleWithExceptionNode node = invokableData.invoke;
Expand All @@ -287,7 +291,7 @@ protected LoopScope handleMethodHandle(MethodScope s, LoopScope loopScope, Invok
if (invoke.callTarget() instanceof ResolvedMethodHandleCallTargetNode t) {
// This special CallTargetNode lowers itself back to the original target (e.g. linkTo*)
// if the invocation hasn't been inlined, which we don't want for Native Image.
callTarget = new MethodCallTargetNode(t.invokeKind(), t.targetMethod(), t.arguments().toArray(ValueNode.EMPTY_ARRAY), t.returnStamp(), t.getTypeProfile());
callTarget = createCallTargetNode(t);
} else {
callTarget = (CallTargetNode) invoke.callTarget().copyWithInputs(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ protected int initializeLayeredImage(Pointer firstHeapStart, Pointer selfReserve
int layerCount = 0;
Pointer currentSection = ImageLayerSection.getInitialLayerSection().get();
Pointer currentHeapStart = firstHeapStart;
WordPointer curEndPointer = endPointer;
if (endPointer.isNull()) {
/*
* When endPointer is null, we still need to track it locally to compute the next heap
* starting location.
*/
curEndPointer = StackValue.get(WordPointer.class);
}
while (currentSection.isNonNull()) {
var cachedFDPointer = ImageLayerSection.getCachedImageFDs().get().addressOf(layerCount);
var cachedOffsetsPointer = ImageLayerSection.getCachedImageHeapOffsets().get().addressOf(layerCount);
Expand All @@ -174,7 +182,7 @@ protected int initializeLayeredImage(Pointer firstHeapStart, Pointer selfReserve
Word heapWritableBegin = currentSection.readWord(ImageLayerSection.getEntryOffset(HEAP_WRITEABLE_BEGIN));
Word heapWritableEnd = currentSection.readWord(ImageLayerSection.getEntryOffset(HEAP_WRITEABLE_END));

result = initializeImageHeap(currentHeapStart, remainingSize, endPointer,
result = initializeImageHeap(currentHeapStart, remainingSize, curEndPointer,
cachedFDPointer, cachedOffsetsPointer, MAGIC.get(),
heapBegin, heapEnd,
heapRelocBegin, heapAnyRelocPointer, heapRelocEnd,
Expand All @@ -183,7 +191,7 @@ protected int initializeLayeredImage(Pointer firstHeapStart, Pointer selfReserve
freeImageHeap(selfReservedHeapBase);
return result;
}
Pointer newHeapStart = endPointer.read(); // aligned
Pointer newHeapStart = curEndPointer.read(); // aligned
remainingSize = remainingSize.subtract(newHeapStart.subtract(currentHeapStart));
currentHeapStart = newHeapStart;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public final class SubstrateMethodCallTargetNode extends MethodCallTargetNode {
private JavaTypeProfile staticTypeProfile;

public SubstrateMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, StampPair returnStamp) {
super(TYPE, invokeKind, targetMethod, arguments, returnStamp, null);
this(invokeKind, targetMethod, arguments, returnStamp, null);
}

public SubstrateMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, StampPair returnStamp, JavaTypeProfile typeProfile) {
super(TYPE, invokeKind, targetMethod, arguments, returnStamp, typeProfile);
}

public void setProfiles(JavaTypeProfile typeProfile, JavaMethodProfile methodProfile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.BaseLayerType;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.hub.DynamicHub;
Expand Down Expand Up @@ -318,7 +317,7 @@ public Set<AnalysisMethod> loadDispatchTableMethods(AnalysisType type) {
}

private static boolean logErrorMessages() {
return SubstrateUtil.assertionsEnabled() || Options.LogOpenTypeWorldDiscrepancies.getValue();
return Options.LogOpenTypeWorldDiscrepancies.getValue();
}

private static boolean generateErrorMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ private void initializeExcludedFields() {
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "monitorOffset"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "hubType"));

/* Needs to be immutable for correct lowering of SubstrateIdentityHashCodeNode. */
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "identityHashOffset"));

/*
* Including this field makes ThreadLocalAllocation.getTlabDescriptorSize reachable through
* ThreadLocalAllocation.regularTLAB which is accessed with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,16 @@ private void doInlineTrivial(DebugContext debug, HostedMethod method) {
}

private boolean makeInlineDecision(HostedMethod method, HostedMethod callee) {
// GR-57832 this will be removed
if (callee.compilationInfo.getCompilationGraph() == null) {
/*
* We have compiled this method in a prior layer, but don't have the graph available
* here.
*/
assert callee.isCompiledInPriorLayer() : method;
return false;
}

if (universe.hostVM().neverInlineTrivial(method.getWrapped(), callee.getWrapped())) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder;
import com.oracle.graal.pointsto.phases.InlineBeforeAnalysisPolicy;
import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode;
import com.oracle.svm.core.nodes.SubstrateMethodCallTargetNode;
import com.oracle.svm.hosted.ameta.FieldValueInterceptionSupport;
import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport;
import com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport;
Expand All @@ -39,7 +40,10 @@
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.nodes.ConstantNode;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.ValueNode;
import jdk.graal.compiler.nodes.java.LoadFieldNode;
import jdk.graal.compiler.nodes.java.MethodCallTargetNode;
import jdk.graal.compiler.replacements.nodes.ResolvedMethodHandleCallTargetNode;

public class InlineBeforeAnalysisGraphDecoderImpl extends InlineBeforeAnalysisGraphDecoder {

Expand Down Expand Up @@ -110,4 +114,9 @@ private Node handleIsStaticFinalFieldInitializedNode(IsStaticFinalFieldInitializ
}
return node;
}

@Override
protected MethodCallTargetNode createCallTargetNode(ResolvedMethodHandleCallTargetNode t) {
return new SubstrateMethodCallTargetNode(t.invokeKind(), t.targetMethod(), t.arguments().toArray(ValueNode.EMPTY_ARRAY), t.returnStamp(), t.getTypeProfile());
}
}