]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
clean outgoing registers after calls
authorAleksey Demakov <ademakov@gmail.com>
Fri, 30 Oct 2009 07:47:14 +0000 (13:47 +0600)
committerAleksey Demakov <ademakov@gmail.com>
Fri, 30 Oct 2009 07:47:14 +0000 (13:47 +0600)
ChangeLog
jit/jit-compile.c
jit/jit-reg-alloc.c
jit/jit-reg-alloc.h

index d939080ed0bdddad7b53fb097b34079255171bc0..9f78ab630003352c51c1bb4bd14a14a48be3a93b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-30  Aleksey Demakov  <ademakov@gmail.com>
 
+       * jit/jit-reg-alloc.h, jit/jit-reg-alloc.c
+       (_jit_regs_clear_all_outgoing): add function.
+       * jit/jit-compile.c (compile_block): use _jit_regs_clear_all_outgoing
+       after each function call.
+
        * include/jit/jit-except.h (JIT_RESULT_CACHE_FULL): add result code.
        * jit/jit-cache.h, jit/jit-cache.c (_jit_cache_check_space): add
        function to check the available cache space.
index 75dab3f8c797123584c242d56ebe35c90b0a6157..59bcca66412a4e87086384c578efeefd1b408ed7 100644 (file)
@@ -189,6 +189,7 @@ compile_block(jit_gencode_t gen, jit_function_t func, jit_block_t block)
                        }
                        break;
 
+#ifndef JIT_BACKEND_INTERP
                case JIT_OP_CALL:
                case JIT_OP_CALL_TAIL:
                case JIT_OP_CALL_INDIRECT:
@@ -199,8 +200,12 @@ compile_block(jit_gencode_t gen, jit_function_t func, jit_block_t block)
                case JIT_OP_CALL_EXTERNAL_TAIL:
                        /* Spill all caller-saved registers before a call */
                        _jit_regs_spill_all(gen);
+                       /* Generate code for the instruction with the back end */
                        _jit_gen_insn(gen, func, block, insn);
+                       /* Free outgoing registers if any */
+                       _jit_regs_clear_all_outgoing(gen);
                        break;
+#endif
 
 #ifndef JIT_BACKEND_INTERP
                case JIT_OP_INCOMING_REG:
@@ -208,6 +213,7 @@ compile_block(jit_gencode_t gen, jit_function_t func, jit_block_t block)
                        _jit_regs_set_incoming(gen,
                                               (int)jit_value_get_nint_constant(insn->value2),
                                               insn->value1);
+                       /* Generate code for the instruction with the back end */
                        _jit_gen_insn(gen, func, block, insn);
                        break;
 #endif
@@ -253,6 +259,7 @@ compile_block(jit_gencode_t gen, jit_function_t func, jit_block_t block)
                        _jit_regs_set_incoming(gen,
                                               (int)jit_value_get_nint_constant(insn->value2),
                                               insn->value1);
+                       /* Generate code for the instruction with the back end */
                        _jit_gen_insn(gen, func, block, insn);
                        break;
 #endif
index 3dad531ec385d55e45a74f6a2933aae259e26f2d..21798c61bfd6a06f95722a08544a01f662b54c23 100644 (file)
@@ -2760,7 +2760,8 @@ void _jit_regs_alloc_global(jit_gencode_t gen, jit_function_t func)
  * Initialize the register allocation state for a new block.
  * @end deftypefun
 @*/
-void _jit_regs_init_for_block(jit_gencode_t gen)
+void
+_jit_regs_init_for_block(jit_gencode_t gen)
 {
        int reg;
        gen->current_age = 1;
@@ -2940,6 +2941,18 @@ _jit_regs_set_outgoing(jit_gencode_t gen, int reg, jit_value_t value)
        }
 }
 
+/*@
+ * @deftypefun void _jit_regs_clear_all_outgoing (jit_gencode_t gen)
+ * Free registers used fot outgoing parameters.  This is used to
+ * clean up after a function call.
+ * @end deftypefun
+@*/
+void
+_jit_regs_clear_all_outgoing(jit_gencode_t gen)
+{
+       gen->inhibit = jit_regused_init;
+}
+
 /* TODO: remove this function */
 /*@
  * @deftypefun void _jit_regs_force_out (jit_gencode_t gen, jit_value_t value, int is_dest)
index 32adb6ffd6030311c0bed3215b526c37f3beeab1..6368fe7e7eb054212c83b8f55d65dd3f6c7624bf 100644 (file)
@@ -146,6 +146,7 @@ void _jit_regs_init_for_block(jit_gencode_t gen);
 void _jit_regs_spill_all(jit_gencode_t gen);
 void _jit_regs_set_incoming(jit_gencode_t gen, int reg, jit_value_t value);
 void _jit_regs_set_outgoing(jit_gencode_t gen, int reg, jit_value_t value);
+void _jit_regs_clear_all_outgoing(jit_gencode_t gen);
 void _jit_regs_force_out(jit_gencode_t gen, jit_value_t value, int is_dest);
 int _jit_regs_load_value(jit_gencode_t gen, jit_value_t value, int destroy, int used_again);