81
81
import com .oracle .truffle .api .dsl .Bind ;
82
82
import com .oracle .truffle .api .dsl .Cached ;
83
83
import com .oracle .truffle .api .dsl .Cached .Shared ;
84
+ import com .oracle .truffle .api .dsl .GenerateCached ;
85
+ import com .oracle .truffle .api .dsl .GenerateInline ;
84
86
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
85
87
import com .oracle .truffle .api .dsl .NodeFactory ;
86
88
import com .oracle .truffle .api .dsl .Specialization ;
@@ -151,16 +153,17 @@ PNone err(ZLibCompObject self, Object data, int maxLength) {
151
153
}
152
154
}
153
155
156
+ @ GenerateInline
157
+ @ GenerateCached (false )
154
158
abstract static class BaseCopyNode extends PNodeWithContext {
155
159
156
- public abstract Object execute (ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory );
160
+ public abstract Object execute (Node inliningTarget , ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory );
157
161
158
162
@ 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 ,
164
167
@ Cached ZlibNodes .ZlibNativeErrorHandling errorHandling ) {
165
168
synchronized (self ) {
166
169
assert self .isInitialized ();
@@ -178,21 +181,21 @@ static Object doNative(ZLibCompObject.NativeZlibCompObject self, PythonContext c
178
181
}
179
182
180
183
@ 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 );
183
186
}
184
187
185
188
@ SuppressWarnings ("unused" )
186
189
@ Specialization (guards = {"self.isInitialized()" , "!self.canCopy()" })
187
190
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 ) {
189
192
throw raise .raise (NotImplementedError , toTruffleStringUncached ("JDK based zlib doesn't support copying" ));
190
193
}
191
194
192
195
@ SuppressWarnings ("unused" )
193
196
@ Specialization (guards = "!self.isInitialized()" )
194
197
static PNone error (ZLibCompObject self , PythonContext ctxt , PythonObjectFactory factory ,
195
- @ Cached .Shared ( "r" ) @ Cached PRaiseNode raise ) {
198
+ @ Cached .Shared @ Cached ( inline = false ) PRaiseNode raise ) {
196
199
throw raise .raise (ValueError , INCONSISTENT_STREAM_STATE );
197
200
}
198
201
}
@@ -202,8 +205,9 @@ static PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory
202
205
abstract static class CopyNode extends PythonUnaryBuiltinNode {
203
206
@ Specialization
204
207
Object doit (ZLibCompObject self ,
208
+ @ Bind ("this" ) Node inliningTarget ,
205
209
@ Cached BaseCopyNode copyNode ) {
206
- return copyNode .execute (self , PythonContext .get (this ), factory ());
210
+ return copyNode .execute (inliningTarget , self , PythonContext .get (this ), factory ());
207
211
}
208
212
}
209
213
@@ -217,8 +221,9 @@ abstract static class UndescoreCopyNode extends CopyNode {
217
221
abstract static class DeepCopyNode extends PythonBinaryBuiltinNode {
218
222
@ Specialization
219
223
Object doit (ZLibCompObject self , @ SuppressWarnings ("unused" ) Object memo ,
224
+ @ Bind ("this" ) Node inliningTarget ,
220
225
@ Cached BaseCopyNode copyNode ) {
221
- return copyNode .execute (self , PythonContext .get (this ), factory ());
226
+ return copyNode .execute (inliningTarget , self , PythonContext .get (this ), factory ());
222
227
}
223
228
}
224
229
@@ -233,6 +238,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
233
238
}
234
239
235
240
@ Specialization (guards = {"length > 0" , "!self.isEof()" , "self.isInitialized()" })
241
+ @ SuppressWarnings ("truffle-static-method" ) // factory
236
242
PBytes doit (ZLibCompObject .NativeZlibCompObject self , int length ,
237
243
@ Bind ("this" ) Node inliningTarget ,
238
244
@ Cached NativeLibrary .InvokeNativeFunction decompressObjFlush ,
@@ -241,7 +247,7 @@ PBytes doit(ZLibCompObject.NativeZlibCompObject self, int length,
241
247
@ Cached ZlibNodes .NativeDeallocation processDeallocation ,
242
248
@ Cached ZlibNodes .ZlibNativeErrorHandling errorHandling ) {
243
249
synchronized (self ) {
244
- PythonContext ctxt = PythonContext .get (this );
250
+ PythonContext ctxt = PythonContext .get (inliningTarget );
245
251
assert self .isInitialized ();
246
252
NFIZlibSupport zlibSupport = ctxt .getNFIZlibSupport ();
247
253
int err = zlibSupport .decompressObjFlush (self .getZst (), length , decompressObjFlush );
0 commit comments