]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
remove extra spills and add missing jit_cache_end_output()
authorAleksey Demakov <ademakov@gmail.com>
Mon, 8 May 2006 10:55:46 +0000 (10:55 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Mon, 8 May 2006 10:55:46 +0000 (10:55 +0000)
jit/jit-reg-alloc.c
jit/jit-rules-x86.c

index bdecc3198d121738cfdd1d08da2fa2bab2f1650d..c2aed7293ea528412ff584d99257c172e3acf164 100644 (file)
@@ -3000,6 +3000,10 @@ spill_reg(jit_gencode_t gen, _jit_regs_t *regs, int reg)
        int other_reg, index, usage;
        jit_value_t value;
 
+#ifdef JIT_REG_DEBUG
+       printf("spill_reg(reg = %d)\n", reg);
+#endif
+
        /* Find the other register in a long pair */
        if(gen->contents[reg].is_long_start)
        {
@@ -3063,6 +3067,12 @@ spill_value(jit_gencode_t gen, _jit_regs_t *regs, jit_value_t value, int reg, in
 {
        int top;
 
+#ifdef JIT_REG_DEBUG
+       printf("spill_value(value = ");
+       jit_dump_value(stdout, jit_value_get_function(value), value, 0);
+       printf(", reg = %d, other_reg = %d)\n", reg, other_reg);
+#endif
+
        if(IS_STACK_REG(reg))
        {
                top = get_stack_top(gen, regs->stack_start);
@@ -3315,13 +3325,13 @@ commit_input_value(jit_gencode_t gen, _jit_regs_t *regs, int index)
 
        if(!desc->used)
        {
-               spill_value(gen, regs, desc->value, reg, other_reg);
                if(desc->live || (IS_STACK_REG(reg) && gen->contents[reg].num_values == 1))
                {
-                       unbind_value(gen, desc->value, reg, other_reg);
+                       spill_value(gen, regs, desc->value, reg, other_reg);
                }
                else
                {
+                       unbind_value(gen, desc->value, reg, other_reg);
                }
        }
 }
@@ -3368,7 +3378,10 @@ commit_output_value(jit_gencode_t gen, _jit_regs_t *regs)
                        {
                                spill_value(gen, regs, desc->value, desc->reg, desc->other_reg);
                        }
-                       unbind_value(gen, desc->value, desc->reg, desc->other_reg);
+                       else
+                       {
+                               unbind_value(gen, desc->value, desc->reg, desc->other_reg);
+                       }
                }
        }
 
index 096fb4e79a1c04f1aa0f1e22138830499ed2251f..ae6e96c085f42f76d6b7a1ec530936a357202e18 100644 (file)
@@ -791,12 +791,12 @@ _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop)
        int offset;
        if(IS_FLOAT_REG(reg))
        {
-               /* Fix the value in place within the local variable frame */
-               _jit_gen_fix_value(value);
-
                /* Make sure that we have sufficient space */
                jit_cache_setup_output(16);
 
+               /* Fix the value in place within the local variable frame */
+               _jit_gen_fix_value(value);
+
                /* Output an appropriate instruction to spill the value */
                offset = (int)(value->frame_offset);
 
@@ -825,6 +825,9 @@ _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop)
                        }
                        break;
                }
+
+               /* End the code output process */
+               jit_cache_end_output();
        }
 }