This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: libgcj and the NPTL posix threads implementation


On Mon, 1 Mar 2004, Anthony Green wrote:
> >  But your version is more efficient
> > within a DSO.
>
> Why is this?  It doesn't call any functions, does it?

For:

static int __thread x;
int t(void) {
  return x;
}

compare the output compiled with -fPIC:

t:
        pushl   %ebx
        call    __i686.get_pc_thunk.bx
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
        leal    x@TLSLDM(%ebx), %eax
        call    ___tls_get_addr@PLT
        popl    %ebx
        movl    x@DTPOFF(%eax), %eax
        ret

vs. without:

t:
    movl    %gs:x@NTPOFF, %eax
    ret

The former is necessary in a DSO where the exact thread-local offset can't
be known at compile time.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]