dotgnu-libjit
[Top][All Lists]
Advanced

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

Re: [Dotgnu-libjit] How to check the value of a boolean variable.


From: Klaus Treichel
Subject: Re: [Dotgnu-libjit] How to check the value of a boolean variable.
Date: Wed, 13 Aug 2008 21:36:42 +0200

Am Montag, den 11.08.2008, 09:56 +0200 schrieb GARCIA DE SORIA LUCENA,
JUAN JESUS:
> Hi everyone.
> 
> 
> I've added conditional expression support to the project we are using libjit 
> for, and I hit several stumbling blocks.
> 
> My implementation has several specializations depending on the expression 
> data type. When a complex type is involved, the compiled code delegates on a 
> native C++ function to test a condition value (in order to check whether it's 
> true or false). When the data type is simple enough, it's checked directly by 
> libjit-generated code.
> 
> Just to put everything in context, we're using a MinGW-compiled libjit from 
> inside a MSVC 2005 project in a Win32 host.
> 
> 
> 
> In the first case I originally used a native function that would return a 
> bool with the condition value. I used a jit_type_sys_bool as the returned 
> type in the native function signature, and tried to feed it to 
> jit_insn_branch_if and/or jit_insn_branch_if_not directly.
> 
> It didn't work, and when looking at the resulting code, I could see that the 
> native function was returning the boolean as a ubyte in register AL, while 
> the generated code was checking its value with (IIRC) an "OR EAX, EAX" 
> opcode, which would fail since the upper bytes of EAX wouldn't be clean. The 
> generated code did not extend the value to 32 bits before the test, nor would 
> it use a byte-sized comparison opcode.
> 
> I tried to follow the code a bit to see whether I was using libjit correctly. 
> I tried an equality comparison with a boolean constant, and it seemed to fail 
> too (in the same way, IIRC).
> 
> I looked at jit_insn_branch_if() in jit-insn.c, and it uses 
> jit_type_promote_int() of jit-type.c to check for a "standard int type" to 
> feed to the comparison opcodes (in this case I suppose that jit_type_uint 
> with JIT_OP_BR_ITRUE ended up being used). I see there that the value should 
> be converted to the correct type by the line:
> 
Did you ckeck with a jit_type_sbyte or jit_type_byte return type?

I don't know to which type jit_type_sys_bool is mapped.

Klaus

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

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