Remove unused parameters
This commit is contained in:
@@ -36,11 +36,113 @@ public abstract class Instruction
|
||||
i.from.remove(this);
|
||||
jump.clear();
|
||||
|
||||
assert from.isEmpty();
|
||||
Exceptions exceptions = instructions.getCode().getExceptions();
|
||||
for (Exception e : exceptions.getExceptions())
|
||||
{
|
||||
assert this != e.getStart();
|
||||
assert this != e.getEnd();
|
||||
assert this != e.getHandler();
|
||||
}
|
||||
|
||||
assert from.isEmpty(); // because this is empty no jumping instructions point here
|
||||
assert exce.isEmpty();
|
||||
}
|
||||
|
||||
public void write(DataOutputStream out, int pc) throws IOException
|
||||
public void replace(Instruction other)
|
||||
{
|
||||
List<Instruction> ins = instructions.getInstructions();
|
||||
|
||||
assert this != other;
|
||||
assert ins.contains(this);
|
||||
assert !ins.contains(other);
|
||||
|
||||
// XXX this corrupts the block graph. we shouldn't keep it around once we are done using it,
|
||||
// too much stuff to keep updated.
|
||||
this.block = null;
|
||||
|
||||
// XXX instructions which hold references to instructions !
|
||||
for (Instruction i : ins)
|
||||
{
|
||||
i.replace(this, other);
|
||||
}
|
||||
|
||||
// update instructions which jump here to jump to the new instruction
|
||||
for (Instruction i : from)
|
||||
{
|
||||
assert i.jump.contains(this);
|
||||
assert !i.jump.contains(other);
|
||||
|
||||
i.jump.remove(this);
|
||||
i.jump.add(other);
|
||||
}
|
||||
from.clear();
|
||||
|
||||
// move jumps over
|
||||
for (Instruction i : jump)
|
||||
{
|
||||
assert i.from.contains(this);
|
||||
assert !i.from.contains(other);
|
||||
|
||||
i.from.remove(this);
|
||||
i.from.add(other);
|
||||
}
|
||||
other.jump = new ArrayList<>(this.jump);
|
||||
jump.clear();
|
||||
|
||||
Exceptions exceptions = instructions.getCode().getExceptions();
|
||||
for (Exception e : exceptions.getExceptions())
|
||||
{
|
||||
e.replace(this, other);
|
||||
}
|
||||
assert exce.isEmpty();
|
||||
|
||||
// replace ins
|
||||
int index = ins.indexOf(this);
|
||||
ins.remove(this);
|
||||
ins.add(index, other);
|
||||
}
|
||||
|
||||
public boolean removeStack()
|
||||
{
|
||||
block = null;
|
||||
|
||||
// update instructions which jump here to jump to the next instruction
|
||||
List<Instruction> ins = instructions.getInstructions();
|
||||
Instruction next = ins.get(ins.indexOf(this) + 1);
|
||||
assert next != null;
|
||||
|
||||
for (Instruction i : ins)
|
||||
{
|
||||
i.replace(this, next);
|
||||
}
|
||||
|
||||
for (Instruction i : from)
|
||||
{
|
||||
assert i.jump.contains(this);
|
||||
|
||||
i.jump.remove(this);
|
||||
|
||||
i.jump.add(next);
|
||||
next.from.add(i);
|
||||
}
|
||||
from.clear();
|
||||
|
||||
this.getInstructions().remove(this); // calls remove()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// resolve jumps
|
||||
public void resolve()
|
||||
{
|
||||
}
|
||||
|
||||
// initialize constant pool to see if instruction u/g is required
|
||||
public void prime()
|
||||
{
|
||||
}
|
||||
|
||||
public void write(DataOutputStream out) throws IOException
|
||||
{
|
||||
out.writeByte(type.getCode());
|
||||
}
|
||||
@@ -64,6 +166,11 @@ public abstract class Instruction
|
||||
{
|
||||
return pc;
|
||||
}
|
||||
|
||||
public void setPc(int pc)
|
||||
{
|
||||
this.pc = pc;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
@@ -75,18 +182,13 @@ public abstract class Instruction
|
||||
return type.getName() + " at pc " + frame.getPc() + " in " + frame.getMethod().getName() + " " + frame.getMethod().getDescriptor() + " class " + frame.getMethod().getCode().getAttributes().getClassFile().getName();
|
||||
}
|
||||
|
||||
protected void addJump(int offset)
|
||||
protected void addJump(Instruction to)
|
||||
{
|
||||
Instruction other = instructions.findInstruction(pc + offset);
|
||||
assert other != null;
|
||||
assert other != this;
|
||||
assert to != null;
|
||||
assert to != this;
|
||||
|
||||
this.jump.add(other);
|
||||
other.from.add(this);
|
||||
}
|
||||
|
||||
public void buildJumpGraph()
|
||||
{
|
||||
this.jump.add(to);
|
||||
to.from.add(this);
|
||||
}
|
||||
|
||||
public void buildInstructionGraph()
|
||||
@@ -104,4 +206,8 @@ public abstract class Instruction
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void replace(Instruction oldi, Instruction newi)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user