Skip to content

Commit bf91be6

Browse files
committed
Resolve all remaining DSL warnings in the zlib module
1 parent d997c3c commit bf91be6

File tree

3 files changed

+40
-70
lines changed

3 files changed

+40
-70
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
import com.oracle.truffle.api.dsl.Bind;
8181
import com.oracle.truffle.api.dsl.Cached;
8282
import com.oracle.truffle.api.dsl.Cached.Shared;
83+
import com.oracle.truffle.api.dsl.GenerateCached;
84+
import com.oracle.truffle.api.dsl.GenerateInline;
8385
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
8486
import com.oracle.truffle.api.dsl.ImportStatic;
8587
import com.oracle.truffle.api.dsl.NodeFactory;
@@ -139,16 +141,17 @@ PBytes error(ZLibCompObject self, Object data) {
139141
}
140142
}
141143

144+
@GenerateInline
145+
@GenerateCached(false)
142146
abstract static class BaseCopyNode extends PNodeWithContext {
143147

144-
public abstract Object execute(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory);
148+
public abstract Object execute(Node inliningTarget, ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory);
145149

146150
@Specialization(guards = "self.isInitialized()")
147-
Object doNative(ZLibCompObject.NativeZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
148-
@Bind("this") Node inliningTarget,
149-
@Cached NativeLibrary.InvokeNativeFunction createCompObject,
150-
@Cached NativeLibrary.InvokeNativeFunction compressObjCopy,
151-
@Cached NativeLibrary.InvokeNativeFunction deallocateStream,
151+
static Object doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
152+
@Cached(inline = false) NativeLibrary.InvokeNativeFunction createCompObject,
153+
@Cached(inline = false) NativeLibrary.InvokeNativeFunction compressObjCopy,
154+
@Cached(inline = false) NativeLibrary.InvokeNativeFunction deallocateStream,
152155
@Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) {
153156
synchronized (self) {
154157
assert self.isInitialized();
@@ -164,21 +167,21 @@ Object doNative(ZLibCompObject.NativeZlibCompObject self, PythonContext ctxt, Py
164167
}
165168

166169
@Specialization(guards = {"self.isInitialized()", "self.canCopy()"})
167-
Object doJava(ZLibCompObject.JavaZlibCompObject self, @SuppressWarnings("unused") PythonContext ctxt, PythonObjectFactory factory) {
170+
static Object doJava(ZLibCompObject.JavaZlibCompObject self, @SuppressWarnings("unused") PythonContext ctxt, PythonObjectFactory factory) {
168171
return self.copyCompressObj(factory);
169172
}
170173

171174
@SuppressWarnings("unused")
172175
@Specialization(guards = {"self.isInitialized()", "!self.canCopy()"})
173-
PNone error(ZLibCompObject.JavaZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
174-
@Cached.Shared("r") @Cached PRaiseNode raise) {
176+
static PNone error(ZLibCompObject.JavaZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
177+
@Cached.Shared @Cached(inline = false) PRaiseNode raise) {
175178
throw raise.raise(NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying"));
176179
}
177180

178181
@SuppressWarnings("unused")
179182
@Specialization(guards = "!self.isInitialized()")
180-
PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
181-
@Cached.Shared("r") @Cached PRaiseNode raise) {
183+
static PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory,
184+
@Cached.Shared @Cached(inline = false) PRaiseNode raise) {
182185
throw raise.raise(ValueError, ErrorMessages.INCONSISTENT_STREAM_STATE);
183186
}
184187
}
@@ -187,9 +190,11 @@ PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory
187190
@GenerateNodeFactory
188191
abstract static class CopyNode extends PythonUnaryBuiltinNode {
189192
@Specialization
193+
@SuppressWarnings("truffle-static-method")
190194
Object doit(ZLibCompObject self,
195+
@Bind("this") Node inliningTarget,
191196
@Cached BaseCopyNode copyNode) {
192-
return copyNode.execute(self, PythonContext.get(this), factory());
197+
return copyNode.execute(inliningTarget, self, PythonContext.get(this), factory());
193198
}
194199
}
195200

@@ -202,9 +207,11 @@ abstract static class UndescoreCopyNode extends CopyNode {
202207
@GenerateNodeFactory
203208
abstract static class DeepCopyNode extends PythonBinaryBuiltinNode {
204209
@Specialization
210+
@SuppressWarnings("truffle-static-method")
205211
Object doit(ZLibCompObject self, @SuppressWarnings("unused") Object memo,
212+
@Bind("this") Node inliningTarget,
206213
@Cached BaseCopyNode copyNode) {
207-
return copyNode.execute(self, PythonContext.get(this), factory());
214+
return copyNode.execute(inliningTarget, self, PythonContext.get(this), factory());
208215
}
209216
}
210217

@@ -226,6 +233,7 @@ PBytes empty(ZLibCompObject self, int mode) {
226233
}
227234

228235
@Specialization(guards = {"mode != Z_NO_FLUSH", "self.isInitialized()"})
236+
@SuppressWarnings("truffle-static-method") // factory
229237
PBytes doit(ZLibCompObject.NativeZlibCompObject self, int mode,
230238
@Bind("this") Node inliningTarget,
231239
@Cached NativeLibrary.InvokeNativeFunction compressObjFlush,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
import com.oracle.truffle.api.dsl.Bind;
8282
import com.oracle.truffle.api.dsl.Cached;
8383
import com.oracle.truffle.api.dsl.Cached.Shared;
84+
import com.oracle.truffle.api.dsl.GenerateCached;
85+
import com.oracle.truffle.api.dsl.GenerateInline;
8486
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
8587
import com.oracle.truffle.api.dsl.NodeFactory;
8688
import 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);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/package-info.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)