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/05/12 13:26:28 UTC

[drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Hi all
I am trying to add read barriers mechanism in DRLVM ( just for practice :=)
)
As the first step, I am inserting read barrier inst in HIR,
I define a new modifier set like this:
enum LoadModifier {
    Load_NoReadBarrier       = 0x1 << 27,
    Load_ReadBarrier       = 0x2 << 27,
    Load_Mask         = 0x3 << 27,
    LoadModifier_IsShiftedBy = 27,
    LoadModifier_BitsToEncode = 1,
    LoadModifier_BitsConsumed = 2
};
it will be used in TauLdInd.

My question is about Instoptimizer of MemoryValueNumberingPass, I am not
familiar with it.
First,
What is this pass mainly used for?

Second,
In the caseTauStInd case of the switch in dispatch method:

Modifier mod(Modifier(inst->getAutoCompressModifier()) |
Modifier(Speculative_No) );
setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
addrOp->getId()));

What does it do here? Why is Op_TauLdInd  used in a caseTauStInd case?

Thanks!

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

Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by George Timoshenko <ge...@gmail.com>.
I see your point. It looks reasonable.

But if the absence of 'base' in TauLdInd arguments is the only reason,
IMO it is easier to get 'base' info from the instruction that defines 
address than to get over memopt and other HLO.
(AFAIU read barriers are not being optimized by HLO optimizations.
  So It is better to insert them into CFG as late as possible)

we have TauLdInd(address) and CodeSelector selects it to some MOV 
instruction.
addrDefInst = address->getDefiningInst()
base = addrDefInst->getSrc(the id of 'base');

Most probably addrDefInst will be ADD instruction. (selected from 
LdFieldAddr or smth. similar)
(Same things are being analyzed in cafl - Complex Address Form Loader 
pass in codegen. So some code can be reused from it.)

Please pay attention that getDefiningInst can be called only when 
CodeSelector finished its work and calculateOpndStatistics was called.

So I'd suggest a dedicated codegen pass for read barrier insertion.
(all above is based on the fact that there is no other arguments for 
doing this in HLO)



Simon Chow wrote:
> George
> Thanks for your suggestion.
> IMO, the current information in Inst of TauLdInd is not enough for read
> barriers generation.
> That's the reason why I tend to implement a new opcode TauLdRef.
> For example, there is no ref holding object reference (like 'base' in
> TauStRef) in TauLdInd, but it is necessary for read barrier.
> Additionally, IMO, not all the 'TauLd' need to be intercepted, my TauLdRef
> only represents the ref loading that requires barrier.
> Do you think it is reasonable?
> 
> Thanks
> 
> 2008/5/19 George Timoshenko <ge...@gmail.com>:
> 
>> Hi.
>>
>> You are trying to work and solve problems in HLO.
>> What do you thing on the current write barrier implementation?
>> WBs appeare only in code selector. HLO knows nothing about them.
>>
>> Why don't use similar approach and just implement read barriers generation
>> in CodeSelector?
>> Doing this you should not care on MemOpt and other HLO stuff.
>>
>>
>> George.
>>
>>
> 
> 


Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Simon Chow <si...@gmail.com>.
George
Thanks for your suggestion.
IMO, the current information in Inst of TauLdInd is not enough for read
barriers generation.
That's the reason why I tend to implement a new opcode TauLdRef.
For example, there is no ref holding object reference (like 'base' in
TauStRef) in TauLdInd, but it is necessary for read barrier.
Additionally, IMO, not all the 'TauLd' need to be intercepted, my TauLdRef
only represents the ref loading that requires barrier.
Do you think it is reasonable?

Thanks

2008/5/19 George Timoshenko <ge...@gmail.com>:

> Hi.
>
> You are trying to work and solve problems in HLO.
> What do you thing on the current write barrier implementation?
> WBs appeare only in code selector. HLO knows nothing about them.
>
> Why don't use similar approach and just implement read barriers generation
> in CodeSelector?
> Doing this you should not care on MemOpt and other HLO stuff.
>
>
> George.
>
>


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

Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by George Timoshenko <ge...@gmail.com>.
Hi.

You are trying to work and solve problems in HLO.
What do you thing on the current write barrier implementation?
WBs appeare only in code selector. HLO knows nothing about them.

Why don't use similar approach and just implement read barriers 
generation in CodeSelector?
Doing this you should not care on MemOpt and other HLO stuff.


George.


Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Simon Chow <si...@gmail.com>.
Egor,
Thank. it is helpful.

2008/5/19 Egor Pasko <eg...@gmail.com>:

