It works fine on x86 - OpenBSD/linux/FreeBSD and should also work on NetBSD
For PPC (Darwin) it generates code correctly just for programs that use *only*
fully jitted opcodes.
It should work with or without JIT_CGP.
After building parrot you should "make exec_start.o" that is used to start
running the compiled code.
Then you can use it like this:
# ./test_main -o t.pbc
This will generate exec_output.o (I know that -o must require an argument I
just don't know which is the correct way to actually make the argument
"visible" from insede the core, should I just add a pointer in the
interpreter and a subroutine to embed.c? or what?)
# cc -o <whatever> exec_output.o exec_start.o blib/lib/libparrot.a -lm -lutil
(or whatever your system require)
It's not finished, vtable and nci stuff is missing.
This are some of the things I did in order to make this work:
* Added an interpreter structure as a global variable.
* Make all the opcodes in core_ops.c global, not static, I add a rellocation
every time a non-JITted opcode is called and need the linker to know about
this functions.
* Put the program bytecode (the pbc) as part of the obj, as pbc2c.pl does
since I need the address of the bytecode in the JITted code and in x86 (at
least in BSD) the bytecode is the same than in the pbc, I know this might not
be 100% correct since if a pbc generated at a 64bit architecture or with a
different endianess will be unpacked differently and this won't work, but
I'll look at this later.
* Added the opcode_map too, this is need to make the restart and the not
jitted opcodes that change the program control flow work, the real adresses
are fixed at runtime, I'll see if I can do something to make the linker take
care of this, I'm sure this is possible yet.
* The constant table is also added and every time the bytecode unpacker need
to add a constant this memory is used instead of allocating new memory.
Now, every time the jit emits an instruction that has the address of a Parrot
regiter, the interpreter, the bytecode or a constant I must add a rellocation
at the exact address of the 4 bytes that will be the adress, for this I
assume that the last 4 bytes of the emited instruction holds this address
adding the rellocation at native_ptr - 4, but this is not correct for macros
that emits more than 1 instruction (like the floating point ones) hence I
made a horrible hack at jit2h.pl which change the displacement from -4 to,
say, -6. Another way I see to make this is adding a list of macros with their
displacement? (if the macro is not in the table it's -4) or what?
Enjoy.
Daniel Grunblatt.
> I have checked in a first attempt to make parrot generate an executable.
>
> It works fine on x86 - OpenBSD/linux/FreeBSD and should also work on NetBSD
It's not working for me on Linux/x86 -- the build is failing with:
In file included from exec.c:20:
include/parrot/exec_dep.h: In function `Parrot_exec_save':
include/parrot/exec_dep.h:383: `ELFOSABI_LINUX' undeclared (first use in
this function)
include/parrot/exec_dep.h:383: (Each undeclared identifier is reported
only onceinclude/parrot/exec_dep.h:383: for each function it appears in.)
make: *** [exec.o] Error 1
Looking in elf.h, these are the only ELFOSABI... constants defined:
#define EI_OSABI 7 /* OS ABI identification */
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
#define ELFOSABI_HPUX 1 /* HP-UX */
#define ELFOSABI_ARM 97 /* ARM */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
I'm using a 2.4 kernel, libc v2.2.4 & gcc v2.96
Simon
>
> Simon
Daniel.
>
> > It works fine on x86 - OpenBSD/linux/FreeBSD and should also work on
> > NetBSD
>
> Not at the moment. My Linux-system (an SUSE 7.3 or 8.0) has a
> /usr/include/elf.h but it does not define ELFOSABI_LINUX. This file
> only contains
> #define EI_OSABI 7 /* OS ABI identification */
> #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
> #define ELFOSABI_HPUX 1 /* HP-UX */
> #define ELFOSABI_ARM 97 /* ARM */
> #define ELFOSABI_STANDALONE 255 /* Standalone (embedded)
> application */
>
> > For PPC (Darwin) it generates code correctly just for programs that use
> > *only* fully jitted opcodes.
> >
> > It should work with or without JIT_CGP.
About to solve this.
>
> Nope
> with Configure.pl --cgoto=0 this fails. Attached patch is what I
> needed to get it to compile, and make it pass make test.
Applied, thanks!
>
> > After building parrot you should "make exec_start.o" that is used to
> > start running the compiled code.
> > Then you can use it like this:
> >
> > # ./test_main -o t.pbc
> >
> > This will generate exec_output.o (I know that -o must require an argument
> > I just don't know which is the correct way to actually make the argument
> > "visible" from insede the core, should I just add a pointer in the
> > interpreter and a subroutine to embed.c? or what?)
>
> Put the name of the outputfile in the interpreter structure.
>
> [...]
>
> bye
> boe
Daniel.
> On Thursday 24 July 2003 15:14, Simon Glover wrote:
> > On Thu, 24 Jul 2003, Daniel Grunblatt wrote:
> > > I have checked in a first attempt to make parrot generate an executable.
> > >
> > > It works fine on x86 - OpenBSD/linux/FreeBSD and should also work on
> > > NetBSD
> >
> > It's not working for me on Linux/x86 -- the build is failing with:
<AOL>Me too.</AOL>
> Could you send me the output of "readelf -h core_ops.o"?
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 616864 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 16
Section header string table index: 13
bye
boe
--
Juergen Boemmels boem...@physik.uni-kl.de
Fachbereich Physik Tel: ++49-(0)631-205-2817
Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906
PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47
Patch is in, please resync and try it.
> boe
Daniel
It's now dieing with:
In file included from exec.c:22:
include/parrot/exec_dep.h: In function `Parrot_exec_normal_op':
include/parrot/exec_dep.h:80: `cgp_core' undeclared (first use in this
function)include/parrot/exec_dep.h:80: (Each undeclared identifier is
reported only once
include/parrot/exec_dep.h:80: for each function it appears in.)
exec.c: In function `Parrot_exec':
exec.c:77: `cgp_core' undeclared (first use in this function)
make: *** [exec.o] Error 1
Still, we're making progress :-)
Simon
>
> Simon
Daniel.
Simon