diff options
author | Mike Pall <mike> | 2010-02-18 02:49:08 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-18 02:49:08 +0100 |
commit | 265a24b97804c39f1bf6be00733890e729092bfd (patch) | |
tree | 5183610f079451b962678295328c382de2648194 /src/lj_record.c | |
parent | 00ad80c9e4258d10b2a26e9af8fa5e86c9e75e2e (diff) | |
download | luajit-265a24b97804c39f1bf6be00733890e729092bfd.tar.gz luajit-265a24b97804c39f1bf6be00733890e729092bfd.tar.bz2 luajit-265a24b97804c39f1bf6be00733890e729092bfd.zip |
Add more assertions to compare the recorder state and the VM state.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r-- | src/lj_record.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index bc19d74c..eaaafc51 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -112,21 +112,48 @@ static void rec_check_frames(jit_State *J) | |||
112 | lua_assert(depth == 0); | 112 | lua_assert(depth == 0); |
113 | } | 113 | } |
114 | 114 | ||
115 | /* Sanity check the slots. */ | 115 | /* Compare stack slots and frames of the recorder and the VM. */ |
116 | static void rec_check_slots(jit_State *J) | 116 | static void rec_check_slots(jit_State *J) |
117 | { | 117 | { |
118 | BCReg s, nslots = J->baseslot + J->maxslot; | 118 | BCReg s, nslots = J->baseslot + J->maxslot; |
119 | int32_t depth; | 119 | int32_t depth; |
120 | cTValue *base = J->L->base - J->baseslot; | ||
120 | lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); | 121 | lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); |
122 | lua_assert(J->baseslot == 1 || (J->slot[J->baseslot-1] & TREF_FRAME)); | ||
121 | lua_assert(nslots < LJ_MAX_JSLOTS); | 123 | lua_assert(nslots < LJ_MAX_JSLOTS); |
122 | for (s = 0; s < nslots; s++) { | 124 | for (s = 0; s < nslots; s++) { |
123 | TRef tr = J->slot[s]; | 125 | TRef tr = J->slot[s]; |
124 | if (s != 0 && (tr & (TREF_CONT|TREF_FRAME))) | ||
125 | depth++; | ||
126 | if (tr) { | 126 | if (tr) { |
127 | cTValue *tv = &base[s]; | ||
127 | IRRef ref = tref_ref(tr); | 128 | IRRef ref = tref_ref(tr); |
129 | IRIns *ir; | ||
128 | lua_assert(ref >= J->cur.nk && ref < J->cur.nins); | 130 | lua_assert(ref >= J->cur.nk && ref < J->cur.nins); |
129 | lua_assert(irt_t(IR(ref)->t) == tref_t(tr)); | 131 | ir = IR(ref); |
132 | lua_assert(irt_t(ir->t) == tref_t(tr)); | ||
133 | if (s == 0) { | ||
134 | lua_assert(tref_isfunc(tr)); | ||
135 | } else if ((tr & TREF_FRAME)) { | ||
136 | GCfunc *fn = gco2func(frame_gc(tv)); | ||
137 | BCReg delta = (BCReg)(tv - frame_prev(tv)); | ||
138 | lua_assert(tref_isfunc(tr)); | ||
139 | if (tref_isk(tr)) lua_assert(fn == ir_kfunc(ir)); | ||
140 | lua_assert(s > delta ? (J->slot[s-delta] & TREF_FRAME) : (s == delta)); | ||
141 | depth++; | ||
142 | } else if ((tr & TREF_CONT)) { | ||
143 | lua_assert(ir_kptr(ir) == gcrefp(tv->gcr, void)); | ||
144 | lua_assert((J->slot[s+1] & TREF_FRAME)); | ||
145 | depth++; | ||
146 | } else { | ||
147 | if (tvisnum(tv)) | ||
148 | lua_assert(tref_isnumber(tr)); /* Could be IRT_INT etc., too. */ | ||
149 | else | ||
150 | lua_assert(itype2irt(tv) == tref_type(tr)); | ||
151 | if (tref_isk(tr)) { /* Compare constants. */ | ||
152 | TValue tvk; | ||
153 | lj_ir_kvalue(J->L, &tvk, ir); | ||
154 | lua_assert(lj_obj_equal(tv, &tvk)); | ||
155 | } | ||
156 | } | ||
130 | } | 157 | } |
131 | } | 158 | } |
132 | lua_assert(J->framedepth == depth); | 159 | lua_assert(J->framedepth == depth); |