Sfoglia il codice sorgente

Fix IR_BUFPUT assembly.

Thanks to Peter Cawley.
Mike Pall 7 anni fa
parent
commit
58d0dde0a2
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      src/lj_asm.c

+ 3 - 3
src/lj_asm.c

@@ -1119,7 +1119,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
   const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_buf_putstr];
   const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_buf_putstr];
   IRRef args[3];
   IRRef args[3];
   IRIns *irs;
   IRIns *irs;
-  int kchar = -1;
+  int kchar = -129;
   args[0] = ir->op1;  /* SBuf * */
   args[0] = ir->op1;  /* SBuf * */
   args[1] = ir->op2;  /* GCstr * */
   args[1] = ir->op2;  /* GCstr * */
   irs = IR(ir->op2);
   irs = IR(ir->op2);
@@ -1127,7 +1127,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
   if (irs->o == IR_KGC) {
   if (irs->o == IR_KGC) {
     GCstr *s = ir_kstr(irs);
     GCstr *s = ir_kstr(irs);
     if (s->len == 1) {  /* Optimize put of single-char string constant. */
     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 */
       args[1] = ASMREF_TMP1;  /* int, truncated to char */
       ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
       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);
   asm_gencall(as, ci, args);
   if (args[1] == ASMREF_TMP1) {
   if (args[1] == ASMREF_TMP1) {
     Reg tmp = ra_releasetmp(as, ASMREF_TMP1);
     Reg tmp = ra_releasetmp(as, ASMREF_TMP1);
-    if (kchar == -1)
+    if (kchar == -129)
       asm_tvptr(as, tmp, irs->op1);
       asm_tvptr(as, tmp, irs->op1);
     else
     else
       ra_allockreg(as, kchar, tmp);
       ra_allockreg(as, kchar, tmp);