harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov" <mike.fur...@gmail.com>
Subject Re: [drlvm][jitrino]Are there any static type checking and type propagation?
Date Thu, 05 Jul 2007 09:36:16 GMT
Clara,
I run your test with -Xem:opt mode and here is the result:

Before escape analysis we load value from array (I32) and store it into
field(I35)

Block L3:
  Predecessors: L14
  Successors: L4
  I3:L3:
  I32:ldind.unc:o   [t20] ((t13,t16)) -) t21:cls:java/lang/Long
  I34:ldsflda   [kit::largest] -) t23:ref:cls:java/lang/Long
  I35:stind.unc:o   t21 ((t13,t13,t45)) -) [t23]
  GOTO L4

After escape analysis based optimization there are no array allocation in
the method at all. Array c[] was removed as dead code and the L3 block have
this code:

Block L3:
  Predecessors: L14
  Successors: L4
  I3:L3:
  I120:ldvar     v2.49 -) t21:cls:java/lang/Long
  I34:ldsflda   [kit::largest] -) t23:ref:cls:java/lang/Long
  I35:stind.unc:o   t21 ((t13,t13,t45)) -) [t23]
  GOTO L4

I see the problem that 'new Long()' operation was not scalarized here and
was not moved to inside of "if (i==m)" clause, but this is the different
problem and cause could be in side effects of Long::<init> constructor (Long
type initialization, loop peeling optimization must help here).

So the good advice (IMO) could be is to think about optimizations more
general. There are a lot of optimizations that do something. Some of them
could do a part of the task you are working on. If  some optimization does
not work by the reason of incomplete implementation it's better to improve
it, but not reimplement all of the optimizations you need in your own and
very specific task.

I propose you finding another example where Jitrino OPT fails, we can check
why does it fail and fix it. After it fixed you can reuse the results in you
task running the optimization needed before 'free()' related analysis.

+ IMO tracking the inter-procedural state of objects in runtime is very
complicated task. You will have to organize TLS storage for flags. Usually
only hot paths in a method affect performance. We have profile to detect
these paths and another profile to devirtualize and inline calls. It makes
me think that if you limit your task by a single procedure for the first
step you get the same performance results for the less work.

On 7/5/07, clara <clarazhang@gmail.com> wrote:
>
> On 7/4/07, Mikhail Fursov <mike.fursov@gmail.com> wrote:
> >
> > Clara,
> >
> > On 7/4/07, clara <clarazhang@gmail.com> wrote:
> > >
> > > Our objective is to exploit a more accurate inter-procedural k-layer
> EA,
> > > which
> > > will guide  the JIT-assisted GC (a bit like free-me [1]) or
> concurrency
> > > analysis.
> >
> >
> > Here my question is: do you want to  compute object lifetime and add
> > free()
> > calls during compilation time only or  use special runtime variables to
> > track if method's  argument and return values of object type are escaped
> > and
> > guard free() call with this variable check?
> >
> We do the former.
>
> Our EA is dependant on SSA, and a rough inter-procedural k-layer EA has
> been
> > > implemented ( by writing a optpass ). We need type propagation  to
> > obtain
> > > and
> > > analyze more related method. But we could not know how this kind of
> type
> > > propagation cost, and why jitrino implement inter-procedural analysis
> by
> > > inlining
> > > and not by cross-procedural infomation transfer.
> >
> >
> > The answer is: this is the easier way to get the same information. Using
> > it
> > for a limited set of methods (hot methods) we do not need to invent new
> > type
> > of profile and we do not depend on the fact if the method we want to
> > analyze
> > was compiled before or not.
> > You can use cross-procedural profiles if it fits your needs better. I
> can
> > help you to integrate into EM's infrastructure and make it JIT
> > independent.
>
>
> The cross-procedural profiling is our next step work. At present we do
> it by cross-procedural infomation transfer in JIT.
>
>
> Another problem is there are many objects referenced by many container
> > > objects
> > > in applications. Do you have some good advices on analyzing such
> > objects?
> >
> >
> > Do you mean something like String and shared between different strings
> > char[] objects here or references from java.util.* containers?
> > Unfortunately I can't give any good advice here unless I learn details
> of
> > your method better.
> >
> > Would it be OK if we start with simple examples and simple solutions and
> > advance step by step?
>
>
> Let's see a simple example below.
> public class kit {
>   static Long largest = NULL;
>   static public void main(String[] arg){
>     kit k = new kit();
>     k.f1(999);
> }
>
>   public void f1(int m){
>     Long[] c = new Long[1000];
>     for(int i=0;i<1000;i++){
>       c[i] = new Long(i);
>       if(i==m)
>         this.largest = c[i];
>     }
>   }
> }
> Here, c is a local array and be allocated 1000 Long instances in f1().
> Only one Long object escape f1 by the static field this.largest, others
> don't escape f1.
> But it is difficult to obtain the above accurate escape state using EA,
> due to the use of array  c.
> In EA of jitrino.JIT, a conservative method is used. One array has only
> one escape state field, and  all the objects referred in the array have
> the uniform escape state.
> There are some other improved methods, such as region-based (to
> divide an array into several regions, each region has a escape state
> field). Or we can use profiling  on the index or a range of indexes,
> but it  would be costly.
> Do you have some good advices?
>
>
> [1] Samuel Z. Guyer, Kathryn S. McKinley, and Daniel Frampton.
> > > Free-Me: a static analysis for automatic individual object.
> > > In PLDI 2006, Ottawa, Ontario, Canada reclamation, 2006.
> > >
> > > ----- Original Message -----
> > > From: "Mikhail Fursov" <mike.fursov@gmail.com>
> > > To: <dev@harmony.apache.org>
> > > Sent: Tuesday, July 03, 2007 5:43 PM
> > > Subject: Re: [drlvm][jitrino]Are there any static type checking and
> type
> > > propagation?
> > >
> > >
> > > > On 7/3/07, clara <clarazhang@gmail.com> wrote:
> > > >>
> > > >> Thanks.
> > > >>
> > > >> We are exploiting an inter-procedural k-layer escape analysis,
> which
> > > are
> > > >> not dependent on inlining. So we will do some cross-procedure type
> > > >> propagation ourselves. :-)
> > > >> Could you give us some advices on it according to your experiences?
> > > >>
> > > >>
> > > > First of all you can use JavaBytecodeTranslator to produce HIR for
> the
> > > > methods you are interested to analyze. Drop this HIR (do not inline
> > it)
> > > > after you checked the data you need.
> > > >
> > > > Could you describe your task and proposed solution in more details,
> so
> > > we
> > > > can think about more precise advices?
> > > >
> > > > --
> > > > Mikhail Fursov
> > > >
> >
> >
> >
> >
> > --
> > Mikhail Fursov
> >
>



-- 
Mikhail Fursov

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message