[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Execution of pre compiled lua code from memory mapped files
- From: Jay Carlson <nop@...>
- Date: Thu, 28 May 2015 08:11:41 -0400
>
> On 2015-05-27, at 5:54 AM, Hans Riekehof <Riekehof@schoeps.de> wrote:
>
> If you call mod = require 'mod' the loader can recognize if mod is in a pre-compiled file which is memory mapable. In Linux this would turn out in a call to mmap() in an embedded system you can
> return a pointer with the starting address of the file in memory.
> Than you can start using mod as you want but it is not copied into the lua state.
On Linux and Windows, mmap can deliver copy-on-write pages. If you’re working on something like an ESP8266, there is no MMU to let you remap pages when they are written to, so some logic is harder.
It may be easier to design something for compile-time. Create some .o files, and try to make them as "const" as possible. On Linux and Windows, you will get copy-on-write for free. On embedded chips, you will have at least figured out which parts of your design need to be allocated in RAM; the linker will take care of placing them in the right spot and initializing them.
eLua's rommable tables can work as backing tables for this purpose: only changed entries are stored in a real table.
Jay