dotgnu-libjit
[Top][All Lists]
Advanced

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

Re: [Dotgnu-libjit] using Libjit with boehm collector


From: Tommaso Tagliapietra
Subject: Re: [Dotgnu-libjit] using Libjit with boehm collector
Date: Wed, 26 Sep 2012 15:49:17 +0200

Hi guys.

> > However I've seen that Libjit uses standard malloc/calloc/free and
> > mmap/VirtualAlloc and I don't understand how this can work with the
> > collector.
>
> libjit is using standard malloc... for its own dynamic memory management,
> hence in
> particular it does not require Boehm's GC to be able to work.

Right...I was wrong in explanation. In few words my question is: if
libjit uses standard allocation functions, how can Boehm GC, used for
other parts of my interpreter, scan the memory allocated by libjit?

> I believe you don't have to bother (but I might be wrong). For such static
> references,
> you could also for safety either keep some (indirect) reference on the
> stack
> (i.e. by ha‌ving closures in your langauge which explicitly references
> them)
> or make them explicit GC roots (by calling GC_add_roots on your segment
> of static data containing them).

Yes I think that the use of GC roots will be one solution but I'm
afraid that  registering a lot of new roots may slow down the
collector (and the interpreter then) or reach a situation where
everything is uncollectable and uncontrollable.

Actually the bytecode that I use is an array of opcodes mixed to
integers and addresses. For example:

[0] --> PUSHIR
[1] --> <memory address>
[2] --> CALL, 1
[3] --> JMP
[4] --> <offset>
[5] --> MAKE_CLOSURE
[6] --> <memory address>
[7] --> RETURN

Ok this is not a usefull example, but may explain how function
bytecode is stored. Another thing that I want to avoid is to invoke
the generated function with an extra parameter to pass some local data
array.

Then, if I make a new function with libjit and make a local pointer
variable giving it a fixed address, and this pointer is the unique
reference to an object allocated with Boehm GC, there a way to protect
this object from garbage collection?

In C is similar to:

0xABCDEF01 := the address of an object allocated with Boehm
0x01EFCDAB := another one.


Object *MyFunction(Object *A, Object *B) {
   Object *data = 0xABCDEF01;

   /* ... some code using or not 'data' */

   return 0x01EFCDAB;  // another pointer.
}

My bytecode that simulate MyFunction protect the objects since the
bytecode array is allocated via Boehm. How can I implement this with
libjit?

Every answer is very usefull for me thank you very much. Best regards.

Tommaso.



reply via email to

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