aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-09-19 19:02:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-09-19 19:02:14 -0300
commitddfa1fbccfe4c1ec69f7396a4f5842abe70927ba (patch)
treedf467dc5dc5c64a21bb976ec661796d17d37f791 /lobject.c
parentb443145ff3415fcaee903a7d95fa7212df5a77db (diff)
downloadlua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.tar.gz
lua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.tar.bz2
lua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.zip
GC back to controling pace counting bytes
Memory is the resource we want to save. Still to be reviewed again.
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lobject.c b/lobject.c
index f7159547..1ca03e76 100644
--- a/lobject.c
+++ b/lobject.c
@@ -85,7 +85,7 @@ lu_byte luaO_codeparam (unsigned int p) {
85** more significant bits, as long as the multiplication does not 85** more significant bits, as long as the multiplication does not
86** overflow, so we check which order is best. 86** overflow, so we check which order is best.
87*/ 87*/
88l_obj luaO_applyparam (lu_byte p, l_obj x) { 88l_mem luaO_applyparam (lu_byte p, l_mem x) {
89 unsigned int m = p & 0xF; /* mantissa */ 89 unsigned int m = p & 0xF; /* mantissa */
90 int e = (p >> 4); /* exponent */ 90 int e = (p >> 4); /* exponent */
91 if (e > 0) { /* normalized? */ 91 if (e > 0) { /* normalized? */
@@ -94,19 +94,19 @@ l_obj luaO_applyparam (lu_byte p, l_obj x) {
94 } 94 }
95 e -= 7; /* correct excess-7 */ 95 e -= 7; /* correct excess-7 */
96 if (e >= 0) { 96 if (e >= 0) {
97 if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */ 97 if (x < (MAX_LMEM / 0x1F) >> e) /* no overflow? */
98 return (x * m) << e; /* order doesn't matter here */ 98 return (x * m) << e; /* order doesn't matter here */
99 else /* real overflow */ 99 else /* real overflow */
100 return MAX_LOBJ; 100 return MAX_LMEM;
101 } 101 }
102 else { /* negative exponent */ 102 else { /* negative exponent */
103 e = -e; 103 e = -e;
104 if (x < MAX_LOBJ / 0x1F) /* multiplication cannot overflow? */ 104 if (x < MAX_LMEM / 0x1F) /* multiplication cannot overflow? */
105 return (x * m) >> e; /* multiplying first gives more precision */ 105 return (x * m) >> e; /* multiplying first gives more precision */
106 else if ((x >> e) < MAX_LOBJ / 0x1F) /* cannot overflow after shift? */ 106 else if ((x >> e) < MAX_LMEM / 0x1F) /* cannot overflow after shift? */
107 return (x >> e) * m; 107 return (x >> e) * m;
108 else /* real overflow */ 108 else /* real overflow */
109 return MAX_LOBJ; 109 return MAX_LMEM;
110 } 110 }
111} 111}
112 112