@Nonnull private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location, int[] codeAddressToIndex, @Nonnull Instruction31t instruction) { int codeAddress = location.getCodeAddress(); Label newLabel; if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) { // if it's a sparse switch or packed switch newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } else { newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } return new BuilderInstruction31t( instruction.getOpcode(), instruction.getRegisterA(), newLabel); }
@Override protected BuilderInstruction getRealInsn0(LabelAssigner assigner) { return new BuilderInstruction31t(opc, (short) getRegA().getNumber(), assigner.getOrCreateLabel(payload)); }
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction31t(opcode, regA, label_ref173));
@Nonnull private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location , int[] codeAddressToIndex, @Nonnull Instruction31t instruction) { int codeAddress = location.getCodeAddress(); Label newLabel; if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) { // if it's a sparse switch or packed switch newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } else { newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } return new BuilderInstruction31t( instruction.getOpcode(), instruction.getRegisterA(), newLabel); }
@Nonnull private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location, int[] codeAddressToIndex, @Nonnull Instruction31t instruction) { int codeAddress = location.getCodeAddress(); Label newLabel; if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) { // if it's a sparse switch or packed switch newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } else { newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } return new BuilderInstruction31t( instruction.getOpcode(), instruction.getRegisterA(), newLabel); }
@Nonnull private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location , int[] codeAddressToIndex, @Nonnull Instruction31t instruction) { int codeAddress = location.getCodeAddress(); Label newLabel; if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) { // if it's a sparse switch or packed switch newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } else { newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } return new BuilderInstruction31t( instruction.getOpcode(), instruction.getRegisterA(), newLabel); }
@Nonnull private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location , int[] codeAddressToIndex, @Nonnull Instruction31t instruction) { int codeAddress = location.getCodeAddress(); Label newLabel; if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) { // if it's a sparse switch or packed switch newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } else { newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset()); } return new BuilderInstruction31t( instruction.getOpcode(), instruction.getRegisterA(), newLabel); }
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction31t(opcode, regA, label_ref159));
method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction31t(opcode, regA, label_ref173));
@Test public void testPayloadAlignmentAddNopWithReferent() { MethodImplementationBuilder implBuilder = new MethodImplementationBuilder(10); Label label = implBuilder.getLabel("array_payload"); implBuilder.addInstruction(new BuilderInstruction31t(Opcode.FILL_ARRAY_DATA, 0, label)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addLabel("array_payload"); implBuilder.addInstruction(new BuilderArrayPayload(4, null)); List<Instruction> instructions = Lists.newArrayList(implBuilder.getMethodImplementation().getInstructions()); checkInstructions(instructions, new Opcode[]{Opcode.FILL_ARRAY_DATA, Opcode.MOVE, Opcode.MOVE, Opcode.MOVE, Opcode.MOVE, Opcode.NOP, Opcode.ARRAY_PAYLOAD}); Instruction31t referent = (Instruction31t)instructions.get(0); Assert.assertEquals(8, referent.getCodeOffset()); }
@Test public void testPayloadAlignmentRemoveNopWithReferent() { MethodImplementationBuilder implBuilder = new MethodImplementationBuilder(10); Label label = implBuilder.getLabel("array_payload"); implBuilder.addInstruction(new BuilderInstruction31t(Opcode.FILL_ARRAY_DATA, 0, label)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction12x(Opcode.MOVE, 0, 0)); implBuilder.addInstruction(new BuilderInstruction10x(Opcode.NOP)); implBuilder.addLabel("array_payload"); implBuilder.addInstruction(new BuilderArrayPayload(4, null)); List<Instruction> instructions = Lists.newArrayList(implBuilder.getMethodImplementation().getInstructions()); checkInstructions(instructions, new Opcode[]{Opcode.FILL_ARRAY_DATA, Opcode.MOVE, Opcode.MOVE, Opcode.MOVE, Opcode.ARRAY_PAYLOAD}); Instruction31t referent = (Instruction31t)instructions.get(0); Assert.assertEquals(6, referent.getCodeOffset()); }
implBuilder.addInstruction(new BuilderInstruction10x(Opcode.NOP)); implBuilder.addInstruction(new BuilderInstruction31t(Opcode.PACKED_SWITCH, 0, implBuilder.getLabel("switch_payload")));
implBuilder.addInstruction(new BuilderInstruction10x(Opcode.NOP)); implBuilder.addInstruction(new BuilderInstruction31t(Opcode.SPARSE_SWITCH, 0, implBuilder.getLabel("switch_payload")));