You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Mikhail Fursov <mi...@gmail.com> on 2006/10/09 16:19:08 UTC

[drlvm] Extending ‘org.vmmagic.unboxed’ package with native calls and TLS access

All,
We have 'org.vmmagic.unboxed' package (address arithmetic) support in both
Jitrino.OPT and Jitrino.JET compilers today. So we can rewrite part of our
VM helper's fast paths in Java and teach JIT compiler to inline it.
The only thing is left to do is to get the answers to the following
questions:

1)  What is the default package for the fast path helpers?
My proposal is 'org.harmony.vmhelper'.

2)  How will JIT know if to use "magic" helpers?
The one option is to pass cmd-line parameter, like -
Djit.use_magic_vmhelpers=on. This option could be placed into the EM
configuration file as any other JIT option.

3)  How to call a slow native helper's version from the fast-path part of
the helper written in Java?
The proposal is to create package like 'org.harmony.vmhelper.native' with
stub methods for all native helpers. Once such a method is called from Java,
JIT will replace it with a real native helper call. In this case we need to
have a mapping between "magic" and native helpers on JIT or VM side.

4)  How to detect native helper calling convention?
We can use one of the approaches JUnit uses: a) check the prefix for the
method: stdcall_new(..), cdecl_new(): b) check the Java annotation for the
method.
I prefer to use approach a). But the only reason for that is that I'm not
sure DRLVM has interface to access to the class annotations today. Could VM
gurus correct me?

5)  How to access to TLS data from Java?
The last agreement was something like "public static Address TLS.getAddress()"
method. We can put TLS class to the package with all of native VM helpers
stubs (see item 3 for details)

6)  Where to keep and which classloader to use to load "unboxed" + "helpers"
Java code? Would it be part of the kernel classes and loaded by bootstrap
classloader?
I vote leave it outside of the kernel class. But this way could cause
security problems in future. Any other opinion?


All of the tasks above are rather easy to implement. But we have to come to
the agreement before coding.
Please, suggest your vision or ask me if something I wrote is unclear.

+
The first candidates for inlining are: allocation helpers, monitor helpers,
write barriers.
Any other ideas?



-- 
Mikhail Fursov

Re: [drlvm] Extending ‘org.vmmagic.unboxed’ package with native calls and TLS access

Posted by Mikhail Fursov <mi...@gmail.com>.
Yes, I'm agree we should protected them (In the initial letter I was not
sure)

+ We have to divide the helpers into the groups: VM helpers, GC helpers. So
switching to the different type of GC version only GC helpers implementation
will be changed.
But this means that GC must provide some of the kernel classes. This is the
problem I think.

On 10/11/06, Weldon Washburn <we...@gmail.com> wrote:
>
> It all seems reasonable.  Regarding #6.  Maybe I misunderstand what you
> are
> saying but it seems best to put the java vmhelpers in the same isolation
> as
> other security sensitive kernel classes.
>


-- 
Mikhail Fursov

Re: [drlvm] Extending ‘org.vmmagic.unboxed’ package with native calls and TLS access

Posted by Weldon Washburn <we...@gmail.com>.
Mikhail,
It all seems reasonable.  Regarding #6.  Maybe I misunderstand what you are
saying but it seems best to put the java vmhelpers in the same isolation as
other security sensitive kernel classes.


