7143038: SIGSEGV in assert_equal / LinearScan::assign_reg_num

Thu, 16 Feb 2012 09:20:40 +0100

author
roland
date
Thu, 16 Feb 2012 09:20:40 +0100
changeset 3575
c7401dcad8bf
parent 3574
fd8114661503
child 3576
ad3b47344802

7143038: SIGSEGV in assert_equal / LinearScan::assign_reg_num
Summary: forced exit may destory global objects that are still in use.
Reviewed-by: twisti, never, kvn

src/share/vm/c1/c1_LinearScan.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LinearScan.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/c1/c1_LinearScan.cpp	Wed Feb 15 21:37:49 2012 -0800
     1.2 +++ b/src/share/vm/c1/c1_LinearScan.cpp	Thu Feb 16 09:20:40 2012 +0100
     1.3 @@ -2464,12 +2464,15 @@
     1.4  
     1.5  
     1.6  // frequently used constants
     1.7 -ConstantOopWriteValue LinearScan::_oop_null_scope_value = ConstantOopWriteValue(NULL);
     1.8 -ConstantIntValue      LinearScan::_int_m1_scope_value = ConstantIntValue(-1);
     1.9 -ConstantIntValue      LinearScan::_int_0_scope_value =  ConstantIntValue(0);
    1.10 -ConstantIntValue      LinearScan::_int_1_scope_value =  ConstantIntValue(1);
    1.11 -ConstantIntValue      LinearScan::_int_2_scope_value =  ConstantIntValue(2);
    1.12 -LocationValue         _illegal_value = LocationValue(Location());
    1.13 +// Allocate them with new so they are never destroyed (otherwise, a
    1.14 +// forced exit could destroy these objects while they are still in
    1.15 +// use).
    1.16 +ConstantOopWriteValue* LinearScan::_oop_null_scope_value = new (ResourceObj::C_HEAP) ConstantOopWriteValue(NULL);
    1.17 +ConstantIntValue*      LinearScan::_int_m1_scope_value = new (ResourceObj::C_HEAP) ConstantIntValue(-1);
    1.18 +ConstantIntValue*      LinearScan::_int_0_scope_value =  new (ResourceObj::C_HEAP) ConstantIntValue(0);
    1.19 +ConstantIntValue*      LinearScan::_int_1_scope_value =  new (ResourceObj::C_HEAP) ConstantIntValue(1);
    1.20 +ConstantIntValue*      LinearScan::_int_2_scope_value =  new (ResourceObj::C_HEAP) ConstantIntValue(2);
    1.21 +LocationValue*         _illegal_value = new (ResourceObj::C_HEAP) LocationValue(Location());
    1.22  
    1.23  void LinearScan::init_compute_debug_info() {
    1.24    // cache for frequently used scope values
    1.25 @@ -2508,7 +2511,7 @@
    1.26      case T_OBJECT: {
    1.27        jobject value = c->as_jobject();
    1.28        if (value == NULL) {
    1.29 -        scope_values->append(&_oop_null_scope_value);
    1.30 +        scope_values->append(_oop_null_scope_value);
    1.31        } else {
    1.32          scope_values->append(new ConstantOopWriteValue(c->as_jobject()));
    1.33        }
    1.34 @@ -2519,10 +2522,10 @@
    1.35      case T_FLOAT: {
    1.36        int value = c->as_jint_bits();
    1.37        switch (value) {
    1.38 -        case -1: scope_values->append(&_int_m1_scope_value); break;
    1.39 -        case 0:  scope_values->append(&_int_0_scope_value); break;
    1.40 -        case 1:  scope_values->append(&_int_1_scope_value); break;
    1.41 -        case 2:  scope_values->append(&_int_2_scope_value); break;
    1.42 +        case -1: scope_values->append(_int_m1_scope_value); break;
    1.43 +        case 0:  scope_values->append(_int_0_scope_value); break;
    1.44 +        case 1:  scope_values->append(_int_1_scope_value); break;
    1.45 +        case 2:  scope_values->append(_int_2_scope_value); break;
    1.46          default: scope_values->append(new ConstantIntValue(c->as_jint_bits())); break;
    1.47        }
    1.48        return 1;
    1.49 @@ -2531,7 +2534,7 @@
    1.50      case T_LONG: // fall through
    1.51      case T_DOUBLE: {
    1.52  #ifdef _LP64
    1.53 -      scope_values->append(&_int_0_scope_value);
    1.54 +      scope_values->append(_int_0_scope_value);
    1.55        scope_values->append(new ConstantLongValue(c->as_jlong_bits()));
    1.56  #else
    1.57        if (hi_word_offset_in_bytes > lo_word_offset_in_bytes) {
    1.58 @@ -2657,7 +2660,7 @@
    1.59        }
    1.60        // Does this reverse on x86 vs. sparc?
    1.61        first =  new LocationValue(loc1);
    1.62 -      second = &_int_0_scope_value;
    1.63 +      second = _int_0_scope_value;
    1.64  #else
    1.65        Location loc1, loc2;
    1.66        if (!frame_map()->locations_for_slot(opr->double_stack_ix(), Location::normal, &loc1, &loc2)) {
    1.67 @@ -2671,7 +2674,7 @@
    1.68  #ifdef _LP64
    1.69        VMReg rname_first = opr->as_register_lo()->as_VMReg();
    1.70        first = new LocationValue(Location::new_reg_loc(Location::lng, rname_first));
    1.71 -      second = &_int_0_scope_value;
    1.72 +      second = _int_0_scope_value;
    1.73  #else
    1.74        VMReg rname_first = opr->as_register_lo()->as_VMReg();
    1.75        VMReg rname_second = opr->as_register_hi()->as_VMReg();
    1.76 @@ -2694,7 +2697,7 @@
    1.77        VMReg rname_first  = opr->as_xmm_double_reg()->as_VMReg();
    1.78  #  ifdef _LP64
    1.79        first = new LocationValue(Location::new_reg_loc(Location::dbl, rname_first));
    1.80 -      second = &_int_0_scope_value;
    1.81 +      second = _int_0_scope_value;
    1.82  #  else
    1.83        first = new LocationValue(Location::new_reg_loc(Location::normal, rname_first));
    1.84        // %%% This is probably a waste but we'll keep things as they were for now
    1.85 @@ -2741,7 +2744,7 @@
    1.86  
    1.87  #ifdef _LP64
    1.88        first = new LocationValue(Location::new_reg_loc(Location::dbl, rname_first));
    1.89 -      second = &_int_0_scope_value;
    1.90 +      second = _int_0_scope_value;
    1.91  #else
    1.92        first = new LocationValue(Location::new_reg_loc(Location::normal, rname_first));
    1.93        // %%% This is probably a waste but we'll keep things as they were for now
    1.94 @@ -2822,7 +2825,7 @@
    1.95      }
    1.96    } else {
    1.97      // append a dummy value because real value not needed
    1.98 -    scope_values->append(&_illegal_value);
    1.99 +    scope_values->append(_illegal_value);
   1.100      return 1;
   1.101    }
   1.102  }
   1.103 @@ -2865,7 +2868,7 @@
   1.104      nof_locals = cur_scope->method()->max_locals();
   1.105      locals = new GrowableArray<ScopeValue*>(nof_locals);
   1.106      for(int i = 0; i < nof_locals; i++) {
   1.107 -      locals->append(&_illegal_value);
   1.108 +      locals->append(_illegal_value);
   1.109      }
   1.110    }
   1.111  
     2.1 --- a/src/share/vm/c1/c1_LinearScan.hpp	Wed Feb 15 21:37:49 2012 -0800
     2.2 +++ b/src/share/vm/c1/c1_LinearScan.hpp	Thu Feb 16 09:20:40 2012 +0100
     2.3 @@ -160,11 +160,11 @@
     2.4    // TODO: cached scope values for registers could be static
     2.5    ScopeValueArray           _scope_value_cache;
     2.6  
     2.7 -  static ConstantOopWriteValue _oop_null_scope_value;
     2.8 -  static ConstantIntValue    _int_m1_scope_value;
     2.9 -  static ConstantIntValue    _int_0_scope_value;
    2.10 -  static ConstantIntValue    _int_1_scope_value;
    2.11 -  static ConstantIntValue    _int_2_scope_value;
    2.12 +  static ConstantOopWriteValue* _oop_null_scope_value;
    2.13 +  static ConstantIntValue*    _int_m1_scope_value;
    2.14 +  static ConstantIntValue*    _int_0_scope_value;
    2.15 +  static ConstantIntValue*    _int_1_scope_value;
    2.16 +  static ConstantIntValue*    _int_2_scope_value;
    2.17  
    2.18    // accessors
    2.19    IR*           ir() const                       { return _ir; }

mercurial