2 Copyright (C) 2001-2006, The Perl Foundation.
7 src/exec_start.c - Call compiled code
15 Exec is a tool for using the JIT at compile time to generate native
26 #include "parrot/parrot.h"
27 #include "parrot/string.h"
28 #include "parrot/exec.h"
32 #include "parrot/embed.h"
34 opcode_t
* run_compiled(Interp
*interpreter
,
35 opcode_t
*cur_opcode
, opcode_t
*code_start
);
39 =item C<int main(int argc, char * argv[])>
48 main(int argc
, char * argv
[])
53 opcode_t
* code_start
;
54 extern char * program_code
;
55 /* extern long opcode_map; */
56 /* extern int bytecode_offset; */
58 extern void * exec_prederef_code
;
60 /* extern int Parrot_exec_run; */
61 /* extern struct PackFile_Constant *exec_const_table; */
62 /* extern struct PackFile_Constant const_table; */
63 extern Interp interpre
;
66 /* Parrot_exec_run = 1; */
67 /* s. packfile.c (PackFile_ConstTable_unpack()) */
68 /* exec_const_table = &const_table; */
69 interpreter
= Parrot_new(NULL
);
74 /* run_native = run_compiled; */
75 /* TODO make also a shared variant of PackFile_new */
76 pf
= PackFile_new(interpreter
, 0);
78 if (!PackFile_unpack(interpreter
, pf
, (opcode_t
*)(&program_code
),
79 sizeof(&program_code
)))
81 printf( "Can't unpack.\n" );
84 Parrot_loadbc(interpreter
, pf
);
85 PackFile_fixup_subs(interpreter
, PBC_PBC
, NULL
);
87 /* opcode_map has the offset of each opcode in the compiled code
88 * this modifies it to be address of the opcode.
92 for (i = 0; i < (int)interpre.code->base.size; i++) {
93 opp[i] += (long)run_compiled;
98 exec_init_prederef(interpreter
, &exec_prederef_code
);
100 /* Parrot_set_run_core(interpreter, PARROT_EXEC_CORE);
101 interpreter->code->base.data =
102 (opcode_t *)&((&program_code)[bytecode_offset]);
103 Parrot_exec_run = 0; */
104 Parrot_runcode(interpreter
, argc
, argv
);
106 run_compiled(interpreter,
107 (opcode_t *)&((&program_code)[bytecode_offset]));
109 Parrot_exit(interpreter
, 0);
118 F<include/parrot/exec.h>, F<src/exec_save.h>, F<src/exec.c>
119 and F<compilers/imcc/main.c>.
123 Initial version by Daniel Grunblatt on 2003.6.9
132 * c-file-style: "parrot"
134 * vim: expandtab shiftwidth=4: