<div dir="ltr">Unfortunately that's where my knowledge ends. The Template Table as it's called is only run once at the start of the program, to insert the assembly into executable memory, I'm not sure how to properly add a log in the middle of the assembly inside the Interpreter. Maybe David or Thomas could help with this?<div><br></div><div>Sorry I couldn't help you further<i></i></div><div><br></div><div>best regards,</div><div>Julian</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2024 at 11:21 AM zhengxianwei <<a href="mailto:baikaishiuc@gmail.com">baikaishiuc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you for your response, which helped clarify some basic knowledge about the JVM interpreter.<br><br>Okay, let's set aside bytecodeInterpreter.cpp for now.<br><br>However, I still have some confusion about the interpreter you mentioned in templateTable_x86.cpp. I conducted a test where I added a print statement in TemplateTable::instanceof():<br><br>```<br>void TemplateTable::instanceof() {<br>  print_info(os)("... %s:%d", __FILE__, __LINE__);<br>    ...<br>}<br>```<br><br>When I used the default dbeaver.ini file, the added log was present, indicating that TemplateTable::instanceof was indeed executed.<br><br>But when I modified dbeaver.ini to include an option -Xint (which I understand to mean running the program entirely using interpretation), the print disappeared. This suggests that after adding -Xint, TemplateTable::instanceof was not executed. So, I'm wondering if there are any other interpretations for instanceof after adding -Xint.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2024 at 11:03 AM Julian Waters <<a href="mailto:tanksherman27@gmail.com" target="_blank">tanksherman27@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Xian Wei,<div><br></div><div>No, you are right! The code in templateTable_x86.cpp that you linked to in your post is not part of the Just in Time Compilers, it is part of the x86 Interpreter! The Java HotSpot VM actually has 2 different Interpreters, the primary Interpreter is written in large chunks of assembly specific to each platform, which is then processed by the HotSpot macro assemblers. The bytecodeInterpreter.cpp file you linked to is part of the second and less often used Interpreter, which is why modifying the bytecodeInterpreter.cpp instanceof implementation did nothing in your case (The Interpreter used actually depends on the platform, and the secondary Interpreter is not used on ARM or x86). The details on the macro assemblers unfortunately elude me since I am not a HotSpot expert (Although I hope to be one day), but to understand how instanceof works on x86 and ARM, you need to understand both x86 and ARM assembly. The Interpreter's instanceof opcode is implemented on x86 in <a href="https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/x86/templateTable_x86.cpp#L4243" target="_blank">https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/x86/templateTable_x86.cpp#L4243</a> and on ARM, it is implemented in <a href="https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/arm/templateTable_arm.cpp#L4182" target="_blank">https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/arm/templateTable_arm.cpp#L4182</a></div><div><br></div><div>Happy to help!</div><div><br></div><div>best regards,</div><div>Julian</div></div>
</blockquote></div>
</blockquote></div>