Skip to content

Commit f8c21ae

Browse files
author
Christian Wimmer
committed
Create prologue/epilogue markers lazily
1 parent 1d91899 commit f8c21ae

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nodes/CFunctionEpilogueNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ public final class CFunctionEpilogueNode extends AbstractStateSplit implements L
5555
public CFunctionEpilogueNode(int oldThreadStatus) {
5656
super(TYPE, StampFactory.forVoid());
5757
this.oldThreadStatus = oldThreadStatus;
58-
marker = new CFunctionEpilogueMarker();
5958
}
6059

6160
@Override
6261
protected void afterClone(Node other) {
6362
super.afterClone(other);
64-
marker = new CFunctionEpilogueMarker();
63+
assert marker == null : "Marker must be unique";
6564
}
6665

6766
public CFunctionEpilogueMarker getMarker() {
67+
if (marker == null) {
68+
marker = new CFunctionEpilogueMarker();
69+
}
6870
return marker;
6971
}
7072

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/nodes/CFunctionPrologueNode.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,32 @@ public final class CFunctionPrologueNode extends FixedWithNextNode implements Lo
6262

6363
private final int newThreadStatus;
6464
/**
65-
* The marker object prevents value numbering of the node. This means that the marker must be a
66-
* unique object per node, even after node cloning (e.g., because of method inlining).
67-
* Therefore, {@link #afterClone} properly re-initializes the field to a new marker instance.
68-
*
69-
* The marker is also used for LIR frame state verification, to ensure we have a proper matching
70-
* of prologue and epilogue and no unexpected machine code while the thread is in Native state.
65+
* The marker is used for LIR frame state verification, to ensure we have a proper matching of
66+
* prologue and epilogue and no unexpected machine code while the thread is in Native state.
7167
*/
7268
private CFunctionPrologueMarker marker;
7369

7470
public CFunctionPrologueNode(int newThreadStatus) {
7571
super(TYPE, StampFactory.forVoid());
7672
this.newThreadStatus = newThreadStatus;
77-
marker = new CFunctionPrologueMarker(newThreadStatus);
7873
}
7974

8075
@Override
8176
protected void afterClone(Node other) {
8277
super.afterClone(other);
83-
marker = new CFunctionPrologueMarker(newThreadStatus);
78+
/*
79+
* Note that this method is invoked by the regular method inlining, but not by the
80+
* PEGraphDecoder. So the method inlining before analysis, as well as the trivial method
81+
* inlining before compilation, do not invoke this method. So it is only suitable for
82+
* assertion checking.
83+
*/
84+
assert marker == null : "Marker must be unique";
8485
}
8586

8687
public CFunctionPrologueMarker getMarker() {
88+
if (marker == null) {
89+
marker = new CFunctionPrologueMarker(newThreadStatus);
90+
}
8791
return marker;
8892
}
8993

0 commit comments

Comments
 (0)