> On the 0x444 day of Apache Harmony Simon Chow wrote:
> > Thanks Egor,
> > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > Modifier(Speculative_No) );
> >
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
> > addrOp->getId()));
> >
> > Why does it use Modifier(Speculative_No) instead of
> > inst->getSpeculativeModifier()? is this pass does not optimise
> 'Speculative
> > Load'?
>
> Simon, sorry for the late answer, these two weeks I am far from home.
>
> Speculative loads are exactly the same as ordinary loads on x86 and
> x86_64, so, you should not care about it much.
>
> I am not sure why we are doing this. Here is my guess: in terms of
> load op elimination there is no difference between a speculative or a
> non-speculative load. So, we are fixing the operation in the hash so
> that it matches both variants. I did not check this, however.
>
> > Thanks
> >
> > 2008/5/14 Egor Pasko <eg...@gmail.com>:
> >
> > > On the 0x444 day of Apache Harmony Simon Chow wrote:
> > > > Egor,
> > > > Thank you every much, it is very helpful.
> > > > AFAIK, only write barrier has been implemented in harmony, my goal is
> > > > implementing read barrier for gen GC and concurrent GC,
> > >
> > > yes, we only have write barriers now
> > >
> > > > As a result, a command option such as
> generate_read_barrier=true/false
> > > is
> > > > added to DRLVM.
> > > > If it is true, GC use information intercepted by read barrier to
> perform
> > > gen
> > > > or concurrent collection instead of using write barrier.
> > > > Maybe the performance will not be better than write barrier, but I
> think
> > > it
> > > > is a good practice to understand the internal of both JIT and GC, do
> you
> > > > think so?
> > >
> > > yes, both a good practice and a good experiment. Good luck!
> > >
> > > > 2008/5/13 Egor Pasko <eg...@gmail.com>:
> > > >
> > > > > On the 0x442 day of Apache Harmony Simon Chow wrote:
> > > > > > Hi all
> > > > > > I am trying to add read barriers mechanism in DRLVM ( just for
> > > practice
> > > > > :=)
> > > > > > )
> > > > > > As the first step, I am inserting read barrier inst in HIR,
> > > > > > I define a new modifier set like this:
> > > > > > enum LoadModifier {
> > > > > >     Load_NoReadBarrier       = 0x1 << 27,
> > > > > >     Load_ReadBarrier       = 0x2 << 27,
> > > > > >     Load_Mask         = 0x3 << 27,
> > > > > >     LoadModifier_IsShiftedBy = 27,
> > > > > >     LoadModifier_BitsToEncode = 1,
> > > > > >     LoadModifier_BitsConsumed = 2
> > > > > > };
> > > > > > it will be used in TauLdInd.
> > > > >
> > > > > you want to optimise some barriers out, right?
> > > > > looks good
> > > > >
> > > > > > My question is about Instoptimizer of MemoryValueNumberingPass, I
> am
> > > not
> > > > > > familiar with it.
> > > > > > First,
> > > > > > What is this pass mainly used for?
> > > > >
> > > > > MemOpt is used to eliminate unnecessary store+load pairs. It puts
> > > > > corresponding operations into a hash. Then eliminates loads if sees
> > > > > loads in this hash.
> > > > >
> > > > > > Second,
> > > > > > In the caseTauStInd case of the switch in dispatch method:
> > > > > >
> > > > > > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > > > > > Modifier(Speculative_No) );
> > > > > > setHashToInst(inst, getKey(Operation(Op_TauLdInd,
> inst->getType(),
> > > mod),
> > > > > > addrOp->getId()));
> > > > > >
> > > > > > What does it do here? Why is Op_TauLdInd  used in a caseTauStInd
> > > case?
> > > > >
> > > > > load operation is stored as if it is there. So, if you have a new
> load
> > > > > op you search if there is the same one in the hash.
> > > > >
> > > >
> > > > Why does it use Modifier(Speculative_No) instead of
> > > > inst->getSpeculativeModifier() ?
> > > > Thanks
> > > >
> > > >
> > > > > --
> > > > > Egor Pasko
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > From : Simon.Chow@Software School of Fudan University
> > >
> > > --
> > > Egor Pasko
> > >
> > >
> >
> >
> > --
> > From : Simon.Chow@Software School of Fudan University
>
> --
> Egor Pasko
>
>


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

Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Egor Pasko <eg...@gmail.com>.
On the 0x444 day of Apache Harmony Simon Chow wrote:
> Thanks Egor,
> Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> Modifier(Speculative_No) );
> 
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
> addrOp->getId()));
> 
> Why does it use Modifier(Speculative_No) instead of
> inst->getSpeculativeModifier()? is this pass does not optimise 'Speculative
> Load'?

