< prev index next >

src/share/vm/oops/cpCache.cpp

Print this page




  84 
  85 // Sets f1, ordering with previous writes.
  86 void ConstantPoolCacheEntry::release_set_f1(Metadata* f1) {
  87   assert(f1 != NULL, "");
  88   OrderAccess::release_store_ptr((HeapWord*) &_f1, f1);
  89 }
  90 
  91 // Sets flags, but only if the value was previously zero.
  92 bool ConstantPoolCacheEntry::init_flags_atomic(intptr_t flags) {
  93   intptr_t result = Atomic::cmpxchg_ptr(flags, &_flags, 0);
  94   return (result == 0);
  95 }
  96 
  97 // Note that concurrent update of both bytecodes can leave one of them
  98 // reset to zero.  This is harmless; the interpreter will simply re-resolve
  99 // the damaged entry.  More seriously, the memory synchronization is needed
 100 // to flush other fields (f1, f2) completely to memory before the bytecodes
 101 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
 102 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
 103                                        Bytecodes::Code put_code,
 104                                        KlassHandle field_holder,
 105                                        int field_index,
 106                                        int field_offset,
 107                                        TosState field_type,
 108                                        bool is_final,
 109                                        bool is_volatile,
 110                                        Klass* root_klass) {
 111   set_f1(field_holder());
 112   set_f2(field_offset);
 113   assert((field_index & field_index_mask) == field_index,
 114          "field index does not fit in low flag bits");
 115   set_field_flags(field_type,
 116                   ((is_volatile ? 1 : 0) << is_volatile_shift) |
 117                   ((is_final    ? 1 : 0) << is_final_shift),
 118                   field_index);
 119   set_bytecode_1(get_code);
 120   set_bytecode_2(put_code);
 121   NOT_PRODUCT(verify(tty));
 122 }
 123 
 124 void ConstantPoolCacheEntry::set_parameter_size(int value) {
 125   // This routine is called only in corner cases where the CPCE is not yet initialized.
 126   // See AbstractInterpreter::deopt_continue_after_entry.
 127   assert(_flags == 0 || parameter_size() == 0 || parameter_size() == value,
 128          "size must not change: parameter_size=%d, value=%d", parameter_size(), value);
 129   // Setting the parameter size by itself is only safe if the
 130   // current value of _flags is 0, otherwise another thread may have
 131   // updated it and we don't want to overwrite that value.  Don't




  84 
  85 // Sets f1, ordering with previous writes.
  86 void ConstantPoolCacheEntry::release_set_f1(Metadata* f1) {
  87   assert(f1 != NULL, "");
  88   OrderAccess::release_store_ptr((HeapWord*) &_f1, f1);
  89 }
  90 
  91 // Sets flags, but only if the value was previously zero.
  92 bool ConstantPoolCacheEntry::init_flags_atomic(intptr_t flags) {
  93   intptr_t result = Atomic::cmpxchg_ptr(flags, &_flags, 0);
  94   return (result == 0);
  95 }
  96 
  97 // Note that concurrent update of both bytecodes can leave one of them
  98 // reset to zero.  This is harmless; the interpreter will simply re-resolve
  99 // the damaged entry.  More seriously, the memory synchronization is needed
 100 // to flush other fields (f1, f2) completely to memory before the bytecodes
 101 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
 102 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
 103                                        Bytecodes::Code put_code,
 104                                        Klass* field_holder,
 105                                        int field_index,
 106                                        int field_offset,
 107                                        TosState field_type,
 108                                        bool is_final,
 109                                        bool is_volatile,
 110                                        Klass* root_klass) {
 111   set_f1(field_holder);
 112   set_f2(field_offset);
 113   assert((field_index & field_index_mask) == field_index,
 114          "field index does not fit in low flag bits");
 115   set_field_flags(field_type,
 116                   ((is_volatile ? 1 : 0) << is_volatile_shift) |
 117                   ((is_final    ? 1 : 0) << is_final_shift),
 118                   field_index);
 119   set_bytecode_1(get_code);
 120   set_bytecode_2(put_code);
 121   NOT_PRODUCT(verify(tty));
 122 }
 123 
 124 void ConstantPoolCacheEntry::set_parameter_size(int value) {
 125   // This routine is called only in corner cases where the CPCE is not yet initialized.
 126   // See AbstractInterpreter::deopt_continue_after_entry.
 127   assert(_flags == 0 || parameter_size() == 0 || parameter_size() == value,
 128          "size must not change: parameter_size=%d, value=%d", parameter_size(), value);
 129   // Setting the parameter size by itself is only safe if the
 130   // current value of _flags is 0, otherwise another thread may have
 131   // updated it and we don't want to overwrite that value.  Don't


< prev index next >