< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  27 #include "memory/resourceArea.hpp"
  28 #include "opto/ad.hpp"
  29 #include "opto/addnode.hpp"
  30 #include "opto/callnode.hpp"
  31 #include "opto/idealGraphPrinter.hpp"
  32 #include "opto/matcher.hpp"
  33 #include "opto/memnode.hpp"
  34 #include "opto/movenode.hpp"
  35 #include "opto/opcodes.hpp"
  36 #include "opto/regmask.hpp"
  37 #include "opto/rootnode.hpp"
  38 #include "opto/runtime.hpp"
  39 #include "opto/type.hpp"
  40 #include "opto/vectornode.hpp"
  41 #include "runtime/os.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "utilities/align.hpp"
  44 #if INCLUDE_ZGC
  45 #include "gc/z/zBarrierSetRuntime.hpp"
  46 #endif // INCLUDE_ZGC



  47 
  48 OptoReg::Name OptoReg::c_frame_pointer;
  49 
  50 const RegMask *Matcher::idealreg2regmask[_last_machine_leaf];
  51 RegMask Matcher::mreg2regmask[_last_Mach_Reg];
  52 RegMask Matcher::STACK_ONLY_mask;
  53 RegMask Matcher::c_frame_ptr_mask;
  54 const uint Matcher::_begin_rematerialize = _BEGIN_REMATERIALIZE;
  55 const uint Matcher::_end_rematerialize   = _END_REMATERIALIZE;
  56 
  57 //---------------------------Matcher-------------------------------------------
  58 Matcher::Matcher()
  59 : PhaseTransform( Phase::Ins_Select ),
  60 #ifdef ASSERT
  61   _old2new_map(C->comp_arena()),
  62   _new2old_map(C->comp_arena()),
  63 #endif
  64   _shared_nodes(C->comp_arena()),
  65   _reduceOp(reduceOp), _leftOp(leftOp), _rightOp(rightOp),
  66   _swallowed(swallowed),


 985     C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
 986     if (C->failing()) return NULL;
 987     n = mstack.node();          // Leave node on stack
 988     Node_State nstate = mstack.state();
 989     if (nstate == Visit) {
 990       mstack.set_state(Post_Visit);
 991       Node *oldn = n;
 992       // Old-space or new-space check
 993       if (!C->node_arena()->contains(n)) {
 994         // Old space!
 995         Node* m;
 996         if (has_new_node(n)) {  // Not yet Label/Reduced
 997           m = new_node(n);
 998         } else {
 999           if (!is_dontcare(n)) { // Matcher can match this guy
1000             // Calls match special.  They match alone with no children.
1001             // Their children, the incoming arguments, match normally.
1002             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1003             if (C->failing())  return NULL;
1004             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }



1005           } else {                  // Nothing the matcher cares about
1006             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1007               // Convert to machine-dependent projection
1008               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
1009 #ifdef ASSERT
1010               _new2old_map.map(m->_idx, n);
1011 #endif
1012               if (m->in(0) != NULL) // m might be top
1013                 collect_null_checks(m, n);
1014             } else {                // Else just a regular 'ol guy
1015               m = n->clone();       // So just clone into new-space
1016 #ifdef ASSERT
1017               _new2old_map.map(m->_idx, n);
1018 #endif
1019               // Def-Use edges will be added incrementally as Uses
1020               // of this node are matched.
1021               assert(m->outcnt() == 0, "no Uses of this clone yet");
1022             }
1023           }
1024 


2137         if (tp->_ptr == TypePtr::AnyNull) {
2138           tn->set_type(TypePtr::NULL_PTR);
2139         }
2140         break;
2141       }
2142       case Op_ConN: {  // Convert narrow pointers above the centerline to NUL
2143         TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2144         const TypePtr* tp = tn->type()->make_ptr();
2145         if (tp && tp->_ptr == TypePtr::AnyNull) {
2146           tn->set_type(TypeNarrowOop::NULL_PTR);
2147         }
2148         break;
2149       }
2150       case Op_Binary:         // These are introduced in the Post_Visit state.
2151         ShouldNotReachHere();
2152         break;
2153       case Op_ClearArray:
2154       case Op_SafePoint:
2155         mem_op = true;
2156         break;









