aboutsummaryrefslogtreecommitdiff
path: root/src/lj_obj.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_obj.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h
index 7d582949..c0ae6892 100644
--- a/src/lj_obj.h
+++ b/src/lj_obj.h
@@ -679,6 +679,11 @@ struct lua_State {
679#define curr_topL(L) (L->base + curr_proto(L)->framesize) 679#define curr_topL(L) (L->base + curr_proto(L)->framesize)
680#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top) 680#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top)
681 681
682#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK)
683LJ_FUNC_NORET void lj_assert_fail(global_State *g, const char *file, int line,
684 const char *func, const char *fmt, ...);
685#endif
686
682/* -- GC object definition and conversions -------------------------------- */ 687/* -- GC object definition and conversions -------------------------------- */
683 688
684/* GC header for generic access to common fields of GC objects. */ 689/* GC header for generic access to common fields of GC objects. */
@@ -732,10 +737,6 @@ typedef union GCobj {
732 737
733/* -- TValue getters/setters ---------------------------------------------- */ 738/* -- TValue getters/setters ---------------------------------------------- */
734 739
735#ifdef LUA_USE_ASSERT
736#include "lj_gc.h"
737#endif
738
739/* Macros to test types. */ 740/* Macros to test types. */
740#if LJ_GC64 741#if LJ_GC64
741#define itype(o) ((uint32_t)((o)->it64 >> 47)) 742#define itype(o) ((uint32_t)((o)->it64 >> 47))
@@ -856,9 +857,19 @@ static LJ_AINLINE void setlightudV(TValue *o, void *p)
856#define setcont(o, f) setlightudV((o), contptr(f)) 857#define setcont(o, f) setlightudV((o), contptr(f))
857#endif 858#endif
858 859
859#define tvchecklive(L, o) \ 860static LJ_AINLINE void checklivetv(lua_State *L, TValue *o, const char *msg)
860 UNUSED(L), lua_assert(!tvisgcv(o) || \ 861{
861 ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) 862 UNUSED(L); UNUSED(o); UNUSED(msg);
863#if LUA_USE_ASSERT
864 if (tvisgcv(o)) {
865 lj_assertL(~itype(o) == gcval(o)->gch.gct,
866 "mismatch of TValue type %d vs GC type %d",
867 ~itype(o), gcval(o)->gch.gct);
868 /* Copy of isdead check from lj_gc.h to avoid circular include. */
869 lj_assertL(!(gcval(o)->gch.marked & (G(L)->gc.currentwhite ^ 3) & 3), msg);
870 }
871#endif
872}
862 873
863static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype) 874static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype)
864{ 875{
@@ -871,7 +882,8 @@ static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype)
871 882
872static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t it) 883static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t it)
873{ 884{
874 setgcVraw(o, v, it); tvchecklive(L, o); 885 setgcVraw(o, v, it);
886 checklivetv(L, o, "store to dead GC object");
875} 887}
876 888
877#define define_setV(name, type, tag) \ 889#define define_setV(name, type, tag) \
@@ -918,7 +930,8 @@ static LJ_AINLINE void setint64V(TValue *o, int64_t i)
918/* Copy tagged values. */ 930/* Copy tagged values. */
919static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2) 931static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2)
920{ 932{
921 *o1 = *o2; tvchecklive(L, o1); 933 *o1 = *o2;
934 checklivetv(L, o1, "copy of dead GC object");
922} 935}
923 936
924/* -- Number to integer conversion ---------------------------------------- */ 937/* -- Number to integer conversion ---------------------------------------- */