< prev index next >

src/share/vm/opto/parse1.cpp

Print this page




1818     if (pnum == 1) {            // Last merge for this Region?
1819       if (!block()->flow()->is_irreducible_entry()) {
1820         Node* result = _gvn.transform_no_reclaim(r);
1821         if (r != result && TraceOptoParse) {
1822           tty->print_cr("Block #%d replace %d with %d", block()->rpo(), r->_idx, result->_idx);
1823         }
1824       }
1825       record_for_igvn(r);
1826     }
1827 
1828     // Update all the non-control inputs to map:
1829     assert(TypeFunc::Parms == newin->jvms()->locoff(), "parser map should contain only youngest jvms");
1830     bool check_elide_phi = target->is_SEL_backedge(save_block);
1831     bool last_merge = (pnum == PhiNode::Input);
1832     for (uint j = 1; j < newin->req(); j++) {
1833       Node* m = map()->in(j);   // Current state of target.
1834       Node* n = newin->in(j);   // Incoming change to target state.
1835       PhiNode* phi;
1836       if (m->is_Phi() && m->as_Phi()->region() == r) {
1837         phi = m->as_Phi();
1838       } else if (m->is_ValueType() && m->as_ValueType()->has_phi_inputs(r)){
1839         phi = m->as_ValueType()->get_oop()->as_Phi();
1840       } else {
1841         phi = NULL;
1842       }
1843       if (m != n) {             // Different; must merge
1844         switch (j) {
1845         // Frame pointer and Return Address never changes
1846         case TypeFunc::FramePtr:// Drop m, use the original value
1847         case TypeFunc::ReturnAdr:
1848           break;
1849         case TypeFunc::Memory:  // Merge inputs to the MergeMem node
1850           assert(phi == NULL, "the merge contains phis, not vice versa");
1851           merge_memory_edges(n->as_MergeMem(), pnum, nophi);
1852           continue;
1853         default:                // All normal stuff
1854           if (phi == NULL) {
1855             const JVMState* jvms = map()->jvms();
1856             if (EliminateNestedLocks &&
1857                 jvms->is_mon(j) && jvms->is_monitor_box(j)) {
1858               // BoxLock nodes are not commoning.
1859               // Use old BoxLock node as merged box.
1860               assert(newin->jvms()->is_monitor_box(j), "sanity");
1861               // This assert also tests that nodes are BoxLock.
1862               assert(BoxLockNode::same_slot(n, m), "sanity");
1863               C->gvn_replace_by(n, m);
1864             } else if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
1865               phi = ensure_phi(j, nophi);
1866             }
1867           }
1868           break;
1869         }
1870       }
1871       // At this point, n might be top if:
1872       //  - there is no phi (because TypeFlow detected a conflict), or
1873       //  - the corresponding control edges is top (a dead incoming path)
1874       // It is a bug if we create a phi which sees a garbage value on a live path.
1875 
1876       // Merging two value types?
1877       assert(phi == NULL || (m->is_ValueType() == n->is_ValueType()),
1878           "value types should only be merged with other value types");
1879       if (phi != NULL && n->isa_ValueType()) {
1880         // Reload current state because it may have been updated by ensure_phi
1881         m = map()->in(j);
1882         ValueTypeNode* vtm = m->as_ValueType(); // Current value type
1883         ValueTypeNode* vtn = n->as_ValueType(); // Incoming value type
1884         assert(vtm->get_oop() == phi, "Value type should have Phi input");
1885         if (TraceOptoParse) {
1886 #ifdef ASSERT
1887           tty->print_cr("\nMerging value types");
1888           tty->print_cr("Current:");
1889           vtm->dump(2);
1890           tty->print_cr("Incoming:");
1891           vtn->dump(2);
1892           tty->cr();
1893 #endif
1894         }
1895         // Do the merge
1896         vtm->merge_with(&_gvn, vtn, pnum, last_merge);
1897         if (last_merge) {
1898           map()->set_req(j, _gvn.transform_no_reclaim(vtm));
1899           record_for_igvn(vtm);
1900         }
1901       } else if (phi != NULL) {
1902         assert(n != top() || r->in(pnum) == top(), "live value must not be garbage");
1903         assert(phi->region() == r, "");


2108     t = o->bottom_type();  // Type::RETURN_ADDRESS or such-like.
2109   } else {
2110     assert(false, "no type information for this phi");
2111   }
2112 
2113   // If the type falls to bottom, then this must be a local that
2114   // is already dead or is mixing ints and oops or some such.
2115   // Forcing it to top makes it go dead.
2116   if (t == Type::BOTTOM) {
2117     map->set_req(idx, top());
2118     return NULL;
2119   }
2120 
2121   // Do not create phis for top either.
2122   // A top on a non-null control flow must be an unused even after the.phi.
2123   if (t == Type::TOP || t == Type::HALF) {
2124     map->set_req(idx, top());
2125     return NULL;
2126   }
2127 
2128   ValueTypeNode* vt = o->isa_ValueType();
2129   if (vt != NULL) {
2130     // Value types are merged by merging their field values.
2131     // Create a cloned ValueTypeNode with phi inputs that
2132     // represents the merged value type and update the map.
2133     vt = vt->clone_with_phis(&_gvn, region);
2134     map->set_req(idx, vt);
2135     return vt->get_oop()->as_Phi();
2136   } else {
2137     PhiNode* phi = PhiNode::make(region, o, t);
2138     gvn().set_type(phi, t);
2139     if (C->do_escape_analysis()) record_for_igvn(phi);
2140     map->set_req(idx, phi);
2141     return phi;
2142   }
2143 }
2144 
2145 //--------------------------ensure_memory_phi----------------------------------
2146 // Turn the idx'th slice of the current memory into a Phi
2147 PhiNode *Parse::ensure_memory_phi(int idx, bool nocreate) {
2148   MergeMemNode* mem = merged_memory();




1818     if (pnum == 1) {            // Last merge for this Region?
1819       if (!block()->flow()->is_irreducible_entry()) {
1820         Node* result = _gvn.transform_no_reclaim(r);
1821         if (r != result && TraceOptoParse) {
1822           tty->print_cr("Block #%d replace %d with %d", block()->rpo(), r->_idx, result->_idx);
1823         }
1824       }
1825       record_for_igvn(r);
1826     }
1827 
1828     // Update all the non-control inputs to map:
1829     assert(TypeFunc::Parms == newin->jvms()->locoff(), "parser map should contain only youngest jvms");
1830     bool check_elide_phi = target->is_SEL_backedge(save_block);
1831     bool last_merge = (pnum == PhiNode::Input);
1832     for (uint j = 1; j < newin->req(); j++) {
1833       Node* m = map()->in(j);   // Current state of target.
1834       Node* n = newin->in(j);   // Incoming change to target state.
1835       PhiNode* phi;
1836       if (m->is_Phi() && m->as_Phi()->region() == r) {
1837         phi = m->as_Phi();
1838       } else if (m->is_ValueTypeBase() && m->as_ValueTypeBase()->has_phi_inputs(r)){
1839         phi = m->as_ValueTypeBase()->get_oop()->as_Phi();
1840       } else {
1841         phi = NULL;
1842       }
1843       if (m != n) {             // Different; must merge
1844         switch (j) {
1845         // Frame pointer and Return Address never changes
1846         case TypeFunc::FramePtr:// Drop m, use the original value
1847         case TypeFunc::ReturnAdr:
1848           break;
1849         case TypeFunc::Memory:  // Merge inputs to the MergeMem node
1850           assert(phi == NULL, "the merge contains phis, not vice versa");
1851           merge_memory_edges(n->as_MergeMem(), pnum, nophi);
1852           continue;
1853         default:                // All normal stuff
1854           if (phi == NULL) {
1855             const JVMState* jvms = map()->jvms();
1856             if (EliminateNestedLocks &&
1857                 jvms->is_mon(j) && jvms->is_monitor_box(j)) {
1858               // BoxLock nodes are not commoning.
1859               // Use old BoxLock node as merged box.
1860               assert(newin->jvms()->is_monitor_box(j), "sanity");
1861               // This assert also tests that nodes are BoxLock.
1862               assert(BoxLockNode::same_slot(n, m), "sanity");
1863               C->gvn_replace_by(n, m);
1864             } else if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
1865               phi = ensure_phi(j, nophi);
1866             }
1867           }
1868           break;
1869         }
1870       }
1871       // At this point, n might be top if:
1872       //  - there is no phi (because TypeFlow detected a conflict), or
1873       //  - the corresponding control edges is top (a dead incoming path)
1874       // It is a bug if we create a phi which sees a garbage value on a live path.
1875 
1876       // Merging two value types?
1877       assert(phi == NULL || (m->is_ValueTypeBase() == n->is_ValueTypeBase()),
1878           "value types should only be merged with other value types");
1879       if (phi != NULL && n->isa_ValueTypeBase()) {
1880         // Reload current state because it may have been updated by ensure_phi
1881         m = map()->in(j);
1882         ValueTypeBaseNode* vtm = m->as_ValueTypeBase(); // Current value type
1883         ValueTypeBaseNode* vtn = n->as_ValueTypeBase(); // Incoming value type
1884         assert(vtm->get_oop() == phi, "Value type should have Phi input");
1885         if (TraceOptoParse) {
1886 #ifdef ASSERT
1887           tty->print_cr("\nMerging value types");
1888           tty->print_cr("Current:");
1889           vtm->dump(2);
1890           tty->print_cr("Incoming:");
1891           vtn->dump(2);
1892           tty->cr();
1893 #endif
1894         }
1895         // Do the merge
1896         vtm->merge_with(&_gvn, vtn, pnum, last_merge);
1897         if (last_merge) {
1898           map()->set_req(j, _gvn.transform_no_reclaim(vtm));
1899           record_for_igvn(vtm);
1900         }
1901       } else if (phi != NULL) {
1902         assert(n != top() || r->in(pnum) == top(), "live value must not be garbage");
1903         assert(phi->region() == r, "");


2108     t = o->bottom_type();  // Type::RETURN_ADDRESS or such-like.
2109   } else {
2110     assert(false, "no type information for this phi");
2111   }
2112 
2113   // If the type falls to bottom, then this must be a local that
2114   // is already dead or is mixing ints and oops or some such.
2115   // Forcing it to top makes it go dead.
2116   if (t == Type::BOTTOM) {
2117     map->set_req(idx, top());
2118     return NULL;
2119   }
2120 
2121   // Do not create phis for top either.
2122   // A top on a non-null control flow must be an unused even after the.phi.
2123   if (t == Type::TOP || t == Type::HALF) {
2124     map->set_req(idx, top());
2125     return NULL;
2126   }
2127 
2128   ValueTypeBaseNode* vt = o->isa_ValueTypeBase();
2129   if (vt != NULL) {
2130     // Value types are merged by merging their field values.
2131     // Create a cloned ValueTypeNode with phi inputs that
2132     // represents the merged value type and update the map.
2133     vt = vt->clone_with_phis(&_gvn, region);
2134     map->set_req(idx, vt);
2135     return vt->get_oop()->as_Phi();
2136   } else {
2137     PhiNode* phi = PhiNode::make(region, o, t);
2138     gvn().set_type(phi, t);
2139     if (C->do_escape_analysis()) record_for_igvn(phi);
2140     map->set_req(idx, phi);
2141     return phi;
2142   }
2143 }
2144 
2145 //--------------------------ensure_memory_phi----------------------------------
2146 // Turn the idx'th slice of the current memory into a Phi
2147 PhiNode *Parse::ensure_memory_phi(int idx, bool nocreate) {
2148   MergeMemNode* mem = merged_memory();


< prev index next >