Skip to content

Commit ea0858a

Browse files
committed
Few warnings fixes
1 parent c696d65 commit ea0858a

File tree

6 files changed

+41
-23
lines changed

6 files changed

+41
-23
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import com.oracle.graal.python.builtins.objects.bytes.BytesBuiltinsFactory.BytesLikeNoGeneralizationNodeGen;
6262
import com.oracle.graal.python.builtins.objects.common.IndexNodes.NormalizeIndexNode;
6363
import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetObjectArrayNode;
64+
import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetSequenceStorageNode;
6465
import com.oracle.graal.python.builtins.objects.common.SequenceNodesFactory.GetObjectArrayNodeGen;
6566
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
6667
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GenNodeSupplier;
@@ -349,15 +350,17 @@ public abstract static class AddNode extends PythonBinaryBuiltinNode {
349350

350351
@Specialization
351352
public Object add(PBytes left, PIBytesLike right,
352-
@Cached("create()") SequenceStorageNodes.ConcatNode concatNode) {
353-
ByteSequenceStorage res = (ByteSequenceStorage) concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage());
353+
@Cached("create()") SequenceStorageNodes.ConcatNode concatNode,
354+
@Cached GetSequenceStorageNode getStorage) {
355+
ByteSequenceStorage res = (ByteSequenceStorage) concatNode.execute(left.getSequenceStorage(), getStorage.execute(right));
354356
return factory().createBytes(res);
355357
}
356358

357359
@Specialization
358360
public Object add(PByteArray self, PIBytesLike other,
359-
@Cached("create()") SequenceStorageNodes.ConcatNode concatNode) {
360-
SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage());
361+
@Cached SequenceStorageNodes.ConcatNode concatNode,
362+
@Cached GetSequenceStorageNode getStorage) {
363+
SequenceStorage res = concatNode.execute(self.getSequenceStorage(), getStorage.execute(other));
361364
return factory().createByteArray(res);
362365
}
363366

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ private Object[] countIt(double manitssa, int exponent) {
14061406
e--;
14071407
}
14081408

