diff options
| author | Mike Pall <mike> | 2011-02-16 00:38:23 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2011-02-16 00:38:23 +0100 |
| commit | 5fe7282d4ca548e604acb89e88ab0196a98c4065 (patch) | |
| tree | 98cb493939c0eb717270db41134bc2940a9ec862 | |
| parent | 4dca589af02ee20edfd797ca041ab8d2daf4caed (diff) | |
| download | luajit-5fe7282d4ca548e604acb89e88ab0196a98c4065.tar.gz luajit-5fe7282d4ca548e604acb89e88ab0196a98c4065.tar.bz2 luajit-5fe7282d4ca548e604acb89e88ab0196a98c4065.zip | |
Fix error handling within metamethods. Special-case FFI mm.
| -rw-r--r-- | src/Makefile.dep | 30 | ||||
| -rw-r--r-- | src/lj_err.c | 16 |
2 files changed, 28 insertions, 18 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index de46c57e..7f87155e 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
| @@ -85,7 +85,8 @@ lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | |||
| 85 | lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_vm.h luajit.h | 85 | lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_vm.h luajit.h |
| 86 | lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ | 86 | lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ |
| 87 | lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ | 87 | lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ |
| 88 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h | 88 | lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ |
| 89 | lj_traceerr.h lj_vm.h | ||
| 89 | lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 90 | lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
| 90 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ | 91 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ |
| 91 | lj_ffdef.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ | 92 | lj_ffdef.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ |
| @@ -162,18 +163,17 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ | |||
| 162 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ | 163 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ |
| 163 | lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_cdata.h lj_ctype.h \ | 164 | lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_cdata.h lj_ctype.h \ |
| 164 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ | 165 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ |
| 165 | lj_char.c lj_char.h lj_bc.c lj_bcdef.h lj_obj.c lj_str.c lj_tab.c \ | 166 | lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h lj_obj.c \ |
| 166 | lj_func.c lj_udata.c lj_meta.c lj_state.c lj_lex.h lj_alloc.h \ | 167 | lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_state.c lj_lex.h \ |
| 167 | lj_dispatch.c lj_ff.h lj_ffdef.h luajit.h lj_vmevent.c lj_vmevent.h \ | 168 | lj_alloc.h lj_dispatch.c luajit.h lj_vmevent.c lj_vmevent.h lj_api.c \ |
| 168 | lj_api.c lj_parse.h lj_lex.c lualib.h lj_parse.c lj_ctype.c lj_cdata.c \ | 169 | lj_parse.h lj_lex.c lualib.h lj_parse.c lj_ctype.c lj_cdata.c lj_cconv.h \ |
| 169 | lj_cconv.h lj_cconv.c lj_ccall.c lj_ccall.h lj_carith.c lj_carith.h \ | 170 | lj_cconv.c lj_ccall.c lj_ccall.h lj_carith.c lj_carith.h lj_clib.c \ |
| 170 | lj_clib.c lj_clib.h lj_cparse.c lj_cparse.h lj_lib.c lj_lib.h lj_ir.c \ | 171 | lj_clib.h lj_cparse.c lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_iropt.h \ |
| 171 | lj_iropt.h lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c \ | 172 | lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ |
| 172 | lj_opt_dce.c lj_opt_loop.c lj_snap.h lj_opt_split.c lj_mcode.c \ | 173 | lj_opt_loop.c lj_snap.h lj_opt_split.c lj_mcode.c lj_mcode.h lj_snap.c \ |
| 173 | lj_mcode.h lj_snap.c lj_target.h lj_target_*.h lj_record.c lj_record.h \ | 174 | lj_target.h lj_target_*.h lj_record.c lj_record.h lj_ffrecord.h \ |
| 174 | lj_ffrecord.h lj_crecord.c lj_crecord.h lj_ffrecord.c lj_recdef.h \ | 175 | lj_crecord.c lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h \ |
| 175 | lj_asm.c lj_asm.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c \ | 176 | lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c lib_base.c \ |
| 176 | lib_aux.c lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c \ | 177 | lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c lib_os.c \ |
| 177 | lib_io.c lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c \ | 178 | lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c lib_init.c |
| 178 | lib_ffi.c lib_init.c | ||
| 179 | luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h | 179 | luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h |
diff --git a/src/lj_err.c b/src/lj_err.c index 239f6e4f..12f32af2 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "lj_state.h" | 17 | #include "lj_state.h" |
| 18 | #include "lj_frame.h" | 18 | #include "lj_frame.h" |
| 19 | #include "lj_bc.h" | 19 | #include "lj_bc.h" |
| 20 | #include "lj_ff.h" | ||
| 20 | #include "lj_trace.h" | 21 | #include "lj_trace.h" |
| 21 | #include "lj_vm.h" | 22 | #include "lj_vm.h" |
| 22 | 23 | ||
| @@ -903,10 +904,19 @@ LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) | |||
| 903 | { | 904 | { |
| 904 | TValue *frame = L->base-1; | 905 | TValue *frame = L->base-1; |
| 905 | TValue *pframe = NULL; | 906 | TValue *pframe = NULL; |
| 906 | if (frame_islua(frame)) | 907 | if (frame_islua(frame)) { |
| 907 | pframe = frame_prevl(frame); | 908 | pframe = frame_prevl(frame); |
| 908 | else if (frame_iscont(frame)) | 909 | } else if (frame_iscont(frame)) { |
| 909 | L->base = (pframe = frame_prevd(frame))+1; /* Remove metamethod frame. */ | 910 | pframe = frame_prevd(frame); |
| 911 | #if LJ_HASFFI | ||
| 912 | /* Remove frame for FFI metamethods. */ | ||
| 913 | if (frame_func(frame)->c.ffid >= FF_ffi_meta___index && | ||
| 914 | frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) { | ||
| 915 | L->base = pframe+1; | ||
| 916 | L->top = frame; | ||
| 917 | } | ||
| 918 | #endif | ||
| 919 | } | ||
| 910 | err_loc(L, msg, pframe, frame); | 920 | err_loc(L, msg, pframe, frame); |
| 911 | lj_err_run(L); | 921 | lj_err_run(L); |
| 912 | } | 922 | } |
