changeset 13928:c9cc84bee17b

util.gc: Handle Lua 5.5 way of passing parameters
author Kim Alvefur <zash@zash.se>
date Wed, 06 Aug 2025 16:34:41 +0200
parents a88566e73a15
children 203a0b5ade55
files util/gc.lua
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/util/gc.lua	Wed Aug 06 16:08:19 2025 +0200
+++ b/util/gc.lua	Wed Aug 06 16:34:41 2025 +0200
@@ -5,7 +5,9 @@
 	generational = set.new { "mode", "minor_threshold", "major_threshold" };
 };
 
-if _VERSION ~= "Lua 5.4" then
+if _VERSION == "Lua 5.5" then
+	known_options.generational = set.new { "mode", "minor_multiplier", "minor_major_threshold", "major_minor_threshold"  };
+elseif _VERSION ~= "Lua 5.4" then
 	known_options.generational = nil;
 	known_options.incremental:remove("step_size");
 end
@@ -31,15 +33,27 @@
 				user.speed or defaults.speed,
 				user.step_size or defaults.step_size
 			);
+		elseif _VERSION == "Lua 5.5" then
+			collectgarbage(mode);
+			collectgarbage("param", "pause", user.threshold or defaults.threshold);
+			collectgarbage("param", "stepmul", user.speed or defaults.speed);
+			collectgarbage("param", "stepsize", user.step_size or defaults.step_size);
 		else
 			collectgarbage("setpause", user.threshold or defaults.threshold);
 			collectgarbage("setstepmul", user.speed or defaults.speed);
 		end
 	elseif mode == "generational" then
-		collectgarbage(mode,
-			user.minor_threshold or defaults.minor_threshold,
-			user.major_threshold or defaults.major_threshold
-		);
+		if _VERSION == "Lua 5.4" then
+			collectgarbage(mode,
+				user.minor_threshold or defaults.minor_threshold,
+				user.major_threshold or defaults.major_threshold
+			);
+		elseif _VERSION == "Lua 5.5" then
+			collectgarbage(mode);
+			collectgarbage("param", "minormul", user.minor_multiplier or defaults.minor_multiplier);
+			collectgarbage("param", "majorminor", user.major_minor_threshold or defaults.major_minor_threshold);
+			collectgarbage("param", "minormajor", user.minor_major_threshold or defaults.minor_major_threshold);
+		end
 	end
 	return true;
 end