RFR: 8296301: Interpreter(RISC-V): Implement -XX:+PrintBytecodeHistogram and -XX:+PrintBytecodePairHistogram options

Fei Yang fyang at openjdk.org
Thu Nov 10 08:12:29 UTC 2022


On Wed, 9 Nov 2022 03:08:57 GMT, Yanhong Zhu <yzhu at openjdk.org> wrote:

> In this patch, count_bytecode() is modified by using "x7" as temporary register. Also implement histogram_bytecode() and histogram_bytecode_pair(), which can be enabled on debug mode by setting the options PrintBytecodeHistogram and PrintBytecodePairHistogram.
> 
> The following is the output when PrintBytecodeHistogram or PrintBytecodePairHistogram is TRUE.
> 
> $ java -XX:+PrintBytecodeHistogram --version|head -n 20
> openjdk 20 2022-11-09
> OpenJDK Runtime Environment (fastdebug build 20)
> OpenJDK 64-Bit Server VM (fastdebug build 20, mixed mode)
> 
> Histogram of 8101142 executed bytecodes:
> 
>   absolute  relative  code    name
> ----------------------------------------------------------------------
>     634592     7.83%    dc    fast_aload_0
>     471840     5.82%    b6    invokevirtual
>     376275     4.64%    2b    aload_1
>     358520     4.43%    e0    fast_iload
>     332267     4.10%    de    fast_aaccess_0
>     270189     3.34%    a7    goto
>     249831     3.08%    19    aload
>     223361     2.76%    b9    invokeinterface
>     215666     2.66%    1c    iload_2
>     194877     2.41%    b8    invokestatic
>     192212     2.37%    2c    aload_2
>     185826     2.29%    1b    iload_1
> 
> $ java -XX:+PrintBytecodePairHistogram --version|head -n 20
> openjdk 20 2022-11-09
> OpenJDK Runtime Environment (fastdebug build 20)
> OpenJDK 64-Bit Server VM (fastdebug build 20, mixed mode)
> 
> Histogram of 7627721 executed bytecode pairs:
> 
>   absolute  relative    codes    1st bytecode        2nd bytecode
> ----------------------------------------------------------------------
>     102673    1.346%    84 a7    iinc                goto
>      85429    1.120%    dc 2b    fast_aload_0        aload_1
>      84394    1.106%    dc b6    fast_aload_0        invokevirtual
>      73131    0.959%    b7 dc    invokespecial       fast_aload_0
>      64605    0.847%    2b b6    aload_1             invokevirtual
>      64086    0.840%    dc b9    fast_aload_0        invokeinterface
>      63663    0.835%    b6 dc    invokevirtual       fast_aload_0
>      59946    0.786%    b6 de    invokevirtual       fast_aaccess_0
>      56631    0.742%    36 e0    istore              fast_iload
>      51261    0.672%    b9 de    invokeinterface     fast_aaccess_0
>      49556    0.650%    3a 19    astore              aload
>      49106    0.644%    a7 e0    goto                fast_iload

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp line 1739:

> 1737: void TemplateInterpreterGenerator::count_bytecode() {
> 1738:   __ mv(x7, (address) &BytecodeCounter::_counter_value);
> 1739:   __ atomic_addalw(noreg, 1, x7);

I think a simpler __ atomic_addw will do here? I don't think there is any memory ordering issue here.

-------------

PR: https://git.openjdk.org/jdk/pull/11051


More information about the hotspot-dev mailing list