|
56 | 56 | import com.oracle.graal.python.nodes.frame.MaterializeFrameNodeGen.SyncFrameValuesNodeGen;
|
57 | 57 | import com.oracle.graal.python.nodes.function.ClassBodyRootNode;
|
58 | 58 | import com.oracle.graal.python.runtime.object.PythonObjectFactory;
|
59 |
| -import com.oracle.truffle.api.CompilerDirectives; |
60 | 59 | import com.oracle.truffle.api.dsl.Cached;
|
61 | 60 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
62 | 61 | import com.oracle.truffle.api.dsl.ImportStatic;
|
|
77 | 76 | **/
|
78 | 77 | public abstract class MaterializeFrameNode extends Node {
|
79 | 78 |
|
80 |
| - private final boolean adoptible; |
| 79 | + private final boolean adoptable; |
| 80 | + private static final MaterializeFrameNode INSTANCE = MaterializeFrameNodeGen.create(false); |
81 | 81 |
|
82 | 82 | public MaterializeFrameNode() {
|
83 |
| - this.adoptible = true; |
| 83 | + this.adoptable = true; |
84 | 84 | }
|
85 | 85 |
|
86 |
| - public MaterializeFrameNode(boolean adoptible) { |
87 |
| - this.adoptible = adoptible; |
| 86 | + protected MaterializeFrameNode(boolean adoptable) { |
| 87 | + this.adoptable = adoptable; |
88 | 88 | }
|
89 | 89 |
|
90 | 90 | public final PFrame execute(VirtualFrame frame, boolean markAsEscaped, Frame frameToMaterialize) {
|
@@ -234,17 +234,26 @@ protected static boolean inModuleRoot(Node location) {
|
234 | 234 | return location.getRootNode() instanceof ModuleRootNode;
|
235 | 235 | }
|
236 | 236 |
|
237 |
| - protected SyncFrameValuesNode createSyncNode() { |
238 |
| - return SyncFrameValuesNodeGen.create(adoptible); |
| 237 | + protected final SyncFrameValuesNode createSyncNode() { |
| 238 | + return SyncFrameValuesNodeGen.create(isAdoptable()); |
239 | 239 | }
|
240 | 240 |
|
241 |
| - protected PythonObjectFactory createFactory() { |
242 |
| - if (adoptible) { |
| 241 | + protected final PythonObjectFactory createFactory() { |
| 242 | + if (isAdoptable()) { |
243 | 243 | return PythonObjectFactory.create();
|
244 | 244 | }
|
245 | 245 | return PythonObjectFactory.getUncached();
|
246 | 246 | }
|
247 | 247 |
|
| 248 | + @Override |
| 249 | + public boolean isAdoptable() { |
| 250 | + return adoptable; |
| 251 | + } |
| 252 | + |
| 253 | + public static MaterializeFrameNode getUnadoptable() { |
| 254 | + return INSTANCE; |
| 255 | + } |
| 256 | + |
248 | 257 | /**
|
249 | 258 | * When refreshing the frame values in the locals dict, there are 4 cases:
|
250 | 259 | * <ol>
|
@@ -494,53 +503,4 @@ public boolean isAdoptable() {
|
494 | 503 | }
|
495 | 504 | }
|
496 | 505 |
|
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 |
| - |
546 | 506 | }
|
0 commit comments