hsdis output from JVMCI

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

hsdis output from JVMCI

Yasumasa Suenaga-4
Hi all,

I tried to disassemble JVMCI installed code via hsdis.
It works but I got duplicate output from hsdis.

How to reproduce:

   1. Clone reproducer from GitHub
        https://github.com/YaSuenag/jdt-2017-examples

   2. Copy some files from hotspot testcase
        Please read README.md in this repository.

   3. Edit Makefile to use hsdis
        - code-injection/Makefile
        - Enable UnlockDiagnosticVMOptions and CompilerDirectivesFile

   4. Deploy hsdis to JDK 9 EA b169

   5. Run reproducer
        $ make JAVA_HOME=/path/to/jdk9 syscall


hsdis is called from JVMCIEnv::register_method() and CodeInstaller::install().
So we get same output from hsdis twice.
I think we should fix it as following:

-------------------------
diff -r d6d7e5caf497 src/share/vm/jvmci/jvmciCodeInstaller.cpp
--- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Mon May 15 12:20:15 2017 +0200
+++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue May 17 16:21:08 2017 +0900
@@ -623,7 +623,7 @@
      if (nm != NULL && env == NULL) {
        DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, compiler);
        bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
-      if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
+      if (!printnmethods && (PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers)) {
          nm->print_nmethod(printnmethods);
        }
        DirectivesStack::release(directive);
-------------------------

Is this bug?
If so, I will file it to JBS and will upload webrev.


Thanks,

Yasumasa


Reply | Threaded
Open this post in threaded view
|

Re: hsdis output from JVMCI

Remi Forax
Hi Yasumasa,
i've read the slides referenced on your github project,

slide 19: i believe that instead of printing the first tiers, you either want the last one or better all the tiers,
   IntStream.range(0, 4).filter(...).boxed().collect(Collectors.joining(", "))

otherwise the whole deck is quite fun, thank you !

Rémi

----- Mail original -----
> De: "Yasumasa Suenaga" <[hidden email]>
> À: [hidden email]
> Envoyé: Mercredi 17 Mai 2017 09:37:30
> Objet: hsdis output from JVMCI

