Where does the openjdk JVM interpreter execute the bytecode instanceof operation

Julian Waters tanksherman27 at gmail.com
Fri May 3 03:32:24 UTC 2024


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?

Sorry I couldn't help you further

best regards,
Julian

On Fri, May 3, 2024 at 11:21 AM zhengxianwei <baikaishiuc at gmail.com> wrote:

> Thank you for your response, which helped clarify some basic knowledge
> about the JVM interpreter.
>
> Okay, let's set aside bytecodeInterpreter.cpp for now.
>
> 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():
>
> ```
> void TemplateTable::instanceof() {
> print_info(os)("... %s:%d", __FILE__, __LINE__);
> ...
> }
> ```
>
> When I used the default dbeaver.ini file, the added log was present,
> indicating that TemplateTable::instanceof was indeed executed.
>
> 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.
>
> On Fri, May 3, 2024 at 11:03 AM Julian Waters <tanksherman27 at gmail.com>
> wrote:
>
>> Hi Xian Wei,
>>
>> 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
>> https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/x86/templateTable_x86.cpp#L4243
>> and on ARM, it is implemented in
>> https://github.com/openjdk/jdk/blob/6bef0474c8b8773d0d20c0f25c36a2ce9cdbd7e8/src/hotspot/cpu/arm/templateTable_arm.cpp#L4182
>>
>> Happy to help!
>>
>> best regards,
>> Julian
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20240503/0ecc16a7/attachment.htm>


More information about the hotspot-dev mailing list