4949import com .oracle .graal .python .builtins .objects .frame .PFrame ;
5050import com .oracle .graal .python .compiler .CodeUnit ;
5151import com .oracle .graal .python .lib .PyDictGetItem ;
52- import com .oracle .graal .python .nodes .PRootNode ;
5352import com .oracle .graal .python .nodes .bytecode .FrameInfo ;
54- import com .oracle .graal .python .nodes .bytecode_dsl .BytecodeDSLFrameInfo ;
55- import com .oracle .graal .python .nodes .bytecode_dsl .PBytecodeDSLRootNode ;
5653import com .oracle .graal .python .runtime .CallerFlags ;
5754import com .oracle .graal .python .runtime .PythonOptions ;
5855import com .oracle .graal .python .runtime .object .PFactory ;
@@ -116,7 +113,7 @@ static Object doLoop(VirtualFrame frame, Node inliningTarget, PFrame pyFrame, bo
116113 localsDict = PFactory .createDict (PythonLanguage .get (inliningTarget ));
117114 pyFrame .setLocalsDict (localsDict );
118115 }
119- copyLocalsToDict .execute (locals , localsDict );
116+ copyLocalsToDict .execute (locals , localsDict , pyFrame . getBytecodeNode () );
120117 return localsDict ;
121118 }
122119
@@ -130,11 +127,11 @@ static Object doCustomLocals(PFrame pyFrame, @SuppressWarnings("unused") boolean
130127 @ GenerateUncached
131128 @ GenerateInline (false ) // footprint reduction 104 -> 86
132129 abstract static class CopyLocalsToDict extends Node {
133- abstract void execute (MaterializedFrame locals , PDict dict );
130+ abstract void execute (MaterializedFrame locals , PDict dict , BytecodeNode bytecodeNode );
134131
135132 @ Specialization (guards = {"cachedFd == locals.getFrameDescriptor()" , "info != null" , "count < 32" }, limit = "1" )
136133 @ ExplodeLoop
137- void doCachedFd (MaterializedFrame locals , PDict dict ,
134+ static void doCachedFd (MaterializedFrame locals , PDict dict , BytecodeNode bytecodeNode ,
138135 @ Bind Node inliningTarget ,
139136 @ SuppressWarnings ("unused" ) @ Cached ("locals.getFrameDescriptor()" ) FrameDescriptor cachedFd ,
140137 @ Bind ("getInfo(cachedFd)" ) FrameInfo info ,
@@ -144,9 +141,7 @@ void doCachedFd(MaterializedFrame locals, PDict dict,
144141 int regularVarCount = info .getRegularVariableCount ();
145142
146143 if (PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ) {
147- BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo ) info ;
148- PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo .getRootNode ();
149- Object [] localsArray = rootNode .getBytecodeNode ().getLocalValues (0 , locals );
144+ Object [] localsArray = bytecodeNode .getLocalValues (0 , locals );
150145 for (int i = 0 ; i < count ; i ++) {
151146 copyItem (inliningTarget , localsArray [i ], info , dict , setItem , delItem , i , i >= regularVarCount );
152147 }
@@ -158,7 +153,7 @@ void doCachedFd(MaterializedFrame locals, PDict dict,
158153 }
159154
160155 @ Specialization (replaces = "doCachedFd" )
161- void doGeneric (MaterializedFrame locals , PDict dict ,
156+ void doGeneric (MaterializedFrame locals , PDict dict , BytecodeNode bytecodeNode ,
162157 @ Bind Node inliningTarget ,
163158 @ Shared ("setItem" ) @ Cached HashingStorageSetItem setItem ,
164159 @ Shared ("delItem" ) @ Cached HashingStorageDelItem delItem ) {
@@ -171,9 +166,7 @@ void doGeneric(MaterializedFrame locals, PDict dict,
171166 int regularVarCount = info .getRegularVariableCount ();
172167
173168 if (PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ) {
174- BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo ) info ;
175- PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo .getRootNode ();
176- Object [] localsArray = rootNode .getBytecodeNode ().getLocalValues (0 , locals );
169+ Object [] localsArray = bytecodeNode .getLocalValues (0 , locals );
177170 for (int i = 0 ; i < count ; i ++) {
178171 copyItem (inliningTarget , localsArray [i ], info , dict , setItem , delItem , i , i >= regularVarCount );
179172 }
@@ -207,19 +200,17 @@ protected static FrameInfo getInfo(FrameDescriptor fd) {
207200 /**
208201 * Equivalent of CPython's {@code PyFrame_LocalsToFast}
209202 */
210- public static void syncLocalsBackToFrame (CodeUnit co , PRootNode root , PFrame pyFrame , Frame localFrame ) {
203+ public static void syncLocalsBackToFrame (CodeUnit co , PFrame pyFrame , Frame localFrame , BytecodeNode bytecodeNode ) {
211204 if (!pyFrame .hasCustomLocals ()) {
212205 PDict localsDict = (PDict ) pyFrame .getLocalsDict ();
213- copyLocalsArray (localFrame , root , localsDict , co .varnames , 0 , false );
214- copyLocalsArray (localFrame , root , localsDict , co .cellvars , co .varnames .length , true );
215- copyLocalsArray (localFrame , root , localsDict , co .freevars , co .varnames .length + co .cellvars .length , true );
206+ copyLocalsArray (localFrame , localsDict , bytecodeNode , co .varnames , 0 , false );
207+ copyLocalsArray (localFrame , localsDict , bytecodeNode , co .cellvars , co .varnames .length , true );
208+ copyLocalsArray (localFrame , localsDict , bytecodeNode , co .freevars , co .varnames .length + co .cellvars .length , true );
216209 }
217210 }
218211
219- private static void copyLocalsArray (Frame localFrame , PRootNode root , PDict localsDict , TruffleString [] namesArray , int offset , boolean deref ) {
212+ private static void copyLocalsArray (Frame localFrame , PDict localsDict , BytecodeNode bytecodeNode , TruffleString [] namesArray , int offset , boolean deref ) {
220213 if (PythonOptions .ENABLE_BYTECODE_DSL_INTERPRETER ) {
221- PBytecodeDSLRootNode bytecodeDSLRootNode = (PBytecodeDSLRootNode ) root ;
222- BytecodeNode bytecodeNode = bytecodeDSLRootNode .getBytecodeNode ();
223214 for (int i = 0 ; i < namesArray .length ; i ++) {
224215 TruffleString varname = namesArray [i ];
225216 Object value = getDictItemUncached (localsDict , varname );
0 commit comments