~ubuntu-branches/ubuntu/wily/proguard/wily

« back to all changes in this revision

Viewing changes to src/proguard/preverify/CodeSubroutineInliner.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-04-10 13:58:11 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20140410135811-ddwzt2avu94rnolt
Tags: 4.11-1
* Team upload.
* New upstream release
* Removed the non-free documentation from the package (Closes: #719706)
* Removed the pre-built jars from the upstream tarball
* debian/control:
  - The package is now co-maintained with the Java Team
  - Standards-Version updated to 3.9.5 (no changes)
  - Added the Vcs-* fields
  - Added the Homepage field
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3
3
 *             of Java bytecode.
4
4
 *
5
 
 * Copyright (c) 2002-2012 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
45
45
    //*
46
46
    private static final boolean DEBUG = false;
47
47
    /*/
48
 
    private static       boolean DEBUG = true;
 
48
    private static       boolean DEBUG = System.getProperty("csi") != null;
49
49
    //*/
50
50
 
51
51
 
52
52
    private final BranchTargetFinder    branchTargetFinder    = new BranchTargetFinder();
53
 
    private final CodeAttributeComposer codeAttributeComposer = new CodeAttributeComposer(true);
 
53
    private final CodeAttributeComposer codeAttributeComposer = new CodeAttributeComposer(true, true);
54
54
 
55
55
    private ExceptionInfoVisitor subroutineExceptionInliner = this;
56
56
    private int                  clipStart                  = 0;
98
98
        branchTargetFinder.visitCodeAttribute(clazz, method, codeAttribute);
99
99
 
100
100
        // Don't bother if there aren't any subroutines anyway.
101
 
        if (!containsSubroutines(codeAttribute))
 
101
        if (!branchTargetFinder.containsSubroutines())
102
102
        {
103
103
            return;
104
104
        }
162
162
 
163
163
 
164
164
    /**
165
 
     * Returns whether the given code attribute contains any subroutines.
166
 
     */
167
 
    private boolean containsSubroutines(CodeAttribute codeAttribute)
168
 
    {
169
 
        for (int offset = 0; offset < codeAttribute.u4codeLength; offset++)
170
 
        {
171
 
            if (branchTargetFinder.isSubroutineInvocation(offset))
172
 
            {
173
 
                return true;
174
 
            }
175
 
        }
176
 
 
177
 
        return false;
178
 
    }
179
 
 
180
 
 
181
 
    /**
182
165
     * Appends the specified subroutine.
183
166
     */
184
167
    private void inlineSubroutine(Clazz         clazz,
246
229
    public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
247
230
    {
248
231
        // Append the instruction.
249
 
        codeAttributeComposer.appendInstruction(offset, instruction.shrink());
 
232
        codeAttributeComposer.appendInstruction(offset, instruction);
250
233
    }
251
234
 
252
235
 
276
259
                // Replace the instruction by a branch.
277
260
                Instruction replacementInstruction =
278
261
                    new BranchInstruction(InstructionConstants.OP_GOTO,
279
 
                                          branchTargetFinder.subroutineEnd(offset) - offset).shrink();
 
262
                                          branchTargetFinder.subroutineEnd(offset) - offset);
280
263
 
281
264
                codeAttributeComposer.appendInstruction(offset, replacementInstruction);
282
265
            }
332
315
                // Replace the subroutine invocation by a simple branch.
333
316
                Instruction replacementInstruction =
334
317
                    new BranchInstruction(InstructionConstants.OP_GOTO,
335
 
                                          branchOffset).shrink();
 
318
                                          branchOffset);
336
319
 
337
320
                codeAttributeComposer.appendInstruction(offset, replacementInstruction);
338
321
            }