< prev index next >

src/hotspot/share/opto/graphKit.hpp

Print this page




  46 class RootNode;
  47 
  48 //-----------------------------------------------------------------------------
  49 //----------------------------GraphKit-----------------------------------------
  50 // Toolkit for building the common sorts of subgraphs.
  51 // Does not know about bytecode parsing or type-flow results.
  52 // It is able to create graphs implementing the semantics of most
  53 // or all bytecodes, so that it can expand intrinsics and calls.
  54 // It may depend on JVMState structure, but it must not depend
  55 // on specific bytecode streams.
  56 class GraphKit : public Phase {
  57   friend class PreserveJVMState;
  58 
  59  protected:
  60   ciEnv*            _env;       // Compilation environment
  61   PhaseGVN         &_gvn;       // Some optimizations while parsing
  62   SafePointNode*    _map;       // Parser map from JVM to Nodes
  63   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
  64   int               _bci;       // JVM Bytecode Pointer
  65   ciMethod*         _method;    // JVM Current Method



  66 
  67  private:
  68   int               _sp;        // JVM Expression Stack Pointer; don't modify directly!
  69 
  70  private:
  71   SafePointNode*     map_not_null() const {
  72     assert(_map != NULL, "must call stopped() to test for reset compiler map");
  73     return _map;
  74   }
  75 
  76  public:
  77   GraphKit();                   // empty constructor
  78   GraphKit(JVMState* jvms);     // the JVM state on which to operate
  79 
  80 #ifdef ASSERT
  81   ~GraphKit() {
  82     assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms");





  83   }
  84 #endif
  85 
  86   virtual Parse*          is_Parse()          const { return NULL; }
  87   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
  88 
  89   ciEnv*        env()           const { return _env; }
  90   PhaseGVN&     gvn()           const { return _gvn; }
  91 
  92   void record_for_igvn(Node* n) const { C->record_for_igvn(n); }  // delegate to Compile
  93 
  94   // Handy well-known nodes:
  95   Node*         null()          const { return zerocon(T_OBJECT); }
  96   Node*         top()           const { return C->top(); }
  97   RootNode*     root()          const { return C->root(); }
  98 
  99   // Create or find a constant node
 100   Node* intcon(jint con)        const { return _gvn.intcon(con); }
 101   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
 102   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
 103   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
 104   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)
 105 
 106   // Helper for byte_map_base
 107   Node* byte_map_base_node();
 108 
 109   jint  find_int_con(Node* n, jint value_if_unknown) {
 110     return _gvn.find_int_con(n, value_if_unknown);
 111   }
 112   jlong find_long_con(Node* n, jlong value_if_unknown) {


 863     set_control(ctrl);
 864     return n;
 865   }
 866 
 867   // Exact type check used for predicted calls and casts.
 868   // Rewrites (*casted_receiver) to be casted to the stronger type.
 869   // (Caller is responsible for doing replace_in_map.)
 870   Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
 871                             Node* *casted_receiver);
 872   Node* type_check(Node* recv_klass, const TypeKlassPtr* tklass, float prob);
 873 
 874   // implementation of object creation
 875   Node* set_output_for_allocation(AllocateNode* alloc,
 876                                   const TypeOopPtr* oop_type,
 877                                   bool deoptimize_on_exception=false);
 878   Node* get_layout_helper(Node* klass_node, jint& constant_value);
 879   Node* new_instance(Node* klass_node,
 880                      Node* slow_test = NULL,
 881                      Node* *return_size_val = NULL,
 882                      bool deoptimize_on_exception = false,
 883                      ValueTypeNode* value_node = NULL);
 884   Node* new_array(Node* klass_node, Node* count_val, int nargs,
 885                   Node* *return_size_val = NULL,
 886                   bool deoptimize_on_exception = false);
 887   void initialize_value_type_array(Node* array, Node* length, ciValueKlass* vk, int nargs);
 888 
 889   // java.lang.String helpers
 890   Node* load_String_length(Node* ctrl, Node* str);
 891   Node* load_String_value(Node* ctrl, Node* str);
 892   Node* load_String_coder(Node* ctrl, Node* str);
 893   void store_String_value(Node* ctrl, Node* str, Node* value);
 894   void store_String_coder(Node* ctrl, Node* str, Node* value);
 895   Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
 896   Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
 897   void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
 898   void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
 899 
 900   // Handy for making control flow
 901   IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
 902     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
 903     _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time




  46 class RootNode;
  47 
  48 //-----------------------------------------------------------------------------
  49 //----------------------------GraphKit-----------------------------------------
  50 // Toolkit for building the common sorts of subgraphs.
  51 // Does not know about bytecode parsing or type-flow results.
  52 // It is able to create graphs implementing the semantics of most
  53 // or all bytecodes, so that it can expand intrinsics and calls.
  54 // It may depend on JVMState structure, but it must not depend
  55 // on specific bytecode streams.
  56 class GraphKit : public Phase {
  57   friend class PreserveJVMState;
  58 
  59  protected:
  60   ciEnv*            _env;       // Compilation environment
  61   PhaseGVN         &_gvn;       // Some optimizations while parsing
  62   SafePointNode*    _map;       // Parser map from JVM to Nodes
  63   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
  64   int               _bci;       // JVM Bytecode Pointer
  65   ciMethod*         _method;    // JVM Current Method
  66 #ifdef ASSERT
  67   uint              _worklist_size;
  68 #endif
  69 
  70  private:
  71   int               _sp;        // JVM Expression Stack Pointer; don't modify directly!
  72 
  73  private:
  74   SafePointNode*     map_not_null() const {
  75     assert(_map != NULL, "must call stopped() to test for reset compiler map");
  76     return _map;
  77   }
  78 
  79  public:
  80   GraphKit();                   // empty constructor
  81   GraphKit(JVMState* jvms, PhaseGVN* gvn = NULL);     // the JVM state on which to operate
  82 
  83 #ifdef ASSERT
  84   ~GraphKit() {
  85     assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms");
  86     // During incremental inlining, the Node_Array of the C->for_igvn() worklist and the IGVN
  87     // worklist are shared but the _in_worklist VectorSet is not. To avoid inconsistencies,
  88     // we should not add nodes to the _for_igvn worklist when using IGVN for the GraphKit.
  89     assert((_gvn.is_IterGVN() == NULL) || (_gvn.C->for_igvn()->size() == _worklist_size),
  90            "GraphKit should not modify _for_igvn worklist after parsing");
  91   }
  92 #endif
  93 
  94   virtual Parse*          is_Parse()          const { return NULL; }
  95   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
  96 
  97   ciEnv*        env()           const { return _env; }
  98   PhaseGVN&     gvn()           const { return _gvn; }
  99 
 100   void record_for_igvn(Node* n) const { _gvn.record_for_igvn(n); }
 101 
 102   // Handy well-known nodes:
 103   Node*         null()          const { return zerocon(T_OBJECT); }
 104   Node*         top()           const { return C->top(); }
 105   RootNode*     root()          const { return C->root(); }
 106 
 107   // Create or find a constant node
 108   Node* intcon(jint con)        const { return _gvn.intcon(con); }
 109   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
 110   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
 111   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
 112   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)
 113 
 114   // Helper for byte_map_base
 115   Node* byte_map_base_node();
 116 
 117   jint  find_int_con(Node* n, jint value_if_unknown) {
 118     return _gvn.find_int_con(n, value_if_unknown);
 119   }
 120   jlong find_long_con(Node* n, jlong value_if_unknown) {


 871     set_control(ctrl);
 872     return n;
 873   }
 874 
 875   // Exact type check used for predicted calls and casts.
 876   // Rewrites (*casted_receiver) to be casted to the stronger type.
 877   // (Caller is responsible for doing replace_in_map.)
 878   Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
 879                             Node* *casted_receiver);
 880   Node* type_check(Node* recv_klass, const TypeKlassPtr* tklass, float prob);
 881 
 882   // implementation of object creation
 883   Node* set_output_for_allocation(AllocateNode* alloc,
 884                                   const TypeOopPtr* oop_type,
 885                                   bool deoptimize_on_exception=false);
 886   Node* get_layout_helper(Node* klass_node, jint& constant_value);
 887   Node* new_instance(Node* klass_node,
 888                      Node* slow_test = NULL,
 889                      Node* *return_size_val = NULL,
 890                      bool deoptimize_on_exception = false,
 891                      ValueTypeBaseNode* value_node = NULL);
 892   Node* new_array(Node* klass_node, Node* count_val, int nargs,
 893                   Node* *return_size_val = NULL,
 894                   bool deoptimize_on_exception = false);
 895   void initialize_value_type_array(Node* array, Node* length, ciValueKlass* vk, int nargs);
 896 
 897   // java.lang.String helpers
 898   Node* load_String_length(Node* ctrl, Node* str);
 899   Node* load_String_value(Node* ctrl, Node* str);
 900   Node* load_String_coder(Node* ctrl, Node* str);
 901   void store_String_value(Node* ctrl, Node* str, Node* value);
 902   void store_String_coder(Node* ctrl, Node* str, Node* value);
 903   Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
 904   Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
 905   void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
 906   void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
 907 
 908   // Handy for making control flow
 909   IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
 910     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
 911     _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time


< prev index next >