src/share/vm/adlc/formssel.cpp

changeset 1034
0ad1cb407fa1
parent 993
3b5ac9e7e6ea
child 1037
ed6404fac86b
     1.1 --- a/src/share/vm/adlc/formssel.cpp	Tue Feb 24 09:53:20 2009 -0800
     1.2 +++ b/src/share/vm/adlc/formssel.cpp	Wed Feb 25 10:53:14 2009 -0800
     1.3 @@ -1217,13 +1217,17 @@
     1.4  // Seach through operands to determine parameters unique positions.
     1.5  void InstructForm::set_unique_opnds() {
     1.6    uint* uniq_idx = NULL;
     1.7 -  uint  nopnds = num_opnds();
     1.8 +  int  nopnds = num_opnds();
     1.9    uint  num_uniq = nopnds;
    1.10 -  uint i;
    1.11 +  int i;
    1.12 +  _uniq_idx_length = 0;
    1.13    if ( nopnds > 0 ) {
    1.14 -    // Allocate index array with reserve.
    1.15 -    uniq_idx = (uint*) malloc(sizeof(uint)*(nopnds + 2));
    1.16 -    for( i = 0; i < nopnds+2; i++ ) {
    1.17 +    // Allocate index array.  Worst case we're mapping from each
    1.18 +    // component back to an index and any DEF always goes at 0 so the
    1.19 +    // length of the array has to be the number of components + 1.
    1.20 +    _uniq_idx_length = _components.count() + 1;
    1.21 +    uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length));
    1.22 +    for( i = 0; i < _uniq_idx_length; i++ ) {
    1.23        uniq_idx[i] = i;
    1.24      }
    1.25    }
    1.26 @@ -1238,8 +1242,8 @@
    1.27      _parameters.reset();
    1.28      while( (name = _parameters.iter()) != NULL ) {
    1.29        count = 0;
    1.30 -      uint position = 0;
    1.31 -      uint uniq_position = 0;
    1.32 +      int position = 0;
    1.33 +      int uniq_position = 0;
    1.34        _components.reset();
    1.35        Component *comp = NULL;
    1.36        if( sets_result() ) {
    1.37 @@ -1255,6 +1259,7 @@
    1.38          }
    1.39          if( strcmp(name, comp->_name)==0 ) {
    1.40            if( ++count > 1 ) {
    1.41 +            assert(position < _uniq_idx_length, "out of bounds");
    1.42              uniq_idx[position] = uniq_position;
    1.43              has_dupl_use = true;
    1.44            } else {

mercurial