< prev index next >

src/hotspot/share/oops/cpCache.cpp

Print this page

118   assert(f1 != NULL, "");
119   Atomic::release_store(&_f1, f1);
120 }
121 
122 void ConstantPoolCacheEntry::set_indy_resolution_failed() {
123   Atomic::release_store(&_flags, _flags | (1 << indy_resolution_failed_shift));
124 }
125 
126 // Note that concurrent update of both bytecodes can leave one of them
127 // reset to zero.  This is harmless; the interpreter will simply re-resolve
128 // the damaged entry.  More seriously, the memory synchronization is needed
129 // to flush other fields (f1, f2) completely to memory before the bytecodes
130 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
131 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
132                                        Bytecodes::Code put_code,
133                                        Klass* field_holder,
134                                        int field_index,
135                                        int field_offset,
136                                        TosState field_type,
137                                        bool is_final,
138                                        bool is_volatile) {


139   set_f1(field_holder);
140   set_f2(field_offset);
141   assert((field_index & field_index_mask) == field_index,
142          "field index does not fit in low flag bits");

143   set_field_flags(field_type,
144                   ((is_volatile ? 1 : 0) << is_volatile_shift) |
145                   ((is_final    ? 1 : 0) << is_final_shift),


146                   field_index);
147   set_bytecode_1(get_code);
148   set_bytecode_2(put_code);
149   NOT_PRODUCT(verify(tty));
150 }
151 
152 void ConstantPoolCacheEntry::set_parameter_size(int value) {
153   // This routine is called only in corner cases where the CPCE is not yet initialized.
154   // See AbstractInterpreter::deopt_continue_after_entry.
155   assert(_flags == 0 || parameter_size() == 0 || parameter_size() == value,
156          "size must not change: parameter_size=%d, value=%d", parameter_size(), value);
157   // Setting the parameter size by itself is only safe if the
158   // current value of _flags is 0, otherwise another thread may have
159   // updated it and we don't want to overwrite that value.  Don't
160   // bother trying to update it once it's nonzero but always make
161   // sure that the final parameter size agrees with what was passed.
162   if (_flags == 0) {
163     intx newflags = (value & parameter_size_mask);
164     Atomic::cmpxchg(&_flags, (intx)0, newflags);
165   }

283     if (do_resolve) {
284       set_bytecode_1(invoke_code);
285     }
286   } else if (byte_no == 2)  {
287     if (change_to_virtual) {
288       assert(invoke_code == Bytecodes::_invokeinterface, "");
289       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
290       //
291       // Workaround for the case where we encounter an invokeinterface, but we
292       // should really have an _invokevirtual since the resolved method is a
293       // virtual method in java.lang.Object. This is a corner case in the spec
294       // but is presumably legal. javac does not generate this code.
295       //
296       // We do not set bytecode_1() to _invokeinterface, because that is the
297       // bytecode # used by the interpreter to see if it is resolved.  In this
298       // case, the method gets reresolved with caller for each interface call
299       // because the actual selected method may not be public.
300       //
301       // We set bytecode_2() to _invokevirtual.
302       // See also interpreterRuntime.cpp. (8/25/2000)

303     } else {
304       assert(invoke_code == Bytecodes::_invokevirtual ||
305              (invoke_code == Bytecodes::_invokeinterface &&
306               ((method->is_private() ||
307                 (method->is_final() && method->method_holder() == vmClasses::Object_klass())))),
308              "unexpected invocation mode");
309       if (invoke_code == Bytecodes::_invokeinterface &&
310           (method->is_private() || method->is_final())) {
311         // We set bytecode_1() to _invokeinterface, because that is the
312         // bytecode # used by the interpreter to see if it is resolved.
313         // We set bytecode_2() to _invokevirtual.
314         set_bytecode_1(invoke_code);
315       }
316     }
317     // set up for invokevirtual, even if linking for invokeinterface also:
318     set_bytecode_2(Bytecodes::_invokevirtual);
319   } else {
320     ShouldNotReachHere();
321   }
322   NOT_PRODUCT(verify(tty));
323 }
324 
325 void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, const methodHandle& method,
326                                              bool sender_is_interface) {
327   int index = Method::nonvirtual_vtable_index;
328   // index < 0; FIXME: inline and customize set_direct_or_vtable_call
329   set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
330 }
331 
332 void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, const methodHandle& method, int index) {
333   // either the method is a miranda or its holder should accept the given index
334   assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
335   // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
336   set_direct_or_vtable_call(invoke_code, method, index, false);
337 }
338 

