Mercurial > hg > graal-compiler
comparison src/share/vm/opto/gcm.cpp @ 14499:1077c8270209
8033260: assert(lrg._area >= 0.0) failed: negative spill area
Summary: Change type from float to double on block frequency, and add check for +Inf - +Inf operation
Reviewed-by: kvn, roland
author | adlertz |
---|---|
date | Tue, 25 Feb 2014 17:51:27 +0100 |
parents | abec000618bf |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14498:04e7587c97dc | 14499:1077c8270209 |
---|---|
1659 ch->compute_freq(); | 1659 ch->compute_freq(); |
1660 ch = ch->_sibling; | 1660 ch = ch->_sibling; |
1661 } | 1661 } |
1662 assert (_members.length() > 0, "no empty loops"); | 1662 assert (_members.length() > 0, "no empty loops"); |
1663 Block* hd = head(); | 1663 Block* hd = head(); |
1664 hd->_freq = 1.0f; | 1664 hd->_freq = 1.0; |
1665 for (int i = 0; i < _members.length(); i++) { | 1665 for (int i = 0; i < _members.length(); i++) { |
1666 CFGElement* s = _members.at(i); | 1666 CFGElement* s = _members.at(i); |
1667 float freq = s->_freq; | 1667 double freq = s->_freq; |
1668 if (s->is_block()) { | 1668 if (s->is_block()) { |
1669 Block* b = s->as_Block(); | 1669 Block* b = s->as_Block(); |
1670 for (uint j = 0; j < b->_num_succs; j++) { | 1670 for (uint j = 0; j < b->_num_succs; j++) { |
1671 Block* sb = b->_succs[j]; | 1671 Block* sb = b->_succs[j]; |
1672 update_succ_freq(sb, freq * b->succ_prob(j)); | 1672 update_succ_freq(sb, freq * b->succ_prob(j)); |
1674 } else { | 1674 } else { |
1675 CFGLoop* lp = s->as_CFGLoop(); | 1675 CFGLoop* lp = s->as_CFGLoop(); |
1676 assert(lp->_parent == this, "immediate child"); | 1676 assert(lp->_parent == this, "immediate child"); |
1677 for (int k = 0; k < lp->_exits.length(); k++) { | 1677 for (int k = 0; k < lp->_exits.length(); k++) { |
1678 Block* eb = lp->_exits.at(k).get_target(); | 1678 Block* eb = lp->_exits.at(k).get_target(); |
1679 float prob = lp->_exits.at(k).get_prob(); | 1679 double prob = lp->_exits.at(k).get_prob(); |
1680 update_succ_freq(eb, freq * prob); | 1680 update_succ_freq(eb, freq * prob); |
1681 } | 1681 } |
1682 } | 1682 } |
1683 } | 1683 } |
1684 | 1684 |
1686 // sum and normalize the exit probability. The "method" loop | 1686 // sum and normalize the exit probability. The "method" loop |
1687 // should keep the initial exit probability of 1, so that | 1687 // should keep the initial exit probability of 1, so that |
1688 // inner blocks do not get erroneously scaled. | 1688 // inner blocks do not get erroneously scaled. |
1689 if (_depth != 0) { | 1689 if (_depth != 0) { |
1690 // Total the exit probabilities for this loop. | 1690 // Total the exit probabilities for this loop. |
1691 float exits_sum = 0.0f; | 1691 double exits_sum = 0.0f; |
1692 for (int i = 0; i < _exits.length(); i++) { | 1692 for (int i = 0; i < _exits.length(); i++) { |
1693 exits_sum += _exits.at(i).get_prob(); | 1693 exits_sum += _exits.at(i).get_prob(); |
1694 } | 1694 } |
1695 | 1695 |
1696 // Normalize the exit probabilities. Until now, the | 1696 // Normalize the exit probabilities. Until now, the |
1933 } | 1933 } |
1934 | 1934 |
1935 //------------------------------update_succ_freq------------------------------- | 1935 //------------------------------update_succ_freq------------------------------- |
1936 // Update the appropriate frequency associated with block 'b', a successor of | 1936 // Update the appropriate frequency associated with block 'b', a successor of |
1937 // a block in this loop. | 1937 // a block in this loop. |
1938 void CFGLoop::update_succ_freq(Block* b, float freq) { | 1938 void CFGLoop::update_succ_freq(Block* b, double freq) { |
1939 if (b->_loop == this) { | 1939 if (b->_loop == this) { |
1940 if (b == head()) { | 1940 if (b == head()) { |
1941 // back branch within the loop | 1941 // back branch within the loop |
1942 // Do nothing now, the loop carried frequency will be | 1942 // Do nothing now, the loop carried frequency will be |
1943 // adjust later in scale_freq(). | 1943 // adjust later in scale_freq(). |
1974 | 1974 |
1975 //------------------------------scale_freq------------------------------------- | 1975 //------------------------------scale_freq------------------------------------- |
1976 // Scale frequency of loops and blocks by trip counts from outer loops | 1976 // Scale frequency of loops and blocks by trip counts from outer loops |
1977 // Do a top down traversal of loop tree (visit outer loops first.) | 1977 // Do a top down traversal of loop tree (visit outer loops first.) |
1978 void CFGLoop::scale_freq() { | 1978 void CFGLoop::scale_freq() { |
1979 float loop_freq = _freq * trip_count(); | 1979 double loop_freq = _freq * trip_count(); |
1980 _freq = loop_freq; | 1980 _freq = loop_freq; |
1981 for (int i = 0; i < _members.length(); i++) { | 1981 for (int i = 0; i < _members.length(); i++) { |
1982 CFGElement* s = _members.at(i); | 1982 CFGElement* s = _members.at(i); |
1983 float block_freq = s->_freq * loop_freq; | 1983 double block_freq = s->_freq * loop_freq; |
1984 if (g_isnan(block_freq) || block_freq < MIN_BLOCK_FREQUENCY) | 1984 if (g_isnan(block_freq) || block_freq < MIN_BLOCK_FREQUENCY) |
1985 block_freq = MIN_BLOCK_FREQUENCY; | 1985 block_freq = MIN_BLOCK_FREQUENCY; |
1986 s->_freq = block_freq; | 1986 s->_freq = block_freq; |
1987 } | 1987 } |
1988 CFGLoop* ch = _child; | 1988 CFGLoop* ch = _child; |
1991 ch = ch->_sibling; | 1991 ch = ch->_sibling; |
1992 } | 1992 } |
1993 } | 1993 } |
1994 | 1994 |
1995 // Frequency of outer loop | 1995 // Frequency of outer loop |
1996 float CFGLoop::outer_loop_freq() const { | 1996 double CFGLoop::outer_loop_freq() const { |
1997 if (_child != NULL) { | 1997 if (_child != NULL) { |
1998 return _child->_freq; | 1998 return _child->_freq; |
1999 } | 1999 } |
2000 return _freq; | 2000 return _freq; |
2001 } | 2001 } |
2040 tty->print("\n "); | 2040 tty->print("\n "); |
2041 for (int j = 0; j < _depth+1; j++) tty->print(" "); | 2041 for (int j = 0; j < _depth+1; j++) tty->print(" "); |
2042 k = 0; | 2042 k = 0; |
2043 } | 2043 } |
2044 Block *blk = _exits.at(i).get_target(); | 2044 Block *blk = _exits.at(i).get_target(); |
2045 float prob = _exits.at(i).get_prob(); | 2045 double prob = _exits.at(i).get_prob(); |
2046 tty->print(" ->%d@%d%%", blk->_pre_order, (int)(prob*100)); | 2046 tty->print(" ->%d@%d%%", blk->_pre_order, (int)(prob*100)); |
2047 } | 2047 } |
2048 tty->print("\n"); | 2048 tty->print("\n"); |
2049 } | 2049 } |
2050 #endif | 2050 #endif |