Esempio n. 1
0
TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins)
{
  ASMFunction cont = (bc_op(ins) & 1) ? lj_cont_condf : lj_cont_condt;
  int op = (int)bc_op(ins) & ~1;
  TValue tv;
  cTValue *mo, *o2, *o1 = &L->base[bc_a(ins)];
  cTValue *o1mm = o1;
  if (op == BC_ISEQV) {
    o2 = &L->base[bc_d(ins)];
    if (!tviscdata(o1mm)) o1mm = o2;
  } else if (op == BC_ISEQS) {
    setstrV(L, &tv, gco2str(proto_kgc(curr_proto(L), ~(ptrdiff_t)bc_d(ins))));
    o2 = &tv;
  } else if (op == BC_ISEQN) {
    o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)];
  } else {
    lua_assert(op == BC_ISEQP);
    setpriV(&tv, ~bc_d(ins));
    o2 = &tv;
  }
  mo = lj_meta_lookup(L, o1mm, MM_eq);
  if (LJ_LIKELY(!tvisnil(mo)))
    return mmcall(L, cont, mo, o1, o2);
  else
    return (TValue *)(intptr_t)(bc_op(ins) & 1);
}
Esempio n. 2
0
/* Recursively set the JIT mode for all children of a prototype. */
static void setptmode_all(global_State *g, GCproto *pt, int mode)
{
  ptrdiff_t i;
  for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) {
    GCobj *o = proto_kgc(pt, i);
    if (o->gch.gct == ~LJ_TPROTO) {
      setptmode(g, gco2pt(o), mode);
      setptmode_all(g, gco2pt(o), mode);
    }
  }
}
Esempio n. 3
0
static void add_activelines(lua_State *L, GCproto *proto) {
    /*
    ** LuaJIT packs active lines depending on function length.
    ** See implementation of lj_debug_getinfo in lj_debug.c.
    */
    ptrdiff_t idx;
    const void *lineinfo = proto_lineinfo(proto);

    if (lineinfo) {
        BCLine first = proto->firstline;
        int sz = proto->numline < 256 ? 1 : proto->numline < 65536 ? 2 : 4;
        MSize i, szl = proto->sizebc - 1;

        for (i = 0; i < szl; i++) {
            BCLine line = first +
                (sz == 1 ? (BCLine) ((const uint8_t *) lineinfo)[i] :
                 sz == 2 ? (BCLine) ((const uint16_t *) lineinfo)[i] :
                 (BCLine) ((const uint32_t *) lineinfo)[i]);
            lua_pushinteger(L, line);
            lua_pushboolean(L, 1);
            lua_settable(L, -3);
        }
    }

    /*
    ** LuaJIT stores nested prototypes as garbage-collectible constants,
    ** iterate over them. See implementation of jit_util_funck in lib_jit.c.
    */
    for (idx = -1; ~idx < (ptrdiff_t) proto->sizekgc; idx--) {
        GCobj *gc = proto_kgc(proto, idx);

        if (~gc->gch.gct == LJ_TPROTO) {
            add_activelines(L, (GCproto *) gc);
        }
    }
}