cvsuser 03/03/03 01:11:02
Modified: . jit.c
languages/imcc cfg.c imc.c optimizer.c
Log:
misc: some CFG and JIT comments
Revision Changes Path
1.61 +13 -4 parrot/jit.c
Index: jit.c
===================================================================
RCS file: /cvs/public/parrot/jit.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -w -r1.60 -r1.61
--- jit.c 28 Feb 2003 14:21:38 -0000 1.60
+++ jit.c 3 Mar 2003 09:10:59 -0000 1.61
@@ -1,7 +1,7 @@
/*
* jit.c
*
- * $Id: jit.c,v 1.60 2003/02/28 14:21:38 leo Exp $
+ * $Id: jit.c,v 1.61 2003/03/03 09:10:59 leo Exp $
*/
#include <parrot/parrot.h>
@@ -54,7 +54,11 @@
void Parrot_jit_debug(struct Parrot_Interp* interpreter);
#endif
-/* look at fixups, mark all fixup entries as branch target */
+/* look at fixups, mark all fixup entries as branch target
+ * TODO: actually this is wrong: fixups belong only to one
+ * code segment. The code below doesn't check, for which
+ * segments the fixups are inserted.
+ */
static void
insert_fixup_targets(struct Parrot_Interp* interpreter, char *branch,
size_t limit)
@@ -712,6 +716,10 @@
/* Allocate space for the optimizer */
optimizer = (Parrot_jit_optimizer_t *)
mem_sys_allocate_zeroed(sizeof(Parrot_jit_optimizer_t));
+ /*
+ * TODO: pass the whole map_branch in the PBC
+ * this would save two runs through all the opcode
+ */
optimizer->map_branch = branch =
(char *)mem_sys_allocate_zeroed((size_t)(code_end - code_start));
ptr = jit_seg->data;
@@ -998,12 +1006,13 @@
* mapped too.
*
* and also, if we have a jitted sections and encounter
- * and "end" opcode, e.g. in evaled code
+ * an "end" opcode, e.g. in evaled code
*/
if ((((map[cur_op - code_start] == JIT_BRANCH_SOURCE) &&
(cur_section->branch_target != cur_section)) ||
!cur_opcode_byte) &&
- cur_section->isjit) {
+ cur_section->isjit &&
+ !jit_seg) {
Parrot_jit_save_registers(jit_info, interpreter);
}
1.23 +16 -2 parrot/languages/imcc/cfg.c
Index: cfg.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/cfg.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -w -r1.22 -r1.23
--- cfg.c 28 Feb 2003 14:32:09 -0000 1.22
+++ cfg.c 3 Mar 2003 09:11:02 -0000 1.23
@@ -115,6 +115,17 @@
/* treat the set_addr as jump source */
found = 1;
}
+#if 0
+ /* treat bsr as jumps, ret jumps to next ins
+ * or as fall through instruction, when bsr target
+ * was not found
+ *
+ * TODO do this below, when ret is found
+ * and then isert correct edges for bsr-ret or not
+ */
+ if (found)
+ ins->type |= IF_goto;
+#endif
}
if (found) {
if (ins->next)
@@ -315,6 +326,8 @@
{
Instruction *ins, *curr;
SymReg *r0, *r1;
+ int any = 0;
+
for (ins = instructions ; ins ; ins = ins->next) {
if (ins->type & ITALIAS) {
/* make r1 live in each instruction
@@ -330,16 +343,18 @@
else if (instruction_reads(ins, r0) &&
!instruction_reads(ins, r1)) {
add_instruc_reads(ins, r1);
+ any = 1;
}
else if (instruction_reads(ins, r1) &&
!instruction_reads(ins, r0)) {
add_instruc_reads(ins, r0);
+ any = 1;
}
ins = curr;
}
}
}
- if (IMCC_DEBUG & DEBUG_CFG) {
+ if (any && (IMCC_DEBUG & DEBUG_CFG)) {
debug(DEBUG_CFG, "\nAfter propagate_alias\n");
dump_instructions();
}
@@ -650,7 +665,6 @@
sort_loops();
if (IMCC_DEBUG & DEBUG_CFG) {
- dump_cfg();
dump_loops();
}
if (bb_list[0]->loop_depth) {
1.42 +0 -5 parrot/languages/imcc/imc.c
Index: imc.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imc.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- imc.c 28 Feb 2003 14:21:43 -0000 1.41
+++ imc.c 3 Mar 2003 09:11:02 -0000 1.42
@@ -63,8 +63,6 @@
todo = cfg_optimize(interpreter);
}
- if (IMCC_DEBUG & DEBUG_CFG)
- dump_cfg();
todo = first = 1;
while (todo) {
if (!first) {
@@ -79,8 +77,6 @@
build_reglist();
life_analysis();
/* optimize, as long as there is something to do */
- if (IMCC_DEBUG & DEBUG_IMC)
- dump_symreg();
if (dont_optimize)
todo = 0;
else {
@@ -297,7 +293,6 @@
}
if (IMCC_DEBUG & DEBUG_IMC) {
- dump_symreg();
dump_interference_graph();
}
}
1.23 +2 -1 parrot/languages/imcc/optimizer.c
Index: optimizer.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/optimizer.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -w -r1.22 -r1.23
--- optimizer.c 28 Feb 2003 14:21:43 -0000 1.22
+++ optimizer.c 3 Mar 2003 09:11:02 -0000 1.23
@@ -839,7 +839,8 @@
}
}
for (last = instructions, ins=last->next; last && ins; ins = ins->next) {
- if ((last->type & IF_goto) && !(ins->type & ITLABEL)) {
+ if ((last->type & IF_goto) && !(ins->type & ITLABEL) &&
+ !strcmp(last->op, "branch")) {
debug(DEBUG_OPT1, "unreachable ins deleted (after branch) %s\n",
ins_string(ins));
ins = delete_ins(ins, 1);