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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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<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> predExceptions = new ArrayList<BasicBlock>();
private List<BasicBlock> succExceptions = new ArrayList<BasicBlock>(); private List<BasicBlock> succExceptions = new ArrayList<BasicBlock>();
public BasicBlock() {
}
public BasicBlock(int id) { public BasicBlock(int id) {
this.id = id; this.id = id;
} }
@ -63,11 +59,10 @@ public class BasicBlock implements IGraphNode {
// ***************************************************************************** // *****************************************************************************
public Object clone() { public Object clone() {
BasicBlock block = new BasicBlock(id);
BasicBlock block = new BasicBlock();
block.id = id;
block.setSeq(seq.clone()); block.setSeq(seq.clone());
block.setInstrOldOffsets(new ArrayList<Integer>(instrOldOffsets)); block.instrOldOffsets.addAll(instrOldOffsets);
return block; return block;
} }
@ -220,10 +215,6 @@ public class BasicBlock implements IGraphNode {
return instrOldOffsets; return instrOldOffsets;
} }
public void setInstrOldOffsets(List<Integer> instrInds) {
this.instrOldOffsets = instrInds;
}
public List<? extends IGraphNode> getPredecessors() { public List<? extends IGraphNode> getPredecessors() {
List<BasicBlock> lst = new ArrayList<BasicBlock>(preds); List<BasicBlock> lst = new ArrayList<BasicBlock>(preds);
lst.addAll(predExceptions); lst.addAll(predExceptions);

@ -296,7 +296,7 @@ public class ControlFlowGraph implements CodeConstants {
VBStyleCollection<BasicBlock, Integer> col = new VBStyleCollection<BasicBlock, Integer>(); VBStyleCollection<BasicBlock, Integer> col = new VBStyleCollection<BasicBlock, Integer>();
InstructionSequence currseq = null; InstructionSequence currseq = null;
ArrayList<Integer> lstOffs = null; List<Integer> lstOffs = null;
int len = startblock.length; int len = startblock.length;
short counter = 0; short counter = 0;
@ -306,14 +306,11 @@ public class ControlFlowGraph implements CodeConstants {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (startblock[i] == 1) { if (startblock[i] == 1) {
currentBlock = new BasicBlock(); currentBlock = new BasicBlock(++counter);
currentBlock.id = ++counter;
currseq = new SimpleInstructionSequence(); currseq = currentBlock.getSeq();
lstOffs = new ArrayList<Integer>(); lstOffs = currentBlock.getInstrOldOffsets();
currentBlock.setSeq(currseq);
currentBlock.setInstrOldOffsets(lstOffs);
col.addWithKey(currentBlock, currentBlock.id); col.addWithKey(currentBlock, currentBlock.id);
blockoffset = instrseq.getOffset(i); blockoffset = instrseq.getOffset(i);
@ -766,9 +763,7 @@ public class ControlFlowGraph implements CodeConstants {
first = blocks.get(0); first = blocks.get(0);
last = new BasicBlock(); last = new BasicBlock(++last_id);
last.id = ++last_id;
last.setSeq(new SimpleInstructionSequence());
for (BasicBlock block : blocks) { for (BasicBlock block : blocks) {
if (block.getSuccs().isEmpty()) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -1038,7 +1038,7 @@ public class FinallyProcessor {
// new empty block // new empty block
BasicBlock emptyblock = new BasicBlock(++graph.last_id); BasicBlock emptyblock = new BasicBlock(++graph.last_id);
emptyblock.setSeq(new SimpleInstructionSequence());
graph.getBlocks().addWithKey(emptyblock, emptyblock.id); graph.getBlocks().addWithKey(emptyblock, emptyblock.id);
// add to ranges if necessary // add to ranges if necessary

Loading…
Cancel
Save