src/share/vm/c1/c1_GraphBuilder.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8073191-work Sdiff src/share/vm/c1

src/share/vm/c1/c1_GraphBuilder.cpp

Print this page




1637       // check for compile-time constants, i.e., initialized static final fields
1638       Value constant = NULL;
1639       if (field->is_static_constant() && !PatchALot) {
1640         ciConstant field_value = field->constant_value();
1641         assert(!field->is_stable() || !field_value.is_null_or_zero(),
1642                "stable static w/ default value shouldn't be a constant");
1643         constant = make_constant(field_value, field);
1644       }
1645       if (constant != NULL) {
1646         push(type, append(constant));
1647       } else {
1648         if (state_before == NULL) {
1649           state_before = copy_state_for_exception();
1650         }
1651         push(type, append(new LoadField(append(obj), offset, field, true,
1652                                         state_before, needs_patching)));
1653       }
1654       break;
1655     }
1656     case Bytecodes::_putstatic: {








1657       Value val = pop(type);
1658       if (state_before == NULL) {
1659         state_before = copy_state_for_exception();
1660       }
1661       if (field->type()->basic_type() == T_BOOLEAN) {
1662         Value mask = append(new Constant(new IntConstant(1)));
1663         val = append(new LogicOp(Bytecodes::_iand, val, mask));
1664       }
1665       append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
1666       break;
1667     }
1668     case Bytecodes::_getfield: {
1669       // Check for compile-time constants, i.e., trusted final non-static fields.
1670       Value constant = NULL;
1671       obj = apop();
1672       ObjectType* obj_type = obj->type()->as_ObjectType();
1673       if (field->is_constant() && obj_type->is_constant() && !PatchALot) {
1674         ciObject* const_oop = obj_type->constant_value();
1675         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
1676           ciConstant field_value = field->constant_value_of(const_oop);


1688         }
1689       }
1690       if (constant != NULL) {
1691         push(type, append(constant));
1692       } else {
1693         if (state_before == NULL) {
1694           state_before = copy_state_for_exception();
1695         }
1696         LoadField* load = new LoadField(obj, offset, field, false, state_before, needs_patching);
1697         Value replacement = !needs_patching ? _memory->load(load) : load;
1698         if (replacement != load) {
1699           assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked");
1700           push(type, replacement);
1701         } else {
1702           push(type, append(load));
1703         }
1704       }
1705       break;
1706     }
1707     case Bytecodes::_putfield: {








1708       Value val = pop(type);
1709       obj = apop();
1710       if (state_before == NULL) {
1711         state_before = copy_state_for_exception();
1712       }
1713       if (field->type()->basic_type() == T_BOOLEAN) {
1714         Value mask = append(new Constant(new IntConstant(1)));
1715         val = append(new LogicOp(Bytecodes::_iand, val, mask));
1716       }
1717       StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching);
1718       if (!needs_patching) store = _memory->store(store);
1719       if (store != NULL) {
1720         append(store);
1721       }
1722       break;
1723     }
1724     default:
1725       ShouldNotReachHere();
1726       break;
1727   }




1637       // check for compile-time constants, i.e., initialized static final fields
1638       Value constant = NULL;
1639       if (field->is_static_constant() && !PatchALot) {
1640         ciConstant field_value = field->constant_value();
1641         assert(!field->is_stable() || !field_value.is_null_or_zero(),
1642                "stable static w/ default value shouldn't be a constant");
1643         constant = make_constant(field_value, field);
1644       }
1645       if (constant != NULL) {
1646         push(type, append(constant));
1647       } else {
1648         if (state_before == NULL) {
1649           state_before = copy_state_for_exception();
1650         }
1651         push(type, append(new LoadField(append(obj), offset, field, true,
1652                                         state_before, needs_patching)));
1653       }
1654       break;
1655     }
1656     case Bytecodes::_putstatic: {
1657       // Check if modification of a static final field is attempted outside of
1658       // the class/interface initializer method.
1659       if (field->is_constant() &&
1660           strcmp(method()->name()->as_quoted_ascii(), "<clinit>") != 0) {
1661         bailout("The current method sets a static final field but "
1662                 "it is not the class or interface initializer method <clinit>.");
1663         return;
1664       }
1665       Value val = pop(type);
1666       if (state_before == NULL) {
1667         state_before = copy_state_for_exception();
1668       }
1669       if (field->type()->basic_type() == T_BOOLEAN) {
1670         Value mask = append(new Constant(new IntConstant(1)));
1671         val = append(new LogicOp(Bytecodes::_iand, val, mask));
1672       }
1673       append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
1674       break;
1675     }
1676     case Bytecodes::_getfield: {
1677       // Check for compile-time constants, i.e., trusted final non-static fields.
1678       Value constant = NULL;
1679       obj = apop();
1680       ObjectType* obj_type = obj->type()->as_ObjectType();
1681       if (field->is_constant() && obj_type->is_constant() && !PatchALot) {
1682         ciObject* const_oop = obj_type->constant_value();
1683         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
1684           ciConstant field_value = field->constant_value_of(const_oop);


1696         }
1697       }
1698       if (constant != NULL) {
1699         push(type, append(constant));
1700       } else {
1701         if (state_before == NULL) {
1702           state_before = copy_state_for_exception();
1703         }
1704         LoadField* load = new LoadField(obj, offset, field, false, state_before, needs_patching);
1705         Value replacement = !needs_patching ? _memory->load(load) : load;
1706         if (replacement != load) {
1707           assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked");
1708           push(type, replacement);
1709         } else {
1710           push(type, append(load));
1711         }
1712       }
1713       break;
1714     }
1715     case Bytecodes::_putfield: {
1716       // Check if modification of a static final field is attempted outside of
1717       // the instance initializer method.
1718       if (field->is_final() &&
1719           strcmp(method()->name()->as_quoted_ascii(), "<init>") != 0) {
1720         bailout("The current method sets a final field but "
1721                 "it is not the instance initializer method <init>.");
1722         return;
1723       }
1724       Value val = pop(type);
1725       obj = apop();
1726       if (state_before == NULL) {
1727         state_before = copy_state_for_exception();
1728       }
1729       if (field->type()->basic_type() == T_BOOLEAN) {
1730         Value mask = append(new Constant(new IntConstant(1)));
1731         val = append(new LogicOp(Bytecodes::_iand, val, mask));
1732       }
1733       StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching);
1734       if (!needs_patching) store = _memory->store(store);
1735       if (store != NULL) {
1736         append(store);
1737       }
1738       break;
1739     }
1740     default:
1741       ShouldNotReachHere();
1742       break;
1743   }


src/share/vm/c1/c1_GraphBuilder.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File