dotgnu-libjit
[Top][All Lists]
Advanced

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

[Dotgnu-libjit] Constant folding


From: Alexey Galakhov
Subject: [Dotgnu-libjit] Constant folding
Date: Fri, 22 Feb 2013 14:30:29 +0400
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

Hello,

I recently discovered that libjit does not fold constants. Consider the
following:

jit_value_t a = jit_value_create_nint_constant(func, jit_type_int, 2);
jit_value_t b = jit_value_create_nint_constant(func, jit_type_int, 3);
jit_value_t x = jit_insn_add(func, a, b);
jit_insn_return(func, x);

After compiling, the jit_dump_function() prints the following:

b777203d:       55                      push   %ebp
b777203e:       8b ec                   mov    %esp,%ebp
b7772040:       b8 02 00 00 00          mov    $0x2,%eax
b7772045:       05 03 00 00 00          add    $0x3,%eax
b777204a:       5d                      pop    %ebp
b777204b:       c3                      ret

I found that the constant folding seems to be done using
_jit_opcode_apply() function from jit-opcode-apply.c. However, it seems
not to be used at all:

$ grep -rI _jit_opcode_apply
jit/jit-internal.h:_jit_opcode_apply(jit_function_t func, jit_uint
opcode, jit_type_t dest_type,
jit/jit-opcode-apply.c: * This is checked on entry of the public
_jit_opcode_apply function.
jit/jit-opcode-apply.c:_jit_opcode_apply(jit_function_t func, jit_uint
opcode, jit_type_t dest_type,

Why?..

My version of libjit is the most recent git one.

Regards,
Alex



reply via email to

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