[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] last "bug"

From: Laurent Michel
Subject: [Lightning] last "bug"
Date: Wed, 11 Jun 2008 14:21:13 -0400

Well, it is not really a bug. 

I sometimes emit a jit_movi_p instruction that I later backpatch with the actual value I wish to move into the register. To this end I do something like:

Adr  toPatch =  jit_movi_p(JIT_R0,0);

and later on I patch "toPatch".

This worked fine in my 1.1.2 version of lightning. The macro being defined as:

#define jit_movi_p(d, is) (MOVLir((is), (d)), _jit.x.pc)

where the instruction always assumes a 32-bit wide operand. The macro was rewritten in the head version to:

#define jit_movi_p(d, is)       (jit_movi_l(d, ((long)(is))), _jit.x.pc)

and that does not work. The cast of (is) does not help. The test inside the movi_l basically determines how many bits one needs to store the literal is and issues a suitably chosen opcode to reduce the number of bytes. In my case, since I back-patch, I will end up putting a real 32-bit wide operand during the patching. But since it emitted with the assumption that the operand would fit in 16 bits, it basically overwrite the next two bytes (the next instruction).

I fixed it on my end by doing:

Adr  toPatch =  jit_movi_p(JIT_R0,0x7fffffff);

which forces the emission of a 32-bit wide move. Still, I thought I'd report it as this is a robustness issue. Since the movi_p is already a variant of movi_l that returns the instruction address with the intent to patch it, maybe it would be safer/more robust to always emit an instruction of the maximum operand size.



Attachment: smime.p7s
Description: S/MIME cryptographic signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]