Code Monkey home page Code Monkey logo

libjit's People

Contributors

ademakov avatar eklitzke avatar kbrow1i avatar m4gnv5 avatar nkoep avatar t3rmin4t0r avatar tcort avatar tromey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

libjit's Issues

Some documented functions are not declared

I noticed that jit_compile, jit_optimize, and jit_compile_entry are documented but not declared in any header. Should they be un-documented (and perhaps renamed), or declared?

Is it possible to change the license of libjit?

Hi,

I was wondering if it is possible to change the license of libjit? It seems that libjit copyright has not been assigned to FSF - is my understanding correct? If so, then are there reasons why the license could not be changed to MIT ?

I think it will make libjit a viable alternative to some other tools.

Regards
Dibyendu

Lightning LibJIT interoperability issue

I encountered a curious issue when using both LibJIT and Lightning in
the same program. The issue occurs on Linux, but not on macOS.
Here is a minimal working example (compile with g++ -g -o test test.C -ljit -llightning):

extern "C"
{
#include <lightning.h>
}

#include "jit/jit.h"

void test()
{
  auto jit_context = jit_context_create();
}

int main()
{
  init_jit(nullptr);
  auto _jit = jit_new_state();
  jit_clear_state();
}

When run this will fail at the lightning jit_clear_state(); call.

debugging details

The program outputs

free(): invalid pointer
Aborted (core dumped)

Running in the debugger I see

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7924859 in __GI_abort () at abort.c:79
#2  0x00007ffff798f3ee in __libc_message
(action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7ab9285 "%s\n") at
../sysdeps/posix/libc_fatal.c:155
#3  0x00007ffff799747c in malloc_printerr
(str=str@entry=0x7ffff7ab74ae "free(): invalid pointer") at
malloc.c:5347
#4  0x00007ffff7998cac in _int_free (av=<optimized out>, p=<optimized
out>, have_lock=0) at malloc.c:4173
#5  0x00007ffff7afc213 in _jit_clear_state (_jit=0x555555559580) at
lightning.c:908
#6  0x00005555555551dd in main () at test.C:17
#5  0x00007ffff7afc213 in _jit_clear_state (_jit=0x555555559580) at
lightning.c:908
908     jit_free((jit_pointer_t *)&_jitc->data.table);
(gdb) print *_jit
$1 = {pc = {uc = 0x0, us = 0x0, ui = 0x0, ul = 0x0, w = 0}, code =
{ptr = 0x0, length = 0}, data = {ptr = 0x0, length = 0}, note = {ptr =
0x0, length = 1}, comp = 0x5555555595d0, user_code = 0, user_data = 0}
(gdb) print *_jit->comp
$2 = {head = 0x0, tail = 0x0, prepare = 0x0, realize = 0, dataset = 0,
done = 0, emit = 0, again = 0, synth = 0, no_data = 0, no_note = 0,
reglen = 40, regarg = 0, regsav = 0, reglive = 0, regmask = 0, code =
{end = 0x0}, data = {ptr = 0x0, table = 0x0, size = 0, count = 0,
offset = 0}, spill = 0x555555559700, gen = 0x555555559850,
  values = 0x555555559900, blocks = {ptr = 0x55555555e480, offset = 0,
length = 16}, patches = {ptr = 0x555555559cd0, offset = 0, length =
1024}, function = 0x0, functions = {ptr = 0x55555555dce0, offset = 0,
length = 16}, pool = {ptr = 0x55555555e3f0, offset = 0, length = 16},
list = 0x0, note = {head = 0x0, tail = 0x0, size = 40,
    name = 0x0, note = 0x0, base = 0x0}}

Note that test() is never called. So just linking to libjit causes the
issue. If the function body is entirely omitted the bug does not occur
(I'm suspecting some linker optimization results in not triggering a
symbol conflict... maybe?)

Throwing exceptions from a libjit function

Hi,
Iโ€™m using libjit to generate code thats calls a c++ function using the jit function jit_insn_call_native.
This c++ function may throw exceptions (e.g. out_of_range exception), I would like to catch this exception in the libjit function we created and return an error code (instead of throwing an exception).

