Skip to content

Commit 2709182

Browse files
committed
Cleanup.
1 parent d7574b1 commit 2709182

File tree

2 files changed

+25
-61
lines changed

2 files changed

+25
-61
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java

Lines changed: 18 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import com.oracle.graal.python.nodes.frame.MaterializeFrameNodeGen.SyncFrameValuesNodeGen;
5757
import com.oracle.graal.python.nodes.function.ClassBodyRootNode;
5858
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
59-
import com.oracle.truffle.api.CompilerDirectives;
6059
import com.oracle.truffle.api.dsl.Cached;
6160
import com.oracle.truffle.api.dsl.Cached.Shared;
6261
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -77,14 +76,15 @@
7776
**/
7877
public abstract class MaterializeFrameNode extends Node {
7978

80-
private final boolean adoptible;
79+
private final boolean adoptable;
80+
private static final MaterializeFrameNode INSTANCE = MaterializeFrameNodeGen.create(false);
8181

8282
public MaterializeFrameNode() {
83-
this.adoptible = true;
83+
this.adoptable = true;
8484
}
8585

86-
public MaterializeFrameNode(boolean adoptible) {
87-
this.adoptible = adoptible;
86+
protected MaterializeFrameNode(boolean adoptable) {
87+
this.adoptable = adoptable;
8888
}
8989

9090
public final PFrame execute(VirtualFrame frame, boolean markAsEscaped, Frame frameToMaterialize) {
@@ -234,17 +234,26 @@ protected static boolean inModuleRoot(Node location) {
234234
return location.getRootNode() instanceof ModuleRootNode;
235235
}
236236

237-
protected SyncFrameValuesNode createSyncNode() {
238-
return SyncFrameValuesNodeGen.create(adoptible);
237+
protected final SyncFrameValuesNode createSyncNode() {
238+
return SyncFrameValuesNodeGen.create(isAdoptable());
239239
}
240240

241-
protected PythonObjectFactory createFactory() {
242-
if (adoptible) {
241+
protected final PythonObjectFactory createFactory() {
242+
if (isAdoptable()) {
243243
return PythonObjectFactory.create();
244244
}
245245
return PythonObjectFactory.getUncached();
246246
}
247247

248+
@Override
249+
public boolean isAdoptable() {
250+
return adoptable;
251+
}
252+
253+
public static MaterializeFrameNode getUnadoptable() {
254+
return INSTANCE;
255+
}
256+
248257
/**
249258
* When refreshing the frame values in the locals dict, there are 4 cases:
250259
* <ol>
@@ -494,53 +503,4 @@ public boolean isAdoptable() {
494503
}
495504
}
496505

497-
public static final class MaterializeFrameUnadoptibleNode extends Node {
498-
499-
private static final MaterializeFrameUnadoptibleNode INSTANCE = new MaterializeFrameUnadoptibleNode();
500-
501-
// deliberately not annotated with '@Child'
502-
private MaterializeFrameNode materializeFrameNode;
503-
504-
public final PFrame execute(VirtualFrame frame, boolean markAsEscaped, Frame frameToMaterialize) {
505-
return execute(frame, markAsEscaped, false, frameToMaterialize);
506-
}
507-
508-
public final PFrame execute(VirtualFrame frame, boolean markAsEscaped, boolean forceSync, Frame frameToMaterialize) {
509-
PFrame.Reference info = PArguments.getCurrentFrameInfo(frameToMaterialize);
510-
assert info != null && info.getCallNode() != null : "cannot materialize a frame without location information";
511-
Node callNode = info.getCallNode();
512-
return execute(frame, callNode, markAsEscaped, forceSync, frameToMaterialize);
513-
}
514-
515-
public final PFrame execute(VirtualFrame frame, boolean markAsEscaped) {
516-
return execute(frame, markAsEscaped, frame);
517-
}
518-
519-
public final PFrame execute(VirtualFrame frame, Node location, boolean markAsEscaped, boolean forceSync) {
520-
return execute(frame, location, markAsEscaped, forceSync, frame);
521-
}
522-
523-
public PFrame execute(VirtualFrame frame, Node location, boolean markAsEscaped, boolean forceSync, Frame frameToMaterialize) {
524-
return ensureMaterializeFrameNode().execute(frame, location, markAsEscaped, forceSync, frameToMaterialize);
525-
}
526-
527-
public static MaterializeFrameUnadoptibleNode getUncached() {
528-
return INSTANCE;
529-
}
530-
531-
private MaterializeFrameNode ensureMaterializeFrameNode() {
532-
if (materializeFrameNode == null) {
533-
CompilerDirectives.transferToInterpreterAndInvalidate();
534-
materializeFrameNode = insert(MaterializeFrameNodeGen.create(false));
535-
}
536-
return materializeFrameNode;
537-
}
538-
539-
@Override
540-
public boolean isAdoptable() {
541-
return false;
542-
}
543-
544-
}
545-
546506
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import com.oracle.graal.python.nodes.frame.MaterializeFrameNode;
4949
import com.oracle.graal.python.nodes.frame.MaterializeFrameNodeGen;
5050
import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
51-
import com.oracle.graal.python.nodes.frame.MaterializeFrameNode.MaterializeFrameUnadoptibleNode;
5251
import com.oracle.graal.python.nodes.util.ExceptionStateNodes.GetCaughtExceptionNode;
5352
import com.oracle.graal.python.runtime.exception.PException;
5453
import com.oracle.truffle.api.CompilerDirectives;
@@ -125,18 +124,23 @@ private PFrame materialize(VirtualFrame frame, Node callNode, boolean markAsEsca
125124
if (adoptable) {
126125
return ensureMaterializeNode().execute(frame, callNode, markAsEscaped, forceSync);
127126
}
128-
return MaterializeFrameUnadoptibleNode.getUncached().execute(frame, callNode, markAsEscaped, forceSync);
127+
return MaterializeFrameNode.getUnadoptable().execute(frame, callNode, markAsEscaped, forceSync);
129128
}
130129

131130
private MaterializeFrameNode ensureMaterializeNode() {
132131
if (materializeNode == null) {
133132
CompilerDirectives.transferToInterpreterAndInvalidate();
134-
materializeNode = insert(MaterializeFrameNodeGen.create(adoptable));
133+
materializeNode = insert(MaterializeFrameNodeGen.create());
135134
}
136135
return materializeNode;
137136

138137
}
139138

139+
@Override
140+
public boolean isAdoptable() {
141+
return adoptable;
142+
}
143+
140144
public static CallContext create() {
141145
return new CallContext(true);
142146
}

0 commit comments

Comments
 (0)