Skip to content

Commit 340293c

Browse files
[GR-37943] Refactorings and cleanups.
PullRequest: graal/11571
2 parents b1a894d + 8427479 commit 340293c

File tree

31 files changed

+439
-214
lines changed

31 files changed

+439
-214
lines changed

compiler/src/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/spi/MetaAccessExtensionProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ public interface MetaAccessExtensionProvider {
5757
* contain a safepoint.
5858
*/
5959
boolean isGuaranteedSafepoint(ResolvedJavaMethod method, boolean isDirect);
60+
61+
/**
62+
* Returns true if the partial escape analysis is allowed to virtualize object allocations of a
63+
* given type.
64+
*/
65+
boolean canVirtualize(ResolvedJavaType instanceType);
6066
}

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotMetaAccessExtensionProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ public boolean canConstantFoldDynamicAllocation(ResolvedJavaType type) {
5151
public boolean isGuaranteedSafepoint(ResolvedJavaMethod method, boolean isDirect) {
5252
return true;
5353
}
54+
55+
@Override
56+
public boolean canVirtualize(ResolvedJavaType instanceType) {
57+
return true;
58+
}
5459
}

compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/NewInstanceNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public void virtualize(VirtualizerTool tool) {
8080
* Reference objects can escape into their ReferenceQueue at any safepoint, therefore
8181
* they're excluded from escape analysis.
8282
*/
83-
if (!tool.getMetaAccess().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) {
83+
if (!tool.getMetaAccess().lookupJavaType(Reference.class).isAssignableFrom(instanceClass) &&
84+
tool.getMetaAccessExtensionProvider().canVirtualize(instanceClass)) {
8485
VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true);
8586
ResolvedJavaField[] fields = virtualObject.getFields();
8687
ValueNode[] state = new ValueNode[fields.length];

compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/AllocationSnippets.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected Object allocateInstanceImpl(Word hub,
6868
return verifyOop(result);
6969
}
7070

71-
protected Object allocateArrayImpl(Word hub,
71+
public Object allocateArrayImpl(Word hub,
7272
int length,
7373
int arrayBaseOffset,
7474
int log2ElementSize,
@@ -259,7 +259,7 @@ private void fillWithGarbage(Word memory,
259259
/**
260260
* Formats some allocated memory with an object header and zeroes out the rest.
261261
*/
262-
protected Object formatObject(Word hub,
262+
public Object formatObject(Word hub,
263263
UnsignedWord size,
264264
Word memory,
265265
FillContent fillContents,
@@ -280,7 +280,7 @@ protected Object formatObject(Word hub,
280280
/**
281281
* Formats some allocated memory with an object header and zeroes out the rest.
282282
*/
283-
protected Object formatArray(Word hub,
283+
public Object formatArray(Word hub,
284284
UnsignedWord allocationSize,
285285
int length,
286286
Word memory,
@@ -304,7 +304,7 @@ protected Object formatArray(Word hub,
304304
return memory.toObjectNonNull();
305305
}
306306

307-
protected void emitMemoryBarrierIf(boolean emitMemoryBarrier) {
307+
public void emitMemoryBarrierIf(boolean emitMemoryBarrier) {
308308
if (emitMemoryBarrier) {
309309
MembarNode.memoryBarrier(MembarNode.FenceKind.ALLOCATION_INIT, LocationIdentity.init());
310310
}
@@ -386,7 +386,7 @@ public AllocationProfilingData(AllocationSnippetCounters snippetCounters) {
386386
}
387387
}
388388

389-
protected static class AllocationSnippetCounters {
389+
public static class AllocationSnippetCounters {
390390
public AllocationSnippetCounters(SnippetCounter.Group.Factory factory) {
391391
Group allocations = factory.createSnippetCounterGroup("Allocations");
392392
unrolledInit = new SnippetCounter(allocations, "tlabSeqInit", "TLAB alloc with unrolled zeroing");

compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/BasicArrayCopyNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ public ValueNode getLength() {
205205
return length;
206206
}
207207

208+
public void setSource(ValueNode value) {
209+
updateUsages(this.src, value);
210+
this.src = value;
211+
}
212+
213+
public void setSourcePosition(ValueNode value) {
214+
updateUsages(this.srcPos, value);
215+
this.srcPos = value;
216+
}
217+
208218
public static boolean checkBounds(int position, int length, VirtualObjectNode virtualObject) {
209219
assert length >= 0;
210220
return position >= 0 && position <= virtualObject.entryCount() - length;

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ GraalVM Native Image: Generating 'helloworld' (executable)...
2929
[6/7] Compiling methods... [**] (3.7s @ 2.38GB)
3030
[7/7] Creating image... (2.1s @ 1.04GB)
3131
3.69MB (27.19%) for code area: 6,955 compilation units
32-
5.86MB (43.18%) for image heap: 1,545 classes and 80,528 objects
32+
5.86MB (43.18%) for image heap: 80,528 objects
3333
3.05MB (22.46%) for debug info generated in 1.0s
3434
997.25KB ( 7.18%) for other data
3535
13.57MB in total

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMetaAccessExtensionProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ public boolean canConstantFoldDynamicAllocation(ResolvedJavaType type) {
5050
public boolean isGuaranteedSafepoint(ResolvedJavaMethod method, boolean isDirect) {
5151
throw GraalError.shouldNotReachHere();
5252
}
53+
54+
@Override
55+
public boolean canVirtualize(ResolvedJavaType instanceType) {
56+
return true;
57+
}
5358
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.graalvm.nativeimage.Platform;
3636
import org.graalvm.nativeimage.Platforms;
3737
import org.graalvm.nativeimage.c.struct.RawField;
38+
import org.graalvm.nativeimage.c.struct.RawFieldOffset;
3839
import org.graalvm.nativeimage.c.struct.RawStructure;
3940
import org.graalvm.nativeimage.c.struct.SizeOf;
4041
import org.graalvm.nativeimage.c.struct.UniqueLocationIdentity;
@@ -109,11 +110,21 @@ public interface Descriptor extends PointerBase {
109110
@RawField
110111
void setAllocationTop(Pointer top, LocationIdentity topIdentity);
111112

113+
@RawFieldOffset
114+
static int offsetOfAllocationTop() {
115+
throw VMError.unimplemented(); // replaced
116+
}
117+
112118
@RawField
113119
Word getAllocationEnd(LocationIdentity endIdentity);
114120

115121
@RawField
116122
void setAllocationEnd(Pointer end, LocationIdentity endIdentity);
123+
124+
@RawFieldOffset
125+
static int offsetOfAllocationEnd() {
126+
throw VMError.unimplemented(); // replaced
127+
}
117128
}
118129

119130
/*

0 commit comments

Comments
 (0)