-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement stack probing using helpers #26807
Changes from all commits
952cb33
8eea8c9
6c70df6
92f109d
7f8c9a5
93be2fa
0805dda
729e267
c62992b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -955,5 +955,37 @@ endif ; _DEBUG | |
|
|
||
| NESTED_END TailCallHelperStub, _TEXT | ||
|
|
||
| end | ||
| ; The following helper will access ("probe") a word on each page of the stack | ||
| ; starting with the page right beneath rsp down to the one pointed to by r11. | ||
| ; The procedure is needed to make sure that the "guard" page is pushed down below the allocated stack frame. | ||
| ; The call to the helper will be emitted by JIT in the function/funclet prolog when large (larger than 0x3000 bytes) stack frame is required. | ||
| ; | ||
| ; NOTE: this helper will NOT modify a value of rsp and can be defined as a leaf function. | ||
|
|
||
| PAGE_SIZE equ 1000h | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An interesting side-effect here is that the page size (that we probe) is hard-coded to 0x1000, whereas in PAL builds, the page size is currently dynamic. For >4K pages, we might over-probe. But I suppose that is ok -- better perhaps than burning a register to pass in the page size, or creating extra page size specific helpers.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though about several options here:
I chose 4 and as a contingency plan if there will be a strong requirement for using "true" page size we can add a logic that will patch the helper during the process startup and adjust the page size. |
||
|
|
||
| LEAF_ENTRY JIT_StackProbe, _TEXT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to see a line or two of comments in these asm helpers describing the purpose and function of the helper (what it does), in addition to the register "on entry" / "on exit" documentation (which is super useful). It would also be useful to indicate what all the requirements are around each helper (as the requirements differ per platform). E.g., on Linux you can't probe beyond ESP/RSP.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BruceForstall I believe I have addressed all your suggestions - please take a look and let me know if I need to clarify anything else |
||
| ; On entry: | ||
| ; r11 - points to the lowest address on the stack frame being allocated (i.e. [InitialSp - FrameSize]) | ||
| ; rsp - points to some byte on the last probed page | ||
| ; On exit: | ||
| ; rax - is not preserved | ||
| ; r11 - is preserved | ||
| ; | ||
| ; NOTE: this helper will probe at least one page below the one pointed by rsp. | ||
|
|
||
| lea rax, [rsp - PAGE_SIZE] ; rax points to some byte on the first unprobed page | ||
| or rax, (PAGE_SIZE - 1) ; rax points to the **highest address** on the first unprobed page | ||
| ; This is done to make the following loop end condition simpler. | ||
|
|
||
| ProbeLoop: | ||
| test dword ptr [rax], eax | ||
| sub rax, PAGE_SIZE ; rax points to the highest address of the **next page** to probe | ||
| cmp rax, r11 | ||
| jge ProbeLoop ; if (rax >= r11), then we need to probe the page pointed to by rax. | ||
|
|
||
| ret | ||
|
|
||
| LEAF_END JIT_StackProbe, _TEXT | ||
|
|
||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.