[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Interpreter not building correct byte code
- From: David Jones <drj@...>
- Date: Mon, 1 Jan 2007 22:36:34 +0000
On 22 Dec 2006, at 18:32, Tom Bates wrote:
>> At the moment, the interpreter does not build correct code from
source
>
>What errors does the compiler give?
Running on the prototype hardware (i.e.68331), the compiler/
interpreter generates no errors, i.e. luaL_loadbuffer returns 0.
However, lua_pcall then either causes a fault or returns a bogus
error message like “attempt to perform arithmetic on a string
value”. To track this down, I worked my way down into the VM code
and found that the instructions there do not match what is
generated by the luac compiler running in Visual Studio 6 under
Windows 2000 Pro. The first few instructions look good, but the
rest is no good (e.g. no return instruction anywhere).
The bytecodes produced by luac are endian dependent (as well as
dependent on word-width and floating point format).
An Intel PC is little-endian, a 68K is big-endian. You can either
swab offline, using Kein-Hong Man's ChunkSpy http://luaforge.net/
projects/chunkspy/ , or rewrite lundump.c to use the other (or
either) endianness. I think LHF posted a modified lundump.c to the
list last year.
This useful fact about luac's bytecodes is documented in its manual:
http://www.lua.org/manual/5.1/luac.html
I hope that helps. Good look with re-alloc.
Cheers,
drj