Simon, sorry for the late answer, these two weeks I am far from home.

Speculative loads are exactly the same as ordinary loads on x86 and
x86_64, so, you should not care about it much.

I am not sure why we are doing this. Here is my guess: in terms of
load op elimination there is no difference between a speculative or a
non-speculative load. So, we are fixing the operation in the hash so
that it matches both variants. I did not check this, however.

> Thanks
> 
> 2008/5/14 Egor Pasko <eg...@gmail.com>:
> 
> > On the 0x444 day of Apache Harmony Simon Chow wrote:
> > > Egor,
> > > Thank you every much, it is very helpful.
> > > AFAIK, only write barrier has been implemented in harmony, my goal is
> > > implementing read barrier for gen GC and concurrent GC,
> >
> > yes, we only have write barriers now
> >
> > > As a result, a command option such as generate_read_barrier=true/false
> > is
> > > added to DRLVM.
> > > If it is true, GC use information intercepted by read barrier to perform
> > gen
> > > or concurrent collection instead of using write barrier.
> > > Maybe the performance will not be better than write barrier, but I think
> > it
> > > is a good practice to understand the internal of both JIT and GC, do you
> > > think so?
> >
> > yes, both a good practice and a good experiment. Good luck!
> >
> > > 2008/5/13 Egor Pasko <eg...@gmail.com>:
> > >
> > > > On the 0x442 day of Apache Harmony Simon Chow wrote:
> > > > > Hi all
> > > > > I am trying to add read barriers mechanism in DRLVM ( just for
> > practice
> > > > :=)
> > > > > )
> > > > > As the first step, I am inserting read barrier inst in HIR,
> > > > > I define a new modifier set like this:
> > > > > enum LoadModifier {
> > > > >     Load_NoReadBarrier       = 0x1 << 27,
> > > > >     Load_ReadBarrier       = 0x2 << 27,
> > > > >     Load_Mask         = 0x3 << 27,
> > > > >     LoadModifier_IsShiftedBy = 27,
> > > > >     LoadModifier_BitsToEncode = 1,
> > > > >     LoadModifier_BitsConsumed = 2
> > > > > };
> > > > > it will be used in TauLdInd.
> > > >
> > > > you want to optimise some barriers out, right?
> > > > looks good
> > > >
> > > > > My question is about Instoptimizer of MemoryValueNumberingPass, I am
> > not
> > > > > familiar with it.
> > > > > First,
> > > > > What is this pass mainly used for?
> > > >
> > > > MemOpt is used to eliminate unnecessary store+load pairs. It puts
> > > > corresponding operations into a hash. Then eliminates loads if sees
> > > > loads in this hash.
> > > >
> > > > > Second,
> > > > > In the caseTauStInd case of the switch in dispatch method:
> > > > >
> > > > > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > > > > Modifier(Speculative_No) );
> > > > > setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(),
> > mod),
> > > > > addrOp->getId()));
> > > > >
> > > > > What does it do here? Why is Op_TauLdInd  used in a caseTauStInd
> > case?
> > > >
> > > > load operation is stored as if it is there. So, if you have a new load
> > > > op you search if there is the same one in the hash.
> > > >
> > >
> > > Why does it use Modifier(Speculative_No) instead of
> > > inst->getSpeculativeModifier() ?
> > > Thanks
> > >
> > >
> > > > --
> > > > Egor Pasko
> > > >
> > > >
> > >
> > >
> > > --
> > > From : Simon.Chow@Software School of Fudan University
> >
> > --
> > Egor Pasko
> >
> >
> 
> 
> -- 
> From : Simon.Chow@Software School of Fudan University

-- 
Egor Pasko


Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Simon Chow <si...@gmail.com>.
Thanks Egor,
Modifier mod(Modifier(inst->getAutoCompressModifier()) |
Modifier(Speculative_No) );

^^^^^^^^^^^^^^^^^^^^^^^^^^^
setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
addrOp->getId()));

Why does it use Modifier(Speculative_No) instead of
inst->getSpeculativeModifier()? is this pass does not optimise 'Speculative
Load'?
Thanks

2008/5/14 Egor Pasko <eg...@gmail.com>:

