(final int opcode, final int var)
| 906 | } |
| 907 | |
| 908 | @Override |
| 909 | public void visitVarInsn(final int opcode, final int var) { |
| 910 | lastBytecodeOffset = code.length; |
| 911 | // Add the instruction to the bytecode of the method. |
| 912 | if (var < 4 && opcode != Opcodes.RET) { |
| 913 | int optimizedOpcode; |
| 914 | if (opcode < Opcodes.ISTORE) { |
| 915 | optimizedOpcode = Constants.ILOAD_0 + ((opcode - Opcodes.ILOAD) << 2) + var; |
| 916 | } else { |
| 917 | optimizedOpcode = Constants.ISTORE_0 + ((opcode - Opcodes.ISTORE) << 2) + var; |
| 918 | } |
| 919 | code.putByte(optimizedOpcode); |
| 920 | } else if (var >= 256) { |
| 921 | code.putByte(Constants.WIDE).put12(opcode, var); |
| 922 | } else { |
| 923 | code.put11(opcode, var); |
| 924 | } |
| 925 | // If needed, update the maximum stack size and number of locals, and stack map frames. |
| 926 | if (currentBasicBlock != null) { |
| 927 | if (compute == COMPUTE_ALL_FRAMES || compute == COMPUTE_INSERTED_FRAMES) { |
| 928 | currentBasicBlock.frame.execute(opcode, var, null, null); |
| 929 | } else { |
| 930 | if (opcode == Opcodes.RET) { |
| 931 | // No stack size delta. |
| 932 | currentBasicBlock.flags |= Label.FLAG_SUBROUTINE_END; |
| 933 | currentBasicBlock.outputStackSize = (short) relativeStackSize; |
| 934 | endCurrentBasicBlockWithNoSuccessor(); |
| 935 | } else { // xLOAD or xSTORE |
| 936 | int size = relativeStackSize + STACK_SIZE_DELTA[opcode]; |
| 937 | if (size > maxRelativeStackSize) { |
| 938 | maxRelativeStackSize = size; |
| 939 | } |
| 940 | relativeStackSize = size; |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | if (compute != COMPUTE_NOTHING) { |
| 945 | int currentMaxLocals; |
| 946 | if (opcode == Opcodes.LLOAD |
| 947 | || opcode == Opcodes.DLOAD |
| 948 | || opcode == Opcodes.LSTORE |
| 949 | || opcode == Opcodes.DSTORE) { |
| 950 | currentMaxLocals = var + 2; |
| 951 | } else { |
| 952 | currentMaxLocals = var + 1; |
| 953 | } |
| 954 | if (currentMaxLocals > maxLocals) { |
| 955 | maxLocals = currentMaxLocals; |
| 956 | } |
| 957 | } |
| 958 | if (opcode >= Opcodes.ISTORE && compute == COMPUTE_ALL_FRAMES && firstHandler != null) { |
| 959 | // If there are exception handler blocks, each instruction within a handler range is, in |
| 960 | // theory, a basic block (since execution can jump from this instruction to the exception |
| 961 | // handler). As a consequence, the local variable types at the beginning of the handler |
| 962 | // block should be the merge of the local variable types at all the instructions within the |
| 963 | // handler range. However, instead of creating a basic block for each instruction, we can |
| 964 | // get the same result in a more efficient way. Namely, by starting a new basic block after |
| 965 | // each xSTORE instruction, which is what we do here. |
no test coverage detected