AMD64Assembler.java:jcc

D.Sturm D.Sturm42 at gmail.com
Sun Sep 8 15:33:06 PDT 2013


Hi,
I'm working on an Aarch64 (new 64-bit ARM ISA) backend at the moment and
spend quite a bit of time looking through the two existing backends. The
following looks like a bug to me:

private void jcc(ConditionFlag cc, int jumpTarget, boolean forceDisp32) {
        int shortSize = 2;
        int longSize = 6;
        long disp = jumpTarget - codeBuffer.position();
        [..]
        assert isInt(disp - longSize) : "must be 32bit offset (call4)";

jumpTarget and codeBuffer.position are both ints and the code probably
wants to get the correct offset without integer overflow, but is missing a
cast to long. It then goes on and asserts that disp is an int which right
now is (almost) always true.

On the other hand I'm not sure how it'd be possible for any of the two
values to be negative, so it's probably only unnecessary code.

-Daniel


More information about the graal-dev mailing list