]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix IR_BUFPUT assembly.
authorMike Pall <mike>
Sun, 14 Jan 2018 12:57:00 +0000 (13:57 +0100)
committerMike Pall <mike>
Sun, 14 Jan 2018 12:57:00 +0000 (13:57 +0100)
Thanks to Peter Cawley.

src/lj_asm.c

index 753fe6bd1ded96d9929132c7dbd6ea3cce2aabc6..5f83779e143e922b565a8f9a85b40496e65306ca 100644 (file)
@@ -1119,7 +1119,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
   const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_buf_putstr];
   IRRef args[3];
   IRIns *irs;
-  int kchar = -1;
+  int kchar = -129;
   args[0] = ir->op1;  /* SBuf * */
   args[1] = ir->op2;  /* GCstr * */
   irs = IR(ir->op2);
@@ -1127,7 +1127,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
   if (irs->o == IR_KGC) {
     GCstr *s = ir_kstr(irs);
     if (s->len == 1) {  /* Optimize put of single-char string constant. */
-      kchar = strdata(s)[0];
+      kchar = (int8_t)strdata(s)[0];  /* Signed! */
       args[1] = ASMREF_TMP1;  /* int, truncated to char */
       ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
     }
@@ -1154,7 +1154,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
   asm_gencall(as, ci, args);
   if (args[1] == ASMREF_TMP1) {
     Reg tmp = ra_releasetmp(as, ASMREF_TMP1);
-    if (kchar == -1)
+    if (kchar == -129)
       asm_tvptr(as, tmp, irs->op1);
     else
       ra_allockreg(as, kchar, tmp);