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