diff options
Diffstat (limited to 'src/vm_x64.dasc')
-rw-r--r-- | src/vm_x64.dasc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc index f99525b5..2b1c8d2d 100644 --- a/src/vm_x64.dasc +++ b/src/vm_x64.dasc | |||
@@ -143,6 +143,9 @@ | |||
143 | |.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). | 143 | |.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). |
144 | |.macro saveregs_ | 144 | |.macro saveregs_ |
145 | | push rbx; push r15; push r14 | 145 | | push rbx; push r15; push r14 |
146 | |.if NO_UNWIND | ||
147 | | push r13; push r12 | ||
148 | |.endif | ||
146 | | sub rsp, CFRAME_SPACE | 149 | | sub rsp, CFRAME_SPACE |
147 | |.endmacro | 150 | |.endmacro |
148 | |.macro saveregs | 151 | |.macro saveregs |
@@ -150,15 +153,28 @@ | |||
150 | |.endmacro | 153 | |.endmacro |
151 | |.macro restoreregs | 154 | |.macro restoreregs |
152 | | add rsp, CFRAME_SPACE | 155 | | add rsp, CFRAME_SPACE |
156 | |.if NO_UNWIND | ||
157 | | pop r12; pop r13 | ||
158 | |.endif | ||
153 | | pop r14; pop r15; pop rbx; pop rbp | 159 | | pop r14; pop r15; pop rbx; pop rbp |
154 | |.endmacro | 160 | |.endmacro |
155 | | | 161 | | |
156 | |//----- 16 byte aligned, | 162 | |//----- 16 byte aligned, |
163 | |.if NO_UNWIND | ||
164 | |.define SAVE_RET, aword [rsp+aword*11] //<-- rsp entering interpreter. | ||
165 | |.define SAVE_R4, aword [rsp+aword*10] | ||
166 | |.define SAVE_R3, aword [rsp+aword*9] | ||
167 | |.define SAVE_R2, aword [rsp+aword*8] | ||
168 | |.define SAVE_R1, aword [rsp+aword*7] | ||
169 | |.define SAVE_RU2, aword [rsp+aword*6] | ||
170 | |.define SAVE_RU1, aword [rsp+aword*5] //<-- rsp after register saves. | ||
171 | |.else | ||
157 | |.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. | 172 | |.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. |
158 | |.define SAVE_R4, aword [rsp+aword*8] | 173 | |.define SAVE_R4, aword [rsp+aword*8] |
159 | |.define SAVE_R3, aword [rsp+aword*7] | 174 | |.define SAVE_R3, aword [rsp+aword*7] |
160 | |.define SAVE_R2, aword [rsp+aword*6] | 175 | |.define SAVE_R2, aword [rsp+aword*6] |
161 | |.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. | 176 | |.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. |
177 | |.endif | ||
162 | |.define SAVE_CFRAME, aword [rsp+aword*4] | 178 | |.define SAVE_CFRAME, aword [rsp+aword*4] |
163 | |.define SAVE_PC, aword [rsp+aword*3] | 179 | |.define SAVE_PC, aword [rsp+aword*3] |
164 | |.define SAVE_L, aword [rsp+aword*2] | 180 | |.define SAVE_L, aword [rsp+aword*2] |
@@ -4682,6 +4698,10 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
4682 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | 4698 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ |
4683 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | 4699 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ |
4684 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | 4700 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ |
4701 | #if LJ_NO_UNWIND | ||
4702 | "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */ | ||
4703 | "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */ | ||
4704 | #endif | ||
4685 | "\t.align 8\n" | 4705 | "\t.align 8\n" |
4686 | ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); | 4706 | ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); |
4687 | #if LJ_HASFFI | 4707 | #if LJ_HASFFI |
@@ -4699,6 +4719,7 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
4699 | "\t.align 8\n" | 4719 | "\t.align 8\n" |
4700 | ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); | 4720 | ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); |
4701 | #endif | 4721 | #endif |
4722 | #if !LJ_NO_UNWIND | ||
4702 | #if (defined(__sun__) && defined(__svr4__)) | 4723 | #if (defined(__sun__) && defined(__svr4__)) |
4703 | fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); | 4724 | fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); |
4704 | #else | 4725 | #else |
@@ -4769,7 +4790,9 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
4769 | "\t.align 8\n" | 4790 | "\t.align 8\n" |
4770 | ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); | 4791 | ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); |
4771 | #endif | 4792 | #endif |
4793 | #endif | ||
4772 | break; | 4794 | break; |
4795 | #if !LJ_NO_UNWIND | ||
4773 | /* Mental note: never let Apple design an assembler. | 4796 | /* Mental note: never let Apple design an assembler. |
4774 | ** Or a linker. Or a plastic case. But I digress. | 4797 | ** Or a linker. Or a plastic case. But I digress. |
4775 | */ | 4798 | */ |
@@ -4864,6 +4887,7 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
4864 | fprintf(ctx->fp, ".subsections_via_symbols\n"); | 4887 | fprintf(ctx->fp, ".subsections_via_symbols\n"); |
4865 | } | 4888 | } |
4866 | break; | 4889 | break; |
4890 | #endif | ||
4867 | default: /* Difficult for other modes. */ | 4891 | default: /* Difficult for other modes. */ |
4868 | break; | 4892 | break; |
4869 | } | 4893 | } |