[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Serializable VM
- From: Sean Conner <sean@...>
- Date: Sun, 16 Aug 2020 22:17:28 -0400
It was thus said that the Great Egor Skriptunoff once stated:
> There is an interesting SO question:
> OP uses Lua in his game and wants to be able to get (using Lua C API)
> current Lua VM snapshot in some serializable form
> for saving it inside a savegame file.
> When the saved game is loaded, Lua VM resumes from the saved snapshot.
> It looks like a useful feature for embeddable language.
> It would also allow running a long-lasting script on one computer,
> then pausing it and resuming the calculations on another computer.
> The idea might be too hard to implement, but it surely worth discussing.
One way to save the Lua state is to provide a custom allocator to Lua that
always allocates from the same address range for Lua. It would then be a
simple matter to save said address range to a file and restore it. The
trick then would be to somehow resume the Lua VM from this saved state.