diff options
author | Mike Pall <mike> | 2010-02-18 03:19:46 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-18 03:19:46 +0100 |
commit | 2b22b9e710023b66591487784ad382975fb6fd22 (patch) | |
tree | 874c045fd75a55f52324fc8130bbdfb5e9a281e6 /src/lj_snap.c | |
parent | 265a24b97804c39f1bf6be00733890e729092bfd (diff) | |
download | luajit-2b22b9e710023b66591487784ad382975fb6fd22.tar.gz luajit-2b22b9e710023b66591487784ad382975fb6fd22.tar.bz2 luajit-2b22b9e710023b66591487784ad382975fb6fd22.zip |
Drop obsolete shadow frame link stack.
Diffstat (limited to 'src/lj_snap.c')
-rw-r--r-- | src/lj_snap.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c index 04b9a7f6..e17b7a0d 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -68,6 +68,31 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) | |||
68 | return n; | 68 | return n; |
69 | } | 69 | } |
70 | 70 | ||
71 | /* Add frame links at the end of the snapshot. */ | ||
72 | static void snapshot_framelinks(jit_State *J, SnapEntry *map) | ||
73 | { | ||
74 | cTValue *frame = J->L->base - 1; | ||
75 | cTValue *lim = J->L->base - J->baseslot; | ||
76 | MSize f = 0; | ||
77 | map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ | ||
78 | while (frame > lim) { /* Backwards traversal of all frames above base. */ | ||
79 | if (frame_islua(frame)) { | ||
80 | map[f++] = SNAP_MKPC(frame_pc(frame)); | ||
81 | frame = frame_prevl(frame); | ||
82 | } else if (frame_ispcall(frame)) { | ||
83 | map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); | ||
84 | frame = frame_prevd(frame); | ||
85 | } else if (frame_iscont(frame)) { | ||
86 | map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); | ||
87 | map[f++] = SNAP_MKPC(frame_contpc(frame)); | ||
88 | frame = frame_prevd(frame); | ||
89 | } else { | ||
90 | lua_assert(0); | ||
91 | } | ||
92 | } | ||
93 | lua_assert(f == (MSize)(1 + J->framedepth)); | ||
94 | } | ||
95 | |||
71 | /* Take a snapshot of the current stack. */ | 96 | /* Take a snapshot of the current stack. */ |
72 | static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) | 97 | static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) |
73 | { | 98 | { |
@@ -78,6 +103,7 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) | |||
78 | lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); | 103 | lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); |
79 | p = &J->cur.snapmap[nsnapmap]; | 104 | p = &J->cur.snapmap[nsnapmap]; |
80 | nent = snapshot_slots(J, p, nslots); | 105 | nent = snapshot_slots(J, p, nslots); |
106 | snapshot_framelinks(J, p + nent); | ||
81 | snap->mapofs = (uint16_t)nsnapmap; | 107 | snap->mapofs = (uint16_t)nsnapmap; |
82 | snap->ref = (IRRef1)J->cur.nins; | 108 | snap->ref = (IRRef1)J->cur.nins; |
83 | snap->nent = (uint8_t)nent; | 109 | snap->nent = (uint8_t)nent; |
@@ -85,9 +111,6 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) | |||
85 | snap->nslots = (uint8_t)nslots; | 111 | snap->nslots = (uint8_t)nslots; |
86 | snap->count = 0; | 112 | snap->count = 0; |
87 | J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); | 113 | J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); |
88 | /* Add frame links at the end of the snapshot. */ | ||
89 | p[nent] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ | ||
90 | memcpy(&p[nent+1], J->frame, sizeof(SnapEntry)*(size_t)J->framedepth); | ||
91 | } | 114 | } |
92 | 115 | ||
93 | /* Add or merge a snapshot. */ | 116 | /* Add or merge a snapshot. */ |
@@ -119,6 +142,7 @@ void lj_snap_shrink(jit_State *J) | |||
119 | snap->nslots = (uint8_t)nslots; | 142 | snap->nslots = (uint8_t)nslots; |
120 | if (nent > 0 && snap_slot(map[nent-1]) >= nslots) { | 143 | if (nent > 0 && snap_slot(map[nent-1]) >= nslots) { |
121 | MSize s, delta, depth = snap->depth; | 144 | MSize s, delta, depth = snap->depth; |
145 | lua_assert(depth == (MSize)J->framedepth); | ||
122 | for (nent--; nent > 0 && snap_slot(map[nent-1]) >= nslots; nent--) | 146 | for (nent--; nent > 0 && snap_slot(map[nent-1]) >= nslots; nent--) |
123 | ; | 147 | ; |
124 | delta = snap->nent - nent; | 148 | delta = snap->nent - nent; |
@@ -187,7 +211,7 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
187 | SnapShot *snap = &T->snap[snapno]; | 211 | SnapShot *snap = &T->snap[snapno]; |
188 | MSize n, nent = snap->nent; | 212 | MSize n, nent = snap->nent; |
189 | SnapEntry *map = &T->snapmap[snap->mapofs]; | 213 | SnapEntry *map = &T->snapmap[snap->mapofs]; |
190 | SnapEntry *flinks = map + nent + 1; | 214 | SnapEntry *flinks = map + nent + snap->depth; |
191 | int32_t ftsz0; | 215 | int32_t ftsz0; |
192 | BCReg nslots = snap->nslots; | 216 | BCReg nslots = snap->nslots; |
193 | TValue *frame; | 217 | TValue *frame; |
@@ -213,7 +237,7 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
213 | lj_ir_kvalue(L, o, ir); | 237 | lj_ir_kvalue(L, o, ir); |
214 | if ((sn & (SNAP_CONT|SNAP_FRAME))) { | 238 | if ((sn & (SNAP_CONT|SNAP_FRAME))) { |
215 | /* Overwrite tag with frame link. */ | 239 | /* Overwrite tag with frame link. */ |
216 | o->fr.tp.ftsz = s != 0 ? (int32_t)*flinks++ : ftsz0; | 240 | o->fr.tp.ftsz = s != 0 ? (int32_t)*flinks-- : ftsz0; |
217 | if ((sn & SNAP_FRAME)) { | 241 | if ((sn & SNAP_FRAME)) { |
218 | GCfunc *fn = ir_kfunc(ir); | 242 | GCfunc *fn = ir_kfunc(ir); |
219 | if (isluafunc(fn)) { | 243 | if (isluafunc(fn)) { |
@@ -264,8 +288,8 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
264 | } | 288 | } |
265 | } | 289 | } |
266 | L->top = curr_topL(L); | 290 | L->top = curr_topL(L); |
267 | lua_assert(map + nent + 1 + snap->depth == flinks); | 291 | lua_assert(map + nent == flinks); |
268 | return snap_pc(map[nent]); | 292 | return snap_pc(*flinks); |
269 | } | 293 | } |
270 | 294 | ||
271 | #undef IR | 295 | #undef IR |