1.1 --- a/src/share/vm/c1/c1_LinearScan.cpp Thu Dec 16 12:47:52 2010 -0800 1.2 +++ b/src/share/vm/c1/c1_LinearScan.cpp Fri Dec 17 15:55:32 2010 -0800 1.3 @@ -90,6 +90,7 @@ 1.4 , _intervals(0) // initialized later with correct length 1.5 , _new_intervals_from_allocation(new IntervalList()) 1.6 , _sorted_intervals(NULL) 1.7 + , _needs_full_resort(false) 1.8 , _lir_ops(0) // initialized later with correct length 1.9 , _block_of_op(0) // initialized later with correct length 1.10 , _has_info(0) 1.11 @@ -1520,6 +1521,14 @@ 1.12 void LinearScan::sort_intervals_before_allocation() { 1.13 TIME_LINEAR_SCAN(timer_sort_intervals_before); 1.14 1.15 + if (_needs_full_resort) { 1.16 + // There is no known reason why this should occur but just in case... 1.17 + assert(false, "should never occur"); 1.18 + // Re-sort existing interval list because an Interval::from() has changed 1.19 + _sorted_intervals->sort(interval_cmp); 1.20 + _needs_full_resort = false; 1.21 + } 1.22 + 1.23 IntervalList* unsorted_list = &_intervals; 1.24 int unsorted_len = unsorted_list->length(); 1.25 int sorted_len = 0; 1.26 @@ -1559,11 +1568,18 @@ 1.27 } 1.28 } 1.29 _sorted_intervals = sorted_list; 1.30 + assert(is_sorted(_sorted_intervals), "intervals unsorted"); 1.31 } 1.32 1.33 void LinearScan::sort_intervals_after_allocation() { 1.34 TIME_LINEAR_SCAN(timer_sort_intervals_after); 1.35 1.36 + if (_needs_full_resort) { 1.37 + // Re-sort existing interval list because an Interval::from() has changed 1.38 + _sorted_intervals->sort(interval_cmp); 1.39 + _needs_full_resort = false; 1.40 + } 1.41 + 1.42 IntervalArray* old_list = _sorted_intervals; 1.43 IntervalList* new_list = _new_intervals_from_allocation; 1.44 int old_len = old_list->length(); 1.45 @@ -1571,6 +1587,7 @@ 1.46 1.47 if (new_len == 0) { 1.48 // no intervals have been added during allocation, so sorted list is already up to date 1.49 + assert(is_sorted(_sorted_intervals), "intervals unsorted"); 1.50 return; 1.51 } 1.52 1.53 @@ -1593,6 +1610,7 @@ 1.54 } 1.55 1.56 _sorted_intervals = combined_list; 1.57 + assert(is_sorted(_sorted_intervals), "intervals unsorted"); 1.58 } 1.59 1.60 1.61 @@ -1825,6 +1843,8 @@ 1.62 interval = interval->split(from_op_id); 1.63 interval->assign_reg(reg, regHi); 1.64 append_interval(interval); 1.65 + } else { 1.66 + _needs_full_resort = true; 1.67 } 1.68 assert(interval->from() == from_op_id, "must be true now"); 1.69 1.70 @@ -4492,7 +4512,8 @@ 1.71 } 1.72 } else { 1.73 type_name = type2name(type()); 1.74 - if (assigned_reg() != -1) { 1.75 + if (assigned_reg() != -1 && 1.76 + (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) { 1.77 opr = LinearScan::calc_operand_for_interval(this); 1.78 } 1.79 }