src/hotspot/share/opto/graphKit.hpp
changeset 50180 ffa644980dff
parent 49982 9042ffe5b7fe
child 51485 0c7040d1d1ca
equal deleted inserted replaced
50179:d9bc8557ae16 50180:ffa644980dff
    25 #ifndef SHARE_VM_OPTO_GRAPHKIT_HPP
    25 #ifndef SHARE_VM_OPTO_GRAPHKIT_HPP
    26 #define SHARE_VM_OPTO_GRAPHKIT_HPP
    26 #define SHARE_VM_OPTO_GRAPHKIT_HPP
    27 
    27 
    28 #include "ci/ciEnv.hpp"
    28 #include "ci/ciEnv.hpp"
    29 #include "ci/ciMethodData.hpp"
    29 #include "ci/ciMethodData.hpp"
       
    30 #include "gc/shared/c2/barrierSetC2.hpp"
    30 #include "opto/addnode.hpp"
    31 #include "opto/addnode.hpp"
    31 #include "opto/callnode.hpp"
    32 #include "opto/callnode.hpp"
    32 #include "opto/cfgnode.hpp"
    33 #include "opto/cfgnode.hpp"
    33 #include "opto/compile.hpp"
    34 #include "opto/compile.hpp"
    34 #include "opto/divnode.hpp"
    35 #include "opto/divnode.hpp"
    36 #include "opto/phaseX.hpp"
    37 #include "opto/phaseX.hpp"
    37 #include "opto/subnode.hpp"
    38 #include "opto/subnode.hpp"
    38 #include "opto/type.hpp"
    39 #include "opto/type.hpp"
    39 #include "runtime/deoptimization.hpp"
    40 #include "runtime/deoptimization.hpp"
    40 
    41 
       
    42 class BarrierSetC2;
    41 class FastLockNode;
    43 class FastLockNode;
    42 class FastUnlockNode;
    44 class FastUnlockNode;
    43 class IdealKit;
    45 class IdealKit;
    44 class LibraryCallKit;
    46 class LibraryCallKit;
    45 class Parse;
    47 class Parse;
    61   PhaseGVN         &_gvn;       // Some optimizations while parsing
    63   PhaseGVN         &_gvn;       // Some optimizations while parsing
    62   SafePointNode*    _map;       // Parser map from JVM to Nodes
    64   SafePointNode*    _map;       // Parser map from JVM to Nodes
    63   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
    65   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
    64   int               _bci;       // JVM Bytecode Pointer
    66   int               _bci;       // JVM Bytecode Pointer
    65   ciMethod*         _method;    // JVM Current Method
    67   ciMethod*         _method;    // JVM Current Method
       
    68   BarrierSetC2*     _barrier_set;
    66 
    69 
    67  private:
    70  private:
    68   int               _sp;        // JVM Expression Stack Pointer; don't modify directly!
    71   int               _sp;        // JVM Expression Stack Pointer; don't modify directly!
    69 
    72 
    70  private:
    73  private:
    84 #endif
    87 #endif
    85 
    88 
    86   virtual Parse*          is_Parse()          const { return NULL; }
    89   virtual Parse*          is_Parse()          const { return NULL; }
    87   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
    90   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
    88 
    91 
    89   ciEnv*        env()           const { return _env; }
    92   ciEnv*        env()               const { return _env; }
    90   PhaseGVN&     gvn()           const { return _gvn; }
    93   PhaseGVN&     gvn()               const { return _gvn; }
       
    94   void*         barrier_set_state() const { return C->barrier_set_state(); }
    91 
    95 
    92   void record_for_igvn(Node* n) const { C->record_for_igvn(n); }  // delegate to Compile
    96   void record_for_igvn(Node* n) const { C->record_for_igvn(n); }  // delegate to Compile
    93 
    97 
    94   // Handy well-known nodes:
    98   // Handy well-known nodes:
    95   Node*         null()          const { return zerocon(T_OBJECT); }
    99   Node*         null()          const { return zerocon(T_OBJECT); }
   100   Node* intcon(jint con)        const { return _gvn.intcon(con); }
   104   Node* intcon(jint con)        const { return _gvn.intcon(con); }
   101   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
   105   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
   102   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
   106   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
   103   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
   107   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
   104   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)
   108   // (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 
   109   jint  find_int_con(Node* n, jint value_if_unknown) {
   110   jint  find_int_con(Node* n, jint value_if_unknown) {
   110     return _gvn.find_int_con(n, value_if_unknown);
   111     return _gvn.find_int_con(n, value_if_unknown);
   111   }
   112   }
   112   jlong find_long_con(Node* n, jlong value_if_unknown) {
   113   jlong find_long_con(Node* n, jlong value_if_unknown) {
   567                         MemNode::MemOrd,
   568                         MemNode::MemOrd,
   568                         bool require_atomic_access = false,
   569                         bool require_atomic_access = false,
   569                         bool unaligned = false,
   570                         bool unaligned = false,
   570                         bool mismatched = false);
   571                         bool mismatched = false);
   571 
   572 
   572 
   573   // Perform decorated accesses
   573   // All in one pre-barrier, store, post_barrier
   574 
   574   // Insert a write-barrier'd store.  This is to let generational GC
   575   Node* access_store_at(Node* ctl,
   575   // work; we have to flag all oop-stores before the next GC point.
   576                         Node* obj,   // containing obj
   576   //
   577                         Node* adr,   // actual adress to store val at
   577   // It comes in 3 flavors of store to an object, array, or unknown.
   578                         const TypePtr* adr_type,
   578   // We use precise card marks for arrays to avoid scanning the entire
   579                         Node* val,
   579   // array. We use imprecise for object. We use precise for unknown
   580                         const Type* val_type,
   580   // since we don't know if we have an array or and object or even
   581                         BasicType bt,
   581   // where the object starts.
   582                         DecoratorSet decorators);
   582   //
   583 
   583   // If val==NULL, it is taken to be a completely unknown value. QQQ
   584   Node* access_load_at(Node* obj,   // containing obj
   584 
   585                        Node* adr,   // actual adress to store val at
   585   Node* store_oop(Node* ctl,
   586                        const TypePtr* adr_type,
   586                   Node* obj,   // containing obj
   587                        const Type* val_type,
   587                   Node* adr,   // actual adress to store val at
   588                        BasicType bt,
   588                   const TypePtr* adr_type,
   589                        DecoratorSet decorators);
   589                   Node* val,
   590 
   590                   const TypeOopPtr* val_type,
   591   Node* access_atomic_cmpxchg_val_at(Node* ctl,
   591                   BasicType bt,
   592                                      Node* obj,
   592                   bool use_precise,
   593                                      Node* adr,
   593                   MemNode::MemOrd mo,
   594                                      const TypePtr* adr_type,
   594                   bool mismatched = false);
   595                                      int alias_idx,
   595 
   596                                      Node* expected_val,
   596   Node* store_oop_to_object(Node* ctl,
   597                                      Node* new_val,
   597                             Node* obj,   // containing obj
   598                                      const Type* value_type,
   598                             Node* adr,   // actual adress to store val at
   599                                      BasicType bt,
   599                             const TypePtr* adr_type,
   600                                      DecoratorSet decorators);
   600                             Node* val,
   601 
   601                             const TypeOopPtr* val_type,
   602   Node* access_atomic_cmpxchg_bool_at(Node* ctl,
   602                             BasicType bt,
   603                                       Node* obj,
   603                             MemNode::MemOrd mo) {
   604                                       Node* adr,
   604     return store_oop(ctl, obj, adr, adr_type, val, val_type, bt, false, mo);
   605                                       const TypePtr* adr_type,
   605   }
   606                                       int alias_idx,
   606 
   607                                       Node* expected_val,
   607   Node* store_oop_to_array(Node* ctl,
   608                                       Node* new_val,
   608                            Node* obj,   // containing obj
   609                                       const Type* value_type,
   609                            Node* adr,   // actual adress to store val at
   610                                       BasicType bt,
   610                            const TypePtr* adr_type,
   611                                       DecoratorSet decorators);
   611                            Node* val,
   612 
   612                            const TypeOopPtr* val_type,
   613   Node* access_atomic_xchg_at(Node* ctl,
   613                            BasicType bt,
   614                               Node* obj,
   614                            MemNode::MemOrd mo) {
   615                               Node* adr,
   615     return store_oop(ctl, obj, adr, adr_type, val, val_type, bt, true, mo);
   616                               const TypePtr* adr_type,
   616   }
   617                               int alias_idx,
   617 
   618                               Node* new_val,
   618   // Could be an array or object we don't know at compile time (unsafe ref.)
   619                               const Type* value_type,
   619   Node* store_oop_to_unknown(Node* ctl,
   620                               BasicType bt,
   620                              Node* obj,   // containing obj
   621                               DecoratorSet decorators);
   621                              Node* adr,   // actual adress to store val at
   622 
       
   623   Node* access_atomic_add_at(Node* ctl,
       
   624                              Node* obj,
       
   625                              Node* adr,
   622                              const TypePtr* adr_type,
   626                              const TypePtr* adr_type,
   623                              Node* val,
   627                              int alias_idx,
       
   628                              Node* new_val,
       
   629                              const Type* value_type,
   624                              BasicType bt,
   630                              BasicType bt,
   625                              MemNode::MemOrd mo,
   631                              DecoratorSet decorators);
   626                              bool mismatched = false);
   632 
   627 
   633   void access_clone(Node* ctl, Node* src, Node* dst, Node* size, bool is_array);
   628   // For the few case where the barriers need special help
       
   629   void pre_barrier(bool do_load, Node* ctl,
       
   630                    Node* obj, Node* adr, uint adr_idx, Node* val, const TypeOopPtr* val_type,
       
   631                    Node* pre_val,
       
   632                    BasicType bt);
       
   633 
       
   634   void post_barrier(Node* ctl, Node* store, Node* obj, Node* adr, uint adr_idx,
       
   635                     Node* val, BasicType bt, bool use_precise);
       
   636 
   634 
   637   // Return addressing for an array element.
   635   // Return addressing for an array element.
   638   Node* array_element_address(Node* ary, Node* idx, BasicType elembt,
   636   Node* array_element_address(Node* ary, Node* idx, BasicType elembt,
   639                               // Optional constraint on the array size:
   637                               // Optional constraint on the array size:
   640                               const TypeInt* sizetype = NULL,
   638                               const TypeInt* sizetype = NULL,
   752   }
   750   }
   753 
   751 
   754   // Returns the object (if any) which was created the moment before.
   752   // Returns the object (if any) which was created the moment before.
   755   Node* just_allocated_object(Node* current_control);
   753   Node* just_allocated_object(Node* current_control);
   756 
   754 
   757   static bool use_ReduceInitialCardMarks();
       
   758 
       
   759   // Sync Ideal and Graph kits.
   755   // Sync Ideal and Graph kits.
   760   void sync_kit(IdealKit& ideal);
   756   void sync_kit(IdealKit& ideal);
   761   void final_sync(IdealKit& ideal);
   757   void final_sync(IdealKit& ideal);
   762 
       
   763   // vanilla/CMS post barrier
       
   764   void write_barrier_post(Node *store, Node* obj,
       
   765                           Node* adr,  uint adr_idx, Node* val, bool use_precise);
       
   766 
       
   767   // Allow reordering of pre-barrier with oop store and/or post-barrier.
       
   768   // Used for load_store operations which loads old value.
       
   769   bool can_move_pre_barrier() const;
       
   770 
       
   771 #if INCLUDE_G1GC
       
   772   // G1 pre/post barriers
       
   773   void g1_write_barrier_pre(bool do_load,
       
   774                             Node* obj,
       
   775                             Node* adr,
       
   776                             uint alias_idx,
       
   777                             Node* val,
       
   778                             const TypeOopPtr* val_type,
       
   779                             Node* pre_val,
       
   780                             BasicType bt);
       
   781 
       
   782   void g1_write_barrier_post(Node* store,
       
   783                              Node* obj,
       
   784                              Node* adr,
       
   785                              uint alias_idx,
       
   786                              Node* val,
       
   787                              BasicType bt,
       
   788                              bool use_precise);
       
   789   // Helper function for g1
       
   790   private:
       
   791   void g1_mark_card(IdealKit& ideal, Node* card_adr, Node* store, uint oop_alias_idx,
       
   792                     Node* index, Node* index_adr,
       
   793                     Node* buffer, const TypeFunc* tf);
       
   794 
       
   795   bool g1_can_remove_pre_barrier(PhaseTransform* phase, Node* adr, BasicType bt, uint adr_idx);
       
   796 
       
   797   bool g1_can_remove_post_barrier(PhaseTransform* phase, Node* store, Node* adr);
       
   798 #endif // INCLUDE_G1GC
       
   799 
   758 
   800   public:
   759   public:
   801   // Helper function to round double arguments before a call
   760   // Helper function to round double arguments before a call
   802   void round_double_arguments(ciMethod* dest_method);
   761   void round_double_arguments(ciMethod* dest_method);
   803   void round_double_result(ciMethod* dest_method);
   762   void round_double_result(ciMethod* dest_method);