On 10/10/06, Rana Dasgupta <rd...@gmail.com> wrote:
>
> Mikhail,
>
>     Please see inline.
>
> On 10/9/06, Mikhail Fursov <mi...@gmail.com> wrote:
> >
> > >All,
> > >We have 'org.vmmagic.unboxed' package (address arithmetic) support in
> > both
> > J>itrino.OPT and Jitrino.JET compilers today. So we can rewrite part of
> > our
> > >VM helper's fast paths in Java and teach JIT compiler to inline it.
> > >The only thing is left to do is to get the answers to the following
> > >questions:
> >
> > >1)  What is the default package for the fast path helpers?
> > >My proposal is 'org.harmony.vmhelper'.
>
>
> >>> Sounds reasonable
>
> >2)  How will JIT know if to use "magic" helpers?
> > >The one option is to pass cmd-line parameter, like -
> > >Djit.use_magic_vmhelpers=on. This option could be placed into the EM
> > >configuration file as any other JIT option.
>
>
> >>> Could use both ?
>
> >3)  How to call a slow native helper's version from the fast-path part of
> > >the helper written in Java?
> > >The proposal is to create package like 'org.harmony.vmhelper.native'
> with
> > >stub methods for all native helpers. Once such a method is called from
> > Java,
> > >JIT will replace it with a real native helper call. In this case we
> need
> > to
> > >have a mapping between "magic" and native helpers on JIT or VM side.
>
>
> >>> This is a good idea. I think the VM needs to do this housekeeping,
> since
> it provides the stubs of regular helpers to the JIT anyway
>
> >4)  How to detect native helper calling convention?
> > >We can use one of the approaches JUnit uses: a) check the prefix for
> the
> > >method: stdcall_new(..), cdecl_new(): b) check the Java annotation for
> > the
> > >method.
> > >I prefer to use approach a). But the only reason for that is that I'm
> not
> > >sure DRLVM has interface to access to the class annotations today.
> Could
> > VM
> > >gurus correct me?
>
>
> >>> We had discussed this elsewhere and annotations look cleaner.
> Annotations should be obtainable via reflection methods
> get/resolve_annotations() on the class, but Alexey V could confirm. We
> could
> have a default like cdecl and even use this exclusively initially, unless
> you want to use a custom platform independent JIT calling convention
>
> 5)  How to access to TLS data from Java?
> > > The last agreement was something like "public static Address
> > > TLS.getAddress()"
> > > method. We can put TLS class to the package with all of native VM
> > > helpers
> > > stubs (see item 3 for details)
> > >
> >
> > >6)  Where to keep and which classloader to use to load "unboxed" +
> > "helpers"
> > >Java code? Would it be part of the kernel classes and loaded by
> bootstrap
> > >classloader?
> > >I vote leave it outside of the kernel class. But this way could cause
> > >security problems in future. Any other opinion?
>
>
> >>> I did not really understand why you are recommending leaving them out
> of
> the boot loader set.
>
> All of the tasks above are rather easy to implement. But we have to come
> to
> > > the agreement before coding.
> > > Please, suggest your vision or ask me if something I wrote is unclear.
> > >
> > > +
> > > The first candidates for inlining are: allocation helpers, monitor
> > > helpers,
> > > write barriers.
> > > Any other ideas?
> > >
> > >
> >
> > --
> > Mikhail Fursov
> >
> >
>
>


-- 
Weldon Washburn
Intel Middleware Products Division

Re: [drlvm] Extending ‘org.vmmagic.unboxed’ package with native calls and TLS access

Posted by Mikhail Fursov <mi...@gmail.com>.
On 10/11/06, Rana Dasgupta <rd...@gmail.com> wrote:
>
> Mikhail,
>
>      Please see inline.
>
> >2)  How will JIT know if to use "magic" helpers?
> > >The one option is to pass cmd-line parameter, like -
> > >Djit.use_magic_vmhelpers=on. This option could be placed into the EM
> > >configuration file as any other JIT option.
>
>
> >>> Could use both ?


Yes, all of the JIT options in EM configuration file are simple -Djit...
Java properties and could be overriden from the command line.

>
> >4)  How to detect native helper calling convention?
> > >We can use one of the approaches JUnit uses: a) check the prefix for
> the
> > >method: stdcall_new(..), cdecl_new(): b) check the Java annotation for
> > the
> > >method.
> > >I prefer to use approach a). But the only reason for that is that I'm
> not
> > >sure DRLVM has interface to access to the class annotations today.
> Could
> > VM
> > >gurus correct me?
>
>
> >>> We had discussed this elsewhere and annotations look cleaner.
> Annotations should be obtainable via reflection methods
> get/resolve_annotations() on the class, but Alexey V could confirm. We
> could
> have a default like cdecl and even use this exclusively initially, unless
> you want to use a custom platform independent JIT calling convention


