< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page
rev 55090 : secret-sfac


  41 
  42 //=============================================================================
  43 // Helper methods for _get* and _put* bytecodes
  44 //=============================================================================
  45 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
  46   // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
  47   // Better to check now than to Deoptimize as soon as we execute
  48   assert( field->is_static(), "Only check if field is static");
  49   // is_being_initialized() is too generous.  It allows access to statics
  50   // by threads that are not running the <clinit> before the <clinit> finishes.
  51   // return field->holder()->is_being_initialized();
  52 
  53   // The following restriction is correct but conservative.
  54   // It is also desirable to allow compilation of methods called from <clinit>
  55   // but this generated code will need to be made safe for execution by
  56   // other threads, or the transition from interpreted to compiled code would
  57   // need to be guarded.
  58   ciInstanceKlass *field_holder = field->holder();
  59 
  60   if (method->holder()->is_subclass_of(field_holder)) {
  61     if (method->is_static_initializer()) {
  62       // OK to access static fields inside initializer
  63       return true;
  64     } else if (method->is_object_initializer()) {
  65       // It's also OK to access static fields inside a constructor,
  66       // because any thread calling the constructor must first have
  67       // synchronized on the class by executing a '_new' bytecode.
  68       return true;
  69     }
  70   }
  71   if (C->is_compiling_clinit_for(field_holder)) {
  72     return true; // access in the context of static initializer
  73   }
  74   return false;
  75 }
  76 
  77 
  78 void Parse::do_field_access(bool is_get, bool is_field) {
  79   bool will_link;
  80   ciField* field = iter().get_field(will_link);
  81   assert(will_link, "getfield: typeflow responsibility");
  82 
  83   ciInstanceKlass* field_holder = field->holder();
  84 




  41 
  42 //=============================================================================
  43 // Helper methods for _get* and _put* bytecodes
  44 //=============================================================================
  45 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
  46   // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
  47   // Better to check now than to Deoptimize as soon as we execute
  48   assert( field->is_static(), "Only check if field is static");
  49   // is_being_initialized() is too generous.  It allows access to statics
  50   // by threads that are not running the <clinit> before the <clinit> finishes.
  51   // return field->holder()->is_being_initialized();
  52 
  53   // The following restriction is correct but conservative.
  54   // It is also desirable to allow compilation of methods called from <clinit>
  55   // but this generated code will need to be made safe for execution by
  56   // other threads, or the transition from interpreted to compiled code would
  57   // need to be guarded.
  58   ciInstanceKlass *field_holder = field->holder();
  59 
  60   if (method->holder()->is_subclass_of(field_holder)) {
  61     if (method->is_class_initializer()) {
  62       // OK to access static fields inside initializer
  63       return true;
  64     } else if (method->is_object_constructor()) {
  65       // It's also OK to access static fields inside a constructor,
  66       // because any thread calling the constructor must first have
  67       // synchronized on the class by executing a '_new' bytecode.
  68       return true;
  69     }
  70   }
  71   if (C->is_compiling_clinit_for(field_holder)) {
  72     return true; // access in the context of static initializer
  73   }
  74   return false;
  75 }
  76 
  77 
  78 void Parse::do_field_access(bool is_get, bool is_field) {
  79   bool will_link;
  80   ciField* field = iter().get_field(will_link);
  81   assert(will_link, "getfield: typeflow responsibility");
  82 
  83   ciInstanceKlass* field_holder = field->holder();
  84 


< prev index next >