mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
FFI: Fix compiled ffi.string() semantics.
This commit is contained in:
parent
83a37aeca7
commit
e1aa8d0d97
@ -713,7 +713,7 @@ LUA_API void lua_concat(lua_State *L, int n)
|
||||
copyTV(L, L->top-1, L->top);
|
||||
} while (--n > 0);
|
||||
} else if (n == 0) { /* Push empty string. */
|
||||
setstrV(L, L->top, lj_str_new(L, "", 0));
|
||||
setstrV(L, L->top, &G(L)->strempty);
|
||||
incr_top(L);
|
||||
}
|
||||
/* else n == 1: nothing to do. */
|
||||
|
@ -4098,7 +4098,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
|
||||
case IR_FSTORE: case IR_XSTORE: asm_fxstore(as, ir); break;
|
||||
|
||||
/* Allocations. */
|
||||
case IR_SNEW: asm_snew(as, ir); break;
|
||||
case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break;
|
||||
case IR_TNEW: asm_tnew(as, ir); break;
|
||||
case IR_TDUP: asm_tdup(as, ir); break;
|
||||
case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break;
|
||||
|
@ -970,7 +970,7 @@ void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd)
|
||||
tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CCHAR), 0, tr, &rd->argv[0]);
|
||||
trlen = lj_ir_call(J, IRCALL_strlen, tr);
|
||||
}
|
||||
J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), tr, trlen);
|
||||
J->base[0] = emitir(IRT(IR_XSNEW, IRT_STR), tr, trlen);
|
||||
} /* else: interpreter will throw. */
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@
|
||||
\
|
||||
/* Allocations. */ \
|
||||
_(SNEW, N , ref, ref) /* CSE is ok, not marked as A. */ \
|
||||
_(XSNEW, A , ref, ref) \
|
||||
_(TNEW, AW, lit, lit) \
|
||||
_(TDUP, AW, ref, ___) \
|
||||
_(CNEW, AW, ref, ref) \
|
||||
|
@ -153,7 +153,8 @@ typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J);
|
||||
*/
|
||||
#define gcstep_barrier(J, ref) \
|
||||
((ref) < J->chain[IR_LOOP] && \
|
||||
(J->chain[IR_SNEW] || J->chain[IR_TNEW] || J->chain[IR_TDUP] || \
|
||||
(J->chain[IR_SNEW] || J->chain[IR_XSNEW] || \
|
||||
J->chain[IR_TNEW] || J->chain[IR_TDUP] || \
|
||||
J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR]))
|
||||
|
||||
/* -- Constant folding for FP numbers ------------------------------------- */
|
||||
@ -445,7 +446,7 @@ LJFOLD(SNEW any KINT)
|
||||
LJFOLDF(kfold_snew_empty)
|
||||
{
|
||||
if (fright->i == 0)
|
||||
return lj_ir_kstr(J, lj_str_new(J->L, "", 0));
|
||||
return lj_ir_kstr(J, &J2G(J)->strempty);
|
||||
return NEXTFOLD;
|
||||
}
|
||||
|
||||
@ -1900,6 +1901,7 @@ LJFOLD(RETF any any) /* Modifies BASE. */
|
||||
LJFOLD(TNEW any any)
|
||||
LJFOLD(TDUP any)
|
||||
LJFOLD(CNEW any any)
|
||||
LJFOLD(XSNEW any any)
|
||||
LJFOLDX(lj_ir_emit)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
Loading…
Reference in New Issue
Block a user