mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-10 05:19:10 +00:00
906a00d498
* General - Fix the benchmark require wrapper function to work in Lua - Fix memory leak in the new Luau C API test * New Solver - Luau: type functions should be able to signal whether or not irreducibility is due to an error - Do not generate extra expansion constraint for uninvoked user-defined type functions - Print in a user-defined type function should be reported as an error instead of logging to stdout - Many e-graphs bugfixes and performance improvements - Many general bugfixes and improvements to the new solver as a whole - Fixed issue with Luau used-defined type functions not having all environments initialized - Infer types of globals under new type solver * Fragment Autocomplete - Miscellaneous fixes to make interop with the old solver better * Runtime - Support disabling specific Luau built-in functions from being fast-called or constant-evaluated - Added constant folding for vector arithmetic - Added constant propagation and type inference for Vector3 globals ---------------------------------------------------------- 9 contributors: Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Daniel Angel <danielangel@roblox.com> Co-authored-by: Jonathan Kelaty <jkelaty@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
57 lines
1.4 KiB
Lua
57 lines
1.4 KiB
Lua
local function prequire(name) local success, result = pcall(require, name); return success and result end
|
|
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")
|
|
|
|
function test()
|
|
local count = 1
|
|
|
|
local function fill_tree(tree, levels)
|
|
local left = tree.left;
|
|
local right = tree.right;
|
|
|
|
if not left then
|
|
left = { id = count }
|
|
count = count + 1
|
|
end
|
|
|
|
if not right then
|
|
right = { id = count }
|
|
count = count + 1
|
|
end
|
|
|
|
if levels ~= 0 then
|
|
fill_tree(left, levels - 1)
|
|
fill_tree(right, levels - 1)
|
|
end
|
|
|
|
tree.left = left;
|
|
tree.right = right;
|
|
end
|
|
|
|
local function prune_tree(tree, level)
|
|
if tree.left then
|
|
if math.random() > 0.9 - level * 0.05 then
|
|
tree.left = nil
|
|
else
|
|
prune_tree(tree.left, level + 1)
|
|
end
|
|
end
|
|
|
|
if tree.right then
|
|
if math.random() > 0.9 - level * 0.05 then
|
|
tree.right = nil
|
|
else
|
|
prune_tree(tree.right, level + 1)
|
|
end
|
|
end
|
|
end
|
|
|
|
local tree = { id = 0 }
|
|
|
|
for i = 1,100 do
|
|
fill_tree(tree, 10)
|
|
|
|
prune_tree(tree, 0)
|
|
end
|
|
end
|
|
|
|
bench.runCode(test, "GC: tree pruning (lazy fill)")
|