Those register are not considered for allocation and their numbers are
> NR_REGISTERS. Letting those fixed intervals into register allocator
can cause memory corruption becuase use position arrays are of size
NR_REGISTERS.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 jit/linear-scan.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/jit/linear-scan.c b/jit/linear-scan.c
index 018daaa..187eb49 100644
--- a/jit/linear-scan.c
+++ b/jit/linear-scan.c
@@ -75,6 +75,7 @@ static void set_use_pos(unsigned long *use_pos, enum 
machine_reg reg,
        /*
         * This function does the same as set_free_pos so we call this directly
         */
+       assert(reg < NR_REGISTERS);
        set_free_pos(use_pos, reg, pos);
 }
 
@@ -84,6 +85,7 @@ static void set_block_pos(unsigned long *block_pos, unsigned 
long *use_pos,
        /*
         * This function does the same as set_free_pos so we call this directly
         */
+       assert(reg < NR_REGISTERS);
        set_free_pos(block_pos, reg, pos);
        set_free_pos(use_pos, reg, pos);
 }
@@ -345,9 +347,10 @@ int allocate_registers(struct compilation_unit *cu)
 
                var->interval->current_range = 
interval_first_range(var->interval);
 
-               if (var->interval->fixed_reg)
-                       list_add(&var->interval->interval_node, &inactive);
-               else
+               if (var->interval->fixed_reg) {
+                       if (var->interval->reg < NR_REGISTERS)
+                               list_add(&var->interval->interval_node, 
&inactive);
+               } else
                        pqueue_insert(unhandled, var->interval);
        }
 
-- 
1.6.3.3


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to