Aarch64 port for ZGC, so far

Stuart Monteith stuart.monteith at linaro.org
Fri Nov 30 11:15:02 UTC 2018


Thanks for taking the time to look at that Per. It was pointed out to
me before, and I've updated it here:

http://cr.openjdk.java.net/~smonteith/zgc/webrev-20181129/

What I've not done is change arraycopy_epilogue, but I'll do that for
completeness.

Thanks,
    Stuart


On Fri, 30 Nov 2018 at 07:29, Per Liden <per.liden at oracle.com> wrote:
>
> Hi,
>
> Just had a quick look and noticed that the signatures for
> arraycopy_prologue/arraycopy_epilogue on aarch64 look wrong.
>
>    virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet
> decorators, bool is_oop, Register addr, Register count, RegSet saved_regs);
>    virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet
> decorators, bool is_oop, Register start, Register end, Register tmp,
> RegSet saved_regs);
>
> They should always take in both source and destination, as it's up the
> to barrier set to decide what needs to be done here. Like we do on x86:
>
>    virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet
> decorators, BasicType type, Register src, Register dst, Register count);
>    virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet
> decorators, BasicType type, Register src, Register dst, Register count);
>
> Leaving it to the barrier set also gives you the runtime optional
> property we want.
>
> cheers,
> Per
>
> On 11/29/18 7:01 PM, Stuart Monteith wrote:
> > Thanks for pointing that out Ma Chunhui,
> >
> > What you suggest can't be done as ZGC isn't just a compile time
> > option, it is also a run-time option. You are quite right though - the
> > array prologue needs to take the src and dest and decide what it needs
> > to do.
> >
> > I'll incorporate this into the aarch64 specific code by adding the
> > source too the method signature and the other dependencies in a manner
> > that will be correct for with/without ZGC.
> >
> > This will explain some of the rarer problems I 'm seeing.
> >
> > On Thu, 29 Nov 2018 at 06:13, machunhui (C) <machunhui2 at huawei.com> wrote:
> >>
> >> Hi, Stuart
> >>
> >>    With your latest patch, It seems that Interpreter and C1 works fine on my machine and my case. But there is a crash when using C2.
> >>
> >>
> >>
> >> My Option is:  -XX:+UseZGC -XX:-TieredCompilation -XX:ParallelGCThreads=1 -XX:ConcGCThreads=1 -XX:+Use64BitLiteralOops
> >>
> >> And the crash happens only when java main thread is exited, after DestroyJavaVM.
> >>
> >>
> >>
> >> The crash stack:
> >>
> >> 30 V  [libjvm.so+0x121b968]  ZPage::is_active() const+0xc
> >>
> >>    31 V  [libjvm.so+0x123b180]  ZMark::try_mark_object(ZMarkCache*, unsigned long, bool)+0x48
> >>
> >>    32 V  [libjvm.so+0x123b28c]  ZMark::mark_and_follow(ZMarkCache*, ZMarkStackEntry)+0x6c
> >>
> >>    33 V  [libjvm.so+0x123e6d4]  bool ZMark::drain<ZMarkNoTimeout>(ZMarkStripe*, ZMarkThreadLocalStacks*, ZMarkCache*, ZMarkNoTimeout*)+0x7c
> >>
> >>
> >>
> >> The crash is because when trying to mark object, it failed to find page for the given object address, which is 0xbaadbabe. And the reason is because in StubGenerator:: generate_disjoint_copy, when trying to add load-barrier in aarch64, the barrier is wrongly added to dest, not src.
> >>
> >> So the fix is quite simple, when using ZGC, add load-barrier to src instead of dest.
> >>
> >>
> >>
> >> diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
> >>
> >> index a1fd069c7b..fc7f209d62 100644
> >>
> >> --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
> >>
> >> +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
> >>
> >> @@ -1377,7 +1377,11 @@ class StubGenerator: public StubCodeGenerator {
> >>
> >>       }
> >>
> >>
> >>
> >>       BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
> >>
> >> +#if INCLUDE_ZGC
> >>
> >> +    bs->arraycopy_prologue(_masm, decorators, is_oop, s, count, saved_reg);
> >>
> >> +#else
> >>
> >>       bs->arraycopy_prologue(_masm, decorators, is_oop, d, count, saved_reg);
> >>
> >> +#endif
> >>
> >>
> >>
> >>       if (is_oop) {
> >>
> >>         // save regs before copy_memory
> >>
> >> @@ -1451,7 +1455,11 @@ class StubGenerator: public StubCodeGenerator {
> >>
> >>       }
> >>
> >>
> >>
> >>       BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
> >>
> >> +#if INCLUDE_ZGC
> >>
> >> +    bs->arraycopy_prologue(_masm, decorators, is_oop, s, count, saved_regs);
> >>
> >> +#else
> >>
> >>      bs->arraycopy_prologue(_masm, decorators, is_oop, d, count, saved_regs);
> >>
> >> +#endif
> >>
> >>
> >>
> >>       if (is_oop) {
> >>
> >>         // save regs before copy_memory
> >>
> >>
> >>
> >> Thanks.
> >>
> >>
> >>
> >> --------------------------------------------------
> >> 马春辉 Ma Chunhui
> >> Mail: machunhui2 at huawei.com
> >> 2012实验室-语言虚拟机实验室
> >> 2012 Laboratories-Language VM Lab,2012Labs
> >>
> >>


More information about the zgc-dev mailing list