You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Simon Chow <si...@gmail.com> on 2008/03/04 07:10:37 UTC

[general][jitrino] How does JIT deal with CALL inst when generating native code?

Att.
If the callee is not compiled, how does JIT prepare the entry location of
callee?

-- 
>From : Simon.Chow@Software School of Fudan University

Re: [general][jitrino] How does JIT deal with CALL inst when generating native code?

Posted by Pavel Pervov <pm...@gmail.com>.
Simon,

Yes, JIT compiles "per-method". When inlining, JIT assumes inlined
method as a part of currently compiled method and does not compile
inlined method itself.

AFAIU, calling B() is a native instruction - namely 'call'. The target
address of that call points either to a resolution stub, a compile-me
stub, or a JITted code.

Pavel.

On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> Pavel,
>
> Thank you for the explanation.
> So the compilation unit in JIT is always a single method, is that true?
> And what is the compilation result of "calling B()", is it a native
> instruction or a stub?
>
>
> On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
> >
> > Simon,
> >
> > Why recursively?
> >
> > First, A() gets compiled and executed, then, as soon as execution runs
> > to calling B(), B() is compiled and executed.
> >
> > The trick is A() is not "called" first time after it gets compiled
> > (from "compile-me" stub), execution jumps to an entry point of A()
> > leaving correct return address on the stack. All subsequent calls land
> > directly into A(). It is achieved through patching "call site" for A()
> > - the place in JITted code, where A() is called from.
> >
> >
> > Pavel.
> >
> > On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > > Pavel,
> > > Does this mean that the "compile_me" will be call recursively when
> > callee's
> > > callee hasn't been compiled yet.
> > >
> > > For instance,
> > > void A() {
> > >   B();
> > > }
> > > where A and B are both not compiled.
> > > Does the calling of A() invoke the "compile_me" for both A() and B()?
> > >
> > > Thank!
> > >
> > >
> > > On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
> > > >
> > > > Simon,
> > > >
> > > > Each time JIT plans to call a method, it does the following:
> > > > 1) if method is not resolved, JIT inserts a call to resolution stub;
> > > > 2) if method is available, JIT asks for
> > > > MethodDesc::getCodeBlockAddress(0) on this method. If method is not
> > > > compiled yet, VM has generated special "compile_me" for this method on
> > > > class preparation, and its address will be returned in a call to
> > > > getCodeBlockAddress.
> > > >
> > > > WBR,
> > > >     Pavel.
> > > >
> > > >
> > > > On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > > > > Att.
> > > > > If the callee is not compiled, how does JIT prepare the entry
> > location
> > > > of
> > > > > callee?
> > > > >
> > > > > --
> > > > > From : Simon.Chow@Software School of Fudan University
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Pavel Pervov,
> > > > Intel Enterprise Solutions Software Division
> > > >
> > >
> > >
> > >
> > > --
> > > From : Simon.Chow@Software School of Fudan University
> > >
> >
> >
> >
> > --
> >
> > Pavel Pervov,
> > Intel Enterprise Solutions Software Division
> >
>
>
>
> --
> From : Simon.Chow@Software School of Fudan University
>


-- 
Pavel Pervov,
Intel Enterprise Solutions Software Division

Re: [general][jitrino] How does JIT deal with CALL inst when generating native code?

Posted by Simon Chow <si...@gmail.com>.
Pavel,

Thank you for the explanation.
So the compilation unit in JIT is always a single method, is that true?
And what is the compilation result of "calling B()", is it a native
instruction or a stub?


On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
>
> Simon,
>
> Why recursively?
>
> First, A() gets compiled and executed, then, as soon as execution runs
> to calling B(), B() is compiled and executed.
>
> The trick is A() is not "called" first time after it gets compiled
> (from "compile-me" stub), execution jumps to an entry point of A()
> leaving correct return address on the stack. All subsequent calls land
> directly into A(). It is achieved through patching "call site" for A()
> - the place in JITted code, where A() is called from.
>
>
> Pavel.
>
> On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > Pavel,
> > Does this mean that the "compile_me" will be call recursively when
> callee's
> > callee hasn't been compiled yet.
> >
> > For instance,
> > void A() {
> >   B();
> > }
> > where A and B are both not compiled.
> > Does the calling of A() invoke the "compile_me" for both A() and B()?
> >
> > Thank!
> >
> >
> > On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
> > >
> > > Simon,
> > >
> > > Each time JIT plans to call a method, it does the following:
> > > 1) if method is not resolved, JIT inserts a call to resolution stub;
> > > 2) if method is available, JIT asks for
> > > MethodDesc::getCodeBlockAddress(0) on this method. If method is not
> > > compiled yet, VM has generated special "compile_me" for this method on
> > > class preparation, and its address will be returned in a call to
> > > getCodeBlockAddress.
> > >
> > > WBR,
> > >     Pavel.
> > >
> > >
> > > On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > > > Att.
> > > > If the callee is not compiled, how does JIT prepare the entry
> location
> > > of
> > > > callee?
> > > >
> > > > --
> > > > From : Simon.Chow@Software School of Fudan University
> > > >
> > >
> > >
> > >
> > > --
> > > Pavel Pervov,
> > > Intel Enterprise Solutions Software Division
> > >
> >
> >
> >
> > --
> > From : Simon.Chow@Software School of Fudan University
> >
>
>
>
> --
>
> Pavel Pervov,
> Intel Enterprise Solutions Software Division
>



