Package org.objectweb.asm
Class ComputeLimits
java.lang.Object
org.objectweb.asm.ComputeLimits
Memory and time limits for potentially costly algorithms.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe size in bytes of the header of an array (class pointer, array length, etc).private intThe remaining number of bytes which can be allocated by the algorithm using these limits.private longThe remaining number of "operations" which can be done by the algorithm using these limits. -
Constructor Summary
ConstructorsConstructorDescriptionComputeLimits(int maxBytes, long maxOperations) Constructs new compute limits.ComputeLimits(ComputeLimits limits) Constructs a copy of the given compute limits. -
Method Summary
Modifier and TypeMethodDescription(package private) int[]checkNewIntArray(int length) Creates a new int array if this does not exceed the memory limits.(package private) voidcheckNewOperations(int numOperations) Checks if some operations can be done without exceeding the limit.
-
Field Details
-
ARRAY_HEADER_BYTES
private static final int ARRAY_HEADER_BYTESThe size in bytes of the header of an array (class pointer, array length, etc).- See Also:
-
remainingBytes
private int remainingBytesThe remaining number of bytes which can be allocated by the algorithm using these limits. -
remainingOperations
private long remainingOperationsThe remaining number of "operations" which can be done by the algorithm using these limits.
-
-
Constructor Details
-
ComputeLimits
ComputeLimits(int maxBytes, long maxOperations) Constructs new compute limits.- Parameters:
maxBytes- the maximum number of bytes which can be allocated.maxOperations- the maximum number of "operations" which can be done. The definition of an operation depends on the algorithms using these limits. The number of operations done by an algorithm should be approximatively proportional to its runtime (and deterministic).
-
ComputeLimits
ComputeLimits(ComputeLimits limits) Constructs a copy of the given compute limits.- Parameters:
limits- the limits to copy.
-
-
Method Details
-
checkNewIntArray
int[] checkNewIntArray(int length) Creates a new int array if this does not exceed the memory limits.- Parameters:
length- the array length (number of elements).- Returns:
- the newly created array.
- Throws:
LimitExceededException- if the memory limit is exceeded.
-
checkNewOperations
void checkNewOperations(int numOperations) Checks if some operations can be done without exceeding the limit.- Parameters:
numOperations- the number of operations to perform.- Throws:
LimitExceededException- if the operations limit is exceeded.
-