960 if (nidx != midx) {
961 if (PrintOpto || (PrintMiscellaneous && (WizardMode || Verbose))) {
962 tty->print_cr("==== Matcher alias shift %d => %d", nidx, midx);
963 n->dump();
964 m->dump();
965 }
966 assert(C->subsume_loads() && C->must_alias(nat, midx),
967 "must not lose alias info when matching");
968 }
969 }
970 #endif
971
972 //------------------------------xform------------------------------------------
973 // Given a Node in old-space, Match him (Label/Reduce) to produce a machine
974 // Node in new-space. Given a new-space Node, recursively walk his children.
975 Node *Matcher::transform( Node *n ) { ShouldNotCallThis(); return n; }
976 Node *Matcher::xform( Node *n, int max_stack ) {
977 // Use one stack to keep both: child's node/state and parent's node/index
978 MStack mstack(max_stack * 2 * 2); // usually: C->live_nodes() * 2 * 2
979 mstack.push(n, Visit, NULL, -1); // set NULL as parent to indicate root
980
981 while (mstack.is_nonempty()) {
982 C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
983 if (C->failing()) return NULL;
984 n = mstack.node(); // Leave node on stack
985 Node_State nstate = mstack.state();
986 if (nstate == Visit) {
987 mstack.set_state(Post_Visit);
988 Node *oldn = n;
989 // Old-space or new-space check
990 if (!C->node_arena()->contains(n)) {
991 // Old space!
992 Node* m;
993 if (has_new_node(n)) { // Not yet Label/Reduced
994 m = new_node(n);
995 } else {
996 if (!is_dontcare(n)) { // Matcher can match this guy
997 // Calls match special. They match alone with no children.
998 // Their children, the incoming arguments, match normally.
999 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1000 if (C->failing()) return NULL;
2105 case Op_JumpProj:
2106 case Op_JProj:
2107 case Op_NeverBranch:
2108 set_dontcare(n);
2109 break;
2110 case Op_Jump:
2111 mstack.push(n->in(1), Pre_Visit); // Switch Value (could be shared)
2112 mstack.push(n->in(0), Pre_Visit); // Visit Control input
2113 continue; // while (mstack.is_nonempty())
2114 case Op_StrComp:
2115 case Op_StrEquals:
2116 case Op_StrIndexOf:
2117 case Op_StrIndexOfChar:
2118 case Op_AryEq:
2119 case Op_HasNegatives:
2120 case Op_StrInflatedCopy:
2121 case Op_StrCompressedCopy:
2122 case Op_EncodeISOArray:
2123 case Op_FmaD:
2124 case Op_FmaF:
2125 set_shared(n); // Force result into register (it will be anyways)
2126 break;
2127 case Op_ConP: { // Convert pointers above the centerline to NUL
2128 TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2129 const TypePtr* tp = tn->type()->is_ptr();
2130 if (tp->_ptr == TypePtr::AnyNull) {
2131 tn->set_type(TypePtr::NULL_PTR);
2132 }
2133 break;
2134 }
2135 case Op_ConN: { // Convert narrow pointers above the centerline to NUL
2136 TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2137 const TypePtr* tp = tn->type()->make_ptr();
2138 if (tp && tp->_ptr == TypePtr::AnyNull) {
2139 tn->set_type(TypeNarrowOop::NULL_PTR);
2140 }
2141 break;
2142 }
2143 case Op_Binary: // These are introduced in the Post_Visit state.
2144 ShouldNotReachHere();
2294 case Op_StrComp:
2295 case Op_StrIndexOf: {
2296 Node *pair1 = new BinaryNode(n->in(2),n->in(3));
2297 n->set_req(2,pair1);
2298 Node *pair2 = new BinaryNode(n->in(4),n->in(5));
2299 n->set_req(3,pair2);
2300 n->del_req(5);
2301 n->del_req(4);
2302 break;
2303 }
2304 case Op_StrCompressedCopy:
2305 case Op_StrInflatedCopy:
2306 case Op_EncodeISOArray: {
2307 // Restructure into a binary tree for Matching.
2308 Node* pair = new BinaryNode(n->in(3), n->in(4));
2309 n->set_req(3, pair);
2310 n->del_req(4);
2311 break;
2312 }
2313 case Op_FmaD:
2314 case Op_FmaF: {
2315 // Restructure into a binary tree for Matching.
2316 Node* pair = new BinaryNode(n->in(1), n->in(2));
2317 n->set_req(2, pair);
2318 n->set_req(1, n->in(3));
2319 n->del_req(3);
2320 break;
2321 }
2322 default:
2323 break;
2324 }
2325 }
2326 else {
2327 ShouldNotReachHere();
2328 }
2329 } // end of while (mstack.is_nonempty())
2330 }
2331
2332 #ifdef ASSERT
2333 // machine-independent root to machine-dependent root
2334 void Matcher::dump_old2new_map() {
|
960 if (nidx != midx) {
961 if (PrintOpto || (PrintMiscellaneous && (WizardMode || Verbose))) {
962 tty->print_cr("==== Matcher alias shift %d => %d", nidx, midx);
963 n->dump();
964 m->dump();
965 }
966 assert(C->subsume_loads() && C->must_alias(nat, midx),
967 "must not lose alias info when matching");
968 }
969 }
970 #endif
971
972 //------------------------------xform------------------------------------------
973 // Given a Node in old-space, Match him (Label/Reduce) to produce a machine
974 // Node in new-space. Given a new-space Node, recursively walk his children.
975 Node *Matcher::transform( Node *n ) { ShouldNotCallThis(); return n; }
976 Node *Matcher::xform( Node *n, int max_stack ) {
977 // Use one stack to keep both: child's node/state and parent's node/index
978 MStack mstack(max_stack * 2 * 2); // usually: C->live_nodes() * 2 * 2
979 mstack.push(n, Visit, NULL, -1); // set NULL as parent to indicate root
980 while (mstack.is_nonempty()) {
981 C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
982 if (C->failing()) return NULL;
983 n = mstack.node(); // Leave node on stack
984 Node_State nstate = mstack.state();
985 if (nstate == Visit) {
986 mstack.set_state(Post_Visit);
987 Node *oldn = n;
988 // Old-space or new-space check
989 if (!C->node_arena()->contains(n)) {
990 // Old space!
991 Node* m;
992 if (has_new_node(n)) { // Not yet Label/Reduced
993 m = new_node(n);
994 } else {
995 if (!is_dontcare(n)) { // Matcher can match this guy
996 // Calls match special. They match alone with no children.
997 // Their children, the incoming arguments, match normally.
998 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
999 if (C->failing()) return NULL;
2104 case Op_JumpProj:
2105 case Op_JProj:
2106 case Op_NeverBranch:
2107 set_dontcare(n);
2108 break;
2109 case Op_Jump:
2110 mstack.push(n->in(1), Pre_Visit); // Switch Value (could be shared)
2111 mstack.push(n->in(0), Pre_Visit); // Visit Control input
2112 continue; // while (mstack.is_nonempty())
2113 case Op_StrComp:
2114 case Op_StrEquals:
2115 case Op_StrIndexOf:
2116 case Op_StrIndexOfChar:
2117 case Op_AryEq:
2118 case Op_HasNegatives:
2119 case Op_StrInflatedCopy:
2120 case Op_StrCompressedCopy:
2121 case Op_EncodeISOArray:
2122 case Op_FmaD:
2123 case Op_FmaF:
2124 case Op_FmaVD:
2125 case Op_FmaVF:
2126 set_shared(n); // Force result into register (it will be anyways)
2127 break;
2128 case Op_ConP: { // Convert pointers above the centerline to NUL
2129 TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2130 const TypePtr* tp = tn->type()->is_ptr();
2131 if (tp->_ptr == TypePtr::AnyNull) {
2132 tn->set_type(TypePtr::NULL_PTR);
2133 }
2134 break;
2135 }
2136 case Op_ConN: { // Convert narrow pointers above the centerline to NUL
2137 TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2138 const TypePtr* tp = tn->type()->make_ptr();
2139 if (tp && tp->_ptr == TypePtr::AnyNull) {
2140 tn->set_type(TypeNarrowOop::NULL_PTR);
2141 }
2142 break;
2143 }
2144 case Op_Binary: // These are introduced in the Post_Visit state.
2145 ShouldNotReachHere();
2295 case Op_StrComp:
2296 case Op_StrIndexOf: {
2297 Node *pair1 = new BinaryNode(n->in(2),n->in(3));
2298 n->set_req(2,pair1);
2299 Node *pair2 = new BinaryNode(n->in(4),n->in(5));
2300 n->set_req(3,pair2);
2301 n->del_req(5);
2302 n->del_req(4);
2303 break;
2304 }
2305 case Op_StrCompressedCopy:
2306 case Op_StrInflatedCopy:
2307 case Op_EncodeISOArray: {
2308 // Restructure into a binary tree for Matching.
2309 Node* pair = new BinaryNode(n->in(3), n->in(4));
2310 n->set_req(3, pair);
2311 n->del_req(4);
2312 break;
2313 }
2314 case Op_FmaD:
2315 case Op_FmaF:
2316 case Op_FmaVD:
2317 case Op_FmaVF: {
2318 // Restructure into a binary tree for Matching.
2319 Node* pair = new BinaryNode(n->in(1), n->in(2));
2320 n->set_req(2, pair);
2321 n->set_req(1, n->in(3));
2322 n->del_req(3);
2323 break;
2324 }
2325 default:
2326 break;
2327 }
2328 }
2329 else {
2330 ShouldNotReachHere();
2331 }
2332 } // end of while (mstack.is_nonempty())
2333 }
2334
2335 #ifdef ASSERT
2336 // machine-independent root to machine-dependent root
2337 void Matcher::dump_old2new_map() {
|