[Gc] allocation with lowest overhead

Kenjiro Taura <[email protected]> Mon, 26 May 2014 12:57:31 +0900 (JST)
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <[email protected]>
Hi,

What is the fastest, yet portable way to allocate
a small object in recent versions (e.g., 7.4.0)?
The current interface seems more complex than what
it used to be many years ago.

Below, I am seeing 7.4.0 sources.

I initially thought:

# define GC_MALLOC_WORDS(result,n,tiny_fl) 

in gc_inline.h is the one I should use, but it
requires tiny_fl argument I must obtain somehow.

Digging into GC_malloc in thread_local_alloc.c,
I found that the following line eventually gets it.

    tiny_fl = ((GC_tlfs)tsd) -> normal_freelists;

The next question then is how to get tsd, for
which a fairly complex conditional compilation 
is going on.  Ignoring portability for a moment,
I figured out that 

      tsd = GC_getspecific(GC_thread_key);

is it.  

I tried copied and pasted it into my source and
got compilation errors.  All in all, I feel I am
not on the right track; they seem intentionally
kept private inside a collector implementation.

I started feeling I am missing some functions that
portably return what needs to be passed to
GC_MALLOC_WORDS, but could not find any so far.

I appreciate if anybody sheds light on it.