diff options
author | Mike Pall <mike> | 2014-12-20 00:59:16 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2014-12-20 01:48:00 +0100 |
commit | 5cb6e2eaaf860045daa30208b21ae6aa88a0503c (patch) | |
tree | b0b4c4edfc1a9a0c3f51efbd3c36580447eaa509 | |
parent | 6e9145a882ea70fe438d59959ac4e65481fe5e85 (diff) | |
download | luajit-5cb6e2eaaf860045daa30208b21ae6aa88a0503c.tar.gz luajit-5cb6e2eaaf860045daa30208b21ae6aa88a0503c.tar.bz2 luajit-5cb6e2eaaf860045daa30208b21ae6aa88a0503c.zip |
Cleanup of TValue setters. No functional changes.
-rw-r--r-- | src/lj_api.c | 2 | ||||
-rw-r--r-- | src/lj_bcread.c | 2 | ||||
-rw-r--r-- | src/lj_ccallback.c | 5 | ||||
-rw-r--r-- | src/lj_err.c | 2 | ||||
-rw-r--r-- | src/lj_frame.h | 2 | ||||
-rw-r--r-- | src/lj_ir.c | 2 | ||||
-rw-r--r-- | src/lj_meta.c | 4 | ||||
-rw-r--r-- | src/lj_obj.h | 12 | ||||
-rw-r--r-- | src/lj_parse.c | 5 | ||||
-rw-r--r-- | src/lj_record.c | 2 | ||||
-rw-r--r-- | src/lj_snap.c | 9 |
11 files changed, 26 insertions, 21 deletions
diff --git a/src/lj_api.c b/src/lj_api.c index 03be80f9..4a7809bc 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
@@ -1101,7 +1101,7 @@ LUA_API int lua_yield(lua_State *L, int nresults) | |||
1101 | top->u64 = cframe_multres(cf); | 1101 | top->u64 = cframe_multres(cf); |
1102 | setcont(top+1, lj_cont_hook); | 1102 | setcont(top+1, lj_cont_hook); |
1103 | setframe_pc(top+1, cframe_pc(cf)-1); | 1103 | setframe_pc(top+1, cframe_pc(cf)-1); |
1104 | setframe_gc(top+2, obj2gco(L)); | 1104 | setframe_gc(top+2, obj2gco(L), LJ_TTHREAD); |
1105 | setframe_ftsz(top+2, ((char *)(top+3)-(char *)L->base)+FRAME_CONT); | 1105 | setframe_ftsz(top+2, ((char *)(top+3)-(char *)L->base)+FRAME_CONT); |
1106 | L->top = L->base = top+3; | 1106 | L->top = L->base = top+3; |
1107 | #if LJ_TARGET_X64 | 1107 | #if LJ_TARGET_X64 |
diff --git a/src/lj_bcread.c b/src/lj_bcread.c index 519164ca..cea20e90 100644 --- a/src/lj_bcread.c +++ b/src/lj_bcread.c | |||
@@ -192,7 +192,7 @@ static void bcread_ktabk(LexState *ls, TValue *o) | |||
192 | o->u32.hi = bcread_uleb128(ls); | 192 | o->u32.hi = bcread_uleb128(ls); |
193 | } else { | 193 | } else { |
194 | lua_assert(tp <= BCDUMP_KTAB_TRUE); | 194 | lua_assert(tp <= BCDUMP_KTAB_TRUE); |
195 | setitype(o, ~tp); | 195 | setpriV(o, ~tp); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c index bef379a5..5fe63a76 100644 --- a/src/lj_ccallback.c +++ b/src/lj_ccallback.c | |||
@@ -411,6 +411,7 @@ static void callback_conv_args(CTState *cts, lua_State *L) | |||
411 | int gcsteps = 0; | 411 | int gcsteps = 0; |
412 | CType *ct; | 412 | CType *ct; |
413 | GCfunc *fn; | 413 | GCfunc *fn; |
414 | int fntp; | ||
414 | MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; | 415 | MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; |
415 | #if CCALL_NARG_FPR | 416 | #if CCALL_NARG_FPR |
416 | MSize nfpr = 0; | 417 | MSize nfpr = 0; |
@@ -423,15 +424,17 @@ static void callback_conv_args(CTState *cts, lua_State *L) | |||
423 | ct = ctype_get(cts, id); | 424 | ct = ctype_get(cts, id); |
424 | rid = ctype_cid(ct->info); | 425 | rid = ctype_cid(ct->info); |
425 | fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); | 426 | fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); |
427 | fntp = LJ_TFUNC; | ||
426 | } else { /* Must set up frame first, before throwing the error. */ | 428 | } else { /* Must set up frame first, before throwing the error. */ |
427 | ct = NULL; | 429 | ct = NULL; |
428 | rid = 0; | 430 | rid = 0; |
429 | fn = (GCfunc *)L; | 431 | fn = (GCfunc *)L; |
432 | fntp = LJ_TTHREAD; | ||
430 | } | 433 | } |
431 | o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ | 434 | o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ |
432 | o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ | 435 | o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ |
433 | o++; | 436 | o++; |
434 | setframe_gc(o, obj2gco(fn)); | 437 | setframe_gc(o, obj2gco(fn), fntp); |
435 | setframe_ftsz(o, ((char *)(o+1) - (char *)L->base) + FRAME_CONT); | 438 | setframe_ftsz(o, ((char *)(o+1) - (char *)L->base) + FRAME_CONT); |
436 | L->top = L->base = ++o; | 439 | L->top = L->base = ++o; |
437 | if (!ct) | 440 | if (!ct) |
diff --git a/src/lj_err.c b/src/lj_err.c index dc2e26f3..a824ee66 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
@@ -631,7 +631,7 @@ LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) | |||
631 | if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { | 631 | if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { |
632 | const char *tname = lj_typename(o); | 632 | const char *tname = lj_typename(o); |
633 | setframe_pc(o, pc); | 633 | setframe_pc(o, pc); |
634 | setframe_gc(o, obj2gco(L)); | 634 | setframe_gc(o, obj2gco(L), LJ_TTHREAD); |
635 | L->top = L->base = o+1; | 635 | L->top = L->base = o+1; |
636 | err_msgv(L, LJ_ERR_BADCALL, tname); | 636 | err_msgv(L, LJ_ERR_BADCALL, tname); |
637 | } | 637 | } |
diff --git a/src/lj_frame.h b/src/lj_frame.h index 2540f4d4..061b396c 100644 --- a/src/lj_frame.h +++ b/src/lj_frame.h | |||
@@ -24,7 +24,7 @@ enum { | |||
24 | #define frame_gc(f) (gcref((f)->fr.func)) | 24 | #define frame_gc(f) (gcref((f)->fr.func)) |
25 | #define frame_ftsz(f) ((ptrdiff_t)(f)->fr.tp.ftsz) | 25 | #define frame_ftsz(f) ((ptrdiff_t)(f)->fr.tp.ftsz) |
26 | #define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) | 26 | #define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) |
27 | #define setframe_gc(f, p) (setgcref((f)->fr.func, (p))) | 27 | #define setframe_gc(f, p, tp) (setgcref((f)->fr.func, (p)), UNUSED(tp)) |
28 | #define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (int32_t)(sz)) | 28 | #define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (int32_t)(sz)) |
29 | #define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) | 29 | #define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) |
30 | 30 | ||
diff --git a/src/lj_ir.c b/src/lj_ir.c index 2eabdb4b..0689bc22 100644 --- a/src/lj_ir.c +++ b/src/lj_ir.c | |||
@@ -392,7 +392,7 @@ void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) | |||
392 | UNUSED(L); | 392 | UNUSED(L); |
393 | lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ | 393 | lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ |
394 | switch (ir->o) { | 394 | switch (ir->o) { |
395 | case IR_KPRI: setitype(tv, irt_toitype(ir->t)); break; | 395 | case IR_KPRI: setpriV(tv, irt_toitype(ir->t)); break; |
396 | case IR_KINT: setintV(tv, ir->i); break; | 396 | case IR_KINT: setintV(tv, ir->i); break; |
397 | case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; | 397 | case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; |
398 | case IR_KPTR: case IR_KKPTR: case IR_KNULL: | 398 | case IR_KPTR: case IR_KKPTR: case IR_KNULL: |
diff --git a/src/lj_meta.c b/src/lj_meta.c index 9c11dd86..520c3763 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
@@ -83,7 +83,7 @@ int lj_meta_tailcall(lua_State *L, cTValue *tv) | |||
83 | copyTV(L, base-1, tv); /* Replace frame with new object. */ | 83 | copyTV(L, base-1, tv); /* Replace frame with new object. */ |
84 | top->u32.lo = LJ_CONT_TAILCALL; | 84 | top->u32.lo = LJ_CONT_TAILCALL; |
85 | setframe_pc(top, pc); | 85 | setframe_pc(top, pc); |
86 | setframe_gc(top+1, obj2gco(L)); /* Dummy frame object. */ | 86 | setframe_gc(top+1, obj2gco(L), LJ_TTHREAD); /* Dummy frame object. */ |
87 | setframe_ftsz(top+1, ((char *)(top+2) - (char *)base) + FRAME_CONT); | 87 | setframe_ftsz(top+1, ((char *)(top+2) - (char *)base) + FRAME_CONT); |
88 | L->base = L->top = top+2; | 88 | L->base = L->top = top+2; |
89 | /* | 89 | /* |
@@ -355,7 +355,7 @@ TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins) | |||
355 | o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; | 355 | o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; |
356 | } else { | 356 | } else { |
357 | lua_assert(op == BC_ISEQP); | 357 | lua_assert(op == BC_ISEQP); |
358 | setitype(&tv, ~bc_d(ins)); | 358 | setpriV(&tv, ~bc_d(ins)); |
359 | o2 = &tv; | 359 | o2 = &tv; |
360 | } | 360 | } |
361 | mo = lj_meta_lookup(L, o1mm, MM_eq); | 361 | mo = lj_meta_lookup(L, o1mm, MM_eq); |
diff --git a/src/lj_obj.h b/src/lj_obj.h index 99e2d819..e5724859 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -43,12 +43,10 @@ typedef struct GCRef { | |||
43 | #define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) | 43 | #define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) |
44 | #define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) | 44 | #define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) |
45 | #define gcrefu(r) ((r).gcptr32) | 45 | #define gcrefu(r) ((r).gcptr32) |
46 | #define gcrefi(r) ((int32_t)(r).gcptr32) | ||
47 | #define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) | 46 | #define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) |
48 | #define gcnext(gc) (gcref((gc)->gch.nextgc)) | 47 | #define gcnext(gc) (gcref((gc)->gch.nextgc)) |
49 | 48 | ||
50 | #define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) | 49 | #define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) |
51 | #define setgcrefi(r, i) ((r).gcptr32 = (uint32_t)(i)) | ||
52 | #define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) | 50 | #define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) |
53 | #define setgcrefnull(r) ((r).gcptr32 = 0) | 51 | #define setgcrefnull(r) ((r).gcptr32 = 0) |
54 | #define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) | 52 | #define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) |
@@ -720,6 +718,7 @@ typedef union GCobj { | |||
720 | #define setitype(o, i) ((o)->it = (i)) | 718 | #define setitype(o, i) ((o)->it = (i)) |
721 | #define setnilV(o) ((o)->it = LJ_TNIL) | 719 | #define setnilV(o) ((o)->it = LJ_TNIL) |
722 | #define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) | 720 | #define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) |
721 | #define setpriV(o, i) (setitype((o), (i))) | ||
723 | 722 | ||
724 | static LJ_AINLINE void setlightudV(TValue *o, void *p) | 723 | static LJ_AINLINE void setlightudV(TValue *o, void *p) |
725 | { | 724 | { |
@@ -744,9 +743,14 @@ static LJ_AINLINE void setlightudV(TValue *o, void *p) | |||
744 | UNUSED(L), lua_assert(!tvisgcv(o) || \ | 743 | UNUSED(L), lua_assert(!tvisgcv(o) || \ |
745 | ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) | 744 | ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) |
746 | 745 | ||
747 | static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t itype) | 746 | static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype) |
748 | { | 747 | { |
749 | setgcref(o->gcr, v); setitype(o, itype); tvchecklive(L, o); | 748 | setgcref(o->gcr, v); setitype(o, itype); |
749 | } | ||
750 | |||
751 | static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t it) | ||
752 | { | ||
753 | setgcVraw(o, v, it); tvchecklive(L, o); | ||
750 | } | 754 | } |
751 | 755 | ||
752 | #define define_setV(name, type, tag) \ | 756 | #define define_setV(name, type, tag) \ |
diff --git a/src/lj_parse.c b/src/lj_parse.c index 064b9b19..198ddfc9 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c | |||
@@ -1684,10 +1684,9 @@ static void expr_bracket(LexState *ls, ExpDesc *v) | |||
1684 | static void expr_kvalue(TValue *v, ExpDesc *e) | 1684 | static void expr_kvalue(TValue *v, ExpDesc *e) |
1685 | { | 1685 | { |
1686 | if (e->k <= VKTRUE) { | 1686 | if (e->k <= VKTRUE) { |
1687 | setitype(v, ~(uint32_t)e->k); | 1687 | setpriV(v, ~(uint32_t)e->k); |
1688 | } else if (e->k == VKSTR) { | 1688 | } else if (e->k == VKSTR) { |
1689 | setgcref(v->gcr, obj2gco(e->u.sval)); | 1689 | setgcVraw(v, obj2gco(e->u.sval), LJ_TSTR); |
1690 | setitype(v, LJ_TSTR); | ||
1691 | } else { | 1690 | } else { |
1692 | lua_assert(tvisnumber(expr_numtv(e))); | 1691 | lua_assert(tvisnumber(expr_numtv(e))); |
1693 | *v = *expr_numtv(e); | 1692 | *v = *expr_numtv(e); |
diff --git a/src/lj_record.c b/src/lj_record.c index 10d76468..01c09c58 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -1891,7 +1891,7 @@ void lj_record_ins(jit_State *J) | |||
1891 | switch (bcmode_c(op)) { | 1891 | switch (bcmode_c(op)) { |
1892 | case BCMvar: | 1892 | case BCMvar: |
1893 | copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; | 1893 | copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; |
1894 | case BCMpri: setitype(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; | 1894 | case BCMpri: setpriV(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; |
1895 | case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); | 1895 | case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); |
1896 | copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : | 1896 | copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : |
1897 | lj_ir_knumint(J, numV(tv)); } break; | 1897 | lj_ir_knumint(J, numV(tv)); } break; |
diff --git a/src/lj_snap.c b/src/lj_snap.c index 8bfbd3d1..2917424f 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -613,8 +613,7 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, | |||
613 | o->u64 = *(uint64_t *)sps; | 613 | o->u64 = *(uint64_t *)sps; |
614 | } else { | 614 | } else { |
615 | lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ | 615 | lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ |
616 | setgcrefi(o->gcr, *sps); | 616 | setgcV(J->L, o, (GCobj *)(uintptr_t)*(GCSize *)sps, irt_toitype(t)); |
617 | setitype(o, irt_toitype(t)); | ||
618 | } | 617 | } |
619 | } else { /* Restore from register. */ | 618 | } else { /* Restore from register. */ |
620 | Reg r = regsp_reg(rs); | 619 | Reg r = regsp_reg(rs); |
@@ -632,10 +631,10 @@ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, | |||
632 | } else if (LJ_64 && irt_islightud(t)) { | 631 | } else if (LJ_64 && irt_islightud(t)) { |
633 | /* 64 bit lightuserdata which may escape already has the tag bits. */ | 632 | /* 64 bit lightuserdata which may escape already has the tag bits. */ |
634 | o->u64 = ex->gpr[r-RID_MIN_GPR]; | 633 | o->u64 = ex->gpr[r-RID_MIN_GPR]; |
634 | } else if (irt_ispri(t)) { | ||
635 | setpriV(o, irt_toitype(t)); | ||
635 | } else { | 636 | } else { |
636 | if (!irt_ispri(t)) | 637 | setgcV(J->L, o, (GCobj *)ex->gpr[r-RID_MIN_GPR], irt_toitype(t)); |
637 | setgcrefi(o->gcr, ex->gpr[r-RID_MIN_GPR]); | ||
638 | setitype(o, irt_toitype(t)); | ||
639 | } | 638 | } |
640 | } | 639 | } |
641 | } | 640 | } |