src/share/vm/opto/memnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7081933 Sdiff src/share/vm/opto

src/share/vm/opto/memnode.cpp

Print this page




2830 // produced by it are optimizable if they match the control edge and
2831 // new oop address associated with the allocation/initialization.
2832 // They return a stored value (if the offset matches) or else zero.
2833 // A write to the memory state, if it matches control and address,
2834 // and if it is to a constant offset, may be 'captured' by the
2835 // InitializeNode.  It is cloned as a raw memory operation and rewired
2836 // inside the initialization, to the raw oop produced by the allocation.
2837 // Operations on addresses which are provably distinct (e.g., to
2838 // other AllocateNodes) are allowed to bypass the initialization.
2839 //
2840 // The effect of all this is to consolidate object initialization
2841 // (both arrays and non-arrays, both piecewise and bulk) into a
2842 // single location, where it can be optimized as a unit.
2843 //
2844 // Only stores with an offset less than TrackedInitializationLimit words
2845 // will be considered for capture by an InitializeNode.  This puts a
2846 // reasonable limit on the complexity of optimized initializations.
2847 
2848 //---------------------------InitializeNode------------------------------------
2849 InitializeNode::InitializeNode(Compile* C, int adr_type, Node* rawoop)
2850   : _is_complete(false),
2851     MemBarNode(C, adr_type, rawoop)
2852 {
2853   init_class_id(Class_Initialize);
2854 
2855   assert(adr_type == Compile::AliasIdxRaw, "only valid atp");
2856   assert(in(RawAddress) == rawoop, "proper init");
2857   // Note:  allocation() can be NULL, for secondary initialization barriers
2858 }
2859 
2860 // Since this node is not matched, it will be processed by the
2861 // register allocator.  Declare that there are no constraints
2862 // on the allocation of the RawAddress edge.
2863 const RegMask &InitializeNode::in_RegMask(uint idx) const {
2864   // This edge should be set to top, by the set_complete.  But be conservative.
2865   if (idx == InitializeNode::RawAddress)
2866     return *(Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()]);
2867   return RegMask::Empty;
2868 }
2869 
2870 Node* InitializeNode::memory(uint alias_idx) {
2871   Node* mem = in(Memory);
2872   if (mem->is_MergeMem()) {
2873     return mem->as_MergeMem()->memory_at(alias_idx);
2874   } else {
2875     // incoming raw memory is not split
2876     return mem;
2877   }
2878 }
2879 
2880 bool InitializeNode::is_non_zero() {
2881   if (is_complete())  return false;
2882   remove_extra_zeroes();
2883   return (req() > RawStores);
2884 }
2885 
2886 void InitializeNode::set_complete(PhaseGVN* phase) {
2887   assert(!is_complete(), "caller responsibility");
2888   _is_complete = true;
2889 
2890   // After this node is complete, it contains a bunch of
2891   // raw-memory initializations.  There is no need for
2892   // it to have anything to do with non-raw memory effects.
2893   // Therefore, tell all non-raw users to re-optimize themselves,
2894   // after skipping the memory effects of this initialization.
2895   PhaseIterGVN* igvn = phase->is_IterGVN();
2896   if (igvn)  igvn->add_users_to_worklist(this);
2897 }
2898 
2899 // convenience function
2900 // return false if the init contains any stores already
2901 bool AllocateNode::maybe_set_complete(PhaseGVN* phase) {
2902   InitializeNode* init = initialization();
2903   if (init == NULL || init->is_complete())  return false;
2904   init->remove_extra_zeroes();
2905   // for now, if this allocation has already collected any inits, bail:
2906   if (init->is_non_zero())  return false;
2907   init->set_complete(phase);
2908   return true;




2830 // produced by it are optimizable if they match the control edge and
2831 // new oop address associated with the allocation/initialization.
2832 // They return a stored value (if the offset matches) or else zero.
2833 // A write to the memory state, if it matches control and address,
2834 // and if it is to a constant offset, may be 'captured' by the
2835 // InitializeNode.  It is cloned as a raw memory operation and rewired
2836 // inside the initialization, to the raw oop produced by the allocation.
2837 // Operations on addresses which are provably distinct (e.g., to
2838 // other AllocateNodes) are allowed to bypass the initialization.
2839 //
2840 // The effect of all this is to consolidate object initialization
2841 // (both arrays and non-arrays, both piecewise and bulk) into a
2842 // single location, where it can be optimized as a unit.
2843 //
2844 // Only stores with an offset less than TrackedInitializationLimit words
2845 // will be considered for capture by an InitializeNode.  This puts a
2846 // reasonable limit on the complexity of optimized initializations.
2847 
2848 //---------------------------InitializeNode------------------------------------
2849 InitializeNode::InitializeNode(Compile* C, int adr_type, Node* rawoop)
2850   : _is_complete(Incomplete),
2851     MemBarNode(C, adr_type, rawoop)
2852 {
2853   init_class_id(Class_Initialize);
2854 
2855   assert(adr_type == Compile::AliasIdxRaw, "only valid atp");
2856   assert(in(RawAddress) == rawoop, "proper init");
2857   // Note:  allocation() can be NULL, for secondary initialization barriers
2858 }
2859 
2860 // Since this node is not matched, it will be processed by the
2861 // register allocator.  Declare that there are no constraints
2862 // on the allocation of the RawAddress edge.
2863 const RegMask &InitializeNode::in_RegMask(uint idx) const {
2864   // This edge should be set to top, by the set_complete.  But be conservative.
2865   if (idx == InitializeNode::RawAddress)
2866     return *(Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()]);
2867   return RegMask::Empty;
2868 }
2869 
2870 Node* InitializeNode::memory(uint alias_idx) {
2871   Node* mem = in(Memory);
2872   if (mem->is_MergeMem()) {
2873     return mem->as_MergeMem()->memory_at(alias_idx);
2874   } else {
2875     // incoming raw memory is not split
2876     return mem;
2877   }
2878 }
2879 
2880 bool InitializeNode::is_non_zero() {
2881   if (is_complete())  return false;
2882   remove_extra_zeroes();
2883   return (req() > RawStores);
2884 }
2885 
2886 void InitializeNode::set_complete(PhaseGVN* phase) {
2887   assert(!is_complete(), "caller responsibility");
2888   _is_complete = Complete;
2889 
2890   // After this node is complete, it contains a bunch of
2891   // raw-memory initializations.  There is no need for
2892   // it to have anything to do with non-raw memory effects.
2893   // Therefore, tell all non-raw users to re-optimize themselves,
2894   // after skipping the memory effects of this initialization.
2895   PhaseIterGVN* igvn = phase->is_IterGVN();
2896   if (igvn)  igvn->add_users_to_worklist(this);
2897 }
2898 
2899 // convenience function
2900 // return false if the init contains any stores already
2901 bool AllocateNode::maybe_set_complete(PhaseGVN* phase) {
2902   InitializeNode* init = initialization();
2903   if (init == NULL || init->is_complete())  return false;
2904   init->remove_extra_zeroes();
2905   // for now, if this allocation has already collected any inits, bail:
2906   if (init->is_non_zero())  return false;
2907   init->set_complete(phase);
2908   return true;


src/share/vm/opto/memnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File