Java Code Examples for proguard.util.ArrayUtil#ensureArraySize()

The following examples show how to use proguard.util.ArrayUtil#ensureArraySize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackSizeComputer.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute)
{
    if (DEBUG)
    {
        System.out.println("StackSizeComputer: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz));
    }

    int codeLength = codeAttribute.u4codeLength;

    // Make sure the global arrays are sufficiently large.
    evaluated        = ArrayUtil.ensureArraySize(evaluated, codeLength, false);
    stackSizesBefore = ArrayUtil.ensureArraySize(stackSizesBefore, codeLength, 0);
    stackSizesAfter  = ArrayUtil.ensureArraySize(stackSizesAfter,  codeLength, 0);

    // The initial stack is always empty.
    stackSize    = 0;
    maxStackSize = 0;

    // Evaluate the instruction block starting at the entry point of the method.
    evaluateInstructionBlock(clazz, method, codeAttribute, 0);

    // Evaluate the exception handlers.
    codeAttribute.exceptionsAccept(clazz, method, this);
}
 
Example 2
Source File: StackSizeComputer.java    From bazel with Apache License 2.0 6 votes vote down vote up
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute)
{
    if (DEBUG)
    {
        System.out.println("StackSizeComputer: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz));
    }

    int codeLength = codeAttribute.u4codeLength;

    // Make sure the global arrays are sufficiently large.
    evaluated        = ArrayUtil.ensureArraySize(evaluated, codeLength, false);
    stackSizesBefore = ArrayUtil.ensureArraySize(stackSizesBefore, codeLength, 0);
    stackSizesAfter  = ArrayUtil.ensureArraySize(stackSizesAfter,  codeLength, 0);

    // The initial stack is always empty.
    stackSize    = 0;
    maxStackSize = 0;

    // Evaluate the instruction block starting at the entry point of the method.
    evaluateInstructionBlock(clazz, method, codeAttribute, 0);

    // Evaluate the exception handlers.
    codeAttribute.exceptionsAccept(clazz, method, this);
}
 
Example 3
Source File: ReferenceEscapeChecker.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
{
    // Evaluate the method.
    if (runPartialEvaluator)
    {
        partialEvaluator.visitCodeAttribute(clazz, method, codeAttribute);
    }

    int codeLength = codeAttribute.u4codeLength;

    // Initialize the global arrays.
    instanceEscaping = ArrayUtil.ensureArraySize(instanceEscaping, codeLength, false);
    instanceReturned = ArrayUtil.ensureArraySize(instanceReturned, codeLength, false);
    instanceModified = ArrayUtil.ensureArraySize(instanceModified, codeLength, false);
    externalInstance = ArrayUtil.ensureArraySize(externalInstance, codeLength, false);

    // Mark the parameters and instances that are escaping from the code.
    codeAttribute.instructionsAccept(clazz, method, partialEvaluator.tracedInstructionFilter(this));

    if (DEBUG)
    {
        System.out.println();
        System.out.println("ReferenceEscapeChecker: ["+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)+"]");

        for (int index = 0; index < codeLength; index++)
        {
            if (partialEvaluator.isInstruction(index))
            {
                System.out.println("  " +
                                   (instanceEscaping[index] ? 'E' : '.') +
                                   (instanceReturned[index] ? 'R' : '.') +
                                   (instanceModified[index] ? 'M' : '.') +
                                   (externalInstance[index] ? 'X' : '.') +
                                   ' ' +
                                   InstructionFactory.create(codeAttribute.code, index).toString(index));
            }
        }
    }
}
 
Example 4
Source File: InstructionUsageMarker.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initializes the necessary data structure.
 */
private void initializeNecessary(CodeAttribute codeAttribute)
{
    int codeLength = codeAttribute.u4codeLength;
    int maxLocals  = codeAttribute.u2maxLocals;
    int maxStack   = codeAttribute.u2maxStack;

    // Create new arrays for storing information at each instruction offset.
    reverseDependencies =
        ArrayUtil.ensureArraySize(reverseDependencies, codeLength, null);

    if (stacksNecessaryAfter.length    < codeLength ||
        stacksNecessaryAfter[0].length < maxStack)
    {
        stacksNecessaryAfter = new boolean[codeLength][maxStack];
    }
    else
    {
        for (int offset = 0; offset < codeLength; offset++)
        {
            Arrays.fill(stacksNecessaryAfter[offset], 0, maxStack, false);
        }
    }

    if (stacksUnwantedBefore.length    < codeLength ||
        stacksUnwantedBefore[0].length < maxStack)
    {
        stacksUnwantedBefore = new boolean[codeLength][maxStack];
    }
    else
    {
        for (int offset = 0; offset < codeLength; offset++)
        {
            Arrays.fill(stacksUnwantedBefore[offset], 0, maxStack, false);
        }
    }

    instructionsNecessary =
        ArrayUtil.ensureArraySize(instructionsNecessary,
                                  codeLength,
                                  false);

    extraPushPopInstructionsNecessary =
        ArrayUtil.ensureArraySize(extraPushPopInstructionsNecessary,
                                  codeLength,
                                  false);
}