shithub: lu9-lua

Download patch

ref: 4fc16e0ad0724a9237629cf95fcd1f8dc67da8a3
parent: 04c3a13e333abf7f4463dad265da65a0bb65b836
author: kvik <kvik@a-b.xyz>
date: Fri Apr 23 08:29:16 EDT 2021

mem: tag allocations for better profiling information

--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1013,8 +1013,9 @@
     free(ptr);
     return NULL;
   }
-  else
-    return realloc(ptr, nsize);
+  ptr = realloc(ptr, nsize);
+  setmalloctag(ptr, getcallerpc(&ud));
+  return ptr;
 }
 
 
--- a/lmem.c
+++ b/lmem.c
@@ -171,6 +171,7 @@
   }
   lua_assert((nsize == 0) == (newblock == NULL));
   g->GCdebt = (g->GCdebt + nsize) - osize;
+  setmalloctag(newblock, getcallerpc(&L));
   return newblock;
 }
 
@@ -180,6 +181,7 @@
   void *newblock = luaM_realloc_(L, block, osize, nsize);
   if (l_unlikely(newblock == NULL && nsize > 0))  /* allocation failed? */
     luaM_error(L);
+  setmalloctag(newblock, getcallerpc(&L));
   return newblock;
 }
 
@@ -196,6 +198,7 @@
         luaM_error(L);
     }
     g->GCdebt += size;
+  	setmalloctag(newblock, getcallerpc(&L));
     return newblock;
   }
 }