src/share/vm/oops/cpCacheOop.cpp

changeset 2811
08ccee2c4dbf
parent 2742
ed69575596ac
child 2982
ddd894528dbc
     1.1 --- a/src/share/vm/oops/cpCacheOop.cpp	Wed Apr 20 18:29:35 2011 -0700
     1.2 +++ b/src/share/vm/oops/cpCacheOop.cpp	Thu Apr 21 00:25:40 2011 -0700
     1.3 @@ -104,7 +104,7 @@
     1.4    void* result = Atomic::cmpxchg_ptr(f1, f1_addr, NULL);
     1.5    bool success = (result == NULL);
     1.6    if (success) {
     1.7 -    update_barrier_set(f1_addr, f1);
     1.8 +    update_barrier_set((void*) f1_addr, f1);
     1.9    }
    1.10  }
    1.11  
    1.12 @@ -275,21 +275,23 @@
    1.13    return (int) bsm_cache_index;
    1.14  }
    1.15  
    1.16 -void ConstantPoolCacheEntry::set_dynamic_call(Handle call_site,
    1.17 -                                              methodHandle signature_invoker) {
    1.18 +void ConstantPoolCacheEntry::set_dynamic_call(Handle call_site, methodHandle signature_invoker) {
    1.19    assert(is_secondary_entry(), "");
    1.20 +  // NOTE: it's important that all other values are set before f1 is
    1.21 +  // set since some users short circuit on f1 being set
    1.22 +  // (i.e. non-null) and that may result in uninitialized values for
    1.23 +  // other racing threads (e.g. flags).
    1.24    int param_size = signature_invoker->size_of_parameters();
    1.25    assert(param_size >= 1, "method argument size must include MH.this");
    1.26 -  param_size -= 1;              // do not count MH.this; it is not stacked for invokedynamic
    1.27 -  if (Atomic::cmpxchg_ptr(call_site(), &_f1, NULL) == NULL) {
    1.28 -    // racing threads might be trying to install their own favorites
    1.29 -    set_f1(call_site());
    1.30 -  }
    1.31 +  param_size -= 1;  // do not count MH.this; it is not stacked for invokedynamic
    1.32    bool is_final = true;
    1.33    assert(signature_invoker->is_final_method(), "is_final");
    1.34 -  set_flags(as_flags(as_TosState(signature_invoker->result_type()), is_final, false, false, false, true) | param_size);
    1.35 +  int flags = as_flags(as_TosState(signature_invoker->result_type()), is_final, false, false, false, true) | param_size;
    1.36 +  assert(_flags == 0 || _flags == flags, "flags should be the same");
    1.37 +  set_flags(flags);
    1.38    // do not do set_bytecode on a secondary CP cache entry
    1.39    //set_bytecode_1(Bytecodes::_invokedynamic);
    1.40 +  set_f1_if_null_atomic(call_site());  // This must be the last one to set (see NOTE above)!
    1.41  }
    1.42  
    1.43  

mercurial