> On the 0x444 day of Apache Harmony Simon Chow wrote:
> > Egor,
> > Thank you every much, it is very helpful.
> > AFAIK, only write barrier has been implemented in harmony, my goal is
> > implementing read barrier for gen GC and concurrent GC,
>
> yes, we only have write barriers now
>
> > As a result, a command option such as generate_read_barrier=true/false
> is
> > added to DRLVM.
> > If it is true, GC use information intercepted by read barrier to perform
> gen
> > or concurrent collection instead of using write barrier.
> > Maybe the performance will not be better than write barrier, but I think
> it
> > is a good practice to understand the internal of both JIT and GC, do you
> > think so?
>
> yes, both a good practice and a good experiment. Good luck!
>
> > 2008/5/13 Egor Pasko <eg...@gmail.com>:
> >
> > > On the 0x442 day of Apache Harmony Simon Chow wrote:
> > > > Hi all
> > > > I am trying to add read barriers mechanism in DRLVM ( just for
> practice
> > > :=)
> > > > )
> > > > As the first step, I am inserting read barrier inst in HIR,
> > > > I define a new modifier set like this:
> > > > enum LoadModifier {
> > > >     Load_NoReadBarrier       = 0x1 << 27,
> > > >     Load_ReadBarrier       = 0x2 << 27,
> > > >     Load_Mask         = 0x3 << 27,
> > > >     LoadModifier_IsShiftedBy = 27,
> > > >     LoadModifier_BitsToEncode = 1,
> > > >     LoadModifier_BitsConsumed = 2
> > > > };
> > > > it will be used in TauLdInd.
> > >
> > > you want to optimise some barriers out, right?
> > > looks good
> > >
> > > > My question is about Instoptimizer of MemoryValueNumberingPass, I am
> not
> > > > familiar with it.
> > > > First,
> > > > What is this pass mainly used for?
> > >
> > > MemOpt is used to eliminate unnecessary store+load pairs. It puts
> > > corresponding operations into a hash. Then eliminates loads if sees
> > > loads in this hash.
> > >
> > > > Second,
> > > > In the caseTauStInd case of the switch in dispatch method:
> > > >
> > > > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > > > Modifier(Speculative_No) );
> > > > setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(),
> mod),
> > > > addrOp->getId()));
> > > >
> > > > What does it do here? Why is Op_TauLdInd  used in a caseTauStInd
> case?
> > >
> > > load operation is stored as if it is there. So, if you have a new load
> > > op you search if there is the same one in the hash.
> > >
> >
> > Why does it use Modifier(Speculative_No) instead of
> > inst->getSpeculativeModifier() ?
> > Thanks
> >
> >
> > > --
> > > Egor Pasko
> > >
> > >
> >
> >
> > --
> > From : Simon.Chow@Software School of Fudan University
>
> --
> Egor Pasko
>
>


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

Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Egor Pasko <eg...@gmail.com>.
On the 0x444 day of Apache Harmony Simon Chow wrote:
> Egor,
> Thank you every much, it is very helpful.
> AFAIK, only write barrier has been implemented in harmony, my goal is
> implementing read barrier for gen GC and concurrent GC,

yes, we only have write barriers now

> As a result, a command option such as generate_read_barrier=true/false is
> added to DRLVM.
> If it is true, GC use information intercepted by read barrier to perform gen
> or concurrent collection instead of using write barrier.
> Maybe the performance will not be better than write barrier, but I think it
> is a good practice to understand the internal of both JIT and GC, do you
> think so?

yes, both a good practice and a good experiment. Good luck!

> 2008/5/13 Egor Pasko <eg...@gmail.com>:
> 
> > On the 0x442 day of Apache Harmony Simon Chow wrote:
> > > Hi all
> > > I am trying to add read barriers mechanism in DRLVM ( just for practice
> > :=)
> > > )
> > > As the first step, I am inserting read barrier inst in HIR,
> > > I define a new modifier set like this:
> > > enum LoadModifier {
> > >     Load_NoReadBarrier       = 0x1 << 27,
> > >     Load_ReadBarrier       = 0x2 << 27,
> > >     Load_Mask         = 0x3 << 27,
> > >     LoadModifier_IsShiftedBy = 27,
> > >     LoadModifier_BitsToEncode = 1,
> > >     LoadModifier_BitsConsumed = 2
> > > };
> > > it will be used in TauLdInd.
> >
> > you want to optimise some barriers out, right?
> > looks good
> >
> > > My question is about Instoptimizer of MemoryValueNumberingPass, I am not
> > > familiar with it.
> > > First,
> > > What is this pass mainly used for?
> >
> > MemOpt is used to eliminate unnecessary store+load pairs. It puts
> > corresponding operations into a hash. Then eliminates loads if sees
> > loads in this hash.
> >
> > > Second,
> > > In the caseTauStInd case of the switch in dispatch method:
> > >
> > > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > > Modifier(Speculative_No) );
> > > setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
> > > addrOp->getId()));
> > >
> > > What does it do here? Why is Op_TauLdInd  used in a caseTauStInd case?
> >
> > load operation is stored as if it is there. So, if you have a new load
> > op you search if there is the same one in the hash.
> >
> 
> Why does it use Modifier(Speculative_No) instead of
> inst->getSpeculativeModifier() ?
> Thanks
> 
> 
> > --
> > Egor Pasko
> >
> >
> 
> 
> -- 
> From : Simon.Chow@Software School of Fudan University

