Point where code installed by C1 and C2 is loaded?

Julian Waters tanksherman27 at gmail.com
Wed Oct 12 15:18:18 UTC 2022


Hi all,

I apologise if this is a silly question, but where exactly is code
installed by C1 and C2 loaded and executed by the runtime? I've tried
looking through the entirety of hotspot, but haven't found anything that
seems to be related. All I can surmise is that the compiler interface
ultimately creates an nmethod that allocates itself on the CodeCache using
a CodeBuffer containing C1 or C2 emitted instructions, and then
Method::set_code sets the method's _code to reference that entry in the
cache (or method->method_holder()->add_osr_nmethod(nm); is called in other
circumstances, I don't quite understand what the difference is but I assume
the end result is probably the same). Given my rudimentary understanding of
hotspot's execution pipeline I'd assume that when a new frame (frame.hpp)
is created, the frame's code blob would be set to reference the nmethod in
the method that was called, or otherwise somehow jump back to the
interpreter if that method hasn't been compiled yet. But there doesn't seem
to be any point where method->code() is called to load the instructions
emitted by either C1 or C2 into a frame, so where does that happen?

I guess this is probably more a question of how hotspot runs loaded
programs in general, which seems to me at a glance like it's chaining
assembly in CodeBlobs together and jumping to the next blob/codelet (in the
next frame?) when it's finished, but I can't really figure out where
those codelets are set for each frame, or how it chooses between one
compiled by C1 or C2, and the handwritten assembly codelets that make up
the interpreter (or for that matter how it even finds the correct
interpreter codelet).

I appreciate any help with this query, sorry if this isn't the correct list
to post this question to, but it seemed like the most appropriate.

best regards,
Julian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-compiler-dev/attachments/20221012/571ed383/attachment-0001.htm>


More information about the hotspot-compiler-dev mailing list