implementing profiler ELT callbacks for AMD64 Linux#12603
Conversation
80a722b to
a9bb036
Compare
|
@sergign60 Looking over source code I found the possible problem with accessing to register arguments in Enter hook. Could you please take a look to ProfileArgIterator::ProfileArgIterator() method in amd64/profiler.cpp and check one more time hidden, this, RetBuff and other possible register args. They should be got from register, not from stack. |
|
@sergign60: did you already had a chance to try our Roman's' patch? we should be ready to merge, if Roman's suggestion is working for you and you make the chance in the PR. |
rartemev
left a comment
There was a problem hiding this comment.
RSP has to be 16 byte aligned at least because movdqa instructions will fail otherwise.
|
|
||
| push_argument_register rdx | ||
| alloc_stack SIZEOF_STACK_FRAME | ||
|
|
There was a problem hiding this comment.
RSP has to be 16 byte aligned. You have to add and rsp, -16 to do so.
| // rdx should be saved here because it can be used for returning struct values | ||
| push_argument_register rdx | ||
| alloc_stack SIZEOF_STACK_FRAME | ||
|
|
| // rdx should be saved here because it can be used for returning struct values | ||
| push_argument_register rdx | ||
| alloc_stack SIZEOF_STACK_FRAME | ||
|
|
There was a problem hiding this comment.
@rartemev I've tried to save 16 byte alignment by adding 0x8 to SIZEOF_STACK_FRAME. So we have two 8 byte pushes at the beginning, and 0x8 * 21 + 0x4 * 2 + 0x10 * 2 + 0x8. Is it not enough? Do you have any failed tests because of misaligning?
There was a problem hiding this comment.
@sergign60 I've seen, but it depends on what comes from above. I mean if you have aligned frame_size and unaligned rsp you will have unaligned rsp in result. On the other hand, if you have aligned rsp and unalinged frame_size you will have unaligned rsp as well. The point is you cannot know what rsp alignment you have in the beginning so that you have to make such correction after allocation.
|
@sergign60 thanks for your work on this. Any guidance on how to use the enter / leave hooks? I'm familiar with how to do this on Windows, with the naked calling convention, but at a loss where to start here. |
|
@dotnetjt The use is the same as in Windows, there is just slightly different calling conventions so you have to make sure to back up and restore some different registers. In asmhelpers.S you can look at ProfileEnterNaked as an example. This is the function we use to call in to C++ code from the naked jit helpers. |
This PR is the duplicate of #7719, that has been closed by mistake