GC back to controling pace counting bytes

Memory is the resource we want to save. Still to be reviewed again.
This commit is contained in:
Roberto Ierusalimschy
2024-09-19 19:02:14 -03:00
parent b443145ff3
commit ddfa1fbccf
11 changed files with 247 additions and 202 deletions

View File

@@ -85,7 +85,7 @@ lu_byte luaO_codeparam (unsigned int p) {
** more significant bits, as long as the multiplication does not
** overflow, so we check which order is best.
*/
l_obj luaO_applyparam (lu_byte p, l_obj x) {
l_mem luaO_applyparam (lu_byte p, l_mem x) {
unsigned int m = p & 0xF; /* mantissa */
int e = (p >> 4); /* exponent */
if (e > 0) { /* normalized? */
@@ -94,19 +94,19 @@ l_obj luaO_applyparam (lu_byte p, l_obj x) {
}
e -= 7; /* correct excess-7 */
if (e >= 0) {
if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */
if (x < (MAX_LMEM / 0x1F) >> e) /* no overflow? */
return (x * m) << e; /* order doesn't matter here */
else /* real overflow */
return MAX_LOBJ;
return MAX_LMEM;
}
else { /* negative exponent */
e = -e;
if (x < MAX_LOBJ / 0x1F) /* multiplication cannot overflow? */
if (x < MAX_LMEM / 0x1F) /* multiplication cannot overflow? */
return (x * m) >> e; /* multiplying first gives more precision */
else if ((x >> e) < MAX_LOBJ / 0x1F) /* cannot overflow after shift? */
else if ((x >> e) < MAX_LMEM / 0x1F) /* cannot overflow after shift? */
return (x >> e) * m;
else /* real overflow */
return MAX_LOBJ;
return MAX_LMEM;
}
}