< prev index next >

src/share/vm/c1/c1_GraphBuilder.cpp

Print this page




1561     case Bytecodes::_getstatic: {
1562       // check for compile-time constants, i.e., initialized static final fields
1563       Instruction* constant = NULL;
1564       if (field->is_constant() && !PatchALot) {
1565         ciConstant field_val = field->constant_value();
1566         BasicType field_type = field_val.basic_type();
1567         switch (field_type) {
1568         case T_ARRAY:
1569         case T_OBJECT:
1570           if (field_val.as_object()->should_be_constant()) {
1571             constant = new Constant(as_ValueType(field_val));
1572           }
1573           break;
1574 
1575         default:
1576           constant = new Constant(as_ValueType(field_val));
1577         }
1578         // Stable static fields are checked for non-default values in ciField::initialize_from().
1579       }
1580       if (constant != NULL) {




1581         push(type, append(constant));
1582       } else {
1583         if (state_before == NULL) {
1584           state_before = copy_state_for_exception();
1585         }
1586         push(type, append(new LoadField(append(obj), offset, field, true,
1587                                         state_before, needs_patching)));
1588       }
1589       break;
1590     }
1591     case Bytecodes::_putstatic:
1592       { Value val = pop(type);
1593         if (state_before == NULL) {
1594           state_before = copy_state_for_exception();
1595         }
1596         append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
1597       }
1598       break;
1599     case Bytecodes::_getfield: {
1600       // Check for compile-time constants, i.e., trusted final non-static fields.


1604       if (obj_type->is_constant() && !PatchALot) {
1605         ciObject* const_oop = obj_type->constant_value();
1606         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
1607           if (field->is_constant()) {
1608             ciConstant field_val = field->constant_value_of(const_oop);
1609             BasicType field_type = field_val.basic_type();
1610             switch (field_type) {
1611             case T_ARRAY:
1612             case T_OBJECT:
1613               if (field_val.as_object()->should_be_constant()) {
1614                 constant = new Constant(as_ValueType(field_val));
1615               }
1616               break;
1617             default:
1618               constant = new Constant(as_ValueType(field_val));
1619             }
1620             if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) {
1621               // Stable field with default value can't be constant.
1622               constant = NULL;
1623             }



1624           } else {
1625             // For CallSite objects treat the target field as a compile time constant.
1626             if (const_oop->is_call_site()) {
1627               ciCallSite* call_site = const_oop->as_call_site();
1628               if (field->is_call_site_target()) {
1629                 ciMethodHandle* target = call_site->get_target();
1630                 if (target != NULL) {  // just in case
1631                   ciConstant field_val(T_OBJECT, target);
1632                   constant = new Constant(as_ValueType(field_val));
1633                   // Add a dependence for invalidation of the optimization.
1634                   if (!call_site->is_constant_call_site()) {
1635                     dependency_recorder()->assert_call_site_target_value(call_site, target);
1636                   }
1637                 }
1638               }
1639             }
1640           }
1641         }
1642       }
1643       if (constant != NULL) {




1561     case Bytecodes::_getstatic: {
1562       // check for compile-time constants, i.e., initialized static final fields
1563       Instruction* constant = NULL;
1564       if (field->is_constant() && !PatchALot) {
1565         ciConstant field_val = field->constant_value();
1566         BasicType field_type = field_val.basic_type();
1567         switch (field_type) {
1568         case T_ARRAY:
1569         case T_OBJECT:
1570           if (field_val.as_object()->should_be_constant()) {
1571             constant = new Constant(as_ValueType(field_val));
1572           }
1573           break;
1574 
1575         default:
1576           constant = new Constant(as_ValueType(field_val));
1577         }
1578         // Stable static fields are checked for non-default values in ciField::initialize_from().
1579       }
1580       if (constant != NULL) {
1581         // Don't bother with static fields yet.
1582 //        if (!field->is_stable()) {
1583 //          dependency_recorder()->assert_constant_field_value_klass(field, field->holder());
1584 //        }
1585         push(type, append(constant));
1586       } else {
1587         if (state_before == NULL) {
1588           state_before = copy_state_for_exception();
1589         }
1590         push(type, append(new LoadField(append(obj), offset, field, true,
1591                                         state_before, needs_patching)));
1592       }
1593       break;
1594     }
1595     case Bytecodes::_putstatic:
1596       { Value val = pop(type);
1597         if (state_before == NULL) {
1598           state_before = copy_state_for_exception();
1599         }
1600         append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
1601       }
1602       break;
1603     case Bytecodes::_getfield: {
1604       // Check for compile-time constants, i.e., trusted final non-static fields.


1608       if (obj_type->is_constant() && !PatchALot) {
1609         ciObject* const_oop = obj_type->constant_value();
1610         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
1611           if (field->is_constant()) {
1612             ciConstant field_val = field->constant_value_of(const_oop);
1613             BasicType field_type = field_val.basic_type();
1614             switch (field_type) {
1615             case T_ARRAY:
1616             case T_OBJECT:
1617               if (field_val.as_object()->should_be_constant()) {
1618                 constant = new Constant(as_ValueType(field_val));
1619               }
1620               break;
1621             default:
1622               constant = new Constant(as_ValueType(field_val));
1623             }
1624             if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) {
1625               // Stable field with default value can't be constant.
1626               constant = NULL;
1627             }
1628             if (TrustFinalNonStaticFields && !field->is_stable()) {
1629               dependency_recorder()->assert_constant_field_value_instance(field, const_oop);
1630             }
1631           } else {
1632             // For CallSite objects treat the target field as a compile time constant.
1633             if (const_oop->is_call_site()) {
1634               ciCallSite* call_site = const_oop->as_call_site();
1635               if (field->is_call_site_target()) {
1636                 ciMethodHandle* target = call_site->get_target();
1637                 if (target != NULL) {  // just in case
1638                   ciConstant field_val(T_OBJECT, target);
1639                   constant = new Constant(as_ValueType(field_val));
1640                   // Add a dependence for invalidation of the optimization.
1641                   if (!call_site->is_constant_call_site()) {
1642                     dependency_recorder()->assert_call_site_target_value(call_site, target);
1643                   }
1644                 }
1645               }
1646             }
1647           }
1648         }
1649       }
1650       if (constant != NULL) {


< prev index next >