2157 #if INCLUDE_ZGC
2158       case Op_CallLeaf:
2159         if (UseZGC) {
2160           if (n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr() ||
2161               n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr()) {
2162             mem_op = true;
2163             mem_addr_idx = TypeFunc::Parms+1;
2164           }
2165           break;
2166         }
2167 #endif
2168       default:
2169         if( n->is_Store() ) {
2170           // Do match stores, despite no ideal reg
2171           mem_op = true;
2172           break;
2173         }
2174         if( n->is_Mem() ) { // Loads and LoadStores
2175           mem_op = true;
2176           // Loads must be root of match tree due to prior load conflict


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  27 #include "memory/resourceArea.hpp"
  28 #include "opto/ad.hpp"
  29 #include "opto/addnode.hpp"
  30 #include "opto/callnode.hpp"
  31 #include "opto/idealGraphPrinter.hpp"
  32 #include "opto/matcher.hpp"
  33 #include "opto/memnode.hpp"
  34 #include "opto/movenode.hpp"
  35 #include "opto/opcodes.hpp"
  36 #include "opto/regmask.hpp"
  37 #include "opto/rootnode.hpp"
  38 #include "opto/runtime.hpp"
  39 #include "opto/type.hpp"
  40 #include "opto/vectornode.hpp"
  41 #include "runtime/os.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "utilities/align.hpp"
  44 #if INCLUDE_ZGC
  45 #include "gc/z/zBarrierSetRuntime.hpp"
  46 #endif // INCLUDE_ZGC
  47 #if INCLUDE_SHENANDOAHGC
  48 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  49 #endif
  50 
  51 OptoReg::Name OptoReg::c_frame_pointer;
  52 
  53 const RegMask *Matcher::idealreg2regmask[_last_machine_leaf];
  54 RegMask Matcher::mreg2regmask[_last_Mach_Reg];
  55 RegMask Matcher::STACK_ONLY_mask;
  56 RegMask Matcher::c_frame_ptr_mask;
  57 const uint Matcher::_begin_rematerialize = _BEGIN_REMATERIALIZE;
  58 const uint Matcher::_end_rematerialize   = _END_REMATERIALIZE;
  59 
  60 //---------------------------Matcher-------------------------------------------
  61 Matcher::Matcher()
  62 : PhaseTransform( Phase::Ins_Select ),
  63 #ifdef ASSERT
  64   _old2new_map(C->comp_arena()),
  65   _new2old_map(C->comp_arena()),
  66 #endif
  67   _shared_nodes(C->comp_arena()),
  68   _reduceOp(reduceOp), _leftOp(leftOp), _rightOp(rightOp),
  69   _swallowed(swallowed),


 988     C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
 989     if (C->failing()) return NULL;
 990     n = mstack.node();          // Leave node on stack
 991     Node_State nstate = mstack.state();
 992     if (nstate == Visit) {
 993       mstack.set_state(Post_Visit);
 994       Node *oldn = n;
 995       // Old-space or new-space check
 996       if (!C->node_arena()->contains(n)) {
 997         // Old space!
 998         Node* m;
 999         if (has_new_node(n)) {  // Not yet Label/Reduced
1000           m = new_node(n);
1001         } else {
1002           if (!is_dontcare(n)) { // Matcher can match this guy
1003             // Calls match special.  They match alone with no children.
1004             // Their children, the incoming arguments, match normally.
1005             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1006             if (C->failing())  return NULL;
1007             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
1008             if (n->is_MemBar()) {
1009               m->as_MachMemBar()->set_adr_type(n->adr_type());
1010             }
1011           } else {                  // Nothing the matcher cares about
1012             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
1013               // Convert to machine-dependent projection
1014               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
1015 #ifdef ASSERT
1016               _new2old_map.map(m->_idx, n);
1017 #endif
1018               if (m->in(0) != NULL) // m might be top
1019                 collect_null_checks(m, n);
1020             } else {                // Else just a regular 'ol guy
1021               m = n->clone();       // So just clone into new-space
1022 #ifdef ASSERT
1023               _new2old_map.map(m->_idx, n);
1024 #endif
1025               // Def-Use edges will be added incrementally as Uses
1026               // of this node are matched.
1027               assert(m->outcnt() == 0, "no Uses of this clone yet");
1028             }
1029           }
1030 


2143         if (tp->_ptr == TypePtr::AnyNull) {
2144           tn->set_type(TypePtr::NULL_PTR);
2145         }
2146         break;
2147       }
2148       case Op_ConN: {  // Convert narrow pointers above the centerline to NUL
2149         TypeNode *tn = n->as_Type(); // Constants derive from type nodes
2150         const TypePtr* tp = tn->type()->make_ptr();
2151         if (tp && tp->_ptr == TypePtr::AnyNull) {
2152           tn->set_type(TypeNarrowOop::NULL_PTR);
2153         }
2154         break;
2155       }
2156       case Op_Binary:         // These are introduced in the Post_Visit state.
2157         ShouldNotReachHere();
2158         break;
2159       case Op_ClearArray:
2160       case Op_SafePoint:
2161         mem_op = true;
2162         break;
2163 #if INCLUDE_SHENANDOAHGC
2164       case Op_ShenandoahReadBarrier:
2165         if (n->in(ShenandoahBarrierNode::ValueIn)->is_DecodeNarrowPtr()) {
2166           set_shared(n->in(ShenandoahBarrierNode::ValueIn)->in(1));
2167         }
2168         mem_op = true;
2169         set_shared(n);
2170         break;
2171 #endif
2172 #if INCLUDE_ZGC
2173       case Op_CallLeaf:
2174         if (UseZGC) {
2175           if (n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr() ||
2176               n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr()) {
2177             mem_op = true;
2178             mem_addr_idx = TypeFunc::Parms+1;
2179           }
2180           break;
2181         }
2182 #endif
2183       default:
2184         if( n->is_Store() ) {
2185           // Do match stores, despite no ideal reg
2186           mem_op = true;
2187           break;
2188         }
2189         if( n->is_Mem() ) { // Loads and LoadStores
2190           mem_op = true;
2191           // Loads must be root of match tree due to prior load conflict


< prev index next >