Class ComputeLimits

java.lang.Object
org.objectweb.asm.ComputeLimits

final class ComputeLimits extends Object
Memory and time limits for potentially costly algorithms.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    The size in bytes of the header of an array (class pointer, array length, etc).
    private int
    The remaining number of bytes which can be allocated by the algorithm using these limits.
    private long
    The remaining number of "operations" which can be done by the algorithm using these limits.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ComputeLimits(int maxBytes, long maxOperations)
    Constructs new compute limits.
    Constructs a copy of the given compute limits.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int[]
    checkNewIntArray(int length)
    Creates a new int array if this does not exceed the memory limits.
    (package private) void
    checkNewOperations(int numOperations)
    Checks if some operations can be done without exceeding the limit.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ARRAY_HEADER_BYTES

      private static final int ARRAY_HEADER_BYTES
      The size in bytes of the header of an array (class pointer, array length, etc).
      See Also:
    • remainingBytes

      private int remainingBytes
      The remaining number of bytes which can be allocated by the algorithm using these limits.
    • remainingOperations

      private long remainingOperations
      The 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.