harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Egor Pasko <egor.pa...@gmail.com>
Subject Re: [general] GSoC 2008 Refactor Java Bytecode Translator
Date Sat, 05 Apr 2008 16:01:57 GMT
On the 0x41C day of Apache Harmony Okonechnikov Konstantin wrote:
> Continue working on removing SCE. Have some questions:
> What are "tau operations"? What does "tau prefix" mean?
> And what about those nasty
> warnings (necessary simplification) in genTauCheckNull etc?

Oh, yeah, this is a big story :)) Everybody asks me about it, and I
often forget the tricky details, so, referring to some explanations
back in time sounds reasonable to me.

Here the references are. One short explanation of TauDiv: [1]. Patent
application for the tau framework [2] is more interesting.

It is easy to explain the situation using chknull instruction
(Op_TauCheckNull) as an example.

suppose we have invokevirtual bytecode instruction. When invoked it
should throw a NullPointerException if the class is null, you
know. Here how it is represented in Jitrino HIR:

chknull class1 -) tau1
ldvtable ((tau1)) class1 -) vtable1
ldvfnslot ((tau1)) vtable1::method -) address1
call ((tau1)) address1 params

ldvtable and ldvfnslot abstract away the means to get the address of
the method.

chknull is of course at the end of the basic block, it throws the
exception if class1 is null.

so, why tau?

suppose we want to move instructions in HIR to optimize the code. But
we need to somehow keep in mind what instructions can be moved and how
far. Here call instruction has a tau source operand produced by
chknull ensuring that call is not moved above the definition of tau1,
which is _exactly_ the same semantics as "nullcheck has to precede the
call". Thus it is the way to describe such precedence rules in HIR.

another example:

-----------------------
chknull class1 -) tau1
...
call ((tau1)) ...
chknull class2 -> tau2
...
call ((tau2)) ...
-----------------------

CSE converts it to:

-----------------------
chknull class1 -) tau1
...
call ((tau1)) ...
...
call ((tau1)) ...
-----------------------

which is a magic. Nullcheck was eliminated with CSE without prior
knowledge about semantics of the nullchecks. The idea was invented
specifically for such things: describing control flow dependencies
using data flow dependencies.

In the code you are referring to translator tries to optimise on the
fly. For example, replacing code like this:
MyClass m = null;
m.run();

with:
throw new NullPointerException();

And this is not a job of translator to do things like that. Simplifier
does that, actually.

TauSafe means that you canmove your instruction anywhere. TauUnsafe
pins the instruction position.

There are also tauedge and taupoint, I tend to forget these details,
you can find more info in [2].

[1] http://thread.gmane.org/gmane.comp.java.harmony.devel/24471/focus=24474

[2] http://www.google.com/patents?id=Ht-XAAAAEBAJ&printsec=abstract&zoom=4&dq=tau+operations+compiler

-- 
Egor Pasko


Mime
View raw message