8181import com .oracle .truffle .api .dsl .Bind ;
8282import com .oracle .truffle .api .dsl .Cached ;
8383import com .oracle .truffle .api .dsl .Cached .Shared ;
84+ import com .oracle .truffle .api .dsl .GenerateCached ;
85+ import com .oracle .truffle .api .dsl .GenerateInline ;
8486import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
8587import com .oracle .truffle .api .dsl .NodeFactory ;
8688import com .oracle .truffle .api .dsl .Specialization ;
@@ -151,16 +153,17 @@ PNone err(ZLibCompObject self, Object data, int maxLength) {
151153 }
152154 }
153155
156+ @ GenerateInline
157+ @ GenerateCached (false )
154158 abstract static class BaseCopyNode extends PNodeWithContext {
155159
156- public abstract Object execute (ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory );
160+ public abstract Object execute (Node inliningTarget , ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory );
157161
158162 @ Specialization (guards = "self.isInitialized()" )
159- static Object doNative (ZLibCompObject .NativeZlibCompObject self , PythonContext ctxt , PythonObjectFactory factory ,
160- @ Bind ("this" ) Node inliningTarget ,
161- @ Cached NativeLibrary .InvokeNativeFunction createCompObject ,
162- @ Cached NativeLibrary .InvokeNativeFunction decompressObjCopy ,
163- @ Cached NativeLibrary .InvokeNativeFunction deallocateStream ,
163+ static Object doNative (Node inliningTarget , ZLibCompObject .NativeZlibCompObject self , PythonContext ctxt , PythonObjectFactory factory ,
164+ @ Cached (inline = false ) NativeLibrary .InvokeNativeFunction createCompObject ,
165+ @ Cached (inline = false ) NativeLibrary .InvokeNativeFunction decompressObjCopy ,
166+ @ Cached (inline = false ) NativeLibrary .InvokeNativeFunction deallocateStream ,
164167 @ Cached ZlibNodes .ZlibNativeErrorHandling errorHandling ) {
165168 synchronized (self ) {
166169 assert self .isInitialized ();
@@ -178,21 +181,21 @@ static Object doNative(ZLibCompObject.NativeZlibCompObject self, PythonContext c
178181 }
179182
180183 @ Specialization (guards = {"self.isInitialized()" , "self.canCopy()" })
181- Object doJava (ZLibCompObject .JavaZlibCompObject self , @ SuppressWarnings ("unused" ) PythonContext ctxt , PythonObjectFactory factory ) {
182- return self .copyDecompressObj (factory , this );
184+ static Object doJava (Node inliningTarget , ZLibCompObject .JavaZlibCompObject self , @ SuppressWarnings ("unused" ) PythonContext ctxt , PythonObjectFactory factory ) {
185+ return self .copyDecompressObj (factory , inliningTarget );
183186 }
184187
185188 @ SuppressWarnings ("unused" )
186189 @ Specialization (guards = {"self.isInitialized()" , "!self.canCopy()" })
187190 static PNone error (ZLibCompObject .JavaZlibCompObject self , PythonContext ctxt , PythonObjectFactory factory ,
188- @ Cached .Shared ( "r" ) @ Cached PRaiseNode raise ) {
191+ @ Cached .Shared @ Cached ( inline = false ) PRaiseNode raise ) {
189192 throw raise .raise (NotImplementedError , toTruffleStringUncached ("JDK based zlib doesn't support copying" ));
190193 }
191194
192195 @ SuppressWarnings ("unused" )
193196 @ Specialization (guards = "!self.isInitialized()" )
194197 static PNone error (ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory ,
195- @ Cached .Shared ( "r" ) @ Cached PRaiseNode raise ) {
198+ @ Cached .Shared @ Cached ( inline = false ) PRaiseNode raise ) {
196199 throw raise .raise (ValueError , INCONSISTENT_STREAM_STATE );
197200 }
198201 }
@@ -202,8 +205,9 @@ static PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory
202205 abstract static class CopyNode extends PythonUnaryBuiltinNode {
203206 @ Specialization
204207 Object doit (ZLibCompObject self ,
208+ @ Bind ("this" ) Node inliningTarget ,
205209 @ Cached BaseCopyNode copyNode ) {
206- return copyNode .execute (self , PythonContext .get (this ), factory ());
210+ return copyNode .execute (inliningTarget , self , PythonContext .get (this ), factory ());
207211 }
208212 }
209213
@@ -217,8 +221,9 @@ abstract static class UndescoreCopyNode extends CopyNode {
217221 abstract static class DeepCopyNode extends PythonBinaryBuiltinNode {
218222 @ Specialization
219223 Object doit (ZLibCompObject self , @ SuppressWarnings ("unused" ) Object memo ,
224+ @ Bind ("this" ) Node inliningTarget ,
220225 @ Cached BaseCopyNode copyNode ) {
221- return copyNode .execute (self , PythonContext .get (this ), factory ());
226+ return copyNode .execute (inliningTarget , self , PythonContext .get (this ), factory ());
222227 }
223228 }
224229
@@ -233,6 +238,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
233238 }
234239
235240 @ Specialization (guards = {"length > 0" , "!self.isEof()" , "self.isInitialized()" })
241+ @ SuppressWarnings ("truffle-static-method" ) // factory
236242 PBytes doit (ZLibCompObject .NativeZlibCompObject self , int length ,
237243 @ Bind ("this" ) Node inliningTarget ,
238244 @ Cached NativeLibrary .InvokeNativeFunction decompressObjFlush ,
@@ -241,7 +247,7 @@ PBytes doit(ZLibCompObject.NativeZlibCompObject self, int length,
241247 @ Cached ZlibNodes .NativeDeallocation processDeallocation ,
242248 @ Cached ZlibNodes .ZlibNativeErrorHandling errorHandling ) {
243249 synchronized (self ) {
244- PythonContext ctxt = PythonContext .get (this );
250+ PythonContext ctxt = PythonContext .get (inliningTarget );
245251 assert self .isInitialized ();
246252 NFIZlibSupport zlibSupport = ctxt .getNFIZlibSupport ();
247253 int err = zlibSupport .decompressObjFlush (self .getZst (), length , decompressObjFlush );
0 commit comments