harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Weldon Washburn" <weldon...@gmail.com>
Subject Re: [drlvm] Helper inlining in JIT
Date Mon, 28 Aug 2006 15:45:16 GMT
On 8/28/06, Mikhail Fursov <mike.fursov@gmail.com> wrote:
> Folks,
> Here is the example of fast allocation helper written in Java with the help
> of VMMagic
> If nobody objects I'm starting to implement VMMagic support in
> Jitrino.OPTthis week.

I like it!  It makes sense.  No objections to what you propose.
  - Weldon

>
>
>
> private static final int GC_TLS_OFFSET = 10;
> private static final int GC_CURRENT_OFFSET= GC_TLS_OFFSET + 0;
> private static final int GC_CEILING_OFFSET= GC_TLS_OFFSET + 4;
> private static final int OBJ_VTABLE_OFFSET = 0;
>
> //annotate with calling convention and real VM helper id/name information
> private static Address slowAlloc(int vtable, int size) {throw new
> Error("must never be called!");}
>
> private static Address fastAlloc(int vtable, int size) {
>    Address tlsBase = TLS.getAddress();  //load thread local client area
> address
>
>    Address currentFieldAddress = tlsBase.plus(GC_CURRENT_OFFSET);
>    Address ceilingFieldAddress = tlsBase.plus(GC_CEILING_OFFSET);
>
>    Address newObjectAddress; //the result of the method
>
>    // check if there is enough size to do allocation in thread local buffer
>    Address current = currentFieldAddress.loadAddress();
>    Address ceiling = ceilingFieldAddress.loadAddress();
>    Address newCurrent = current.plus(size);
>    if (newCurrent.LT(ceiling)) {
>        currentFieldAddress.store(newCurrent.toWord());
>        newObjectAddress = newCurrent;
>        newObjectAddress.store(vtable, Offset.fromInt(OBJ_VTABLE_OFFSET));
>
>    } else {
>        newObjectAddress = slowAlloc(vtable, size);
>    }
>    return newObjectAddress;
> }
>
> --
> Mikhail Fursov
>
>


-- 
Weldon Washburn
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message