Javaアセンブリのガイドラインを取得する方法

Javaアセンブリのガイドラインを取得する方法

これに 協会 rustyx-XX:+PrintOptoAssemblyJavaバイトコードのアセンブリ命令を取得するために、デバッグ仮想マシンと次のフラグを使用したと述べました。

デバッグ仮想マシンをインストールしましたsudo apt-get install openjdk-17-dbg

私はコマンドを使用しますjava -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly Main

私はgdbを使ってC ++でこれを行うことに慣れていますが、Java printAssemblyでは動作させることはできません。次の例のように、コマンドの16進値を印刷します。実際のコード関数や意味のあるシンボル記号なしで複数回繰り返されます。

abstract class Base {
    Base(){
        System.out.println("Base Constructor Called");
    }
    abstract void fun();
}
class Dervied extends Base {
    Dervied(){
        System.out.println("Dervied Constructor called");
    }
    void fun(){
        int x = 0;
        x = x + 1;
        System.out.println("Dervied fun() called " + x);
    }
}

class Main {
    public static void main(String args[]){
        Dervied d = new Dervied();
        d.fun();
    }
}

     32    1       3       java.lang.Object::<init> (1 bytes)

============================= C1-compiled nmethod ==============================
----------------------------------- Assembly -----------------------------------

Compiled method (c1)      32    1       3       java.lang.Object::<init> (1 bytes)
 total in heap  [0x00007fca25878010,0x00007fca25878320] = 784
 relocation     [0x00007fca25878170,0x00007fca258781a0] = 48
 main code      [0x00007fca258781a0,0x00007fca25878280] = 224
 stub code      [0x00007fca25878280,0x00007fca258782b0] = 48
 metadata       [0x00007fca258782b0,0x00007fca258782c0] = 16
 scopes data    [0x00007fca258782c0,0x00007fca258782d8] = 24
 scopes pcs     [0x00007fca258782d8,0x00007fca25878318] = 64
 dependencies   [0x00007fca25878318,0x00007fca25878320] = 8

[Constant Pool (empty)]

[MachCode]
[Entry Point]
  # {method} {0x0000000800448920} '<init>' '()V' in 'java/lang/Object'
  #           [sp+0x40]  (sp of caller)
  0x00007fca258781a0: 448b 5608 | 49bb 0000 | 0000 0800 | 0000 4d03 | d34c 3bd0 

  0x00007fca258781b4: ;   {runtime_call ic_miss_stub}
  0x00007fca258781b4: 0f85 c6a5 | abff 660f | 1f44 0000 
[Verified Entry Point]
  0x00007fca258781c0: 8984 2400 | c0fe ff55 | 4883 ec30 

  0x00007fca258781cc: ;   {metadata(method data for {method} {0x0000000800448920} '<init>' '()V' in 'java/lang/Object')}
  0x00007fca258781cc: 48bf 1888 | 801c ca7f | 0000 8b9f | f400 0000 | 83c3 0289 | 9ff4 0000 | 0081 e3fe | 0700 0083 
  0x00007fca258781ec: fb00 0f84 

  0x00007fca258781f0: ;*return {reexecute=0 rethrow=0 return_oop=0}
                      ; - java.lang.Object::<init>@0 (line 44)
  0x00007fca258781f0: 1300 0000 | 4883 c430 

  0x00007fca258781f8: ;   {poll_return}
  0x00007fca258781f8: 5d49 3ba7 | 4003 0000 | 0f87 1f00 

  0x00007fca25878204: ;   {metadata({method} {0x0000000800448920} '<init>' '()V' in 'java/lang/Object')}
  0x00007fca25878204: 0000 c349 | ba20 8944 | 0008 0000 | 004c 8954 | 2408 48c7 | 0424 ffff 

  0x00007fca2587821c: ;   {runtime_call counter_overflow Runtime1 stub}
  0x00007fca2587821c: ffff e8dd 

  0x00007fca25878220: ; ImmutableOopMap {rsi=Oop }
                      ;*synchronization entry
                      ; - java.lang.Object::<init>@-1 (line 44)
  0x00007fca25878220: 6ab6 ffeb 

  0x00007fca25878224: ;   {internal_word}
  0x00007fca25878224: cf49 baf9 | 8187 25ca | 7f00 004d | 8997 5803 

  0x00007fca25878234: ;   {runtime_call SafepointBlob}
  0x00007fca25878234: 0000 e9c5 | 0eac ff90 | 9049 8b87 | d003 0000 | 49c7 87d0 | 0300 0000 | 0000 0049 | c787 d803 
  0x00007fca25878254: 0000 0000 | 0000 4883 

  0x00007fca2587825c: ;   {runtime_call unwind_exception Runtime1 stub}
  0x00007fca2587825c: c430 5de9 | 9c01 b6ff | f4f4 f4f4 | f4f4 f4f4 | f4f4 f4f4 | f4f4 f4f4 | f4f4 f4f4 | f4f4 f4f4 
  0x00007fca2587827c: f4f4 f4f4 
[Exception Handler]
  0x00007fca25878280: ;   {no_reloc}
  0x00007fca25878280: e87b 31b6 

  0x00007fca25878284: ;   {external_word}
  0x00007fca25878284: ff48 bf6a | 7482 41ca | 7f00 0048 

  0x00007fca25878290: ;   {runtime_call}
  0x00007fca25878290: 83e4 f0e8 | 080a ae1b 

  0x00007fca25878298: ;   {section_word}
  0x00007fca25878298: f449 ba99 | 8287 25ca | 7f00 0041 

  0x00007fca258782a4: ;   {runtime_call DeoptimizationBlob}
  0x00007fca258782a4: 52e9 f600 | acff f4f4 | f4f4 f4f4 
[/MachCode]
     34    2       3       java.lang.String::hashCode (60 bytes)


ベストアンサー1

を使用するには、逆+PrintAssemblyアセンブラプラグインが必要です。 Debianまたはその派生製品を使用している場合はインストールしてくださいlibhsdis0-fcml

これはopenjdk-17-dbgデバッグJDKではありません。デバッグJDKです。汎用JDKデバッグシンボルを含むパッケージ。

おすすめ記事