Is this something we can do?

when i run ./mkpdf.sh in libjit-master/doc,i got this issue down below,how can i fix?

root@VM-0-12-debian:~/downloads/libjit-master/doc# ./mkpdf.sh
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdfetex)
restricted \write18 enabled.
entering extended mode
(./libjit.texi (/usr/share/texmf/tex/texinfo/texinfo.tex
Loading texinfo [version 2018-01-09.11]: pdf, fonts, markup, glyphs,
page headings, tables, conditionals, indexing, sectioning, toc, environments,
defuns, macros, cross references, insertions, localization, formatting,
and turning on texinfo input format.) [1{/var/lib/texmf/fonts/map/pdftex/updmap
/pdftex.map}]
Writing index file libjit.cp
Chapter 1 (/root/downloads/libjit-master/doc/libjit.aux) [1] Chapter 2
Chapter 3 [2] [3] l.309: Undefined cross reference Types-snt'. l.309: Undefined cross reference Types-snt'.
l.309: Undefined cross reference Types-pg'. l.349: Undefined cross reference Instructions-snt'.
l.349: Undefined cross reference Instructions-snt'. l.349: Undefined cross reference Instructions-pg'. [4] [5] [6] [7] [8]
[9] l.773: Undefined cross reference C++ Interface-snt'. l.773: Undefined cross reference C++ Interface-snt'.
l.773: Undefined cross reference C++ Interface-pg'. Overfull \hbox (14.94176pt too wide) in paragraph at lines 800--800 []@texttt jit_insn_call(function, "gcd", function, 0, temp_args, 2, JIT_CALL_T AIL);[] | [10] [11] [12] Chapter 4 ./libjit.texi:980: I can't find file libjitext-init.texi'.
@temp ->@input libjitext-init.texi

@includezzz ...and @input #1 }@expandafter }@temp
@popthisfilestack
l.980 @include libjitext-init.texi

(Press Enter to retry, or Control-D to exit)
Please type another input file name:

building libjit.dll

hi, I was looking for an easy jit library, with a C interface, and libjit seems all I could hope for.
But I have no knowledge of the linux dev at all.

I've cloned the sources, installed MinGw, and selected a lot of MSys packages, googled a lot, and I'm stuck.

I first had to downgrade configure.ac from 2.69 to 2.68 (hoping I'm not breaking anything)
from MinGW bash:

$ autoconf-2.68
configure.ac:14: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:108: error: possibly undefined macro: AM_PROG_AR
configure.ac:113: error: possibly undefined macro: AM_PROG_LEX

it shows error but still generated the configure file, then it tried to run

$ configure
configure: error: cannot find install-sh, install.sh, or shtool in build-aux "."
/build-aux

So now I'm here, and I don't know what to do. libjit looks very nice, but feels unfriendly to windows users, and doesn't support win64 :/

Possible memory leak

When executing the following test code:

#include <jit/jit.h>

jit_context_t context = NULL;

void build_function() {
    jit_type_t signature = jit_type_create_signature(jit_abi_cdecl, jit_type_int, NULL, 0, 1);
    jit_function_t func = jit_function_create(context, signature);

    jit_function_compile(func);
    jit_function_to_closure(func);
    //jit_function_abandon(func);
    return;
}

int main() {
    jit_init();
    int c;
    for(c = 0; c < 10000000; ++c) {
        context = jit_context_create();
        jit_context_build_start(context);

        build_function();
        
        jit_context_build_end(context);
        jit_context_destroy(context);
    }
    return 0;
}

Valgrind detects a O(c) memory leak of 64 bytes per cycle. This does not change even when using jit_function_abandon() instead of compiling the function. More careful analysis shows that the block is allocated at jit_calloc(), called from create_complex() (at line 489 of jit-type.c), called in turn from jit_type_create_signature() (at line 612 of jit-type.c). Looks like these blocks are not kept track of by LibJIT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.