-- 
>From : Simon.Chow@Software School of Fudan University

Re: [general][jitrino] How does JIT deal with CALL inst when generating native code?

Posted by Pavel Pervov <pm...@gmail.com>.
Simon,

Why recursively?

First, A() gets compiled and executed, then, as soon as execution runs
to calling B(), B() is compiled and executed.

The trick is A() is not "called" first time after it gets compiled
(from "compile-me" stub), execution jumps to an entry point of A()
leaving correct return address on the stack. All subsequent calls land
directly into A(). It is achieved through patching "call site" for A()
- the place in JITted code, where A() is called from.

Pavel.

On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> Pavel,
> Does this mean that the "compile_me" will be call recursively when callee's
> callee hasn't been compiled yet.
>
> For instance,
> void A() {
>   B();
> }
> where A and B are both not compiled.
> Does the calling of A() invoke the "compile_me" for both A() and B()?
>
> Thank!
>
>
> On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
> >
> > Simon,
> >
> > Each time JIT plans to call a method, it does the following:
> > 1) if method is not resolved, JIT inserts a call to resolution stub;
> > 2) if method is available, JIT asks for
> > MethodDesc::getCodeBlockAddress(0) on this method. If method is not
> > compiled yet, VM has generated special "compile_me" for this method on
> > class preparation, and its address will be returned in a call to
> > getCodeBlockAddress.
> >
> > WBR,
> >     Pavel.
> >
> >
> > On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > > Att.
> > > If the callee is not compiled, how does JIT prepare the entry location
> > of
> > > callee?
> > >
> > > --
> > > From : Simon.Chow@Software School of Fudan University
> > >
> >
> >
> >
> > --
> > Pavel Pervov,
> > Intel Enterprise Solutions Software Division
> >
>
>
>
> --
> From : Simon.Chow@Software School of Fudan University
>


-- 
Pavel Pervov,
Intel Enterprise Solutions Software Division

Re: [general][jitrino] How does JIT deal with CALL inst when generating native code?

Posted by Simon Chow <si...@gmail.com>.
Pavel,
Does this mean that the "compile_me" will be call recursively when callee's
callee hasn't been compiled yet.

For instance,
void A() {
   B();
}
where A and B are both not compiled.
Does the calling of A() invoke the "compile_me" for both A() and B()?

Thank!


On 04/03/2008, Pavel Pervov <pm...@gmail.com> wrote:
>
> Simon,
>
> Each time JIT plans to call a method, it does the following:
> 1) if method is not resolved, JIT inserts a call to resolution stub;
> 2) if method is available, JIT asks for
> MethodDesc::getCodeBlockAddress(0) on this method. If method is not
> compiled yet, VM has generated special "compile_me" for this method on
> class preparation, and its address will be returned in a call to
> getCodeBlockAddress.
>
> WBR,
>     Pavel.
>
>
> On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> > Att.
> > If the callee is not compiled, how does JIT prepare the entry location
> of
> > callee?
> >
> > --
> > From : Simon.Chow@Software School of Fudan University
> >
>
>
>
> --
> Pavel Pervov,
> Intel Enterprise Solutions Software Division
>



-- 
>From : Simon.Chow@Software School of Fudan University

Re: [general][jitrino] How does JIT deal with CALL inst when generating native code?

Posted by Pavel Pervov <pm...@gmail.com>.
Simon,

Each time JIT plans to call a method, it does the following:
1) if method is not resolved, JIT inserts a call to resolution stub;
2) if method is available, JIT asks for
MethodDesc::getCodeBlockAddress(0) on this method. If method is not
compiled yet, VM has generated special "compile_me" for this method on
class preparation, and its address will be returned in a call to
getCodeBlockAddress.

WBR,
    Pavel.

On 3/4/08, Simon Chow <si...@gmail.com> wrote:
> Att.
> If the callee is not compiled, how does JIT prepare the entry location of
> callee?
>
> --
> From : Simon.Chow@Software School of Fudan University
>


-- 
Pavel Pervov,
Intel Enterprise Solutions Software Division