diff options
author | Mike Pall <mike> | 2011-11-11 22:10:31 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-11-12 01:16:10 +0100 |
commit | 635371c212a2d344df2aff80506ea51afdd065ef (patch) | |
tree | a26a06fb3384366b8e6a036c4e6cdcd11ebd36ec /src/buildvm_asm.c | |
parent | 0123e4fc895f4a52422dff05a29596e389b4749c (diff) | |
download | luajit-635371c212a2d344df2aff80506ea51afdd065ef.tar.gz luajit-635371c212a2d344df2aff80506ea51afdd065ef.tar.bz2 luajit-635371c212a2d344df2aff80506ea51afdd065ef.zip |
FFI: Add unwind definitions for lj_vm_ffi_call.
Adds exception interoperability for C/C++ functions called via FFI
from the interpreter.
Diffstat (limited to 'src/buildvm_asm.c')
-rw-r--r-- | src/buildvm_asm.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/buildvm_asm.c b/src/buildvm_asm.c index 6a860c9f..01330456 100644 --- a/src/buildvm_asm.c +++ b/src/buildvm_asm.c | |||
@@ -202,6 +202,17 @@ void emit_asm(BuildCtx *ctx) | |||
202 | for (i = rel = 0; i < ctx->nsym; i++) { | 202 | for (i = rel = 0; i < ctx->nsym; i++) { |
203 | int32_t ofs = ctx->sym[i].ofs; | 203 | int32_t ofs = ctx->sym[i].ofs; |
204 | int32_t next = ctx->sym[i+1].ofs; | 204 | int32_t next = ctx->sym[i+1].ofs; |
205 | #if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND) && \ | ||
206 | LJ_HASFFI | ||
207 | if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call")) | ||
208 | fprintf(ctx->fp, | ||
209 | ".globl lj_err_unwind_arm\n" | ||
210 | ".personality lj_err_unwind_arm\n" | ||
211 | ".fnend\n" | ||
212 | ".fnstart\n" | ||
213 | ".save {r4, r5, r11, lr}\n" | ||
214 | ".setfp r11, sp\n"); | ||
215 | #endif | ||
205 | emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); | 216 | emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); |
206 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { | 217 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { |
207 | BuildReloc *r = &ctx->reloc[rel]; | 218 | BuildReloc *r = &ctx->reloc[rel]; |
@@ -229,8 +240,10 @@ void emit_asm(BuildCtx *ctx) | |||
229 | 240 | ||
230 | #if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND) | 241 | #if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND) |
231 | fprintf(ctx->fp, | 242 | fprintf(ctx->fp, |
243 | #if !LJ_HASFFI | ||
232 | ".globl lj_err_unwind_arm\n" | 244 | ".globl lj_err_unwind_arm\n" |
233 | ".personality lj_err_unwind_arm\n" | 245 | ".personality lj_err_unwind_arm\n" |
246 | #endif | ||
234 | ".fnend\n"); | 247 | ".fnend\n"); |
235 | #endif | 248 | #endif |
236 | 249 | ||