> Hi all,
>
> I tried to disassemble JVMCI installed code via hsdis.
> It works but I got duplicate output from hsdis.
>
> How to reproduce:
>
>   1. Clone reproducer from GitHub
>        https://github.com/YaSuenag/jdt-2017-examples
>
>   2. Copy some files from hotspot testcase
>        Please read README.md in this repository.
>
>   3. Edit Makefile to use hsdis
>        - code-injection/Makefile
>        - Enable UnlockDiagnosticVMOptions and CompilerDirectivesFile
>
>   4. Deploy hsdis to JDK 9 EA b169
>
>   5. Run reproducer
>        $ make JAVA_HOME=/path/to/jdk9 syscall
>
>
> hsdis is called from JVMCIEnv::register_method() and CodeInstaller::install().
> So we get same output from hsdis twice.
> I think we should fix it as following:
>
> -------------------------
> diff -r d6d7e5caf497 src/share/vm/jvmci/jvmciCodeInstaller.cpp
> --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Mon May 15 12:20:15 2017 +0200
> +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue May 17 16:21:08 2017 +0900
> @@ -623,7 +623,7 @@
>      if (nm != NULL && env == NULL) {
>        DirectiveSet* directive = DirectivesStack::getMatchingDirective(method,
>        compiler);
>        bool printnmethods = directive->PrintAssemblyOption ||
>        directive->PrintNMethodsOption;
> -      if (printnmethods || PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers) {
> +      if (!printnmethods && (PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers)) {
>          nm->print_nmethod(printnmethods);
>        }
>        DirectivesStack::release(directive);
> -------------------------
>
> Is this bug?
> If so, I will file it to JBS and will upload webrev.
>
>
> Thanks,
>
> Yasumasa
Reply | Threaded
Open this post in threaded view
|

Re: hsdis output from JVMCI

Yasumasa Suenaga-4
Hi Remi,

Thank you for reading my slides in spite of Japanese :-)

> slide 19: i believe that instead of printing the first tiers, you either want the last one or better all the tiers,
>    IntStream.range(0, 4).filter(...).boxed().collect(Collectors.joining(", "))

It is correct.
HotSpotResolvedJavaMethod#hasCompiledCodeAtLevel() collects data from nmethod object [1].
It is single value [2] because one nmethod has one compiled code.


Anyway, I'm waiting the response about hsdis.


Thanks,

Yasumasa

[2] http://hg.openjdk.java.net/jdk9/dev/hotspot/file/507f8a7678b4/src/share/vm/code/nmethod.hpp#l105


2017-05-17 19:28 GMT+09:00 Remi Forax <[hidden email]>:
Hi Yasumasa,
i've read the slides referenced on your github project,

slide 19: i believe that instead of printing the first tiers, you either want the last one or better all the tiers,
   IntStream.range(0, 4).filter(...).boxed().collect(Collectors.joining(", "))

otherwise the whole deck is quite fun, thank you !

Rémi

----- Mail original -----
> De: "Yasumasa Suenaga" <[hidden email]>
> À: [hidden email]
> Envoyé: Mercredi 17 Mai 2017 09:37:30
> Objet: hsdis output from JVMCI

> Hi all,
>
> I tried to disassemble JVMCI installed code via hsdis.
> It works but I got duplicate output from hsdis.
>
> How to reproduce:
>
>   1. Clone reproducer from GitHub
>        https://github.com/YaSuenag/jdt-2017-examples
>
>   2. Copy some files from hotspot testcase
>        Please read README.md in this repository.
>
>   3. Edit Makefile to use hsdis
>        - code-injection/Makefile
>        - Enable UnlockDiagnosticVMOptions and CompilerDirectivesFile
>
>   4. Deploy hsdis to JDK 9 EA b169
>
>   5. Run reproducer
>        $ make JAVA_HOME=/path/to/jdk9 syscall
>
>
> hsdis is called from JVMCIEnv::register_method() and CodeInstaller::install().
> So we get same output from hsdis twice.
> I think we should fix it as following:
>
> -------------------------
> diff -r d6d7e5caf497 src/share/vm/jvmci/jvmciCodeInstaller.cpp
> --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp       Mon May 15 12:20:15 2017 +0200
> +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp       Tue May 17 16:21:08 2017 +0900
> @@ -623,7 +623,7 @@
>      if (nm != NULL && env == NULL) {
>        DirectiveSet* directive = DirectivesStack::getMatchingDirective(method,
>        compiler);
>        bool printnmethods = directive->PrintAssemblyOption ||
>        directive->PrintNMethodsOption;
> -      if (printnmethods || PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers) {
> +      if (!printnmethods && (PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers)) {
>          nm->print_nmethod(printnmethods);
>        }
>        DirectivesStack::release(directive);
> -------------------------
>
> Is this bug?
> If so, I will file it to JBS and will upload webrev.
>
>
> Thanks,
>
> Yasumasa

Reply | Threaded
Open this post in threaded view
|

Re: hsdis output from JVMCI

Remi Forax



De: "Yasumasa Suenaga" <[hidden email]>
À: "Remi Forax" <[hidden email]>
Cc: [hidden email]
Envoyé: Jeudi 18 Mai 2017 05:02:55
Objet: Re: hsdis output from JVMCI
Hi Remi,

Thank you for reading my slides in spite of Japanese :-)

> slide 19: i believe that instead of printing the first tiers, you either want the last one or better all the tiers,
>    IntStream.range(0, 4).filter(...).boxed().collect(Collectors.joining(", "))

It is correct.
HotSpotResolvedJavaMethod#hasCompiledCodeAtLevel() collects data from nmethod object [1].
It is single value [2] because one nmethod has one compiled code.

ok, good to know,
hence the 'resolved' in HotSpotResolvedJavaMethod i suppose.




Anyway, I'm waiting the response about hsdis.

i can't hep you on that :)



Thanks,

Yasumasa

cheers,
Rémi


[2] http://hg.openjdk.java.net/jdk9/dev/hotspot/file/507f8a7678b4/src/share/vm/code/nmethod.hpp#l105


2017-05-17 19:28 GMT+09:00 Remi Forax <[hidden email]>:
Hi Yasumasa,
i've read the slides referenced on your github project,

slide 19: i believe that instead of printing the first tiers, you either want the last one or better all the tiers,
   IntStream.range(0, 4).filter(...).boxed().collect(Collectors.joining(", "))

otherwise the whole deck is quite fun, thank you !

Rémi

----- Mail original -----
> De: "Yasumasa Suenaga" <[hidden email]>
> À: [hidden email]
> Envoyé: Mercredi 17 Mai 2017 09:37:30
> Objet: hsdis output from JVMCI

> Hi all,
>
> I tried to disassemble JVMCI installed code via hsdis.
> It works but I got duplicate output from hsdis.
>
> How to reproduce:
>
>   1. Clone reproducer from GitHub
>        https://github.com/YaSuenag/jdt-2017-examples
>
>   2. Copy some files from hotspot testcase
>        Please read README.md in this repository.
>
>   3. Edit Makefile to use hsdis
>        - code-injection/Makefile
>        - Enable UnlockDiagnosticVMOptions and CompilerDirectivesFile
>
>   4. Deploy hsdis to JDK 9 EA b169
>
>   5. Run reproducer
>        $ make JAVA_HOME=/path/to/jdk9 syscall
>
>
> hsdis is called from JVMCIEnv::register_method() and CodeInstaller::install().
> So we get same output from hsdis twice.
> I think we should fix it as following:
>
> -------------------------
> diff -r d6d7e5caf497 src/share/vm/jvmci/jvmciCodeInstaller.cpp
> --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp       Mon May 15 12:20:15 2017 +0200
> +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp       Tue May 17 16:21:08 2017 +0900
> @@ -623,7 +623,7 @@
>      if (nm != NULL && env == NULL) {
>        DirectiveSet* directive = DirectivesStack::getMatchingDirective(method,
>        compiler);
>        bool printnmethods = directive->PrintAssemblyOption ||
>        directive->PrintNMethodsOption;
> -      if (printnmethods || PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers) {
> +      if (!printnmethods && (PrintDebugInfo || PrintRelocations ||
> PrintDependencies || PrintExceptionHandlers)) {
>          nm->print_nmethod(printnmethods);
>        }
>        DirectivesStack::release(directive);
> -------------------------
>
> Is this bug?
> If so, I will file it to JBS and will upload webrev.
>
>
> Thanks,
>
> Yasumasa

Reply | Threaded
Open this post in threaded view
|

Re: hsdis output from JVMCI

Doug Simon @ Oracle
In reply to this post by Yasumasa Suenaga-4

> On 17 May 2017, at 09:37, Yasumasa Suenaga <[hidden email]> wrote:
>
> Hi all,
>
> I tried to disassemble JVMCI installed code via hsdis.
> It works but I got duplicate output from hsdis.
>
> How to reproduce:
>
>  1. Clone reproducer from GitHub
>       https://github.com/YaSuenag/jdt-2017-examples
>
>  2. Copy some files from hotspot testcase
>       Please read README.md in this repository.
>
>  3. Edit Makefile to use hsdis
>       - code-injection/Makefile
>       - Enable UnlockDiagnosticVMOptions and CompilerDirectivesFile
>
>  4. Deploy hsdis to JDK 9 EA b169
>
>  5. Run reproducer
>       $ make JAVA_HOME=/path/to/jdk9 syscall
>
>
> hsdis is called from JVMCIEnv::register_method() and CodeInstaller::install().
> So we get same output from hsdis twice.
> I think we should fix it as following:
>
> -------------------------
> diff -r d6d7e5caf497 src/share/vm/jvmci/jvmciCodeInstaller.cpp
> --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Mon May 15 12:20:15 2017 +0200
> +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue May 17 16:21:08 2017 +0900
> @@ -623,7 +623,7 @@
>     if (nm != NULL && env == NULL) {
>       DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, compiler);
>       bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
> -      if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
> +      if (!printnmethods && (PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers)) {
>         nm->print_nmethod(printnmethods);
>       }
>       DirectivesStack::release(directive);
> -------------------------

That looks like a sensible change to me.

-Doug