/* Take a snapshot of the current stack. */ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) { BCReg nslots = J->baseslot + J->maxslot; MSize nsm, nframelinks; IRRef2 *p; /* Conservative estimate. Continuation frames need 2 slots. */ nsm = nsnapmap + nslots + (uint32_t)J->framedepth*2+1; if (LJ_UNLIKELY(nsm > J->sizesnapmap)) { /* Need to grow snapshot map? */ if (nsm < 2*J->sizesnapmap) nsm = 2*J->sizesnapmap; else if (nsm < 64) nsm = 64; J->snapmapbuf = (IRRef2 *)lj_mem_realloc(J->L, J->snapmapbuf, J->sizesnapmap*sizeof(IRRef2), nsm*sizeof(IRRef2)); J->cur.snapmap = J->snapmapbuf; J->sizesnapmap = nsm; } p = &J->cur.snapmap[nsnapmap]; snapshot_slots(J, p, nslots); nframelinks = snapshot_framelinks(J, p + nslots); J->cur.nsnapmap = (uint16_t)(nsnapmap + nslots + nframelinks); snap->mapofs = (uint16_t)nsnapmap; snap->ref = (IRRef1)J->cur.nins; snap->nslots = (uint8_t)nslots; snap->nframelinks = (uint8_t)nframelinks; snap->count = 0; }
/* Take a snapshot of the current stack. */ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) { BCReg nslots = J->baseslot + J->maxslot; MSize nent; SnapEntry *p; /* Conservative estimate. */ lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); p = &J->cur.snapmap[nsnapmap]; nent = snapshot_slots(J, p, nslots); snap->topslot = (uint8_t)snapshot_framelinks(J, p + nent); snap->mapofs = (uint16_t)nsnapmap; snap->ref = (IRRef1)J->cur.nins; snap->nent = (uint8_t)nent; snap->nslots = (uint8_t)nslots; snap->count = 0; J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); }