mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Fix compiled error handling for buffer methods.
Contributed by XmiliaH.
This commit is contained in:
parent
4077f0c3d6
commit
c929efc039
@ -1222,6 +1222,12 @@ static void LJ_FASTCALL recff_buffer_method_put(jit_State *J, RecordFFData *rd)
|
||||
TRef tr;
|
||||
ptrdiff_t arg;
|
||||
if (!J->base[1]) return;
|
||||
for (arg = 1; (tr = J->base[arg]); arg++) {
|
||||
if (tref_isudata(tr)) {
|
||||
TRef ud2 = recff_sbufx_check(J, rd, arg);
|
||||
emitir(IRTG(IR_NE, IRT_PGC), ud, ud2);
|
||||
}
|
||||
}
|
||||
for (arg = 1; (tr = J->base[arg]); arg++) {
|
||||
if (tref_isstr(tr)) {
|
||||
trbuf = emitir(IRTG(IR_BUFPUT, IRT_PGC), trbuf, tr);
|
||||
@ -1230,11 +1236,9 @@ static void LJ_FASTCALL recff_buffer_method_put(jit_State *J, RecordFFData *rd)
|
||||
emitir(IRT(IR_TOSTR, IRT_STR), tr,
|
||||
tref_isnum(tr) ? IRTOSTR_NUM : IRTOSTR_INT));
|
||||
} else if (tref_isudata(tr)) {
|
||||
TRef ud2 = recff_sbufx_check(J, rd, arg);
|
||||
TRef trr = recff_sbufx_get_ptr(J, ud2, IRFL_SBUF_R);
|
||||
TRef trw = recff_sbufx_get_ptr(J, ud2, IRFL_SBUF_W);
|
||||
TRef trr = recff_sbufx_get_ptr(J, tr, IRFL_SBUF_R);
|
||||
TRef trw = recff_sbufx_get_ptr(J, tr, IRFL_SBUF_W);
|
||||
TRef len = recff_sbufx_len(J, trr, trw);
|
||||
emitir(IRTG(IR_NE, IRT_PGC), ud, ud2);
|
||||
trbuf = lj_ir_call(J, IRCALL_lj_buf_putmem, trbuf, trr, len);
|
||||
} else {
|
||||
recff_nyiu(J, rd);
|
||||
@ -1258,15 +1262,19 @@ static void LJ_FASTCALL recff_buffer_method_get(jit_State *J, RecordFFData *rd)
|
||||
TRef tr;
|
||||
ptrdiff_t arg;
|
||||
if (!J->base[1]) { J->base[1] = TREF_NIL; J->base[2] = 0; }
|
||||
for (arg = 0; (tr = J->base[arg+1]); arg++) {
|
||||
if (!tref_isnil(tr)) {
|
||||
J->base[arg+1] = recff_sbufx_checkint(J, rd, arg+1);
|
||||
}
|
||||
}
|
||||
for (arg = 0; (tr = J->base[arg+1]); arg++) {
|
||||
TRef len = recff_sbufx_len(J, trr, trw);
|
||||
if (tref_isnil(tr)) {
|
||||
J->base[arg] = emitir(IRT(IR_XSNEW, IRT_STR), trr, len);
|
||||
trr = trw;
|
||||
} else {
|
||||
TRef trn = recff_sbufx_checkint(J, rd, arg+1);
|
||||
TRef tru;
|
||||
len = emitir(IRTI(IR_MIN), len, trn);
|
||||
len = emitir(IRTI(IR_MIN), len, tr);
|
||||
tru = emitir(IRT(IR_ADD, IRT_PTR), trr, len);
|
||||
J->base[arg] = emitir(IRT(IR_XSNEW, IRT_STR), trr, len);
|
||||
trr = tru; /* Doing the ADD before the SNEW generates better code. */
|
||||
|
Loading…
Reference in New Issue
Block a user