src/share/vm/c1/c1_GraphBuilder.cpp

changeset 2634
425688247f3d
parent 2600
6f3746e69a78
child 2658
c7f3d0b4570f
     1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Sat Mar 05 11:02:04 2011 -0800
     1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Sun Mar 06 22:09:23 2011 -0800
     1.3 @@ -1456,12 +1456,12 @@
     1.4    BasicType field_type = field->type()->basic_type();
     1.5    ValueType* type = as_ValueType(field_type);
     1.6    // call will_link again to determine if the field is valid.
     1.7 -  const bool is_loaded = holder->is_loaded() &&
     1.8 -                         field->will_link(method()->holder(), code);
     1.9 -  const bool is_initialized = is_loaded && holder->is_initialized();
    1.10 +  const bool needs_patching = !holder->is_loaded() ||
    1.11 +                              !field->will_link(method()->holder(), code) ||
    1.12 +                              PatchALot;
    1.13  
    1.14    ValueStack* state_before = NULL;
    1.15 -  if (!is_initialized || PatchALot) {
    1.16 +  if (!holder->is_initialized() || needs_patching) {
    1.17      // save state before instruction for debug info when
    1.18      // deoptimization happens during patching
    1.19      state_before = copy_state_before();
    1.20 @@ -1469,10 +1469,6 @@
    1.21  
    1.22    Value obj = NULL;
    1.23    if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) {
    1.24 -    // commoning of class constants should only occur if the class is
    1.25 -    // fully initialized and resolved in this constant pool.  The will_link test
    1.26 -    // above essentially checks if this class is resolved in this constant pool
    1.27 -    // so, the is_initialized flag should be suffiect.
    1.28      if (state_before != NULL) {
    1.29        // build a patching constant
    1.30        obj = new Constant(new ClassConstant(holder), state_before);
    1.31 @@ -1482,7 +1478,7 @@
    1.32    }
    1.33  
    1.34  
    1.35 -  const int offset = is_loaded ? field->offset() : -1;
    1.36 +  const int offset = !needs_patching ? field->offset() : -1;
    1.37    switch (code) {
    1.38      case Bytecodes::_getstatic: {
    1.39        // check for compile-time constants, i.e., initialized static final fields
    1.40 @@ -1509,7 +1505,7 @@
    1.41            state_before = copy_state_for_exception();
    1.42          }
    1.43          push(type, append(new LoadField(append(obj), offset, field, true,
    1.44 -                                        state_before, is_loaded, is_initialized)));
    1.45 +                                        state_before, needs_patching)));
    1.46        }
    1.47        break;
    1.48      }
    1.49 @@ -1518,7 +1514,7 @@
    1.50          if (state_before == NULL) {
    1.51            state_before = copy_state_for_exception();
    1.52          }
    1.53 -        append(new StoreField(append(obj), offset, field, val, true, state_before, is_loaded, is_initialized));
    1.54 +        append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
    1.55        }
    1.56        break;
    1.57      case Bytecodes::_getfield :
    1.58 @@ -1526,8 +1522,8 @@
    1.59          if (state_before == NULL) {
    1.60            state_before = copy_state_for_exception();
    1.61          }
    1.62 -        LoadField* load = new LoadField(apop(), offset, field, false, state_before, is_loaded, true);
    1.63 -        Value replacement = is_loaded ? _memory->load(load) : load;
    1.64 +        LoadField* load = new LoadField(apop(), offset, field, false, state_before, needs_patching);
    1.65 +        Value replacement = !needs_patching ? _memory->load(load) : load;
    1.66          if (replacement != load) {
    1.67            assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked");
    1.68            push(type, replacement);
    1.69 @@ -1542,8 +1538,8 @@
    1.70          if (state_before == NULL) {
    1.71            state_before = copy_state_for_exception();
    1.72          }
    1.73 -        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, is_loaded, true);
    1.74 -        if (is_loaded) store = _memory->store(store);
    1.75 +        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, needs_patching);
    1.76 +        if (!needs_patching) store = _memory->store(store);
    1.77          if (store != NULL) {
    1.78            append(store);
    1.79          }

mercurial