| 1 | # Constants that depend on whether we are on 32-bit or 64-bit |
| 2 | # the frame is absolutely standard. Stores callee-saved registers, |
| 3 | # return address and some scratch space for arguments. |
| 4 | |
| 5 | import sys |
| 6 | if sys.maxint == (2**31 - 1): |
| 7 | WORD = 4 |
| 8 | IS_X86_32 = True |
| 9 | IS_X86_64 = False |
| 10 | else: |
| 11 | WORD = 8 |
| 12 | IS_X86_32 = False |
| 13 | IS_X86_64 = True |
| 14 | WIN64 = sys.platform == "win32" and sys.maxint > 2**32 |
| 15 | |
| 16 | # |
| 17 | # +--------------------+ <== aligned to 16 bytes |
| 18 | # | return address | |
| 19 | # +--------------------+ ----------------------. |
| 20 | # | saved regs | FRAME_FIXED_SIZE | |
| 21 | # +--------------------+ --------------------. | |
| 22 | # | scratch | PASS_ON_MY_FRAME | | |
| 23 | # | space | | | |
| 24 | # +--------------------+ <== aligned to 16 -----' ----' |
| 25 | |
| 26 | # All the rest of the data is in a GC-managed variable-size "frame". |
| 27 | # This frame object's address is always stored in the register EBP/RBP. |
| 28 | # A frame is a jit.backend.llsupport.llmodel.JITFRAME = GcArray(Signed). |
| 29 | |
| 30 | # The frame's fixed size gives the standard fixed part at the |
| 31 | # start of every frame: the saved value of some registers |
| 32 | |
| 33 | if WORD == 4: |
| 34 | # ebp + ebx + esi + edi + 15 extra words = 19 words |
| 35 | FRAME_FIXED_SIZE = 19 + 4 # 4 for vmprof, XXX make more compact! |
| 36 | PASS_ON_MY_FRAME = 15 |
| 37 | JITFRAME_FIXED_SIZE = 6 + 8 * 2 # 6 GPR + 8 XMM * 2 WORDS/float |
| 38 | # 'threadlocal_addr' is passed as 2nd argument on the stack, |
| 39 | # and it can be left here for when it is needed. |
| 40 | THREADLOCAL_OFS = (FRAME_FIXED_SIZE + 2) * WORD |
| 41 | else: |
| 42 | # rbp + rbx + r12 + r13 + r14 + r15 + threadlocal + 12 extra words = 19 |
| 43 | # win64: we save instead rbp + rbx + rsi + rdi + r12 + 12 extra words = 17 |
| 44 | # win64: and we save r14 + r15 in the shadow store, and never use r13 |
| 45 | if not WIN64: |
| 46 | FRAME_FIXED_SIZE = 19 + 4 # 4 for vmprof, XXX make more compact! |
| 47 | else: |
| 48 | FRAME_FIXED_SIZE = 17 + 4 # 4 for vmprof, XXX make more compact! |
| 49 | PASS_ON_MY_FRAME = 12 |
| 50 | JITFRAME_FIXED_SIZE = 28 # 13 GPR + 15 XMM |
| 51 | if not WIN64: |
| 52 | # 'threadlocal_addr' is passed as 2nd argument in %esi, |
| 53 | # and is moved into this frame location. |
| 54 | THREADLOCAL_OFS = (FRAME_FIXED_SIZE - 1) * WORD |
| 55 | else: |
| 56 | # 'threadlocal_addr' is passed as 2nd argument in %edx, |
| 57 | # and is moved into its official shadow store location. |
| 58 | THREADLOCAL_OFS = (FRAME_FIXED_SIZE + 2) * WORD |
| 59 | SHADOWSTORE2_OFS = (FRAME_FIXED_SIZE + 3) * WORD |
| 60 | SHADOWSTORE3_OFS = (FRAME_FIXED_SIZE + 4) * WORD |
| 61 | |
| 62 | assert PASS_ON_MY_FRAME >= 12 |
| 63 | |
| 64 | # return address, followed by FRAME_FIXED_SIZE words |
| 65 | DEFAULT_FRAME_BYTES = (1 + FRAME_FIXED_SIZE) * WORD |