< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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.hpp"
  29 #include "oops/objArrayKlass.hpp"

  30 #include "opto/addnode.hpp"
  31 #include "opto/castnode.hpp"
  32 #include "opto/memnode.hpp"
  33 #include "opto/parse.hpp"
  34 #include "opto/rootnode.hpp"
  35 #include "opto/runtime.hpp"
  36 #include "opto/subnode.hpp"

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


  63       // It's also OK to access static fields inside a constructor,
  64       // because any thread calling the constructor must first have
  65       // synchronized on the class by executing a '_new' bytecode.
  66       return true;
  67     }
  68   }
  69   if (C->is_compiling_clinit_for(field_holder)) {
  70     return true; // access in the context of static initializer
  71   }
  72   return false;
  73 }
  74 
  75 
  76 void Parse::do_field_access(bool is_get, bool is_field) {
  77   bool will_link;
  78   ciField* field = iter().get_field(will_link);
  79   assert(will_link, "getfield: typeflow responsibility");
  80 
  81   ciInstanceKlass* field_holder = field->holder();
  82 








  83   if (is_field == field->is_static()) {
  84     // Interpreter will throw java_lang_IncompatibleClassChangeError
  85     // Check this before allowing <clinit> methods to access static fields
  86     uncommon_trap(Deoptimization::Reason_unhandled,
  87                   Deoptimization::Action_none);
  88     return;
  89   }
  90 
  91   if (!is_field && !field_holder->is_initialized()) {
  92     if (!static_field_ok_in_clinit(field, method())) {
  93       uncommon_trap(Deoptimization::Reason_uninitialized,
  94                     Deoptimization::Action_reinterpret,
  95                     NULL, "!static_field_ok_in_clinit");
  96       return;
  97     }
  98   }
  99 
 100   // Deoptimize on putfield writes to call site target field.
 101   if (!is_get && field->is_call_site_target()) {
 102     uncommon_trap(Deoptimization::Reason_unhandled,


 110   // Note:  We do not check for an unloaded field type here any more.
 111 
 112   // Generate code for the object pointer.
 113   Node* obj;
 114   if (is_field) {
 115     int obj_depth = is_get ? 0 : field->type()->size();
 116     obj = null_check(peek(obj_depth));
 117     // Compile-time detect of null-exception?
 118     if (stopped())  return;
 119 
 120 #ifdef ASSERT
 121     const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
 122     assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
 123 #endif
 124 
 125     if (is_get) {
 126       (void) pop();  // pop receiver before getting
 127       do_get_xxx(obj, field, is_field);
 128     } else {
 129       do_put_xxx(obj, field, is_field);



 130       (void) pop();  // pop receiver after putting
 131     }
 132   } else {
 133     const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
 134     obj = _gvn.makecon(tip);
 135     if (is_get) {
 136       do_get_xxx(obj, field, is_field);
 137     } else {
 138       do_put_xxx(obj, field, is_field);
 139     }
 140   }
 141 }
 142 
 143 
 144 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
 145   BasicType bt = field->layout_type();
 146 
 147   // Does this field have a constant value?  If so, just push the value.
 148   if (field->is_constant() &&
 149       // Keep consistent with types found by ciTypeFlow: for an
 150       // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
 151       // speculates the field is null. The code in the rest of this
 152       // method does the same. We must not bypass it and use a non
 153       // null constant here.
 154       (bt != T_OBJECT || field->type()->is_loaded())) {
 155     // final or stable field
 156     Node* con = make_constant_from_field(field, obj);
 157     if (con != NULL) {
 158       push_node(field->layout_type(), con);
 159       return;
 160     }
 161   }
 162 
 163   ciType* field_klass = field->type();
 164   bool is_vol = field->is_volatile();


 165 
 166   // Compute address and memory type.
 167   int offset = field->offset_in_bytes();
 168   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 169   Node *adr = basic_plus_adr(obj, obj, offset);
 170 
 171   // Build the resultant type of the load
 172   const Type *type;
 173 
 174   bool must_assert_null = false;
 175 
 176   DecoratorSet decorators = IN_HEAP;
 177   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 178 
 179   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 180 
 181   if (is_obj) {
 182     if (!field->type()->is_loaded()) {
 183       type = TypeInstPtr::BOTTOM;
 184       must_assert_null = true;
 185     } else if (field->is_static_constant()) {
 186       // This can happen if the constant oop is non-perm.
 187       ciObject* con = field->constant_value().as_object();
 188       // Do not "join" in the previous type; it doesn't add value,
 189       // and may yield a vacuous result if the field is of interface type.
 190       if (con->is_null_object()) {
 191         type = TypePtr::NULL_PTR;
 192       } else {
 193         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 194       }
 195       assert(type != NULL, "field singleton type must be consistent");
 196     } else {
 197       type = TypeOopPtr::make_from_klass(field_klass->as_klass());









 198     }
 199   } else {
 200     type = Type::get_const_basic_type(bt);
 201   }
 202 
 203   Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
















 204 
 205   // Adjust Java stack
 206   if (type2size[bt] == 1)
 207     push(ld);
 208   else
 209     push_pair(ld);
 210 
 211   if (must_assert_null) {
 212     // Do not take a trap here.  It's possible that the program
 213     // will never load the field's class, and will happily see
 214     // null values in this field forever.  Don't stumble into a
 215     // trap for such a program, or we might get a long series
 216     // of useless recompilations.  (Or, we might load a class
 217     // which should not be loaded.)  If we ever see a non-null
 218     // value, we will then trap and recompile.  (The trap will
 219     // not need to mention the class index, since the class will
 220     // already have been loaded if we ever see a non-null value.)
 221     // uncommon_trap(iter().get_field_signature_index());
 222     if (PrintOpto && (Verbose || WizardMode)) {
 223       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());


 230     set_bci(iter().next_bci());
 231     null_assert(peek());
 232     set_bci(iter().cur_bci()); // put it back
 233   }
 234 }
 235 
 236 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 237   bool is_vol = field->is_volatile();
 238 
 239   // Compute address and memory type.
 240   int offset = field->offset_in_bytes();
 241   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 242   Node* adr = basic_plus_adr(obj, obj, offset);
 243   BasicType bt = field->layout_type();
 244   // Value to be stored
 245   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
 246 
 247   DecoratorSet decorators = IN_HEAP;
 248   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 249 
 250   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 251 
 252   // Store the value.
 253   const Type* field_type;
 254   if (!field->type()->is_loaded()) {
 255     field_type = TypeInstPtr::BOTTOM;
 256   } else {
 257     if (is_obj) {
 258       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
 259     } else {
 260       field_type = Type::BOTTOM;
 261     }
 262   }
















 263   access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);

 264 
 265   if (is_field) {
 266     // Remember we wrote a volatile field.
 267     // For not multiple copy atomic cpu (ppc64) a barrier should be issued
 268     // in constructors which have such stores. See do_exits() in parse1.cpp.
 269     if (is_vol) {
 270       set_wrote_volatile(true);
 271     }
 272     set_wrote_fields(true);
 273 
 274     // If the field is final, the rules of Java say we are in <init> or <clinit>.
 275     // Note the presence of writes to final non-static fields, so that we
 276     // can insert a memory barrier later on to keep the writes from floating
 277     // out of the constructor.
 278     // Any method can write a @Stable field; insert memory barriers after those also.
 279     if (field->is_final()) {
 280       set_wrote_final(true);
 281       if (AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 282         // Preserve allocation ptr to create precedent edge to it in membar
 283         // generated on exit from constructor.
 284         // Can't bind stable with its allocation, only record allocation for final field.
 285         set_alloc_with_final(obj);
 286       }
 287     }
 288     if (field->is_stable()) {
 289       set_wrote_stable(true);
 290     }
 291   }
 292 }
 293 
 294 //=============================================================================
 295 void Parse::do_anewarray() {

 296   bool will_link;
 297   ciKlass* klass = iter().get_klass(will_link);
 298 
 299   // Uncommon Trap when class that array contains is not loaded
 300   // we need the loaded class for the rest of graph; do not
 301   // initialize the container class (see Java spec)!!!
 302   assert(will_link, "anewarray: typeflow responsibility");
 303 
 304   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 305   // Check that array_klass object is loaded
 306   if (!array_klass->is_loaded()) {
 307     // Generate uncommon_trap for unloaded array_class
 308     uncommon_trap(Deoptimization::Reason_unloaded,
 309                   Deoptimization::Action_reinterpret,
 310                   array_klass);







 311     return;
 312   }
 313 
 314   kill_dead_locals();
 315 
 316   const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
 317   Node* count_val = pop();
 318   Node* obj = new_array(makecon(array_klass_type), count_val, 1);
 319   push(obj);
 320 }
 321 
 322 
 323 void Parse::do_newarray(BasicType elem_type) {
 324   kill_dead_locals();
 325 
 326   Node*   count_val = pop();
 327   const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
 328   Node*   obj = new_array(makecon(array_klass), count_val, 1);
 329   // Push resultant oop onto stack
 330   push(obj);




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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.hpp"
  29 #include "oops/objArrayKlass.hpp"
  30 #include "oops/valueArrayKlass.hpp"
  31 #include "opto/addnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/memnode.hpp"
  34 #include "opto/parse.hpp"
  35 #include "opto/rootnode.hpp"
  36 #include "opto/runtime.hpp"
  37 #include "opto/subnode.hpp"
  38 #include "opto/valuetypenode.hpp"
  39 #include "runtime/deoptimization.hpp"
  40 #include "runtime/handles.inline.hpp"
  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();


  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 
  85   if (is_field && field_holder->is_valuetype() && peek()->is_ValueType()) {
  86     assert(is_get, "value type field store not supported");
  87     ValueTypeNode* vt = pop()->as_ValueType();
  88     Node* value = vt->field_value_by_offset(field->offset());
  89     push_node(field->layout_type(), value);
  90     return;
  91   }
  92 
  93   if (is_field == field->is_static()) {
  94     // Interpreter will throw java_lang_IncompatibleClassChangeError
  95     // Check this before allowing <clinit> methods to access static fields
  96     uncommon_trap(Deoptimization::Reason_unhandled,
  97                   Deoptimization::Action_none);
  98     return;
  99   }
 100 
 101   if (!is_field && !field_holder->is_initialized()) {
 102     if (!static_field_ok_in_clinit(field, method())) {
 103       uncommon_trap(Deoptimization::Reason_uninitialized,
 104                     Deoptimization::Action_reinterpret,
 105                     NULL, "!static_field_ok_in_clinit");
 106       return;
 107     }
 108   }
 109 
 110   // Deoptimize on putfield writes to call site target field.
 111   if (!is_get && field->is_call_site_target()) {
 112     uncommon_trap(Deoptimization::Reason_unhandled,


 120   // Note:  We do not check for an unloaded field type here any more.
 121 
 122   // Generate code for the object pointer.
 123   Node* obj;
 124   if (is_field) {
 125     int obj_depth = is_get ? 0 : field->type()->size();
 126     obj = null_check(peek(obj_depth));
 127     // Compile-time detect of null-exception?
 128     if (stopped())  return;
 129 
 130 #ifdef ASSERT
 131     const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
 132     assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
 133 #endif
 134 
 135     if (is_get) {
 136       (void) pop();  // pop receiver before getting
 137       do_get_xxx(obj, field, is_field);
 138     } else {
 139       do_put_xxx(obj, field, is_field);
 140       if (stopped()) {
 141         return;
 142       }
 143       (void) pop();  // pop receiver after putting
 144     }
 145   } else {
 146     const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
 147     obj = _gvn.makecon(tip);
 148     if (is_get) {
 149       do_get_xxx(obj, field, is_field);
 150     } else {
 151       do_put_xxx(obj, field, is_field);
 152     }
 153   }
 154 }
 155 

 156 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
 157   BasicType bt = field->layout_type();
 158 
 159   // Does this field have a constant value?  If so, just push the value.
 160   if (field->is_constant() &&
 161       // Keep consistent with types found by ciTypeFlow: for an
 162       // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
 163       // speculates the field is null. The code in the rest of this
 164       // method does the same. We must not bypass it and use a non
 165       // null constant here.
 166       (bt != T_OBJECT || field->type()->is_loaded())) {
 167     // final or stable field
 168     Node* con = make_constant_from_field(field, obj);
 169     if (con != NULL) {
 170       push_node(field->layout_type(), con);
 171       return;
 172     }
 173   }
 174 
 175   ciType* field_klass = field->type();
 176   bool is_vol = field->is_volatile();
 177   bool flattened = field->is_flattened();
 178   bool flattenable = field->is_flattenable();
 179 
 180   // Compute address and memory type.
 181   int offset = field->offset_in_bytes();
 182   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 183   Node *adr = basic_plus_adr(obj, obj, offset);
 184 
 185   // Build the resultant type of the load
 186   const Type *type;
 187 
 188   bool must_assert_null = false;
 189 
 190   if (bt == T_OBJECT || bt == T_ARRAY || bt == T_VALUETYPE) {





 191     if (!field->type()->is_loaded()) {
 192       type = TypeInstPtr::BOTTOM;
 193       must_assert_null = true;
 194     } else if (field->is_static_constant()) {
 195       // This can happen if the constant oop is non-perm.
 196       ciObject* con = field->constant_value().as_object();
 197       // Do not "join" in the previous type; it doesn't add value,
 198       // and may yield a vacuous result if the field is of interface type.
 199       if (con->is_null_object()) {
 200         type = TypePtr::NULL_PTR;
 201       } else {
 202         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 203       }
 204       assert(type != NULL, "field singleton type must be consistent");
 205     } else {
 206       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
 207       if (bt == T_VALUETYPE && field->is_static()) {
 208         // Check if static value type field is already initialized
 209         assert(!flattened, "static fields should not be flattened");
 210         ciInstance* mirror = field->holder()->java_mirror();
 211         ciObject* val = mirror->field_value(field).as_object();
 212         if (!val->is_null_object()) {
 213           type = type->join_speculative(TypePtr::NOTNULL);
 214         }
 215       }
 216     }
 217   } else {
 218     type = Type::get_const_basic_type(bt);
 219   }
 220 
 221   Node* ld = NULL;
 222   if (flattened) {
 223     // Load flattened value type
 224     ld = ValueTypeNode::make_from_flattened(this, field_klass->as_value_klass(), obj, obj, field->holder(), offset);
 225   } else {
 226     DecoratorSet decorators = IN_HEAP;
 227     decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 228     ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
 229     if (flattenable) {
 230       // Load a non-flattened but flattenable value type from memory
 231       if (field_klass->as_value_klass()->is_scalarizable()) {
 232         ld = ValueTypeNode::make_from_oop(this, ld, field_klass->as_value_klass());
 233       } else {
 234         ld = null2default(ld, field_klass->as_value_klass());
 235       }
 236     }
 237   }
 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     if (PrintOpto && (Verbose || WizardMode)) {
 257       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());


 264     set_bci(iter().next_bci());
 265     null_assert(peek());
 266     set_bci(iter().cur_bci()); // put it back
 267   }
 268 }
 269 
 270 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 271   bool is_vol = field->is_volatile();
 272 
 273   // Compute address and memory type.
 274   int offset = field->offset_in_bytes();
 275   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 276   Node* adr = basic_plus_adr(obj, obj, offset);
 277   BasicType bt = field->layout_type();
 278   // Value to be stored
 279   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
 280 
 281   DecoratorSet decorators = IN_HEAP;
 282   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 283 


 284   // Store the value.
 285   const Type* field_type;
 286   if (!field->type()->is_loaded()) {
 287     field_type = TypeInstPtr::BOTTOM;
 288   } else {
 289     if (bt == T_OBJECT || bt == T_ARRAY || bt == T_VALUETYPE) {
 290       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
 291     } else {
 292       field_type = Type::BOTTOM;
 293     }
 294   }
 295 
 296   if (field->is_flattenable() && !val->is_ValueType()) {
 297     inc_sp(1);
 298     val = null_check(val);
 299     dec_sp(1);
 300     if (stopped()) return;
 301   }
 302 
 303   if (field->is_flattened()) {
 304     // Store flattened value type to a non-static field
 305     if (!val->is_ValueType()) {
 306       assert(!gvn().type(val)->maybe_null(), "should never be null");
 307       val = ValueTypeNode::make_from_oop(this, val, field->type()->as_value_klass());
 308     }
 309     val->as_ValueType()->store_flattened(this, obj, obj, field->holder(), offset);
 310   } else {
 311     access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);
 312   }
 313 
 314   if (is_field) {
 315     // Remember we wrote a volatile field.
 316     // For not multiple copy atomic cpu (ppc64) a barrier should be issued
 317     // in constructors which have such stores. See do_exits() in parse1.cpp.
 318     if (is_vol) {
 319       set_wrote_volatile(true);
 320     }
 321     set_wrote_fields(true);
 322 
 323     // If the field is final, the rules of Java say we are in <init> or <clinit>.
 324     // Note the presence of writes to final non-static fields, so that we
 325     // can insert a memory barrier later on to keep the writes from floating
 326     // out of the constructor.
 327     // Any method can write a @Stable field; insert memory barriers after those also.
 328     if (field->is_final()) {
 329       set_wrote_final(true);
 330       if (AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 331         // Preserve allocation ptr to create precedent edge to it in membar
 332         // generated on exit from constructor.
 333         // Can't bind stable with its allocation, only record allocation for final field.
 334         set_alloc_with_final(obj);
 335       }
 336     }
 337     if (field->is_stable()) {
 338       set_wrote_stable(true);
 339     }
 340   }
 341 }
 342 
 343 //=============================================================================
 344 
 345 void Parse::do_newarray() {
 346   bool will_link;
 347   ciKlass* klass = iter().get_klass(will_link);
 348 
 349   // Uncommon Trap when class that array contains is not loaded
 350   // we need the loaded class for the rest of graph; do not
 351   // initialize the container class (see Java spec)!!!
 352   assert(will_link, "newarray: typeflow responsibility");
 353 
 354   ciArrayKlass* array_klass = ciArrayKlass::make(klass);
 355   // Check that array_klass object is loaded
 356   if (!array_klass->is_loaded()) {
 357     // Generate uncommon_trap for unloaded array_class
 358     uncommon_trap(Deoptimization::Reason_unloaded,
 359                   Deoptimization::Action_reinterpret,
 360                   array_klass);
 361     return;
 362   } else if (array_klass->element_klass() != NULL &&
 363              array_klass->element_klass()->is_valuetype() &&
 364              !array_klass->element_klass()->as_value_klass()->is_initialized()) {
 365     uncommon_trap(Deoptimization::Reason_uninitialized,
 366                   Deoptimization::Action_reinterpret,
 367                   NULL);
 368     return;
 369   }
 370 
 371   kill_dead_locals();
 372 
 373   const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
 374   Node* count_val = pop();
 375   Node* obj = new_array(makecon(array_klass_type), count_val, 1);
 376   push(obj);
 377 }
 378 
 379 
 380 void Parse::do_newarray(BasicType elem_type) {
 381   kill_dead_locals();
 382 
 383   Node*   count_val = pop();
 384   const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
 385   Node*   obj = new_array(makecon(array_klass), count_val, 1);
 386   // Push resultant oop onto stack
 387   push(obj);


< prev index next >