lua-users home
lua-l archive

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


Ralph,

After walking all the way through the lexical parsing on both the PC (which
was working properly) and the prototype hardware, I've since found that
there's a bug in our realloc function! <gasp> Not to mention a minor
inefficiency where if both the old size and new size are the same, it still
reallocates the block!

I worked around the bug temporarily in luaM_realloc by using
malloc,copy,free; that seems to work, and the interpreter is now functioning
on the prototype.

The memory allocator we're using does return aligned blocks. I would think
that's a real necessity in any environment. Does the C standard have
anything to say about this? The 68331 will get an odd address trap, but
natural boundaries aren't required (i.e. 4-byte alignment for longs) since
it's basically a 16-bit machine externally.

Since the allocations all appear to be rather small, I don't think we're
going to have any issues with memory allocation. It crossed my mind to
instrument the allocator as well.

What's a Lua GEM? When the code seems stable, perhaps I'll post my thoughts
to get a "porting guide" started.

Thanks for the reply
Tom

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Ralph Hempel
Sent: Saturday, December 23, 2006 9:31 AM
To: Lua list
Subject: Re: Interpreter not building correct byte code


> BTW, is there a good porting guide somewhere? I need something for what 
> I call an "embedded" environment; i.e. not embedded in other software, 
> but embedded in a hardware device with limited resources. Also, I'm 
> working with version 5.0.2.

Tom,

I'm very interested in the work you are doing, as I'm busy
porting 5.1.1 onto an ARM7 with 256K flash and 64K RAM.

I finally figured out one of my problems which was that
my memory allocator was not forcing the block size to an
aligned value.

I'm not sure about the 68331 but it might require aligned
access too.

There are a lot of reallocs when Lua runs, and I'm worried about
heap fragmentation. I need to instrument it to make sure that
it's not a bigger problem than I think it is, though...

I agree a porting guide would be handy, maybe that would
make an interesting Lua GEM?

Ralph