Debugging the architecture-dependent AD file

Volker Simonis volker.simonis at gmail.com
Tue Oct 25 14:02:35 UTC 2016


Hi Gustavo,

the ad-file is a template which is used by the adlc compiler to
generate various C++ classes. If you look at the build logs (if
running with LOG=debug) you'll see that at the very beginning of the
hotspot build the 'adlc' executable is being build (from the sources
in hotspot/src/share/vm/adlc/) and afterwards 'adlc' is being called
on the corresponding .ad file to generate the files under
OUTPUT_DIR/hotspot/variant-server/gensrc/adfiles. These generated
files are compiled and linked together with all the other hotspot
source files into libjvm.so. The generated files contain a lot of
"#line" directives (see [1]) which link back to the original .ad file.

The instruction "loadB_indirect_Ex" you're interested in is converted
into the class loadB_indirect_ExNode (see
OUTPUT_DIR/hotspot/variant-server/gensrc/adfiles/ad_ppc.hpp). You can
browse the other generated files under
OUTPUT_DIR/hotspot/variant-server/gensrc/adfiles for
loadB_indirect_ExNode to get an impression how the various constructs
of the .ad file in general and the contents of an .ad 'instruction'
are converted into C++ code.

You can find some ancient (i.e. almost 20 years old) information about
the adlc syntax in hotspot/src/share/vm/adlc/Doc/Syntax.doc

Regards,
Volker

[1] https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html

On Tue, Oct 25, 2016 at 3:15 PM, Gustavo Serra Scalet
<gustavo.scalet at eldorado.org.br> wrote:
> Hi,
>
> I'd like to know if there is any easier way to debug the architecture-dependent
> AD file. I see that some compilers include a set of gdb-python scripts in order
> to facilitate debugging.
>
> On this example I wanted to closely check how loadB_indirect_Ex is behaving on
> ppc. I could manage to debug the hotspot overall, but I'm confused about what is
> happening when looking at the AD file:
>
> ~/hs-comp $ ./build/linux-ppc64le-normal-server-slowdebug/jdk/bin/javac pidigits.java
> ~/hs-comp $ gdb ./build/linux-ppc64le-normal-server-slowdebug/jdk/bin/java
> GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
> Copyright (C) 2015 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "powerpc64le-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from java...done.
> (gdb 64) handle SIGILL nostop noprint pass
> Signal        Stop      Print   Pass to program Description
> SIGILL        No        No      Yes             Illegal instruction
> (gdb 64) handle SIGSEGV nostop noprint pass
> Signal        Stop      Print   Pass to program Description
> SIGSEGV       No        No      Yes             Segmentation fault
> (gdb 64) b ppc.ad:5030
> No source file named ppc.ad.
> Make breakpoint pending on future shared library load? (y or [n]) y
> Breakpoint 1 (ppc.ad:5030) pending.
> (gdb 64) r -Xcomp -XX:-UseSIGTRAP pidigits 10
> Starting program: /home/gut/hs-comp/java -Xcomp -XX:-UseSIGTRAP pidigits 10
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
> [New Thread 0x3fffb61df1a0 (LWP 17208)]
> ... (removed for readability purposes)
> [New Thread 0x3fffb534f1a0 (LWP 17209)]
> [Switching to Thread 0x3ffe7944f1a0 (LWP 17292)]
>
> Breakpoint 1, State::_sub_Op_LoadB (this=0x3ffe68044950, n=0x3ffe34326930) at /home/gut/hs-comp/hotspot/src/cpu/ppc/vm/ppc.ad:5031
> warning: Source file is more recent than executable.
> 5031      predicate(n->as_Load()->is_unordered() || followed_by_acquire(n));
> (gdb 64) l
> 5026    %}
> 5027
> 5028    // Load Byte (8bit signed). LoadB = LoadUB + ConvUB2B.
> 5029    instruct loadB_indirect_Ex(iRegIdst dst, indirectMemory mem) %{
> 5030      match(Set dst (LoadB mem));
> 5031      predicate(n->as_Load()->is_unordered() || followed_by_acquire(n));
> 5032      ins_cost(MEMORY_REF_COST + DEFAULT_COST);
> 5033      expand %{
> 5034        iRegIdst tmp;
> 5035        loadUB_indirect(tmp, mem);
> (gdb 64) n
> 7500    dfa_ppc.cpp: No such file or directory.
> (gdb 64) dir build/linux-ppc64le-normal-server-slowdebug/hotspot/variant-server/gensrc/adfiles/
> Source directories searched: /home/gut/hs-comp/build/linux-ppc64le-normal-server-slowdebug/hotspot/variant-server/gensrc/adfiles:$cdir:$cwd
> (gdb 64) l
> 7495            DFA_PRODUCTION__SET_VALID(RARG3REGI, loadB_indirect_ac_Ex_rule, c+1)
> 7496          }
> 7497          if (STATE__NOT_YET_VALID(RARG4REGI) || _cost[RARG4REGI] > c+1) {
> 7498            DFA_PRODUCTION__SET_VALID(RARG4REGI, loadB_indirect_ac_Ex_rule, c+1)
> 7499          }
> 7500        }
> 7501        if( STATE__VALID_CHILD(_kids[0], INDIRECTMEMORY) &&
> 7502            (
> 7503    #line 5031 "/home/gut/hs-comp/hotspot/src/cpu/ppc/vm/ppc.ad"
> 7504    n->as_Load()->is_unordered() || followed_by_acquire(n)
> (gdb 64) #WTH?!
> (gdb 64) fin
> Run till exit from #0  State::_sub_Op_LoadB (this=0x3ffe68044950, n=0x3ffe34326930) at dfa_ppc.cpp:7514
> State::DFA (this=0x3ffe68044950, opcode=156, n=0x3ffe34326930) at dfa_ppc.cpp:11395
> 11395     case Op_LoadB: { _sub_Op_LoadB(n);
> (gdb 64) n
> 11676     }
> (gdb 64)
> 11677     return true;
> (gdb 64)
> Matcher::Label_Root (this=0x3ffe7944b5d8, n=0x3ffe34326930, svec=0x3ffe68044950, control=0x3ffe34326748, mem=0x1)
>     at /home/gut/hs-comp/hotspot/src/share/vm/opto/matcher.cpp:1565
> 1565      for( x = 0; x < _LAST_MACH_OPER; x++ )
>
>
> I see that the wiki page dedicated to this topic is unfortunately empty:
> https://wiki.openjdk.java.net/display/HotSpot/UsingGDB
>
> And I also didn't find any blog post about this (I'm considering doing one after
> I figure this out).
>
> Thanks in advance


More information about the hotspot-compiler-dev mailing list