Ok, I'll use annotation if we support them.

>
> > >6)  Where to keep and which classloader to use to load "unboxed" +
> > "helpers"
> > >Java code? Would it be part of the kernel classes and loaded by
> bootstrap
> > >classloader?
> > >I vote leave it outside of the kernel class. But this way could cause
> > >security problems in future. Any other opinion?
>
>
> >>> I did not really understand why you are recommending leaving them out
> of
> the boot loader set.


I changed my opinion after posting this proposal. Once VM helpers are
internals of VM we should protect them and use only boot classloader to load
them.


I'm going to implement the first helper today/tomorrow. I know that while
doing it there will more problems arise and I'll report them to discuss.

-- 
Mikhail Fursov

Re: [drlvm] Extending ‘org.vmmagic.unboxed’ package with native calls and TLS access

Posted by Rana Dasgupta <rd...@gmail.com>.
Mikhail,

     Please see inline.

On 10/9/06, Mikhail Fursov <mi...@gmail.com> wrote:
>
> >All,
> >We have 'org.vmmagic.unboxed' package (address arithmetic) support in
> both
> J>itrino.OPT and Jitrino.JET compilers today. So we can rewrite part of
> our
> >VM helper's fast paths in Java and teach JIT compiler to inline it.
> >The only thing is left to do is to get the answers to the following
> >questions:
>
> >1)  What is the default package for the fast path helpers?
> >My proposal is 'org.harmony.vmhelper'.


>>> Sounds reasonable

>2)  How will JIT know if to use "magic" helpers?
> >The one option is to pass cmd-line parameter, like -
> >Djit.use_magic_vmhelpers=on. This option could be placed into the EM
> >configuration file as any other JIT option.


>>> Could use both ?

>3)  How to call a slow native helper's version from the fast-path part of
> >the helper written in Java?
> >The proposal is to create package like 'org.harmony.vmhelper.native' with
> >stub methods for all native helpers. Once such a method is called from
> Java,
> >JIT will replace it with a real native helper call. In this case we need
> to
> >have a mapping between "magic" and native helpers on JIT or VM side.


>>> This is a good idea. I think the VM needs to do this housekeeping, since
it provides the stubs of regular helpers to the JIT anyway

>4)  How to detect native helper calling convention?
> >We can use one of the approaches JUnit uses: a) check the prefix for the
> >method: stdcall_new(..), cdecl_new(): b) check the Java annotation for
> the
> >method.
> >I prefer to use approach a). But the only reason for that is that I'm not
> >sure DRLVM has interface to access to the class annotations today. Could
> VM
> >gurus correct me?


>>> We had discussed this elsewhere and annotations look cleaner.
Annotations should be obtainable via reflection methods
get/resolve_annotations() on the class, but Alexey V could confirm. We could
have a default like cdecl and even use this exclusively initially, unless
you want to use a custom platform independent JIT calling convention

 5)  How to access to TLS data from Java?
> > The last agreement was something like "public static Address
> > TLS.getAddress()"
> > method. We can put TLS class to the package with all of native VM
> > helpers
> > stubs (see item 3 for details)
> >
>
> >6)  Where to keep and which classloader to use to load "unboxed" +
> "helpers"
> >Java code? Would it be part of the kernel classes and loaded by bootstrap
> >classloader?
> >I vote leave it outside of the kernel class. But this way could cause
> >security problems in future. Any other opinion?


>>> I did not really understand why you are recommending leaving them out of
the boot loader set.

 All of the tasks above are rather easy to implement. But we have to come to
> > the agreement before coding.
> > Please, suggest your vision or ask me if something I wrote is unclear.
> >
> > +
> > The first candidates for inlining are: allocation helpers, monitor
> > helpers,
> > write barriers.
> > Any other ideas?
> >
> >
>
> --
> Mikhail Fursov
>
>