diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_err.c | 161 |
1 files changed, 95 insertions, 66 deletions
diff --git a/src/lj_err.c b/src/lj_err.c index de30619c..a847ca07 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include "lj_ff.h" | 16 | #include "lj_ff.h" |
17 | #include "lj_trace.h" | 17 | #include "lj_trace.h" |
18 | #include "lj_vm.h" | 18 | #include "lj_vm.h" |
19 | #include "lj_strfmt.h" | ||
19 | 20 | ||
20 | /* | 21 | /* |
21 | ** LuaJIT can either use internal or external frame unwinding: | 22 | ** LuaJIT can either use internal or external frame unwinding: |
@@ -98,14 +99,14 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
98 | TValue *top = restorestack(L, -nres); | 99 | TValue *top = restorestack(L, -nres); |
99 | if (frame < top) { /* Frame reached? */ | 100 | if (frame < top) { /* Frame reached? */ |
100 | if (errcode) { | 101 | if (errcode) { |
101 | L->cframe = cframe_prev(cf); | ||
102 | L->base = frame+1; | 102 | L->base = frame+1; |
103 | L->cframe = cframe_prev(cf); | ||
103 | unwindstack(L, top); | 104 | unwindstack(L, top); |
104 | } | 105 | } |
105 | return cf; | 106 | return cf; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | if (frame <= tvref(L->stack)) | 109 | if (frame <= tvref(L->stack)+LJ_FR2) |
109 | break; | 110 | break; |
110 | switch (frame_typep(frame)) { | 111 | switch (frame_typep(frame)) { |
111 | case FRAME_LUA: /* Lua frame. */ | 112 | case FRAME_LUA: /* Lua frame. */ |
@@ -113,14 +114,12 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
113 | frame = frame_prevl(frame); | 114 | frame = frame_prevl(frame); |
114 | break; | 115 | break; |
115 | case FRAME_C: /* C frame. */ | 116 | case FRAME_C: /* C frame. */ |
116 | #if LJ_HASFFI | ||
117 | unwind_c: | 117 | unwind_c: |
118 | #endif | ||
119 | #if LJ_UNWIND_EXT | 118 | #if LJ_UNWIND_EXT |
120 | if (errcode) { | 119 | if (errcode) { |
121 | L->cframe = cframe_prev(cf); | ||
122 | L->base = frame_prevd(frame) + 1; | 120 | L->base = frame_prevd(frame) + 1; |
123 | unwindstack(L, frame); | 121 | L->cframe = cframe_prev(cf); |
122 | unwindstack(L, frame - LJ_FR2); | ||
124 | } else if (cf != stopcf) { | 123 | } else if (cf != stopcf) { |
125 | cf = cframe_prev(cf); | 124 | cf = cframe_prev(cf); |
126 | frame = frame_prevd(frame); | 125 | frame = frame_prevd(frame); |
@@ -143,16 +142,14 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
143 | return cf; | 142 | return cf; |
144 | } | 143 | } |
145 | if (errcode) { | 144 | if (errcode) { |
146 | L->cframe = cframe_prev(cf); | ||
147 | L->base = frame_prevd(frame) + 1; | 145 | L->base = frame_prevd(frame) + 1; |
148 | unwindstack(L, frame); | 146 | L->cframe = cframe_prev(cf); |
147 | unwindstack(L, frame - LJ_FR2); | ||
149 | } | 148 | } |
150 | return cf; | 149 | return cf; |
151 | case FRAME_CONT: /* Continuation frame. */ | 150 | case FRAME_CONT: /* Continuation frame. */ |
152 | #if LJ_HASFFI | 151 | if (frame_iscont_fficb(frame)) |
153 | if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) | ||
154 | goto unwind_c; | 152 | goto unwind_c; |
155 | #endif | ||
156 | case FRAME_VARG: /* Vararg frame. */ | 153 | case FRAME_VARG: /* Vararg frame. */ |
157 | frame = frame_prevd(frame); | 154 | frame = frame_prevd(frame); |
158 | break; | 155 | break; |
@@ -165,8 +162,8 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
165 | } | 162 | } |
166 | if (frame_typep(frame) == FRAME_PCALL) | 163 | if (frame_typep(frame) == FRAME_PCALL) |
167 | hook_leave(G(L)); | 164 | hook_leave(G(L)); |
168 | L->cframe = cf; | ||
169 | L->base = frame_prevd(frame) + 1; | 165 | L->base = frame_prevd(frame) + 1; |
166 | L->cframe = cf; | ||
170 | unwindstack(L, L->base); | 167 | unwindstack(L, L->base); |
171 | } | 168 | } |
172 | return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); | 169 | return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); |
@@ -174,8 +171,8 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
174 | } | 171 | } |
175 | /* No C frame. */ | 172 | /* No C frame. */ |
176 | if (errcode) { | 173 | if (errcode) { |
174 | L->base = tvref(L->stack)+1+LJ_FR2; | ||
177 | L->cframe = NULL; | 175 | L->cframe = NULL; |
178 | L->base = tvref(L->stack)+1; | ||
179 | unwindstack(L, L->base); | 176 | unwindstack(L, L->base); |
180 | if (G(L)->panic) | 177 | if (G(L)->panic) |
181 | G(L)->panic(L); | 178 | G(L)->panic(L); |
@@ -193,13 +190,6 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
193 | ** since various OS, distros and compilers mess up the header installation. | 190 | ** since various OS, distros and compilers mess up the header installation. |
194 | */ | 191 | */ |
195 | 192 | ||
196 | typedef struct _Unwind_Exception | ||
197 | { | ||
198 | uint64_t exclass; | ||
199 | void (*excleanup)(int, struct _Unwind_Exception *); | ||
200 | uintptr_t p1, p2; | ||
201 | } __attribute__((__aligned__)) _Unwind_Exception; | ||
202 | |||
203 | typedef struct _Unwind_Context _Unwind_Context; | 193 | typedef struct _Unwind_Context _Unwind_Context; |
204 | 194 | ||
205 | #define _URC_OK 0 | 195 | #define _URC_OK 0 |
@@ -209,8 +199,20 @@ typedef struct _Unwind_Context _Unwind_Context; | |||
209 | #define _URC_CONTINUE_UNWIND 8 | 199 | #define _URC_CONTINUE_UNWIND 8 |
210 | #define _URC_FAILURE 9 | 200 | #define _URC_FAILURE 9 |
211 | 201 | ||
202 | #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ | ||
203 | #define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) | ||
204 | #define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) | ||
205 | #define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) | ||
206 | |||
212 | #if !LJ_TARGET_ARM | 207 | #if !LJ_TARGET_ARM |
213 | 208 | ||
209 | typedef struct _Unwind_Exception | ||
210 | { | ||
211 | uint64_t exclass; | ||
212 | void (*excleanup)(int, struct _Unwind_Exception *); | ||
213 | uintptr_t p1, p2; | ||
214 | } __attribute__((__aligned__)) _Unwind_Exception; | ||
215 | |||
214 | extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); | 216 | extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); |
215 | extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); | 217 | extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); |
216 | extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); | 218 | extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); |
@@ -222,11 +224,6 @@ extern int _Unwind_RaiseException(_Unwind_Exception *); | |||
222 | #define _UA_HANDLER_FRAME 4 | 224 | #define _UA_HANDLER_FRAME 4 |
223 | #define _UA_FORCE_UNWIND 8 | 225 | #define _UA_FORCE_UNWIND 8 |
224 | 226 | ||
225 | #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ | ||
226 | #define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) | ||
227 | #define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) | ||
228 | #define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) | ||
229 | |||
230 | /* DWARF2 personality handler referenced from interpreter .eh_frame. */ | 227 | /* DWARF2 personality handler referenced from interpreter .eh_frame. */ |
231 | LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, | 228 | LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, |
232 | uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) | 229 | uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) |
@@ -305,10 +302,22 @@ static void err_raise_ext(int errcode) | |||
305 | } | 302 | } |
306 | #endif | 303 | #endif |
307 | 304 | ||
308 | #else | 305 | #else /* LJ_TARGET_ARM */ |
306 | |||
307 | #define _US_VIRTUAL_UNWIND_FRAME 0 | ||
308 | #define _US_UNWIND_FRAME_STARTING 1 | ||
309 | #define _US_ACTION_MASK 3 | ||
310 | #define _US_FORCE_UNWIND 8 | ||
311 | |||
312 | typedef struct _Unwind_Control_Block _Unwind_Control_Block; | ||
313 | |||
314 | struct _Unwind_Control_Block { | ||
315 | uint64_t exclass; | ||
316 | uint32_t misc[20]; | ||
317 | }; | ||
309 | 318 | ||
310 | extern void _Unwind_DeleteException(void *); | 319 | extern int _Unwind_RaiseException(_Unwind_Control_Block *); |
311 | extern int __gnu_unwind_frame (void *, _Unwind_Context *); | 320 | extern int __gnu_unwind_frame(_Unwind_Control_Block *, _Unwind_Context *); |
312 | extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); | 321 | extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); |
313 | extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); | 322 | extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); |
314 | 323 | ||
@@ -324,34 +333,57 @@ static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v) | |||
324 | _Unwind_VRS_Set(ctx, 0, r, 0, &v); | 333 | _Unwind_VRS_Set(ctx, 0, r, 0, &v); |
325 | } | 334 | } |
326 | 335 | ||
327 | #define _US_VIRTUAL_UNWIND_FRAME 0 | 336 | extern void lj_vm_unwind_ext(void); |
328 | #define _US_UNWIND_FRAME_STARTING 1 | ||
329 | #define _US_ACTION_MASK 3 | ||
330 | #define _US_FORCE_UNWIND 8 | ||
331 | 337 | ||
332 | /* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ | 338 | /* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ |
333 | LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx) | 339 | LJ_FUNCA int lj_err_unwind_arm(int state, _Unwind_Control_Block *ucb, |
340 | _Unwind_Context *ctx) | ||
334 | { | 341 | { |
335 | void *cf = (void *)_Unwind_GetGR(ctx, 13); | 342 | void *cf = (void *)_Unwind_GetGR(ctx, 13); |
336 | lua_State *L = cframe_L(cf); | 343 | lua_State *L = cframe_L(cf); |
337 | if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) { | 344 | int errcode; |
338 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); | 345 | |
346 | switch ((state & _US_ACTION_MASK)) { | ||
347 | case _US_VIRTUAL_UNWIND_FRAME: | ||
348 | if ((state & _US_FORCE_UNWIND)) break; | ||
339 | return _URC_HANDLER_FOUND; | 349 | return _URC_HANDLER_FOUND; |
340 | } | 350 | case _US_UNWIND_FRAME_STARTING: |
341 | if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) { | 351 | if (LJ_UEXCLASS_CHECK(ucb->exclass)) { |
342 | _Unwind_DeleteException(ucb); | 352 | errcode = LJ_UEXCLASS_ERRCODE(ucb->exclass); |
343 | _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw); | 353 | } else { |
344 | _Unwind_SetGR(ctx, 0, (uint32_t)L); | 354 | errcode = LUA_ERRRUN; |
345 | _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN); | 355 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); |
356 | } | ||
357 | cf = err_unwind(L, cf, errcode); | ||
358 | if ((state & _US_FORCE_UNWIND) || cf == NULL) break; | ||
359 | _Unwind_SetGR(ctx, 15, (uint32_t)lj_vm_unwind_ext); | ||
360 | _Unwind_SetGR(ctx, 0, (uint32_t)ucb); | ||
361 | _Unwind_SetGR(ctx, 1, (uint32_t)errcode); | ||
362 | _Unwind_SetGR(ctx, 2, cframe_unwind_ff(cf) ? | ||
363 | (uint32_t)lj_vm_unwind_ff_eh : | ||
364 | (uint32_t)lj_vm_unwind_c_eh); | ||
346 | return _URC_INSTALL_CONTEXT; | 365 | return _URC_INSTALL_CONTEXT; |
366 | default: | ||
367 | return _URC_FAILURE; | ||
347 | } | 368 | } |
348 | if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) | 369 | if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) |
349 | return _URC_FAILURE; | 370 | return _URC_FAILURE; |
350 | return _URC_CONTINUE_UNWIND; | 371 | return _URC_CONTINUE_UNWIND; |
351 | } | 372 | } |
352 | 373 | ||
374 | #if LJ_UNWIND_EXT | ||
375 | static __thread _Unwind_Control_Block static_uex; | ||
376 | |||
377 | static void err_raise_ext(int errcode) | ||
378 | { | ||
379 | memset(&static_uex, 0, sizeof(static_uex)); | ||
380 | static_uex.exclass = LJ_UEXCLASS_MAKE(errcode); | ||
381 | _Unwind_RaiseException(&static_uex); | ||
382 | } | ||
353 | #endif | 383 | #endif |
354 | 384 | ||
385 | #endif /* LJ_TARGET_ARM */ | ||
386 | |||
355 | #elif LJ_TARGET_X64 && LJ_ABI_WIN | 387 | #elif LJ_TARGET_X64 && LJ_ABI_WIN |
356 | 388 | ||
357 | /* | 389 | /* |
@@ -454,7 +486,7 @@ LJ_NOINLINE void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode) | |||
454 | { | 486 | { |
455 | global_State *g = G(L); | 487 | global_State *g = G(L); |
456 | lj_trace_abort(g); | 488 | lj_trace_abort(g); |
457 | setgcrefnull(g->jit_L); | 489 | setmref(g->jit_base, NULL); |
458 | L->status = 0; | 490 | L->status = 0; |
459 | #if LJ_UNWIND_EXT | 491 | #if LJ_UNWIND_EXT |
460 | err_raise_ext(errcode); | 492 | err_raise_ext(errcode); |
@@ -499,7 +531,7 @@ LJ_NOINLINE void lj_err_mem(lua_State *L) | |||
499 | /* Find error function for runtime errors. Requires an extra stack traversal. */ | 531 | /* Find error function for runtime errors. Requires an extra stack traversal. */ |
500 | static ptrdiff_t finderrfunc(lua_State *L) | 532 | static ptrdiff_t finderrfunc(lua_State *L) |
501 | { | 533 | { |
502 | cTValue *frame = L->base-1, *bot = tvref(L->stack); | 534 | cTValue *frame = L->base-1, *bot = tvref(L->stack)+LJ_FR2; |
503 | void *cf = L->cframe; | 535 | void *cf = L->cframe; |
504 | while (frame > bot && cf) { | 536 | while (frame > bot && cf) { |
505 | while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ | 537 | while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ |
@@ -523,10 +555,8 @@ static ptrdiff_t finderrfunc(lua_State *L) | |||
523 | frame = frame_prevd(frame); | 555 | frame = frame_prevd(frame); |
524 | break; | 556 | break; |
525 | case FRAME_CONT: | 557 | case FRAME_CONT: |
526 | #if LJ_HASFFI | 558 | if (frame_iscont_fficb(frame)) |
527 | if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) | ||
528 | cf = cframe_prev(cf); | 559 | cf = cframe_prev(cf); |
529 | #endif | ||
530 | frame = frame_prevd(frame); | 560 | frame = frame_prevd(frame); |
531 | break; | 561 | break; |
532 | case FRAME_CP: | 562 | case FRAME_CP: |
@@ -537,8 +567,8 @@ static ptrdiff_t finderrfunc(lua_State *L) | |||
537 | break; | 567 | break; |
538 | case FRAME_PCALL: | 568 | case FRAME_PCALL: |
539 | case FRAME_PCALLH: | 569 | case FRAME_PCALLH: |
540 | if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */ | 570 | if (frame_func(frame_prevd(frame))->c.ffid == FF_xpcall) |
541 | return savestack(L, frame-1); /* Point to xpcall's errorfunc. */ | 571 | return savestack(L, frame_prevd(frame)+1); /* xpcall's errorfunc. */ |
542 | return 0; | 572 | return 0; |
543 | default: | 573 | default: |
544 | lua_assert(0); | 574 | lua_assert(0); |
@@ -561,8 +591,9 @@ LJ_NOINLINE void lj_err_run(lua_State *L) | |||
561 | lj_err_throw(L, LUA_ERRERR); | 591 | lj_err_throw(L, LUA_ERRERR); |
562 | } | 592 | } |
563 | L->status = LUA_ERRERR; | 593 | L->status = LUA_ERRERR; |
564 | copyTV(L, top, top-1); | 594 | copyTV(L, top+LJ_FR2, top-1); |
565 | copyTV(L, top-1, errfunc); | 595 | copyTV(L, top-1, errfunc); |
596 | if (LJ_FR2) setnilV(top++); | ||
566 | L->top = top+1; | 597 | L->top = top+1; |
567 | lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ | 598 | lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ |
568 | } | 599 | } |
@@ -576,7 +607,7 @@ LJ_NORET LJ_NOINLINE static void err_msgv(lua_State *L, ErrMsg em, ...) | |||
576 | va_list argp; | 607 | va_list argp; |
577 | va_start(argp, em); | 608 | va_start(argp, em); |
578 | if (curr_funcisL(L)) L->top = curr_topL(L); | 609 | if (curr_funcisL(L)) L->top = curr_topL(L); |
579 | msg = lj_str_pushvf(L, err2msg(em), argp); | 610 | msg = lj_strfmt_pushvf(L, err2msg(em), argp); |
580 | va_end(argp); | 611 | va_end(argp); |
581 | lj_debug_addloc(L, msg, L->base-1, NULL); | 612 | lj_debug_addloc(L, msg, L->base-1, NULL); |
582 | lj_err_run(L); | 613 | lj_err_run(L); |
@@ -594,11 +625,11 @@ LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok, | |||
594 | { | 625 | { |
595 | char buff[LUA_IDSIZE]; | 626 | char buff[LUA_IDSIZE]; |
596 | const char *msg; | 627 | const char *msg; |
597 | lj_debug_shortname(buff, src); | 628 | lj_debug_shortname(buff, src, line); |
598 | msg = lj_str_pushvf(L, err2msg(em), argp); | 629 | msg = lj_strfmt_pushvf(L, err2msg(em), argp); |
599 | msg = lj_str_pushf(L, "%s:%d: %s", buff, line, msg); | 630 | msg = lj_strfmt_pushf(L, "%s:%d: %s", buff, line, msg); |
600 | if (tok) | 631 | if (tok) |
601 | lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); | 632 | lj_strfmt_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); |
602 | lj_err_throw(L, LUA_ERRSYNTAX); | 633 | lj_err_throw(L, LUA_ERRSYNTAX); |
603 | } | 634 | } |
604 | 635 | ||
@@ -637,8 +668,9 @@ LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) | |||
637 | const BCIns *pc = cframe_Lpc(L); | 668 | const BCIns *pc = cframe_Lpc(L); |
638 | if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { | 669 | if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { |
639 | const char *tname = lj_typename(o); | 670 | const char *tname = lj_typename(o); |
671 | if (LJ_FR2) o++; | ||
640 | setframe_pc(o, pc); | 672 | setframe_pc(o, pc); |
641 | setframe_gc(o, obj2gco(L)); | 673 | setframe_gc(o, obj2gco(L), LJ_TTHREAD); |
642 | L->top = L->base = o+1; | 674 | L->top = L->base = o+1; |
643 | err_msgv(L, LJ_ERR_BADCALL, tname); | 675 | err_msgv(L, LJ_ERR_BADCALL, tname); |
644 | } | 676 | } |
@@ -653,13 +685,10 @@ LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) | |||
653 | if (frame_islua(frame)) { | 685 | if (frame_islua(frame)) { |
654 | pframe = frame_prevl(frame); | 686 | pframe = frame_prevl(frame); |
655 | } else if (frame_iscont(frame)) { | 687 | } else if (frame_iscont(frame)) { |
656 | #if LJ_HASFFI | 688 | if (frame_iscont_fficb(frame)) { |
657 | if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) { | ||
658 | pframe = frame; | 689 | pframe = frame; |
659 | frame = NULL; | 690 | frame = NULL; |
660 | } else | 691 | } else { |
661 | #endif | ||
662 | { | ||
663 | pframe = frame_prevd(frame); | 692 | pframe = frame_prevd(frame); |
664 | #if LJ_HASFFI | 693 | #if LJ_HASFFI |
665 | /* Remove frame for FFI metamethods. */ | 694 | /* Remove frame for FFI metamethods. */ |
@@ -682,7 +711,7 @@ LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...) | |||
682 | const char *msg; | 711 | const char *msg; |
683 | va_list argp; | 712 | va_list argp; |
684 | va_start(argp, em); | 713 | va_start(argp, em); |
685 | msg = lj_str_pushvf(L, err2msg(em), argp); | 714 | msg = lj_strfmt_pushvf(L, err2msg(em), argp); |
686 | va_end(argp); | 715 | va_end(argp); |
687 | lj_err_callermsg(L, msg); | 716 | lj_err_callermsg(L, msg); |
688 | } | 717 | } |
@@ -702,9 +731,9 @@ LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg, | |||
702 | if (narg < 0 && narg > LUA_REGISTRYINDEX) | 731 | if (narg < 0 && narg > LUA_REGISTRYINDEX) |
703 | narg = (int)(L->top - L->base) + narg + 1; | 732 | narg = (int)(L->top - L->base) + narg + 1; |
704 | if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ | 733 | if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ |
705 | msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); | 734 | msg = lj_strfmt_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); |
706 | else | 735 | else |
707 | msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); | 736 | msg = lj_strfmt_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); |
708 | lj_err_callermsg(L, msg); | 737 | lj_err_callermsg(L, msg); |
709 | } | 738 | } |
710 | 739 | ||
@@ -714,7 +743,7 @@ LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...) | |||
714 | const char *msg; | 743 | const char *msg; |
715 | va_list argp; | 744 | va_list argp; |
716 | va_start(argp, em); | 745 | va_start(argp, em); |
717 | msg = lj_str_pushvf(L, err2msg(em), argp); | 746 | msg = lj_strfmt_pushvf(L, err2msg(em), argp); |
718 | va_end(argp); | 747 | va_end(argp); |
719 | err_argmsg(L, narg, msg); | 748 | err_argmsg(L, narg, msg); |
720 | } | 749 | } |
@@ -744,7 +773,7 @@ LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) | |||
744 | TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; | 773 | TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; |
745 | tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; | 774 | tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; |
746 | } | 775 | } |
747 | msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); | 776 | msg = lj_strfmt_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); |
748 | err_argmsg(L, narg, msg); | 777 | err_argmsg(L, narg, msg); |
749 | } | 778 | } |
750 | 779 | ||
@@ -794,7 +823,7 @@ LUALIB_API int luaL_error(lua_State *L, const char *fmt, ...) | |||
794 | const char *msg; | 823 | const char *msg; |
795 | va_list argp; | 824 | va_list argp; |
796 | va_start(argp, fmt); | 825 | va_start(argp, fmt); |
797 | msg = lj_str_pushvf(L, fmt, argp); | 826 | msg = lj_strfmt_pushvf(L, fmt, argp); |
798 | va_end(argp); | 827 | va_end(argp); |
799 | lj_err_callermsg(L, msg); | 828 | lj_err_callermsg(L, msg); |
800 | return 0; /* unreachable */ | 829 | return 0; /* unreachable */ |