lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

On Fri, Jul 28, 2023 at 8:28 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > How does it handle alignments? The arrays of opcodes inside a compiled
> > bytecode are not necessarily aligned (at least not in the standard format
> > that Lua uses to represent binary code).
> >
> >
> eLua has a "ROM file system", which is basically a bunch of files and some
> metadata about their names arranged in a contiguous memory area. The
> alignment for the files can be controlled at compile time, when the ROMFS
> is created, so any bytecode file can be aligned in memory as needed. I
> think the current alignment is 8 bytes, but I'm pretty sure that 4 bytes
> also worked.

My question was really about the internal alignment. Even if a file
starts aligned, it would need internal padding to keep its structures
and arrays aligned. The standard Lua binary format doesn't do that.
Maybe eLua doesn't store the code using the standard Lua binary format?

I never thought about that, because I thought that internal alignment is preserved by default. Apparently things just worked, which admittedly is quite rare :)

Bogdan
 

-- Roberto