88 , _max_spills(0) |
88 , _max_spills(0) |
89 , _unused_spill_slot(-1) |
89 , _unused_spill_slot(-1) |
90 , _intervals(0) // initialized later with correct length |
90 , _intervals(0) // initialized later with correct length |
91 , _new_intervals_from_allocation(new IntervalList()) |
91 , _new_intervals_from_allocation(new IntervalList()) |
92 , _sorted_intervals(NULL) |
92 , _sorted_intervals(NULL) |
|
93 , _needs_full_resort(false) |
93 , _lir_ops(0) // initialized later with correct length |
94 , _lir_ops(0) // initialized later with correct length |
94 , _block_of_op(0) // initialized later with correct length |
95 , _block_of_op(0) // initialized later with correct length |
95 , _has_info(0) |
96 , _has_info(0) |
96 , _has_call(0) |
97 , _has_call(0) |
97 , _scope_value_cache(0) // initialized later with correct length |
98 , _scope_value_cache(0) // initialized later with correct length |
1518 |
1519 |
1519 |
1520 |
1520 void LinearScan::sort_intervals_before_allocation() { |
1521 void LinearScan::sort_intervals_before_allocation() { |
1521 TIME_LINEAR_SCAN(timer_sort_intervals_before); |
1522 TIME_LINEAR_SCAN(timer_sort_intervals_before); |
1522 |
1523 |
|
1524 if (_needs_full_resort) { |
|
1525 // There is no known reason why this should occur but just in case... |
|
1526 assert(false, "should never occur"); |
|
1527 // Re-sort existing interval list because an Interval::from() has changed |
|
1528 _sorted_intervals->sort(interval_cmp); |
|
1529 _needs_full_resort = false; |
|
1530 } |
|
1531 |
1523 IntervalList* unsorted_list = &_intervals; |
1532 IntervalList* unsorted_list = &_intervals; |
1524 int unsorted_len = unsorted_list->length(); |
1533 int unsorted_len = unsorted_list->length(); |
1525 int sorted_len = 0; |
1534 int sorted_len = 0; |
1526 int unsorted_idx; |
1535 int unsorted_idx; |
1527 int sorted_idx = 0; |
1536 int sorted_idx = 0; |
1557 sorted_idx++; |
1566 sorted_idx++; |
1558 } |
1567 } |
1559 } |
1568 } |
1560 } |
1569 } |
1561 _sorted_intervals = sorted_list; |
1570 _sorted_intervals = sorted_list; |
|
1571 assert(is_sorted(_sorted_intervals), "intervals unsorted"); |
1562 } |
1572 } |
1563 |
1573 |
1564 void LinearScan::sort_intervals_after_allocation() { |
1574 void LinearScan::sort_intervals_after_allocation() { |
1565 TIME_LINEAR_SCAN(timer_sort_intervals_after); |
1575 TIME_LINEAR_SCAN(timer_sort_intervals_after); |
|
1576 |
|
1577 if (_needs_full_resort) { |
|
1578 // Re-sort existing interval list because an Interval::from() has changed |
|
1579 _sorted_intervals->sort(interval_cmp); |
|
1580 _needs_full_resort = false; |
|
1581 } |
1566 |
1582 |
1567 IntervalArray* old_list = _sorted_intervals; |
1583 IntervalArray* old_list = _sorted_intervals; |
1568 IntervalList* new_list = _new_intervals_from_allocation; |
1584 IntervalList* new_list = _new_intervals_from_allocation; |
1569 int old_len = old_list->length(); |
1585 int old_len = old_list->length(); |
1570 int new_len = new_list->length(); |
1586 int new_len = new_list->length(); |
1571 |
1587 |
1572 if (new_len == 0) { |
1588 if (new_len == 0) { |
1573 // no intervals have been added during allocation, so sorted list is already up to date |
1589 // no intervals have been added during allocation, so sorted list is already up to date |
|
1590 assert(is_sorted(_sorted_intervals), "intervals unsorted"); |
1574 return; |
1591 return; |
1575 } |
1592 } |
1576 |
1593 |
1577 // conventional sort-algorithm for new intervals |
1594 // conventional sort-algorithm for new intervals |
1578 new_list->sort(interval_cmp); |
1595 new_list->sort(interval_cmp); |
1823 if (interval->from() != from_op_id) { |
1841 if (interval->from() != from_op_id) { |
1824 // the part before from_op_id is unchanged |
1842 // the part before from_op_id is unchanged |
1825 interval = interval->split(from_op_id); |
1843 interval = interval->split(from_op_id); |
1826 interval->assign_reg(reg, regHi); |
1844 interval->assign_reg(reg, regHi); |
1827 append_interval(interval); |
1845 append_interval(interval); |
|
1846 } else { |
|
1847 _needs_full_resort = true; |
1828 } |
1848 } |
1829 assert(interval->from() == from_op_id, "must be true now"); |
1849 assert(interval->from() == from_op_id, "must be true now"); |
1830 |
1850 |
1831 Interval* spilled_part = interval; |
1851 Interval* spilled_part = interval; |
1832 if (interval->to() != to_op_id) { |
1852 if (interval->to() != to_op_id) { |
4490 } else { |
4510 } else { |
4491 ShouldNotReachHere(); |
4511 ShouldNotReachHere(); |
4492 } |
4512 } |
4493 } else { |
4513 } else { |
4494 type_name = type2name(type()); |
4514 type_name = type2name(type()); |
4495 if (assigned_reg() != -1) { |
4515 if (assigned_reg() != -1 && |
|
4516 (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) { |
4496 opr = LinearScan::calc_operand_for_interval(this); |
4517 opr = LinearScan::calc_operand_for_interval(this); |
4497 } |
4518 } |
4498 } |
4519 } |
4499 |
4520 |
4500 out->print("%d %s ", reg_num(), type_name); |
4521 out->print("%d %s ", reg_num(), type_name); |