Skip to content

Commit 6cbb163

Browse files
committed
Adjust library limit for BuiltinConstructors
1 parent 9528681 commit 6cbb163

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public Object bytearray(Object cls, @SuppressWarnings("unused") PNone source, @S
268268

269269
@Specialization(guards = {"lib.canBeIndex(capObj)", "isNoValue(encoding)", "isNoValue(errors)"})
270270
public Object bytearray(VirtualFrame frame, Object cls, Object capObj, @SuppressWarnings("unused") PNone encoding, @SuppressWarnings("unused") PNone errors,
271-
@SuppressWarnings("unused") @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
271+
@SuppressWarnings("unused") @CachedLibrary(limit = "5") PythonObjectLibrary lib) {
272272
int cap = lib.asSizeWithState(capObj, PArguments.getThreadState(frame));
273273
return create(cls, BytesUtils.fromSize(getCore(), cap));
274274
}
@@ -302,13 +302,13 @@ public Object bytearray(Object cls, PByteArray iterable, @SuppressWarnings("unus
302302
return create(cls, (byte[]) ((ByteSequenceStorage) iterable.getSequenceStorage()).getCopyOfInternalArrayObject());
303303
}
304304

305-
@Specialization(guards = {"!lib.canBeIndex(iterable)", "!isNoValue(iterable)", "isNoValue(encoding)", "isNoValue(errors)"}, limit = "1")
305+
@Specialization(guards = {"!lib.canBeIndex(iterable)", "!isNoValue(iterable)", "isNoValue(encoding)", "isNoValue(errors)"})
306306
public Object bytearray(VirtualFrame frame, Object cls, Object iterable, @SuppressWarnings("unused") PNone encoding, @SuppressWarnings("unused") PNone errors,
307307
@Cached("create()") GetIteratorNode getIteratorNode,
308308
@Cached("create()") GetNextNode getNextNode,
309309
@Cached("create()") IsBuiltinClassProfile stopIterationProfile,
310310
@Cached("create()") CastToByteNode castToByteNode,
311-
@SuppressWarnings("unused") @CachedLibrary("iterable") PythonObjectLibrary lib) {
311+
@SuppressWarnings("unused") @CachedLibrary(limit = "3") PythonObjectLibrary lib) {
312312

313313
Object it = getIteratorNode.executeWith(frame, iterable);
314314
byte[] arr = new byte[16];
@@ -887,7 +887,7 @@ public PythonObject reversed(Object cls, String value) {
887887
return factory().createStringReverseIterator(cls, value);
888888
}
889889

890-
@Specialization(guards = {"!isString(sequence)", "!isPRange(sequence)"}, limit = "3")
890+
@Specialization(guards = {"!isString(sequence)", "!isPRange(sequence)"}, limit = "4")
891891
public Object reversed(VirtualFrame frame, Object cls, Object sequence,
892892
@CachedLibrary("sequence") PythonObjectLibrary lib,
893893
@Cached("create(__REVERSED__)") LookupSpecialMethodNode reversedNode,
@@ -1602,7 +1602,7 @@ Object fail(Object cls, Object arg, Object base) {
16021602
throw raise(TypeError, ErrorMessages.INT_CANT_CONVERT_STRING_WITH_EXPL_BASE);
16031603
}
16041604

1605-
@Specialization(guards = {"isNoValue(base)", "!isNoValue(obj)", "!isHandledType(obj)"}, limit = "2")
1605+
@Specialization(guards = {"isNoValue(base)", "!isNoValue(obj)", "!isHandledType(obj)"}, limit = "5")
16061606
Object createIntGeneric(VirtualFrame frame, Object cls, Object obj, @SuppressWarnings("unused") PNone base,
16071607
@CachedLibrary("obj") PythonObjectLibrary lib) {
16081608
// This method (together with callInt and callIndex) reflects the logic of PyNumber_Long
@@ -3105,20 +3105,19 @@ protected static boolean isPFrame(Object obj) {
31053105
public abstract static class CodeTypeNode extends PythonBuiltinNode {
31063106

31073107
// limit is 2 because we expect PBytes or String
3108-
@Specialization(guards = {"codestringBufferLib.isBuffer(codestring)", "lnotabBufferLib.isBuffer(lnotab)"}, limit = "2", rewriteOn = UnsupportedMessageException.class)
3108+
@Specialization(guards = {"bufferLib.isBuffer(codestring)", "bufferLib.isBuffer(lnotab)"}, rewriteOn = UnsupportedMessageException.class)
31093109
Object call(VirtualFrame frame, Object cls, int argcount,
31103110
int posonlyargcount, int kwonlyargcount,
31113111
int nlocals, int stacksize, int flags,
31123112
Object codestring, PTuple constants, PTuple names,
31133113
PTuple varnames, Object filename, Object name,
31143114
int firstlineno, Object lnotab,
31153115
PTuple freevars, PTuple cellvars,
3116-
@CachedLibrary("codestring") PythonObjectLibrary codestringBufferLib,
3117-
@CachedLibrary("lnotab") PythonObjectLibrary lnotabBufferLib,
3116+
@CachedLibrary(limit = "2") PythonObjectLibrary bufferLib,
31183117
@Cached CodeNodes.CreateCodeNode createCodeNode,
31193118
@Cached GetObjectArrayNode getObjectArrayNode) throws UnsupportedMessageException {
3120-
byte[] codeBytes = codestringBufferLib.getBufferBytes(codestring);
3121-
byte[] lnotabBytes = lnotabBufferLib.getBufferBytes(lnotab);
3119+
byte[] codeBytes = bufferLib.getBufferBytes(codestring);
3120+
byte[] lnotabBytes = bufferLib.getBufferBytes(lnotab);
31223121

31233122
Object[] constantsArr = getObjectArrayNode.execute(constants);
31243123
Object[] namesArr = getObjectArrayNode.execute(names);
@@ -3134,21 +3133,20 @@ Object call(VirtualFrame frame, Object cls, int argcount,
31343133
lnotabBytes);
31353134
}
31363135

3137-
@Specialization(guards = {"codestringBufferLib.isBuffer(codestring)", "lnotabBufferLib.isBuffer(lnotab)"}, limit = "2", rewriteOn = UnsupportedMessageException.class)
3136+
@Specialization(guards = {"bufferLib.isBuffer(codestring)", "bufferLib.isBuffer(lnotab)"}, rewriteOn = UnsupportedMessageException.class)
31383137
Object call(VirtualFrame frame, Object cls, Object argcount,
31393138
int posonlyargcount, Object kwonlyargcount,
31403139
Object nlocals, Object stacksize, Object flags,
31413140
Object codestring, PTuple constants, PTuple names,
31423141
PTuple varnames, Object filename, Object name,
31433142
Object firstlineno, Object lnotab,
31443143
PTuple freevars, PTuple cellvars,
3145-
@CachedLibrary("codestring") PythonObjectLibrary codestringBufferLib,
3146-
@CachedLibrary("lnotab") PythonObjectLibrary lnotabBufferLib,
3144+
@CachedLibrary(limit = "2") PythonObjectLibrary bufferLib,
31473145
@CachedLibrary(limit = "2") PythonObjectLibrary objectLibrary,
31483146
@Cached CodeNodes.CreateCodeNode createCodeNode,
31493147
@Cached GetObjectArrayNode getObjectArrayNode) throws UnsupportedMessageException {
3150-
byte[] codeBytes = codestringBufferLib.getBufferBytes(codestring);
3151-
byte[] lnotabBytes = lnotabBufferLib.getBufferBytes(lnotab);
3148+
byte[] codeBytes = bufferLib.getBufferBytes(codestring);
3149+
byte[] lnotabBytes = bufferLib.getBufferBytes(lnotab);
31523150

31533151
Object[] constantsArr = getObjectArrayNode.execute(constants);
31543152
Object[] namesArr = getObjectArrayNode.execute(names);

0 commit comments

Comments
 (0)