< prev index next >

src/hotspot/share/oops/cpCache.cpp

Print this page




  80                                        int field_index_or_method_params) {
  81   assert(state < number_of_states, "Invalid state in make_flags");
  82   int f = ((int)state << tos_state_shift) | option_bits | field_index_or_method_params;
  83   // Preserve existing flag bit values
  84   // The low bits are a field offset, or else the method parameter size.
  85 #ifdef ASSERT
  86   TosState old_state = flag_state();
  87   assert(old_state == (TosState)0 || old_state == state,
  88          "inconsistent cpCache flags state");
  89 #endif
  90   return (_flags | f) ;
  91 }
  92 
  93 void ConstantPoolCacheEntry::set_bytecode_1(Bytecodes::Code code) {
  94 #ifdef ASSERT
  95   // Read once.
  96   volatile Bytecodes::Code c = bytecode_1();
  97   assert(c == 0 || c == code || code == 0, "update must be consistent");
  98 #endif
  99   // Need to flush pending stores here before bytecode is written.
 100   OrderAccess::release_store(&_indices, _indices | ((u_char)code << bytecode_1_shift));
 101 }
 102 
 103 void ConstantPoolCacheEntry::set_bytecode_2(Bytecodes::Code code) {
 104 #ifdef ASSERT
 105   // Read once.
 106   volatile Bytecodes::Code c = bytecode_2();
 107   assert(c == 0 || c == code || code == 0, "update must be consistent");
 108 #endif
 109   // Need to flush pending stores here before bytecode is written.
 110   OrderAccess::release_store(&_indices, _indices | ((u_char)code << bytecode_2_shift));
 111 }
 112 
 113 // Sets f1, ordering with previous writes.
 114 void ConstantPoolCacheEntry::release_set_f1(Metadata* f1) {
 115   assert(f1 != NULL, "");
 116   OrderAccess::release_store(&_f1, f1);
 117 }
 118 
 119 void ConstantPoolCacheEntry::set_indy_resolution_failed() {
 120   OrderAccess::release_store(&_flags, _flags | (1 << indy_resolution_failed_shift));
 121 }
 122 
 123 // Note that concurrent update of both bytecodes can leave one of them
 124 // reset to zero.  This is harmless; the interpreter will simply re-resolve
 125 // the damaged entry.  More seriously, the memory synchronization is needed
 126 // to flush other fields (f1, f2) completely to memory before the bytecodes
 127 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
 128 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
 129                                        Bytecodes::Code put_code,
 130                                        Klass* field_holder,
 131                                        int field_index,
 132                                        int field_offset,
 133                                        TosState field_type,
 134                                        bool is_final,
 135                                        bool is_volatile,
 136                                        Klass* root_klass) {
 137   set_f1(field_holder);
 138   set_f2(field_offset);
 139   assert((field_index & field_index_mask) == field_index,
 140          "field index does not fit in low flag bits");




  80                                        int field_index_or_method_params) {
  81   assert(state < number_of_states, "Invalid state in make_flags");
  82   int f = ((int)state << tos_state_shift) | option_bits | field_index_or_method_params;
  83   // Preserve existing flag bit values
  84   // The low bits are a field offset, or else the method parameter size.
  85 #ifdef ASSERT
  86   TosState old_state = flag_state();
  87   assert(old_state == (TosState)0 || old_state == state,
  88          "inconsistent cpCache flags state");
  89 #endif
  90   return (_flags | f) ;
  91 }
  92 
  93 void ConstantPoolCacheEntry::set_bytecode_1(Bytecodes::Code code) {
  94 #ifdef ASSERT
  95   // Read once.
  96   volatile Bytecodes::Code c = bytecode_1();
  97   assert(c == 0 || c == code || code == 0, "update must be consistent");
  98 #endif
  99   // Need to flush pending stores here before bytecode is written.
 100   Atomic::release_store(&_indices, _indices | ((u_char)code << bytecode_1_shift));
 101 }
 102 
 103 void ConstantPoolCacheEntry::set_bytecode_2(Bytecodes::Code code) {
 104 #ifdef ASSERT
 105   // Read once.
 106   volatile Bytecodes::Code c = bytecode_2();
 107   assert(c == 0 || c == code || code == 0, "update must be consistent");
 108 #endif
 109   // Need to flush pending stores here before bytecode is written.
 110   Atomic::release_store(&_indices, _indices | ((u_char)code << bytecode_2_shift));
 111 }
 112 
 113 // Sets f1, ordering with previous writes.
 114 void ConstantPoolCacheEntry::release_set_f1(Metadata* f1) {
 115   assert(f1 != NULL, "");
 116   Atomic::release_store(&_f1, f1);
 117 }
 118 
 119 void ConstantPoolCacheEntry::set_indy_resolution_failed() {
 120   Atomic::release_store(&_flags, _flags | (1 << indy_resolution_failed_shift));
 121 }
 122 
 123 // Note that concurrent update of both bytecodes can leave one of them
 124 // reset to zero.  This is harmless; the interpreter will simply re-resolve
 125 // the damaged entry.  More seriously, the memory synchronization is needed
 126 // to flush other fields (f1, f2) completely to memory before the bytecodes
 127 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
 128 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
 129                                        Bytecodes::Code put_code,
 130                                        Klass* field_holder,
 131                                        int field_index,
 132                                        int field_offset,
 133                                        TosState field_type,
 134                                        bool is_final,
 135                                        bool is_volatile,
 136                                        Klass* root_klass) {
 137   set_f1(field_holder);
 138   set_f2(field_offset);
 139   assert((field_index & field_index_mask) == field_index,
 140          "field index does not fit in low flag bits");


< prev index next >