Compare:
void Assembler::cmpq(Address dst, Register src) {
InstructionMark im(this);
emit_int16(get_prefixq(dst, src), 0x3B);
emit_operand(src, dst);
}
void Assembler::cmpq(Register dst, Address src) {
InstructionMark im(this);
emit_int16(get_prefixq(src, dst), 0x3B);
emit_operand(dst, src);
}
They use the same opcode -- 0x3B, which is for "CMP r, r/m". While cmpq(Address,Register) actually should be using 0x39 for "CMP r/m, r". I also suspect they emit basically the same instruction, because the get_prefixq and emit_operand order is irrelevant.
AFAIU, it does not break horribly, because the cmpq(Address,Register) is not used anywhere except the new code in MacroAssembler::safepoint_poll, added by JDK-8253180. This was found by Zhengyu, when he was trying to enable that new code on x86_32.
We should either encode this cmpq properly, or remove cmpq(Address,Register) and use the other one, cmpq(Register,Address) consistently.