118   assert(f1 != NULL, "");
119   Atomic::release_store(&_f1, f1);
120 }
121 
122 void ConstantPoolCacheEntry::set_indy_resolution_failed() {
123   Atomic::release_store(&_flags, _flags | (1 << indy_resolution_failed_shift));
124 }
125 
126 // Note that concurrent update of both bytecodes can leave one of them
127 // reset to zero.  This is harmless; the interpreter will simply re-resolve
128 // the damaged entry.  More seriously, the memory synchronization is needed
129 // to flush other fields (f1, f2) completely to memory before the bytecodes
130 // are updated, lest other processors see a non-zero bytecode but zero f1/f2.
131 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
132                                        Bytecodes::Code put_code,
133                                        Klass* field_holder,
134                                        int field_index,
135                                        int field_offset,
136                                        TosState field_type,
137                                        bool is_final,
138                                        bool is_volatile,
139                                        bool is_inlined,
140                                        bool is_null_free_inline_type) {
141   set_f1(field_holder);
142   set_f2(field_offset);
143   assert((field_index & field_index_mask) == field_index,
144          "field index does not fit in low flag bits");
145   assert(!is_inlined || is_null_free_inline_type, "Sanity check");
146   set_field_flags(field_type,
147                   ((is_volatile ? 1 : 0) << is_volatile_shift) |
148                   ((is_final    ? 1 : 0) << is_final_shift) |
149                   ((is_inlined  ? 1 : 0) << is_inlined_shift) |
150                   ((is_null_free_inline_type ? 1 : 0) << is_null_free_inline_type_shift),
151                   field_index);
152   set_bytecode_1(get_code);
153   set_bytecode_2(put_code);
154   NOT_PRODUCT(verify(tty));
155 }
156 
157 void ConstantPoolCacheEntry::set_parameter_size(int value) {
158   // This routine is called only in corner cases where the CPCE is not yet initialized.
159   // See AbstractInterpreter::deopt_continue_after_entry.
160   assert(_flags == 0 || parameter_size() == 0 || parameter_size() == value,
161          "size must not change: parameter_size=%d, value=%d", parameter_size(), value);
162   // Setting the parameter size by itself is only safe if the
163   // current value of _flags is 0, otherwise another thread may have
164   // updated it and we don't want to overwrite that value.  Don't
165   // bother trying to update it once it's nonzero but always make
166   // sure that the final parameter size agrees with what was passed.
167   if (_flags == 0) {
168     intx newflags = (value & parameter_size_mask);
169     Atomic::cmpxchg(&_flags, (intx)0, newflags);
170   }

288     if (do_resolve) {
289       set_bytecode_1(invoke_code);
290     }
291   } else if (byte_no == 2)  {
292     if (change_to_virtual) {
293       assert(invoke_code == Bytecodes::_invokeinterface, "");
294       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
295       //
296       // Workaround for the case where we encounter an invokeinterface, but we
297       // should really have an _invokevirtual since the resolved method is a
298       // virtual method in java.lang.Object. This is a corner case in the spec
299       // but is presumably legal. javac does not generate this code.
300       //
301       // We do not set bytecode_1() to _invokeinterface, because that is the
302       // bytecode # used by the interpreter to see if it is resolved.  In this
303       // case, the method gets reresolved with caller for each interface call
304       // because the actual selected method may not be public.
305       //
306       // We set bytecode_2() to _invokevirtual.
307       // See also interpreterRuntime.cpp. (8/25/2000)
308       invoke_code = Bytecodes::_invokevirtual;
309     } else {
310       assert(invoke_code == Bytecodes::_invokevirtual ||
311              (invoke_code == Bytecodes::_invokeinterface &&
312               ((method->is_private() ||
313                 (method->is_final() && method->method_holder() == vmClasses::Object_klass())))),
314              "unexpected invocation mode");
315       if (invoke_code == Bytecodes::_invokeinterface &&
316           (method->is_private() || method->is_final())) {
317         // We set bytecode_1() to _invokeinterface, because that is the
318         // bytecode # used by the interpreter to see if it is resolved.
319         // We set bytecode_2() to _invokevirtual.
320         set_bytecode_1(invoke_code);
321       }
322     }
323     // set up for invokevirtual, even if linking for invokeinterface also:
324     set_bytecode_2(invoke_code);
325   } else {
326     ShouldNotReachHere();
327   }
328   NOT_PRODUCT(verify(tty));
329 }
330 
331 void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, const methodHandle& method,
332                                              bool sender_is_interface) {
333   int index = Method::nonvirtual_vtable_index;
334   // index < 0; FIXME: inline and customize set_direct_or_vtable_call
335   set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
336 }
337 
338 void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, const methodHandle& method, int index) {
339   // either the method is a miranda or its holder should accept the given index
340   assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
341   // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
342   set_direct_or_vtable_call(invoke_code, method, index, false);
343 }
344 
< prev index next >