hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
changeset 8671 13ffa40a2f0a
parent 8492 e93bfdd91c63
child 8725 8c1e3dd5fe1b
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Sat Mar 05 11:02:04 2011 -0800
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Sun Mar 06 22:09:23 2011 -0800
@@ -1456,12 +1456,12 @@
   BasicType field_type = field->type()->basic_type();
   ValueType* type = as_ValueType(field_type);
   // call will_link again to determine if the field is valid.
-  const bool is_loaded = holder->is_loaded() &&
-                         field->will_link(method()->holder(), code);
-  const bool is_initialized = is_loaded && holder->is_initialized();
+  const bool needs_patching = !holder->is_loaded() ||
+                              !field->will_link(method()->holder(), code) ||
+                              PatchALot;
 
   ValueStack* state_before = NULL;
-  if (!is_initialized || PatchALot) {
+  if (!holder->is_initialized() || needs_patching) {
     // save state before instruction for debug info when
     // deoptimization happens during patching
     state_before = copy_state_before();
@@ -1469,10 +1469,6 @@
 
   Value obj = NULL;
   if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) {
-    // commoning of class constants should only occur if the class is
-    // fully initialized and resolved in this constant pool.  The will_link test
-    // above essentially checks if this class is resolved in this constant pool
-    // so, the is_initialized flag should be suffiect.
     if (state_before != NULL) {
       // build a patching constant
       obj = new Constant(new ClassConstant(holder), state_before);
@@ -1482,7 +1478,7 @@
   }
 
 
-  const int offset = is_loaded ? field->offset() : -1;
+  const int offset = !needs_patching ? field->offset() : -1;
   switch (code) {
     case Bytecodes::_getstatic: {
       // check for compile-time constants, i.e., initialized static final fields
@@ -1509,7 +1505,7 @@
           state_before = copy_state_for_exception();
         }
         push(type, append(new LoadField(append(obj), offset, field, true,
-                                        state_before, is_loaded, is_initialized)));
+                                        state_before, needs_patching)));
       }
       break;
     }
@@ -1518,7 +1514,7 @@
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        append(new StoreField(append(obj), offset, field, val, true, state_before, is_loaded, is_initialized));
+        append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
       }
       break;
     case Bytecodes::_getfield :
@@ -1526,8 +1522,8 @@
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        LoadField* load = new LoadField(apop(), offset, field, false, state_before, is_loaded, true);
-        Value replacement = is_loaded ? _memory->load(load) : load;
+        LoadField* load = new LoadField(apop(), offset, field, false, state_before, needs_patching);
+        Value replacement = !needs_patching ? _memory->load(load) : load;
         if (replacement != load) {
           assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked");
           push(type, replacement);
@@ -1542,8 +1538,8 @@
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, is_loaded, true);
-        if (is_loaded) store = _memory->store(store);
+        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, needs_patching);
+        if (!needs_patching) store = _memory->store(store);
         if (store != NULL) {
           append(store);
         }