< prev index next >

src/share/vm/opto/memnode.cpp

Print this page




  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/objArrayKlass.hpp"
  31 #include "opto/addnode.hpp"
  32 #include "opto/arraycopynode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/compile.hpp"
  35 #include "opto/connode.hpp"
  36 #include "opto/convertnode.hpp"
  37 #include "opto/loopnode.hpp"
  38 #include "opto/machnode.hpp"
  39 #include "opto/matcher.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/mulnode.hpp"
  42 #include "opto/narrowptrnode.hpp"
  43 #include "opto/phaseX.hpp"
  44 #include "opto/regmask.hpp"

  45 #include "utilities/copy.hpp"
  46 
  47 // Portions of code courtesy of Clifford Click
  48 
  49 // Optimization - Graph Style
  50 
  51 static Node *step_through_mergemem(PhaseGVN *phase, MergeMemNode *mmem,  const TypePtr *tp, const TypePtr *adr_check, outputStream *st);
  52 
  53 //=============================================================================
  54 uint MemNode::size_of() const { return sizeof(*this); }
  55 
  56 const TypePtr *MemNode::adr_type() const {
  57   Node* adr = in(Address);
  58   if (adr == NULL)  return NULL; // node is dead
  59   const TypePtr* cross_check = NULL;
  60   DEBUG_ONLY(cross_check = _adr_type);
  61   return calculate_adr_type(adr->bottom_type(), cross_check);
  62 }
  63 
  64 bool MemNode::check_if_adr_maybe_raw(Node* adr) {


1077   if( in(Memory)->is_Phi() && in(Memory)->in(0) == ctrl &&
1078       in(Address)->is_AddP() ) {
1079     const TypeOopPtr* t_oop = in(Address)->bottom_type()->isa_oopptr();
1080     // Only instances and boxed values.
1081     if( t_oop != NULL &&
1082         (t_oop->is_ptr_to_boxed_value() ||
1083          t_oop->is_known_instance_field()) &&
1084         t_oop->offset() != Type::OffsetBot &&
1085         t_oop->offset() != Type::OffsetTop) {
1086       return true;
1087     }
1088   }
1089   return false;
1090 }
1091 
1092 //------------------------------Identity---------------------------------------
1093 // Loads are identity if previous store is to same address
1094 Node* LoadNode::Identity(PhaseGVN* phase) {
1095   // If the previous store-maker is the right kind of Store, and the store is
1096   // to the same address, then we are equal to the value stored.












1097   Node* mem = in(Memory);
1098   Node* value = can_see_stored_value(mem, phase);
1099   if( value ) {
1100     // byte, short & char stores truncate naturally.
1101     // A load has to load the truncated value which requires
1102     // some sort of masking operation and that requires an
1103     // Ideal call instead of an Identity call.
1104     if (memory_size() < BytesPerInt) {
1105       // If the input to the store does not fit with the load's result type,
1106       // it must be truncated via an Ideal call.
1107       if (!phase->type(value)->higher_equal(phase->type(this)))
1108         return this;
1109     }
1110     // (This works even when value is a Con, but LoadNode::Value
1111     // usually runs first, producing the singleton type of the Con.)
1112     return value;
1113   }
1114 
1115   // Search for an existing data phi which was generated before for the same
1116   // instance's field to avoid infinite generation of phis in a loop.




  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/objArrayKlass.hpp"
  31 #include "opto/addnode.hpp"
  32 #include "opto/arraycopynode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/compile.hpp"
  35 #include "opto/connode.hpp"
  36 #include "opto/convertnode.hpp"
  37 #include "opto/loopnode.hpp"
  38 #include "opto/machnode.hpp"
  39 #include "opto/matcher.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/mulnode.hpp"
  42 #include "opto/narrowptrnode.hpp"
  43 #include "opto/phaseX.hpp"
  44 #include "opto/regmask.hpp"
  45 #include "opto/valuetypenode.hpp"
  46 #include "utilities/copy.hpp"
  47 
  48 // Portions of code courtesy of Clifford Click
  49 
  50 // Optimization - Graph Style
  51 
  52 static Node *step_through_mergemem(PhaseGVN *phase, MergeMemNode *mmem,  const TypePtr *tp, const TypePtr *adr_check, outputStream *st);
  53 
  54 //=============================================================================
  55 uint MemNode::size_of() const { return sizeof(*this); }
  56 
  57 const TypePtr *MemNode::adr_type() const {
  58   Node* adr = in(Address);
  59   if (adr == NULL)  return NULL; // node is dead
  60   const TypePtr* cross_check = NULL;
  61   DEBUG_ONLY(cross_check = _adr_type);
  62   return calculate_adr_type(adr->bottom_type(), cross_check);
  63 }
  64 
  65 bool MemNode::check_if_adr_maybe_raw(Node* adr) {


1078   if( in(Memory)->is_Phi() && in(Memory)->in(0) == ctrl &&
1079       in(Address)->is_AddP() ) {
1080     const TypeOopPtr* t_oop = in(Address)->bottom_type()->isa_oopptr();
1081     // Only instances and boxed values.
1082     if( t_oop != NULL &&
1083         (t_oop->is_ptr_to_boxed_value() ||
1084          t_oop->is_known_instance_field()) &&
1085         t_oop->offset() != Type::OffsetBot &&
1086         t_oop->offset() != Type::OffsetTop) {
1087       return true;
1088     }
1089   }
1090   return false;
1091 }
1092 
1093 //------------------------------Identity---------------------------------------
1094 // Loads are identity if previous store is to same address
1095 Node* LoadNode::Identity(PhaseGVN* phase) {
1096   // If the previous store-maker is the right kind of Store, and the store is
1097   // to the same address, then we are equal to the value stored.
1098   Node* addr = in(Address);
1099   intptr_t offset;
1100   Node* base = AddPNode::Ideal_base_and_offset(addr, phase, offset);
1101   if (base != NULL && base->Opcode() == Op_ValueTypePtr) {
1102     Node* value = base->as_ValueTypeBase()->field_value_by_offset((int)offset, true);
1103     if (bottom_type()->isa_narrowoop()) {
1104       assert(!phase->type(value)->isa_narrowoop(), "should already be decoded");
1105       value = phase->transform(new EncodePNode(value, bottom_type()));
1106     }
1107     return value;
1108   }
1109 
1110   Node* mem = in(Memory);
1111   Node* value = can_see_stored_value(mem, phase);
1112   if( value ) {
1113     // byte, short & char stores truncate naturally.
1114     // A load has to load the truncated value which requires
1115     // some sort of masking operation and that requires an
1116     // Ideal call instead of an Identity call.
1117     if (memory_size() < BytesPerInt) {
1118       // If the input to the store does not fit with the load's result type,
1119       // it must be truncated via an Ideal call.
1120       if (!phase->type(value)->higher_equal(phase->type(this)))
1121         return this;
1122     }
1123     // (This works even when value is a Con, but LoadNode::Value
1124     // usually runs first, producing the singleton type of the Con.)
1125     return value;
1126   }
1127 
1128   // Search for an existing data phi which was generated before for the same
1129   // instance's field to avoid infinite generation of phis in a loop.


< prev index next >