1
1
/*
2
- * Copyright (c) 2019, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2019, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -106,21 +106,30 @@ public final PFrame execute(VirtualFrame frame, boolean markAsEscaped, boolean f
106
106
PFrame .Reference info = PArguments .getCurrentFrameInfo (frameToMaterialize );
107
107
assert info != null && info .getCallNode () != null : "cannot materialize a frame without location information" ;
108
108
Node callNode = info .getCallNode ();
109
- return execute (frame , callNode , markAsEscaped , forceSync , frameToMaterialize );
109
+ return execute (frame , callNode , markAsEscaped , forceSync , false , frameToMaterialize );
110
110
}
111
111
112
112
public final PFrame execute (VirtualFrame frame , boolean markAsEscaped ) {
113
113
return execute (frame , markAsEscaped , frame );
114
114
}
115
115
116
116
public final PFrame execute (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync ) {
117
- return execute (frame , location , markAsEscaped , forceSync , frame );
117
+ return execute (frame , location , markAsEscaped , forceSync , false );
118
118
}
119
119
120
- public abstract PFrame execute (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , Frame frameToMaterialize );
120
+ public final PFrame execute (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , boolean updateLocationIfMissing ) {
121
+ return execute (frame , location , markAsEscaped , forceSync , updateLocationIfMissing , frame );
122
+ }
123
+
124
+ public final PFrame execute (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , Frame frameToMaterialize ) {
125
+ return execute (frame , location , markAsEscaped , forceSync , false , frameToMaterialize );
126
+ }
127
+
128
+ public abstract PFrame execute (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , boolean updateLocationIfMissing , Frame frameToMaterialize );
121
129
122
130
@ Specialization (guards = {"getPFrame(frameToMaterialize) == null" , "isGeneratorFrame(frameToMaterialize)" })
123
- static PFrame freshPFrameForGenerator (Node location , @ SuppressWarnings ("unused" ) boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync , Frame frameToMaterialize ,
131
+ static PFrame freshPFrameForGenerator (Node location , @ SuppressWarnings ("unused" ) boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync ,
132
+ @ SuppressWarnings ("unused" ) boolean updateLocationIfMissing , Frame frameToMaterialize ,
124
133
@ Shared ("factory" ) @ Cached ("createFactory()" ) PythonObjectFactory factory ) {
125
134
PFrame escapedFrame = factory .createPFrame (PArguments .getCurrentFrameInfo (frameToMaterialize ), location , PArguments .getGeneratorFrameLocals (frameToMaterialize ));
126
135
PArguments .synchronizeArgs (frameToMaterialize , escapedFrame );
@@ -130,7 +139,8 @@ static PFrame freshPFrameForGenerator(Node location, @SuppressWarnings("unused")
130
139
}
131
140
132
141
@ Specialization (guards = {"cachedFD == frameToMaterialize.getFrameDescriptor()" , "getPFrame(frameToMaterialize) == null" , "!isGeneratorFrame(frameToMaterialize)" }, limit = "1" )
133
- static PFrame freshPFrameCachedFD (VirtualFrame frame , Node location , boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync , Frame frameToMaterialize ,
142
+ static PFrame freshPFrameCachedFD (VirtualFrame frame , Node location , boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync ,
143
+ @ SuppressWarnings ("unused" ) boolean updateLocationIfMissing , Frame frameToMaterialize ,
134
144
@ Cached ("frameToMaterialize.getFrameDescriptor()" ) FrameDescriptor cachedFD ,
135
145
@ Shared ("factory" ) @ Cached ("createFactory()" ) PythonObjectFactory factory ,
136
146
@ Shared ("syncValuesNode" ) @ Cached ("createSyncNode()" ) SyncFrameValuesNode syncValuesNode ) {
@@ -140,7 +150,8 @@ static PFrame freshPFrameCachedFD(VirtualFrame frame, Node location, boolean mar
140
150
}
141
151
142
152
@ Specialization (guards = {"getPFrame(frameToMaterialize) == null" , "!isGeneratorFrame(frameToMaterialize)" }, replaces = "freshPFrameCachedFD" )
143
- static PFrame freshPFrame (VirtualFrame frame , Node location , boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync , Frame frameToMaterialize ,
153
+ static PFrame freshPFrame (VirtualFrame frame , Node location , boolean markAsEscaped , @ SuppressWarnings ("unused" ) boolean forceSync , @ SuppressWarnings ("unused" ) boolean updateLocationIfMissing ,
154
+ Frame frameToMaterialize ,
144
155
@ Shared ("factory" ) @ Cached ("createFactory()" ) PythonObjectFactory factory ,
145
156
@ Shared ("syncValuesNode" ) @ Cached ("createSyncNode()" ) SyncFrameValuesNode syncValuesNode ) {
146
157
PDict locals = factory .createDictLocals (frameToMaterialize .getFrameDescriptor ());
@@ -156,7 +167,7 @@ static PFrame freshPFrame(VirtualFrame frame, Node location, boolean markAsEscap
156
167
* @see PFrame#isIncomplete
157
168
**/
158
169
@ Specialization (guards = {"getPFrame(frameToMaterialize) != null" , "!getPFrame(frameToMaterialize).isAssociated()" })
159
- static PFrame incompleteFrame (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , Frame frameToMaterialize ,
170
+ static PFrame incompleteFrame (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , @ SuppressWarnings ( "unused" ) boolean updateLocationIfMissing , Frame frameToMaterialize ,
160
171
@ Shared ("factory" ) @ Cached ("createFactory()" ) PythonObjectFactory factory ,
161
172
@ Shared ("syncValuesNode" ) @ Cached ("createSyncNode()" ) SyncFrameValuesNode syncValuesNode ) {
162
173
Object locals = getPFrame (frameToMaterialize ).getLocalsDict ();
@@ -165,7 +176,7 @@ static PFrame incompleteFrame(VirtualFrame frame, Node location, boolean markAsE
165
176
}
166
177
167
178
@ Specialization (guards = {"getPFrame(frameToMaterialize) != null" , "getPFrame(frameToMaterialize).isAssociated()" })
168
- static PFrame alreadyEscapedFrame (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , Frame frameToMaterialize ,
179
+ static PFrame alreadyEscapedFrame (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , boolean updateLocationIfMissing , Frame frameToMaterialize ,
169
180
@ Shared ("syncValuesNode" ) @ Cached ("createSyncNode()" ) SyncFrameValuesNode syncValuesNode ,
170
181
@ Cached ConditionProfile syncProfile ) {
171
182
PFrame pyFrame = getPFrame (frameToMaterialize );
@@ -175,28 +186,30 @@ static PFrame alreadyEscapedFrame(VirtualFrame frame, Node location, boolean mar
175
186
if (markAsEscaped ) {
176
187
pyFrame .getRef ().markAsEscaped ();
177
188
}
178
- // update the location so the line number is correct
179
- pyFrame .setLocation (location );
189
+ if (!updateLocationIfMissing || pyFrame .getLocation () == null ) {
190
+ // update the location so the line number is correct
191
+ pyFrame .setLocation (location );
192
+ }
180
193
return pyFrame ;
181
194
}
182
195
183
196
@ Specialization (replaces = {"freshPFrame" , "alreadyEscapedFrame" , "incompleteFrame" })
184
- static PFrame generic (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , Frame frameToMaterialize ,
197
+ static PFrame generic (VirtualFrame frame , Node location , boolean markAsEscaped , boolean forceSync , boolean updateLocationIfMissing , Frame frameToMaterialize ,
185
198
@ Shared ("factory" ) @ Cached ("createFactory()" ) PythonObjectFactory factory ,
186
199
@ Shared ("syncValuesNode" ) @ Cached ("createSyncNode()" ) SyncFrameValuesNode syncValuesNode ,
187
200
@ Cached ConditionProfile syncProfile ) {
188
201
PFrame pyFrame = getPFrame (frameToMaterialize );
189
202
if (pyFrame != null ) {
190
203
if (pyFrame .isAssociated ()) {
191
- return alreadyEscapedFrame (frame , location , markAsEscaped , forceSync , frameToMaterialize , syncValuesNode , syncProfile );
204
+ return alreadyEscapedFrame (frame , location , markAsEscaped , forceSync , updateLocationIfMissing , frameToMaterialize , syncValuesNode , syncProfile );
192
205
} else {
193
- return incompleteFrame (frame , location , markAsEscaped , forceSync , frameToMaterialize , factory , syncValuesNode );
206
+ return incompleteFrame (frame , location , markAsEscaped , forceSync , updateLocationIfMissing , frameToMaterialize , factory , syncValuesNode );
194
207
}
195
208
} else {
196
209
if (isGeneratorFrame (frameToMaterialize )) {
197
- return freshPFrameForGenerator (location , markAsEscaped , forceSync , frameToMaterialize , factory );
210
+ return freshPFrameForGenerator (location , markAsEscaped , forceSync , updateLocationIfMissing , frameToMaterialize , factory );
198
211
} else {
199
- return freshPFrame (frame , location , markAsEscaped , forceSync , frameToMaterialize , factory , syncValuesNode );
212
+ return freshPFrame (frame , location , markAsEscaped , forceSync , updateLocationIfMissing , frameToMaterialize , factory , syncValuesNode );
200
213
}
201
214
}
202
215
}
0 commit comments