summaryrefslogtreecommitdiff
path: root/indra/llcommon
AgeCommit message (Collapse)Author
2024-06-19Improve LL.help() function.Nat Goodspeed
The help string for each lua_function() must restate the function name and its arguments. The help string is all that's shown; unless it restates the function name, LL.help() output lists terse explanations for functions whose names are not shown. Make help() prepend "LL." to help output, because these functions must be accessed via the "builtin" LL table instead of directly populating the global Lua namespace. Similarly, before string name lookup, remove "LL." prefix if specified.
2024-06-19Try harder to keep Luau's lua_getinfo() from crashing.Nat Goodspeed
2024-06-18Merge branch 'lua-login' of github.com:secondlife/viewer into lua-loginNat Goodspeed
2024-06-18Initialize lua_Debug lluau::source_path() passes to lua_getinfo().Nat Goodspeed
On Mac it doesn't seem to matter, but on Windows, leaving it uninitialized can produce garbage results and even crash the coroutine. This seems strange, since we've been assuming lua_getinfo() treats its lua_Debug* as output-only.
2024-06-18Use LL_DEBUGS("Lua") for LuaLog.Nat Goodspeed
We might decide to leave some of them in place.
2024-06-18Make ~LuaState() walk Registry.atexit table backwardsNat Goodspeed
so cleanup happens in reverse order, as is conventional. Streamline LL.atexit() function: luaL_newmetatable() performs all the find-or-create named Registry table logic.
2024-06-18lua_emplace<T>() should permit GC despite LL.atexit() safety net.Nat Goodspeed
lua_emplace<T>() was passing LL.atexit() a closure binding the new userdata with a cleanup function. The trouble with that was that a strong reference to the new userdata would prevent it ever being garbage collected, even if that was the only remaining reference. Instead, create a new weak table referencing the userdata, and bind that into the cleanup function's closure. Then if the only remaining reference to the userdata is from the weak table, the userdata can be collected. Make lua_emplace_call_gc<T>() check the bound weak table in case the userdata has in fact been collected. Also, in lua_toclass<T>(), use luaL_checkudata() to synopsize comparing the putative userdata's metatable against the one synthesized by lua_emplace<T>(). This saves several explicit steps.
2024-06-18Make lluau::source_path() report top-level script path.Nat Goodspeed
source_path() previously reported the path of the module containing the current (lowest-level) Lua function. The effect was that the Floater.lua module would always try to look up the XUI file relative to scripts/lua/require. It makes more intuitive sense to make source_path() return the path containing the top-level script, so that a script engaging the Floater.lua module looks for the XUI file relative to the script.
2024-06-17Store script's LuaListener in userdata in lua_State's Registry.Nat Goodspeed
Instead of deriving LuaListener from LLInstanceTracker with an int key, generating a unique int key and storing that key in the Registry, use new lua_emplace<LuaState>() to store the LuaListener directly in a Lua userdata object in the Lua Registry. Because lua_emplace<T>() uses LL.atexit() to guarantee that ~LuaState will destroy the T object, we no longer need ~LuaState() to make a special call specifically to destroy the LuaListener, if any. So we no longer need LuaState::getListener() separate from obtainListener(). Since LuaListener is no longer an LLInstanceTracker subclass, make LuaState::obtainListener() return LuaListener& rather than LuaListener::ptr_t.
2024-06-14Introduce LL.atexit(), internal lua_emplace<T>(), lua_toclass<T>().Nat Goodspeed
Publish new LL.atexit() function that accepts a Lua function (or C++ closure) and saves it (in Registry["atexit"] table) to call later. Make ~LuaState() walk the Registry["atexit"] table, if it exists, calling each function appended to that table. (Consider using that mechanism to clean up a LuaListener, if one was instantiated. Possibly also use for p.s. leap.run()? But that's run after every expr() call, instead of only at ~LuaState() time. Pragmatically, though, the distinction only matters for a LUA Debug Console LUA string with "clean lua_State" unchecked.) For use by future lua_function() entry points, lua_emplace<T>(ctor args...) pushes a Lua userdata object containing a newly-constructed T instance -- actually a std::optional<T> to avoid double destruction. lua_emplace<T>() is specifically intended to be usable even for T with a nontrivial destructor: it gives the userdata a metatable with a __gc function that destroys the contained T instance when the userdata is garbage collected. But since garbage collection doesn't guarantee to clean up global variables with __gc methods, lua_emplace<T>() also uses LL.atexit() to ensure that ~T() will run when the LuaState is destroyed. The companion to lua_emplace<T>() is lua_toclass<T>(), which returns a non-nullptr T* if the referenced index is in fact a userdata created by lua_emplace<T>() for the same T, that has not yet been destroyed. This lets C++ code access a T previously embedded in Lua userdata.
2024-06-12Add LL_DEBUGS("LLCoros") start/end messages.Nat Goodspeed
We have log messages when a coroutine terminates abnormally, but we don't report either when it starts or when it terminates normally. Address that.
2024-06-12LuaState::expr() has log messages for ending, add for starting.Nat Goodspeed
It's helpful to see when expr() is actually going to start running a particular Lua chunk. We already report not only when it's done, but also if/when we start and finish a p.s. fiber.run() call.
2024-06-12Extract TempSet from llcallbacklist.cpp into its own tempset.h.Nat Goodspeed
2024-06-11Merge branch 'main' of github.com:secondlife/viewer into lua-bradfixNat Goodspeed
to pick up Featurettes promotion + Brad's GitHub Windows build workaround.
2024-06-10Merge release/materials_featurette to main on promotion of secondlife/viewer ↵Nat Goodspeed
#648: Release/materials featurette
2024-06-07Fix another merge glitchNat Goodspeed
2024-06-07Tidy up merge from main.Nat Goodspeed
2024-06-07Merge branch 'main' of secondlife/viewer into release/luau-scriptingNat Goodspeed
2024-06-05Make LLLeap iterate over child stdout while read data is pendingNat Goodspeed
instead of using mutual recursion to exhaust the read buffer.
2024-06-03Fix a small typoNat Goodspeed
2024-06-03Allow consumer code to query or adjust the per-tick timeslice.Nat Goodspeed
2024-06-03Distinguish TimersListener callers by reply LLEventPump name.Nat Goodspeed
The reqid is only distinct within a particular calling script.
2024-05-31Add timers.lua API module and test_timers.lua test program.Nat Goodspeed
Since timers presents a timers.Timer Lua class supporting queries and cancellation, make TimersListener::scheduleAfter() and scheduleEvery() respond immediately so the newly constructed Timer object has the reqid necessary to perform those subsequent operations. This requires that Lua invocations of these operations avoid calling the caller's callback with that initial response. Reinvent leap.generate() to return a Lua object supporting next() and done() methods. A plain Lua coroutine that (indirectly) calls fiber.wait() confuses the fiber scheduler, so avoid implementing generate() as a Lua coroutine. Add a bit more leap.lua diagnostic output.
2024-05-31Explain the name of the LL::WorkQueue::BackJack class.Nat Goodspeed
2024-05-29Merge branch 'release/luau-scripting' into lua-timersNat Goodspeed
2024-05-29Make ~ThreadPool() join every thread before destroying its vector.Nat Goodspeed
Otherwise we fall into the trap of destroying a joinable std::thread, which calls std::terminate() and hence our crash-on-terminate() handler. The previous ~ThreadPool() logic only joined threads if the queue wasn't already closed, but evidently we can reach the destructor with the queue closed but the threads not yet joined. Fixes #1534.
2024-05-24Merge branch 'release/luau-scripting' into lua-timersNat Goodspeed
2024-05-24Nat's ideas from PR #1547Nat Goodspeed
2024-05-23More vestigial whitespace fixesNat Goodspeed
2024-05-23Fix lingering trailing whitespace in llmainthreadtask.h.Nat Goodspeed
2024-05-23Fix lingering trailing whitespace in lleventfilter.cpp.Nat Goodspeed
2024-05-23Fix lingering trailing whitespace in lleventfilter.h.Nat Goodspeed
2024-05-23Fix test program termination crash.Nat Goodspeed
2024-05-22WIP: Trying to diagnose and fix test program shutdown crashNat Goodspeed
2024-05-15Merge branch 'release/luau-scripting' into lua-timers after Maint XNat Goodspeed
2024-05-15Manual whitespace cleanup (fix_whitespace.py).Nat Goodspeed
2024-05-15Merge commit 'e7eced3' into lua-timers for whitespace fixes.Nat Goodspeed
2024-05-15Merge branch 'main' into release/luau-scripting for Maint X release.Nat Goodspeed
2024-05-15Manual whitespace fixes (fix_whitespace.py).Nat Goodspeed
2024-05-15Merge commit 'e7eced3' into release/luau-scripting: whitespace fix.Nat Goodspeed
2024-05-15Merge branch 'main' into marchcat/x-mf-mergeAndrey Lihatskiy
# Conflicts: # doc/contributions.txt # indra/newview/llfloaterimagepreview.cpp
2024-05-15Post-merge spaces fixAndrey Lihatskiy
2024-05-15Merge branch 'marchcat/w-whitespace' into marchcat/x-mf-mergeAndrey Lihatskiy
2024-05-14Merge DRTVWR-591-maint-X to main on promotion of secondlife/viewer #705: ↵Nat Goodspeed
Maintenance X
2024-05-14Merge remote-tracking branch 'origin/main' into release/materials_featuretteBrad Linden
2024-05-10Fix up a few #includesNat Goodspeed
2024-05-10Fix latent access violation in ~LLEventPump() if LLEventPumps gone.Nat Goodspeed
Instead of making LLEventPumps an LLHandleProvider, and storing an LLHandle<LLEventPumps> in each LLEventPump instance, just make ~LLEventPump() query LLEventPumps::instanceExists() before calling instance().
2024-05-09Add "Timers" LLEventAPI, actually a LazyEventAPI, for LL::Timers.Nat Goodspeed
Rename LL::Timers::scheduleRepeating() to scheduleEvery().
2024-05-09Bump up coroutine stack size: saw C00000FD test termination.Nat Goodspeed
(cherry picked from commit dc0b3aed4782e4e4835fd6b9d59d1d70b78be4a7)
2024-05-08Tweak a couple thingsNat Goodspeed