aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-06-27 11:24:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-06-27 11:24:27 -0300
commit9904c253da9690728710082cfb94654709ab89e7 (patch)
treef556ebbf8d99baa37ea8e39608a3d6bea77f8267 /testes
parentfb7e5b76c9d41108c399cf4d16470018b717007b (diff)
downloadlua-9904c253da9690728710082cfb94654709ab89e7.tar.gz
lua-9904c253da9690728710082cfb94654709ab89e7.tar.bz2
lua-9904c253da9690728710082cfb94654709ab89e7.zip
Flexible limit for use of registers by constructors
Instead of a fixed limit of 50 registers (which, in a bad worst case, can limit the nesting of constructors to 5 levels), the compiler computes an individual limit for each constructor based on how many registers are available when it runs. This limit then controls the frequency of SETLIST instructions.
Diffstat (limited to 'testes')
-rw-r--r--testes/code.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/testes/code.lua b/testes/code.lua
index 329619f1..08b3e23f 100644
--- a/testes/code.lua
+++ b/testes/code.lua
@@ -460,5 +460,16 @@ do -- check number of available registers
460 assert(string.find(msg, "too many registers")) 460 assert(string.find(msg, "too many registers"))
461end 461end
462 462
463
464do -- basic check for SETLIST
465 -- create a list constructor with 50 elements
466 local source = "local a; return {" .. string.rep("a, ", 50) .. "}"
467 local func = assert(load(source))
468 local code = table.concat(T.listcode(func), "\n")
469 local _, count = string.gsub(code, "SETLIST", "")
470 -- code uses only 1 SETLIST for the constructor
471 assert(count == 1)
472end
473
463print 'OK' 474print 'OK'
464 475