Skip to content

Commit 6a4ca06

Browse files
committed
few adjustments
1 parent 3d9f422 commit 6a4ca06

File tree

5 files changed

+25
-34
lines changed

5 files changed

+25
-34
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,19 @@ PBytes doBytes(LZMACompressor self, PBytesLike data,
170170
@Cached SequenceStorageNodes.GetInternalByteArrayNode toBytes,
171171
@Cached SequenceStorageNodes.LenNode lenNode,
172172
@Shared("c") @Cached LZMANodes.CompressNode compress) {
173-
synchronized (self) {
174-
byte[] bytes = toBytes.execute(data.getSequenceStorage());
175-
int len = lenNode.execute(data.getSequenceStorage());
176-
return factory().createBytes(compress.compress(self, ctxt, bytes, len));
177-
}
173+
byte[] bytes = toBytes.execute(data.getSequenceStorage());
174+
int len = lenNode.execute(data.getSequenceStorage());
175+
return factory().createBytes(compress.compress(self, ctxt, bytes, len));
178176
}
179177

180178
@Specialization(guards = {"!self.isFlushed()"})
181179
PBytes doObject(LZMACompressor self, Object data,
182180
@Shared("ct") @CachedContext(PythonLanguage.class) PythonContext ctxt,
183181
@Cached BytesNodes.ToBytesNode toBytes,
184182
@Shared("c") @Cached LZMANodes.CompressNode compress) {
185-
synchronized (self) {
186-
byte[] bytes = toBytes.execute(data);
187-
int len = bytes.length;
188-
return factory().createBytes(compress.compress(self, ctxt, bytes, len));
189-
}
183+
byte[] bytes = toBytes.execute(data);
184+
int len = bytes.length;
185+
return factory().createBytes(compress.compress(self, ctxt, bytes, len));
190186
}
191187

192188
@SuppressWarnings("unused")
@@ -206,10 +202,8 @@ abstract static class FlushNode extends PythonUnaryBuiltinNode {
206202
PBytes doit(LZMACompressor self,
207203
@CachedContext(PythonLanguage.class) PythonContext ctxt,
208204
@Cached LZMANodes.CompressNode compress) {
209-
synchronized (self) {
210-
self.setFlushed();
211-
return factory().createBytes(compress.flush(self, ctxt));
212-
}
205+
self.setFlushed();
206+
return factory().createBytes(compress.flush(self, ctxt));
213207
}
214208

215209
@SuppressWarnings("unused")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,19 @@ PBytes doBytes(LZMADecompressor self, PBytesLike data, int maxLength,
186186
@Cached SequenceStorageNodes.GetInternalByteArrayNode toBytes,
187187
@Cached SequenceStorageNodes.LenNode lenNode,
188188
@Shared("d") @Cached LZMANodes.DecompressNode decompress) {
189-
synchronized (self) {
190-
byte[] bytes = toBytes.execute(data.getSequenceStorage());
191-
int len = lenNode.execute(data.getSequenceStorage());
192-
return factory().createBytes(decompress.execute(self, bytes, len, maxLength));
193-
}
189+
byte[] bytes = toBytes.execute(data.getSequenceStorage());
190+
int len = lenNode.execute(data.getSequenceStorage());
191+
return factory().createBytes(decompress.execute(self, bytes, len, maxLength));
192+
194193
}
195194

196195
@Specialization(guards = {"!self.isEOF()"})
197196
PBytes doObject(LZMADecompressor self, Object data, int maxLength,
198197
@Cached BytesNodes.ToBytesNode toBytes,
199198
@Shared("d") @Cached LZMANodes.DecompressNode decompress) {
200-
synchronized (self) {
201-
byte[] bytes = toBytes.execute(data);
202-
int len = bytes.length;
203-
return factory().createBytes(decompress.execute(self, bytes, len, maxLength));
204-
}
199+
byte[] bytes = toBytes.execute(data);
200+
int len = bytes.length;
201+
return factory().createBytes(decompress.execute(self, bytes, len, maxLength));
205202
}
206203

207204
@SuppressWarnings("unused")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import org.tukaani.xz.XZ;
8080
import org.tukaani.xz.XZOutputStream;
8181

82-
import com.oracle.graal.python.PythonLanguage;
8382
import com.oracle.graal.python.builtins.Builtin;
8483
import com.oracle.graal.python.builtins.CoreFunctions;
8584
import com.oracle.graal.python.builtins.PythonBuiltins;
@@ -96,11 +95,9 @@
9695
import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode;
9796
import com.oracle.graal.python.runtime.NFILZMASupport;
9897
import com.oracle.graal.python.runtime.NativeLibrary;
99-
import com.oracle.graal.python.runtime.PythonContext;
10098
import com.oracle.graal.python.runtime.PythonCore;
10199
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
102100
import com.oracle.truffle.api.dsl.Cached;
103-
import com.oracle.truffle.api.dsl.CachedContext;
104101
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
105102
import com.oracle.truffle.api.dsl.NodeFactory;
106103
import com.oracle.truffle.api.dsl.Specialization;
@@ -266,10 +263,9 @@ public void postInitialize(PythonCore c) {
266263
abstract static class LZMACompressorNode extends PythonBuiltinNode {
267264

268265
@Specialization
269-
LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg,
270-
@CachedContext(PythonLanguage.class) PythonContext ctxt) {
266+
LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg) {
271267
// data filled in subsequent __init__ call - see LZMACompressorBuiltins.InitNode
272-
return factory().createLZMACompressor(cls, ctxt.getNFILZMASupport().isAvailable());
268+
return factory().createLZMACompressor(cls, getContext().getNFILZMASupport().isAvailable());
273269
}
274270
}
275271

@@ -279,10 +275,9 @@ LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg,
279275
abstract static class LZMADecompressorNode extends PythonBuiltinNode {
280276

281277
@Specialization
282-
LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg,
283-
@CachedContext(PythonLanguage.class) PythonContext ctxt) {
278+
LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg) {
284279
// data filled in subsequent __init__ call - see LZMADecompressorBuiltins.InitNode
285-
return factory().createLZMADecompressor(cls, ctxt.getNFILZMASupport().isAvailable());
280+
return factory().createLZMADecompressor(cls, getContext().getNFILZMASupport().isAvailable());
286281
}
287282
}
288283

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMANodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ FilterOptions[] parseFilterChainSpec(VirtualFrame frame, Object filterSpecs,
529529
try {
530530
optionsChain[i] = getFilterOptions(filters[i]);
531531
} catch (UnsupportedOptionsException e) {
532-
raise(ValueError, "%s", getMessage(e));
532+
throw raise(ValueError, "%m", e);
533533
}
534534

535535
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceNodes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ static boolean fset(@SuppressWarnings("unused") PFrozenSet fset) {
193193
return true;
194194
}
195195

196+
@Specialization
197+
static boolean string(@SuppressWarnings("unused") String str) {
198+
return true;
199+
}
200+
196201
@Fallback
197202
boolean notSeqence(Object obj) {
198203
if (lib.isMapping(obj)) {

0 commit comments

Comments
 (0)