< prev index next >

src/share/vm/opto/parse3.cpp

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "interpreter/linkResolver.hpp"
  28 #include "memory/universe.inline.hpp"
  29 #include "oops/objArrayKlass.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/memnode.hpp"
  32 #include "opto/parse.hpp"
  33 #include "opto/rootnode.hpp"
  34 #include "opto/runtime.hpp"
  35 #include "opto/subnode.hpp"
  36 #include "runtime/deoptimization.hpp"
  37 #include "runtime/handles.inline.hpp"
  38 




  39 //=============================================================================
  40 // Helper methods for _get* and _put* bytecodes
  41 //=============================================================================
  42 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
  43   // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
  44   // Better to check now than to Deoptimize as soon as we execute
  45   assert( field->is_static(), "Only check if field is static");
  46   // is_being_initialized() is too generous.  It allows access to statics
  47   // by threads that are not running the <clinit> before the <clinit> finishes.
  48   // return field->holder()->is_being_initialized();
  49 
  50   // The following restriction is correct but conservative.
  51   // It is also desirable to allow compilation of methods called from <clinit>
  52   // but this generated code will need to be made safe for execution by
  53   // other threads, or the transition from interpreted to compiled code would
  54   // need to be guarded.
  55   ciInstanceKlass *field_holder = field->holder();
  56 
  57   bool access_OK = false;
  58   if (method->holder()->is_subclass_of(field_holder)) {


 219       // This can happen if the constant oop is non-perm.
 220       ciObject* con = field->constant_value().as_object();
 221       // Do not "join" in the previous type; it doesn't add value,
 222       // and may yield a vacuous result if the field is of interface type.
 223       type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 224       assert(type != NULL, "field singleton type must be consistent");
 225     } else {
 226       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
 227     }
 228   } else {
 229     type = Type::get_const_basic_type(bt);
 230   }
 231   if (support_IRIW_for_not_multiple_copy_atomic_cpu && field->is_volatile()) {
 232     leading_membar = insert_mem_bar(Op_MemBarVolatile);   // StoreLoad barrier
 233   }
 234   // Build the load.
 235   //
 236   MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered;
 237   Node* ld = make_load(NULL, adr, type, bt, adr_type, mo, LoadNode::DependsOnlyOnTest, is_vol);
 238 







 239   // Adjust Java stack
 240   if (type2size[bt] == 1)
 241     push(ld);
 242   else
 243     push_pair(ld);
 244 
 245   if (must_assert_null) {
 246     // Do not take a trap here.  It's possible that the program
 247     // will never load the field's class, and will happily see
 248     // null values in this field forever.  Don't stumble into a
 249     // trap for such a program, or we might get a long series
 250     // of useless recompilations.  (Or, we might load a class
 251     // which should not be loaded.)  If we ever see a non-null
 252     // value, we will then trap and recompile.  (The trap will
 253     // not need to mention the class index, since the class will
 254     // already have been loaded if we ever see a non-null value.)
 255     // uncommon_trap(iter().get_field_signature_index());
 256 #ifndef PRODUCT
 257     if (PrintOpto && (Verbose || WizardMode)) {
 258       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
 259     }
 260 #endif
 261     if (C->log() != NULL) {
 262       C->log()->elem("assert_null reason='field' klass='%d'",
 263                      C->log()->identify(field->type()));
 264     }
 265     // If there is going to be a trap, put it at the next bytecode:
 266     set_bci(iter().next_bci());
 267     null_assert(peek());
 268     set_bci(iter().cur_bci()); // put it back
 269   }
 270 
 271   // If reference is volatile, prevent following memory ops from
 272   // floating up past the volatile read.  Also prevents commoning
 273   // another volatile read.
 274   if (field->is_volatile()) {
 275     // Memory barrier includes bogus read of value to force load BEFORE membar
 276     assert(leading_membar == NULL || support_IRIW_for_not_multiple_copy_atomic_cpu, "no leading membar expected");
 277     Node* mb = insert_mem_bar(Op_MemBarAcquire, ld);
 278     mb->as_MemBar()->set_trailing_load();
 279   }
 280 }
 281 
 282 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 283   Node* leading_membar = NULL;
 284   bool is_vol = field->is_volatile();
 285   // If reference is volatile, prevent following memory ops from
 286   // floating down past the volatile write.  Also prevents commoning
 287   // another volatile read.
 288   if (is_vol) {
 289     leading_membar = insert_mem_bar(Op_MemBarRelease);
 290   }
 291 
 292   // Compute address and memory type.
 293   int offset = field->offset_in_bytes();
 294   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 295   Node* adr = basic_plus_adr(obj, obj, offset);
 296   BasicType bt = field->layout_type();
 297   // Value to be stored




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "interpreter/linkResolver.hpp"
  28 #include "memory/universe.inline.hpp"
  29 #include "oops/objArrayKlass.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/memnode.hpp"
  32 #include "opto/parse.hpp"
  33 #include "opto/rootnode.hpp"
  34 #include "opto/runtime.hpp"
  35 #include "opto/subnode.hpp"
  36 #include "runtime/deoptimization.hpp"
  37 #include "runtime/handles.inline.hpp"
  38 
  39 #if INCLUDE_ALL_GCS
  40 #include "gc_implementation/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  41 #endif
  42 
  43 //=============================================================================
  44 // Helper methods for _get* and _put* bytecodes
  45 //=============================================================================
  46 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
  47   // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
  48   // Better to check now than to Deoptimize as soon as we execute
  49   assert( field->is_static(), "Only check if field is static");
  50   // is_being_initialized() is too generous.  It allows access to statics
  51   // by threads that are not running the <clinit> before the <clinit> finishes.
  52   // return field->holder()->is_being_initialized();
  53 
  54   // The following restriction is correct but conservative.
  55   // It is also desirable to allow compilation of methods called from <clinit>
  56   // but this generated code will need to be made safe for execution by
  57   // other threads, or the transition from interpreted to compiled code would
  58   // need to be guarded.
  59   ciInstanceKlass *field_holder = field->holder();
  60 
  61   bool access_OK = false;
  62   if (method->holder()->is_subclass_of(field_holder)) {


 223       // This can happen if the constant oop is non-perm.
 224       ciObject* con = field->constant_value().as_object();
 225       // Do not "join" in the previous type; it doesn't add value,
 226       // and may yield a vacuous result if the field is of interface type.
 227       type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 228       assert(type != NULL, "field singleton type must be consistent");
 229     } else {
 230       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
 231     }
 232   } else {
 233     type = Type::get_const_basic_type(bt);
 234   }
 235   if (support_IRIW_for_not_multiple_copy_atomic_cpu && field->is_volatile()) {
 236     leading_membar = insert_mem_bar(Op_MemBarVolatile);   // StoreLoad barrier
 237   }
 238   // Build the load.
 239   //
 240   MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered;
 241   Node* ld = make_load(NULL, adr, type, bt, adr_type, mo, LoadNode::DependsOnlyOnTest, is_vol);
 242 
 243   Node* load = ld;
 244 #if INCLUDE_ALL_GCS
 245   if (UseShenandoahGC && (bt == T_OBJECT || bt == T_ARRAY)) {
 246     ld = ShenandoahBarrierSetC2::bsc2()->load_reference_barrier(this, ld);
 247   }
 248 #endif
 249 
 250   // Adjust Java stack
 251   if (type2size[bt] == 1)
 252     push(ld);
 253   else
 254     push_pair(ld);
 255 
 256   if (must_assert_null) {
 257     // Do not take a trap here.  It's possible that the program
 258     // will never load the field's class, and will happily see
 259     // null values in this field forever.  Don't stumble into a
 260     // trap for such a program, or we might get a long series
 261     // of useless recompilations.  (Or, we might load a class
 262     // which should not be loaded.)  If we ever see a non-null
 263     // value, we will then trap and recompile.  (The trap will
 264     // not need to mention the class index, since the class will
 265     // already have been loaded if we ever see a non-null value.)
 266     // uncommon_trap(iter().get_field_signature_index());
 267 #ifndef PRODUCT
 268     if (PrintOpto && (Verbose || WizardMode)) {
 269       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
 270     }
 271 #endif
 272     if (C->log() != NULL) {
 273       C->log()->elem("assert_null reason='field' klass='%d'",
 274                      C->log()->identify(field->type()));
 275     }
 276     // If there is going to be a trap, put it at the next bytecode:
 277     set_bci(iter().next_bci());
 278     null_assert(peek());
 279     set_bci(iter().cur_bci()); // put it back
 280   }
 281 
 282   // If reference is volatile, prevent following memory ops from
 283   // floating up past the volatile read.  Also prevents commoning
 284   // another volatile read.
 285   if (field->is_volatile()) {
 286     // Memory barrier includes bogus read of value to force load BEFORE membar
 287     assert(leading_membar == NULL || support_IRIW_for_not_multiple_copy_atomic_cpu, "no leading membar expected");
 288     Node* mb = insert_mem_bar(Op_MemBarAcquire, load);
 289     mb->as_MemBar()->set_trailing_load();
 290   }
 291 }
 292 
 293 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 294   Node* leading_membar = NULL;
 295   bool is_vol = field->is_volatile();
 296   // If reference is volatile, prevent following memory ops from
 297   // floating down past the volatile write.  Also prevents commoning
 298   // another volatile read.
 299   if (is_vol) {
 300     leading_membar = insert_mem_bar(Op_MemBarRelease);
 301   }
 302 
 303   // Compute address and memory type.
 304   int offset = field->offset_in_bytes();
 305   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 306   Node* adr = basic_plus_adr(obj, obj, offset);
 307   BasicType bt = field->layout_type();
 308   // Value to be stored


< prev index next >