Instruction getting wrongly transformed.
Problem:-
java.lang.IllegalArgumentException: The number 28 can't be held in 4 bits !
at
org.ow2.asmdex.instruction.Instruction.test4BitsLimit(Instruction.java:150)
at
org.ow2.asmdex.instruction.Instruction.test4BitsLimit(Instruction.java:176)
at
org.ow2.asmdex.instruction.InstructionFormat35C.<init>
(InstructionFormat35C.java:170)
InstructionFormat35C in asmdex source code:-
public InstructionFormat35C(int opcode, String type, int[] registers) {
super(opcode);
this.type = type;
this.registers = registers;
Instruction.test4BitsLimit(registers);
}
Registers-> [28, 29]
test4BitsLimit(...) throws up since it expects registers in the range 0..15
Any idea why the registers are out of bound in the above case?
From Pierre:-
The mistake is in InstructionEncoder.encodeMultiANewArrayInsn
The main difference with method calls instruction is that the visitor does not
have the opcode as argument. So it does not know
the format it should use.
The test do decide the format is wrong. Not only the number of arguments must
be bellow 5 but the registers must also be bellow
16. A quick and dirty solution is to test the last register.
If it is above 15 then when must use a 3RC.
So the test is now
int l = registers.length;
if (l <= 5 && l > 0 && registers[l - 1] < 16)
If there was another register above 15 but the last is below then the format is
wrong anyway.
I will check later where and how the complete check on the correctness of
indices is done.