Przeglądaj źródła

Check for IR_HREF vs. IR_HREFK aliasing in non-nil store check.

Thanks to Peter Cawley. #1133
Mike Pall 1 rok temu
rodzic
commit
658530562c
2 zmienionych plików z 3 dodań i 0 usunięć
  1. 1 0
      src/lj_ir.h
  2. 2 0
      src/lj_opt_mem.c

+ 1 - 0
src/lj_ir.h

@@ -346,6 +346,7 @@ typedef struct IRType1 { uint8_t irt; } IRType1;
 #define irt_isu32(t)		(irt_type(t) == IRT_U32)
 #define irt_isi64(t)		(irt_type(t) == IRT_I64)
 #define irt_isu64(t)		(irt_type(t) == IRT_U64)
+#define irt_isp32(t)		(irt_type(t) == IRT_P32)
 
 #define irt_isfp(t)		(irt_isnum(t) || irt_isfloat(t))
 #define irt_isinteger(t)	(irt_typerange((t), IRT_I8, IRT_INT))

+ 2 - 0
src/lj_opt_mem.c

@@ -879,6 +879,8 @@ int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref)
 	if (skref == xkref || !irref_isk(skref) || !irref_isk(xkref))
 	  return 0;  /* A nil store with same const key or var key MAY alias. */
 	/* Different const keys CANNOT alias. */
+      } else if (irt_isp32(IR(skref)->t) != irt_isp32(IR(xkref)->t)) {
+	return 0;  /* HREF and HREFK MAY alias. */
       }  /* Different key types CANNOT alias. */
     }  /* Other non-nil stores MAY alias. */
     ref = store->prev;