decompiler: create less thrown away objects

master
Egor.Ushakov 9 years ago
parent 917c680276
commit f3af4dd681
  1. 17
      src/org/jetbrains/java/decompiler/code/cfg/BasicBlock.java
  2. 15
      src/org/jetbrains/java/decompiler/code/cfg/ControlFlowGraph.java
  3. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,16 +44,12 @@ public class BasicBlock implements IGraphNode {
private List<BasicBlock> succs = new ArrayList<BasicBlock>();
private List<Integer> instrOldOffsets = new ArrayList<Integer>();
private final List<Integer> instrOldOffsets = new ArrayList<Integer>();
private List<BasicBlock> predExceptions = new ArrayList<BasicBlock>();
private List<BasicBlock> succExceptions = new ArrayList<BasicBlock>();
public BasicBlock() {
}
public BasicBlock(int id) {
this.id = id;
}
@ -63,11 +59,10 @@ public class BasicBlock implements IGraphNode {
// *****************************************************************************
public Object clone() {
BasicBlock block = new BasicBlock(id);
BasicBlock block = new BasicBlock();
block.id = id;
block.setSeq(seq.clone());
block.setInstrOldOffsets(new ArrayList<Integer>(instrOldOffsets));
block.instrOldOffsets.addAll(instrOldOffsets);
return block;
}
@ -220,10 +215,6 @@ public class BasicBlock implements IGraphNode {
return instrOldOffsets;
}
public void setInstrOldOffsets(List<Integer> instrInds) {
this.instrOldOffsets = instrInds;
}
public List<? extends IGraphNode> getPredecessors() {
List<BasicBlock> lst = new ArrayList<BasicBlock>(preds);
lst.addAll(predExceptions);

@ -296,7 +296,7 @@ public class ControlFlowGraph implements CodeConstants {
VBStyleCollection<BasicBlock, Integer> col = new VBStyleCollection<BasicBlock, Integer>();
InstructionSequence currseq = null;
ArrayList<Integer> lstOffs = null;
List<Integer> lstOffs = null;
int len = startblock.length;
short counter = 0;
@ -306,14 +306,11 @@ public class ControlFlowGraph implements CodeConstants {
for (int i = 0; i < len; i++) {
if (startblock[i] == 1) {
currentBlock = new BasicBlock();
currentBlock.id = ++counter;
currentBlock = new BasicBlock(++counter);
currseq = new SimpleInstructionSequence();
lstOffs = new ArrayList<Integer>();
currseq = currentBlock.getSeq();
lstOffs = currentBlock.getInstrOldOffsets();
currentBlock.setSeq(currseq);
currentBlock.setInstrOldOffsets(lstOffs);
col.addWithKey(currentBlock, currentBlock.id);
blockoffset = instrseq.getOffset(i);
@ -766,9 +763,7 @@ public class ControlFlowGraph implements CodeConstants {
first = blocks.get(0);
last = new BasicBlock();
last.id = ++last_id;
last.setSeq(new SimpleInstructionSequence());
last = new BasicBlock(++last_id);
for (BasicBlock block : blocks) {
if (block.getSuccs().isEmpty()) {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1038,7 +1038,7 @@ public class FinallyProcessor {
// new empty block
BasicBlock emptyblock = new BasicBlock(++graph.last_id);
emptyblock.setSeq(new SimpleInstructionSequence());
graph.getBlocks().addWithKey(emptyblock, emptyblock.id);
// add to ranges if necessary

Loading…
Cancel
Save