1409-
BigInteger numerator = BigInteger.valueOf((new Double(m)).longValue());
1409+
BigInteger numerator = BigInteger.valueOf(((Double) m).longValue());
14101410
BigInteger denominator = BigInteger.ONE;
14111411
BigInteger py_exponent = denominator.shiftLeft(Math.abs(e));
14121412
if (e > 0) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,17 @@ public abstract static class ReprNode extends PythonUnaryBuiltinNode {
141141

142142
@Specialization
143143
public Object repr(VirtualFrame frame, PList self,
144-
@Cached("create(__REPR__)") LookupAndCallUnaryNode repr) {
144+
@Cached("create(__REPR__)") LookupAndCallUnaryNode repr,
145+
@Cached SequenceStorageNodes.LenNode lenNode,
146+
@Cached SequenceStorageNodes.GetItemNode getItem) {
145147
StringBuilder result = new StringBuilder();
146148
sbAppend(result, "[");
147149
SequenceStorage storage = self.getSequenceStorage();
148150
boolean initial = true;
149151
Object value;
150152
Object reprString;
151-
for (int index = 0; index < storage.length(); index++) {
152-
value = storage.getItemNormalized(index);
153+
for (int index = 0; index < lenNode.execute(storage); index++) {
154+
value = getItem.execute(frame, storage, index);
153155
if (self != value) {
154156
reprString = repr.executeObject(frame, value);
155157
if (reprString instanceof PString) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ private PythonObjectLibrary getPythonObjectLibrary() {
107107
return pythonObjectLibrary;
108108
}
109109

110+
@TruffleBoundary
111+
private static boolean acquireBlocking(AbstractPythonLock self) {
112+
return self.acquireBlocking();
113+
}
114+
110115
@Specialization
111116
boolean doAcquire(VirtualFrame frame, AbstractPythonLock self, Object blocking, Object timeout) {
112117
// args setup
@@ -133,7 +138,7 @@ boolean doAcquire(VirtualFrame frame, AbstractPythonLock self, Object blocking,
133138
return self.acquireNonBlocking();
134139
} else {
135140
if (defaultTimeoutProfile.profile(timeoutSeconds == UNSET_TIMEOUT)) {
136-
return self.acquireBlocking();
141+
return acquireBlocking(self);
137142
} else {
138143
return self.acquireTimeout(timeoutSeconds);
139144
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/ReadAttributeFromObjectNode.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,14 @@ protected static HashingStorage getStorage(Object module, Object cachedGlobals)
122122
"getStorage(object, cachedDict) == cachedStorage",
123123
"isBuiltinDict(cachedDict, isBuiltinDict)",
124124
}, assumptions = "singleContextAssumption", limit = "1")
125-
protected Object readFromBuiltinModuleDictUnchanged(@SuppressWarnings("unused") PythonModule object, String key,
126-
@SuppressWarnings("unused") @CachedLibrary("object") PythonObjectLibrary lib,
127-
@SuppressWarnings("unused") @Cached("object") PythonModule cachedObject,
128-
@SuppressWarnings("unused") @Cached("lib.getDict(cachedObject)") PHashingCollection cachedDict,
129-
@SuppressWarnings("unused") @Cached("singleContextAssumption()") Assumption singleContextAssumption,
125+
@SuppressWarnings("unused")
126+
protected Object readFromBuiltinModuleDictUnchanged(PythonModule object, String key,
127+
@CachedLibrary("object") PythonObjectLibrary lib,
128+
@Cached("object") PythonModule cachedObject,
129+
@Cached("lib.getDict(cachedObject)") PHashingCollection cachedDict,
130+
@Cached("singleContextAssumption()") Assumption singleContextAssumption,
130131
@Cached("getStorage(object, cachedDict)") HashingStorage cachedStorage,
131-
@SuppressWarnings("unused") @Cached IsBuiltinClassProfile isBuiltinDict,
132+
@Cached IsBuiltinClassProfile isBuiltinDict,
132133
@CachedLibrary(limit = "1") HashingStorageLibrary hlib) {
133134
// note that we don't need to pass the state here - string keys are hashable by definition
134135
Object value = hlib.getItem(cachedStorage, key);
@@ -144,15 +145,16 @@ protected Object readFromBuiltinModuleDictUnchanged(@SuppressWarnings("unused")
144145
"cachedObject == object",
145146
"lib.getDict(cachedObject) == cachedDict",
146147
"hasBuiltinDict(cachedObject, lib, isBuiltinDict, isBuiltinMappingproxy)",
147-
}, assumptions = "singleContextAssumption", limit = "1", replaces = "readFromBuiltinModuleDictUnchanged")
148-
protected Object readFromBuiltinModuleDict(@SuppressWarnings("unused") PythonModule object, String key,
149-
@SuppressWarnings("unused") @CachedLibrary("object") PythonObjectLibrary lib,
150-
@SuppressWarnings("unused") @Cached("object") PythonModule cachedObject,
151-
@SuppressWarnings("unused") @Cached("lib.getDict(cachedObject)") PHashingCollection cachedDict,
152-
@SuppressWarnings("unused") @Cached("singleContextAssumption()") Assumption singleContextAssumption,
148+
}, assumptions = "singleContextAssumption", replaces = "readFromBuiltinModuleDictUnchanged")
149+
@SuppressWarnings("unused")
150+
protected Object readFromBuiltinModuleDict(PythonModule object, String key,
151+
@CachedLibrary(limit = "1") PythonObjectLibrary lib,
152+
@Cached("object") PythonModule cachedObject,
153+
@Cached("lib.getDict(cachedObject)") PHashingCollection cachedDict,
154+
@Cached("singleContextAssumption()") Assumption singleContextAssumption,
153155
@Cached HashingCollectionNodes.GetDictStorageNode getDictStorage,
154-
@SuppressWarnings("unused") @Cached IsBuiltinClassProfile isBuiltinDict,
155-
@SuppressWarnings("unused") @Cached IsBuiltinClassProfile isBuiltinMappingproxy,
156+
@Cached IsBuiltinClassProfile isBuiltinDict,
157+
@Cached IsBuiltinClassProfile isBuiltinMappingproxy,
156158
@CachedLibrary(limit = "1") HashingStorageLibrary hlib) {
157159
Object value = hlib.getItem(getDictStorage.execute(cachedDict), key);
158160
if (value == null) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsBuiltinClassProfile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.oracle.truffle.api.CompilerDirectives;
4949
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
5050
import com.oracle.truffle.api.nodes.Node;
51+
import com.oracle.truffle.api.nodes.NodeCost;
5152

5253
public final class IsBuiltinClassProfile extends Node {
5354
@CompilationFinal private boolean isBuiltinType;
@@ -229,6 +230,11 @@ public static boolean profileClassSlowPath(Object clazz, PythonBuiltinClassType
229230
}
230231
}
231232

233+
@Override
234+
public NodeCost getCost() {
235+
return NodeCost.NONE;
236+
}
237+
232238
@Override
233239
public boolean isAdoptable() {
234240
return adoptable;

0 commit comments

Comments
 (0)