-- 
Egor Pasko


Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Simon Chow <si...@gmail.com>.
Egor,
Thank you every much, it is very helpful.
AFAIK, only write barrier has been implemented in harmony, my goal is
implementing read barrier for gen GC and concurrent GC,
As a result, a command option such as generate_read_barrier=true/false is
added to DRLVM.
If it is true, GC use information intercepted by read barrier to perform gen
or concurrent collection instead of using write barrier.
Maybe the performance will not be better than write barrier, but I think it
is a good practice to understand the internal of both JIT and GC, do you
think so?


2008/5/13 Egor Pasko <eg...@gmail.com>:

> On the 0x442 day of Apache Harmony Simon Chow wrote:
> > Hi all
> > I am trying to add read barriers mechanism in DRLVM ( just for practice
> :=)
> > )
> > As the first step, I am inserting read barrier inst in HIR,
> > I define a new modifier set like this:
> > enum LoadModifier {
> >     Load_NoReadBarrier       = 0x1 << 27,
> >     Load_ReadBarrier       = 0x2 << 27,
> >     Load_Mask         = 0x3 << 27,
> >     LoadModifier_IsShiftedBy = 27,
> >     LoadModifier_BitsToEncode = 1,
> >     LoadModifier_BitsConsumed = 2
> > };
> > it will be used in TauLdInd.
>
> you want to optimise some barriers out, right?
> looks good
>
> > My question is about Instoptimizer of MemoryValueNumberingPass, I am not
> > familiar with it.
> > First,
> > What is this pass mainly used for?
>
> MemOpt is used to eliminate unnecessary store+load pairs. It puts
> corresponding operations into a hash. Then eliminates loads if sees
> loads in this hash.
>
> > Second,
> > In the caseTauStInd case of the switch in dispatch method:
> >
> > Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> > Modifier(Speculative_No) );
> > setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
> > addrOp->getId()));
> >
> > What does it do here? Why is Op_TauLdInd  used in a caseTauStInd case?
>
> load operation is stored as if it is there. So, if you have a new load
> op you search if there is the same one in the hash.
>

Why does it use Modifier(Speculative_No) instead of
inst->getSpeculativeModifier() ?
Thanks


> --
> Egor Pasko
>
>


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

Re: [drlvm][jit] Instoptimizer in MemoryValueNumberingPass

Posted by Egor Pasko <eg...@gmail.com>.
On the 0x442 day of Apache Harmony Simon Chow wrote:
> Hi all
> I am trying to add read barriers mechanism in DRLVM ( just for practice :=)
> )
> As the first step, I am inserting read barrier inst in HIR,
> I define a new modifier set like this:
> enum LoadModifier {
>     Load_NoReadBarrier       = 0x1 << 27,
>     Load_ReadBarrier       = 0x2 << 27,
>     Load_Mask         = 0x3 << 27,
>     LoadModifier_IsShiftedBy = 27,
>     LoadModifier_BitsToEncode = 1,
>     LoadModifier_BitsConsumed = 2
> };
> it will be used in TauLdInd.

you want to optimise some barriers out, right?
looks good

> My question is about Instoptimizer of MemoryValueNumberingPass, I am not
> familiar with it.
> First,
> What is this pass mainly used for?

MemOpt is used to eliminate unnecessary store+load pairs. It puts
corresponding operations into a hash. Then eliminates loads if sees
loads in this hash.

> Second,
> In the caseTauStInd case of the switch in dispatch method:
> 
> Modifier mod(Modifier(inst->getAutoCompressModifier()) |
> Modifier(Speculative_No) );
> setHashToInst(inst, getKey(Operation(Op_TauLdInd, inst->getType(), mod),
> addrOp->getId()));
> 
> What does it do here? Why is Op_TauLdInd  used in a caseTauStInd case?

load operation is stored as if it is there. So, if you have a new load
op you search if there is the same one in the hash.

-- 
Egor Pasko