78
78
import com .oracle .truffle .api .TruffleLanguage .LanguageReference ;
79
79
import com .oracle .truffle .api .dsl .Cached ;
80
80
import com .oracle .truffle .api .dsl .Specialization ;
81
+ import com .oracle .truffle .api .frame .MaterializedFrame ;
81
82
import com .oracle .truffle .api .frame .VirtualFrame ;
82
83
import com .oracle .truffle .api .instrumentation .StandardTags ;
83
84
import com .oracle .truffle .api .instrumentation .Tag ;
@@ -267,11 +268,15 @@ static Object genericImport(VirtualFrame frame, PythonContext context, String na
267
268
}
268
269
if (level == 0 ) {
269
270
String front = name .substring (0 , dotIndex );
270
- // recursion up number of dots in the name
271
- return levelZeroNoFromlist (frame , context , front , null , null , 0 ,
271
+ // recursion up number of dots in the name. we use a boundary call here to avoid PE going recursive
272
+ return genericImportBoundary (frame .materialize (), context , front , null , PythonUtils .EMPTY_STRING_ARRAY , 0 ,
273
+ null , // resolveName is not used with level == 0
272
274
raiseNode , // raiseNode only needed if front.length() == 0 at this point
273
275
getModuleNode , // used multiple times to get the 'front' module
274
276
ensureInitialized , // used multiple times on the 'front' module
277
+ null , // getPathNode is not used with fromList.length == 0
278
+ null , // callHandleFromlist not used with fromList.length == 0
279
+ null , // factory not used with fromList.length == 0
275
280
findAndLoad ); // used multiple times, but always to call the exact same function
276
281
} else {
277
282
int cutoff = nameLength - dotIndex ;
@@ -297,6 +302,27 @@ static Object genericImport(VirtualFrame frame, PythonContext context, String na
297
302
}
298
303
}
299
304
}
305
+
306
+ @ TruffleBoundary
307
+ static Object genericImportBoundary (MaterializedFrame frame , PythonContext context , String name , Object globals , String [] fromList , int level ,
308
+ ResolveName resolveName ,
309
+ PRaiseNode raiseNode ,
310
+ PyDictGetItem getModuleNode ,
311
+ EnsureInitializedNode ensureInitialized ,
312
+ PyObjectLookupAttr getPathNode ,
313
+ PyObjectCallMethodObjArgs callHandleFromlist ,
314
+ PythonObjectFactory factory ,
315
+ FindAndLoad findAndLoad ) {
316
+ return genericImport (frame , context , name , globals , fromList , level ,
317
+ resolveName ,
318
+ raiseNode ,
319
+ getModuleNode ,
320
+ ensureInitialized ,
321
+ getPathNode ,
322
+ callHandleFromlist ,
323
+ factory ,
324
+ findAndLoad );
325
+ }
300
326
}
301
327
302
328
/**
0 commit comments