< prev index next >

src/hotspot/share/opto/graphKit.hpp

Print this page

 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  *
 23  */
 24 
 25 #ifndef SHARE_OPTO_GRAPHKIT_HPP
 26 #define SHARE_OPTO_GRAPHKIT_HPP
 27 
 28 #include "ci/ciEnv.hpp"
 29 #include "ci/ciMethodData.hpp"
 30 #include "gc/shared/c2/barrierSetC2.hpp"
 31 #include "opto/addnode.hpp"
 32 #include "opto/callnode.hpp"
 33 #include "opto/cfgnode.hpp"
 34 #include "opto/compile.hpp"
 35 #include "opto/divnode.hpp"

 36 #include "opto/mulnode.hpp"
 37 #include "opto/phaseX.hpp"
 38 #include "opto/subnode.hpp"
 39 #include "opto/type.hpp"
 40 #include "runtime/deoptimization.hpp"
 41 
 42 class BarrierSetC2;
 43 class FastLockNode;
 44 class FastUnlockNode;
 45 class IdealKit;
 46 class LibraryCallKit;
 47 class Parse;
 48 class RootNode;
 49 
 50 //-----------------------------------------------------------------------------
 51 //----------------------------GraphKit-----------------------------------------
 52 // Toolkit for building the common sorts of subgraphs.
 53 // Does not know about bytecode parsing or type-flow results.
 54 // It is able to create graphs implementing the semantics of most
 55 // or all bytecodes, so that it can expand intrinsics and calls.
 56 // It may depend on JVMState structure, but it must not depend
 57 // on specific bytecode streams.
 58 class GraphKit : public Phase {
 59   friend class PreserveJVMState;
 60 
 61  protected:
 62   ciEnv*            _env;       // Compilation environment
 63   PhaseGVN         &_gvn;       // Some optimizations while parsing
 64   SafePointNode*    _map;       // Parser map from JVM to Nodes
 65   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
 66   int               _bci;       // JVM Bytecode Pointer
 67   ciMethod*         _method;    // JVM Current Method
 68   BarrierSetC2*     _barrier_set;



 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);     // 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   }
 87 #endif
 88 
 89   virtual Parse*          is_Parse()          const { return NULL; }
 90   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
 91 
 92   ciEnv*        env()               const { return _env; }
 93   PhaseGVN&     gvn()               const { return _gvn; }
 94   void*         barrier_set_state() const { return C->barrier_set_state(); }
 95 
 96   void record_for_igvn(Node* n) const { C->record_for_igvn(n); }  // delegate to Compile
 97 
 98   // Handy well-known nodes:
 99   Node*         null()          const { return zerocon(T_OBJECT); }
100   Node*         top()           const { return C->top(); }
101   RootNode*     root()          const { return C->root(); }
102 
103   // Create or find a constant node
104   Node* intcon(jint con)        const { return _gvn.intcon(con); }
105   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
106   Node* integercon(jlong con, BasicType bt)   const {
107     if (bt == T_INT) {
108       return intcon(checked_cast<jint>(con));
109     }
110     assert(bt == T_LONG, "basic type not an int or long");
111     return longcon(con);
112   }
113   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
114   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
115   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)
116 

337   Node* ConvL2I(Node* offset);
338   // Find out the klass of an object.
339   Node* load_object_klass(Node* object);
340   // Find out the length of an array.
341   Node* load_array_length(Node* array);
342   // Cast array allocation's length as narrow as possible.
343   // If replace_length_in_map is true, replace length with CastIINode in map.
344   // This method is invoked after creating/moving ArrayAllocationNode or in load_array_length
345   Node* array_ideal_length(AllocateArrayNode* alloc,
346                            const TypeOopPtr* oop_type,
347                            bool replace_length_in_map);
348 
349 
350   // Helper function to do a NULL pointer check or ZERO check based on type.
351   // Throw an exception if a given value is null.
352   // Return the value cast to not-null.
353   // Be clever about equivalent dominating null checks.
354   Node* null_check_common(Node* value, BasicType type,
355                           bool assert_null = false,
356                           Node* *null_control = NULL,
357                           bool speculative = false);

358   Node* null_check(Node* value, BasicType type = T_OBJECT) {
359     return null_check_common(value, type, false, NULL, !_gvn.type(value)->speculative_maybe_null());
360   }
361   Node* null_check_receiver() {
362     assert(argument(0)->bottom_type()->isa_ptr(), "must be");
363     return null_check(argument(0));
364   }
365   Node* zero_check_int(Node* value) {
366     assert(value->bottom_type()->basic_type() == T_INT,
367            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
368     return null_check_common(value, T_INT);
369   }
370   Node* zero_check_long(Node* value) {
371     assert(value->bottom_type()->basic_type() == T_LONG,
372            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
373     return null_check_common(value, T_LONG);
374   }
375   // Throw an uncommon trap if a given value is __not__ null.
376   // Return the value cast to null, and be clever about dominating checks.
377   Node* null_assert(Node* value, BasicType type = T_OBJECT) {
378     return null_check_common(value, type, true, NULL, _gvn.type(value)->speculative_always_null());
379   }
380 
381   // Check if value is null and abort if it is
382   Node* must_be_not_null(Node* value, bool do_replace_in_map);

577                            unaligned, mismatched, unsafe);
578   }
579   // This is the base version which is given alias index
580   // Return the new StoreXNode
581   Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt,
582                         int adr_idx,
583                         MemNode::MemOrd,
584                         bool require_atomic_access = false,
585                         bool unaligned = false,
586                         bool mismatched = false,
587                         bool unsafe = false);
588 
589   // Perform decorated accesses
590 
591   Node* access_store_at(Node* obj,   // containing obj
592                         Node* adr,   // actual address to store val at
593                         const TypePtr* adr_type,
594                         Node* val,
595                         const Type* val_type,
596                         BasicType bt,
597                         DecoratorSet decorators);

598 
599   Node* access_load_at(Node* obj,   // containing obj
600                        Node* adr,   // actual address to load val at
601                        const TypePtr* adr_type,
602                        const Type* val_type,
603                        BasicType bt,
604                        DecoratorSet decorators);

605 
606   Node* access_load(Node* adr,   // actual address to load val at
607                     const Type* val_type,
608                     BasicType bt,
609                     DecoratorSet decorators);
610 
611   Node* access_atomic_cmpxchg_val_at(Node* obj,
612                                      Node* adr,
613                                      const TypePtr* adr_type,
614                                      int alias_idx,
615                                      Node* expected_val,
616                                      Node* new_val,
617                                      const Type* value_type,
618                                      BasicType bt,
619                                      DecoratorSet decorators);
620 
621   Node* access_atomic_cmpxchg_bool_at(Node* obj,
622                                       Node* adr,
623                                       const TypePtr* adr_type,
624                                       int alias_idx,

662   void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);
663   void make_dtrace_method_entry(ciMethod* method) {
664     make_dtrace_method_entry_exit(method, true);
665   }
666   void make_dtrace_method_exit(ciMethod* method) {
667     make_dtrace_method_entry_exit(method, false);
668   }
669 
670   //--------------- stub generation -------------------
671  public:
672   void gen_stub(address C_function,
673                 const char *name,
674                 int is_fancy_jump,
675                 bool pass_tls,
676                 bool return_pc);
677 
678   //---------- help for generating calls --------------
679 
680   // Do a null check on the receiver as it would happen before the call to
681   // callee (with all arguments still on the stack).
682   Node* null_check_receiver_before_call(ciMethod* callee) {
683     assert(!callee->is_static(), "must be a virtual method");
684     // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
685     // Use callsite signature always.
686     ciMethod* declared_method = method()->get_method_at_bci(bci());
687     const int nargs = declared_method->arg_size();
688     inc_sp(nargs);
689     Node* n = null_check_receiver();
690     dec_sp(nargs);
691     return n;
692   }
693 
694   // Fill in argument edges for the call from argument(0), argument(1), ...
695   // (The next step is to call set_edges_for_java_call.)
696   void  set_arguments_for_java_call(CallJavaNode* call);
697 
698   // Fill in non-argument edges for the call.
699   // Transform the call, and update the basics: control, i_o, memory.
700   // (The next step is usually to call set_results_for_java_call.)
701   void set_edges_for_java_call(CallJavaNode* call,
702                                bool must_throw = false, bool separate_io_proj = false);
703 
704   // Finish up a java call that was started by set_edges_for_java_call.
705   // Call add_exception on any throw arising from the call.
706   // Return the call result (transformed).
707   Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false);
708 
709   // Similar to set_edges_for_java_call, but simplified for runtime calls.
710   void  set_predefined_output_for_runtime_call(Node* call) {
711     set_predefined_output_for_runtime_call(call, NULL, NULL);
712   }
713   void  set_predefined_output_for_runtime_call(Node* call,
714                                                Node* keep_mem,
715                                                const TypePtr* hook_mem);
716   Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL);

815   void merge_memory(Node* new_mem, Node* region, int new_path);
816   void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false);
817 
818   // Helper functions to build synchronizations
819   int next_monitor();
820   Node* insert_mem_bar(int opcode, Node* precedent = NULL);
821   Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL);
822   // Optional 'precedent' is appended as an extra edge, to force ordering.
823   FastLockNode* shared_lock(Node* obj);
824   void shared_unlock(Node* box, Node* obj);
825 
826   // helper functions for the fast path/slow path idioms
827   Node* fast_and_slow(Node* in, const Type *result_type, Node* null_result, IfNode* fast_test, Node* fast_result, address slow_call, const TypeFunc *slow_call_type, Node* slow_arg, Klass* ex_klass, Node* slow_result);
828 
829   // Generate an instance-of idiom.  Used by both the instance-of bytecode
830   // and the reflective instance-of call.
831   Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false);
832 
833   // Generate a check-cast idiom.  Used by both the check-cast bytecode
834   // and the array-store bytecode
835   Node* gen_checkcast( Node *subobj, Node* superkls,
836                        Node* *failure_control = NULL );







837 
838   Node* gen_subtype_check(Node* obj, Node* superklass);
839 
840   // Exact type check used for predicted calls and casts.
841   // Rewrites (*casted_receiver) to be casted to the stronger type.
842   // (Caller is responsible for doing replace_in_map.)
843   Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
844                             Node* *casted_receiver);

845 
846   // Inexact type check used for predicted calls.
847   Node* subtype_check_receiver(Node* receiver, ciKlass* klass,
848                                Node** casted_receiver);
849 
850   // implementation of object creation
851   Node* set_output_for_allocation(AllocateNode* alloc,
852                                   const TypeOopPtr* oop_type,
853                                   bool deoptimize_on_exception=false);
854   Node* get_layout_helper(Node* klass_node, jint& constant_value);
855   Node* new_instance(Node* klass_node,
856                      Node* slow_test = NULL,
857                      Node* *return_size_val = NULL,
858                      bool deoptimize_on_exception = false);

859   Node* new_array(Node* klass_node, Node* count_val, int nargs,
860                   Node* *return_size_val = NULL,
861                   bool deoptimize_on_exception = false);
862 
863   // java.lang.String helpers
864   Node* load_String_length(Node* str, bool set_ctrl);
865   Node* load_String_value(Node* str, bool set_ctrl);
866   Node* load_String_coder(Node* str, bool set_ctrl);
867   void store_String_value(Node* str, Node* value);
868   void store_String_coder(Node* str, Node* value);
869   Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
870   Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
871   void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
872   void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
873 
874   // Handy for making control flow
875   IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
876     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
877     _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time
878     // Place 'if' on worklist if it will be in graph
879     if (!tst->is_Con())  record_for_igvn(iff);     // Range-check and Null-check removal is later
880     return iff;
881   }
882 
883   IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) {
884     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
885     _gvn.transform(iff);                           // Value may be known at parse-time
886     // Place 'if' on worklist if it will be in graph
887     if (!tst->is_Con())  record_for_igvn(iff);     // Range-check and Null-check removal is later
888     return iff;
889   }
890 
891   void add_empty_predicates(int nargs = 0);
892   void add_empty_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
893 
894   Node* make_constant_from_field(ciField* field, Node* obj);

895 
896   // Vector API support (implemented in vectorIntrinsics.cpp)
897   Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false);
898   Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false);
899   Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem);
900 };
901 
902 // Helper class to support building of control flow branches. Upon
903 // creation the map and sp at bci are cloned and restored upon de-
904 // struction. Typical use:
905 //
906 // { PreserveJVMState pjvms(this);
907 //   // code of new branch
908 // }
909 // // here the JVM state at bci is established
910 
911 class PreserveJVMState: public StackObj {
912  protected:
913   GraphKit*      _kit;
914 #ifdef ASSERT

 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  *
 23  */
 24 
 25 #ifndef SHARE_OPTO_GRAPHKIT_HPP
 26 #define SHARE_OPTO_GRAPHKIT_HPP
 27 
 28 #include "ci/ciEnv.hpp"
 29 #include "ci/ciMethodData.hpp"
 30 #include "gc/shared/c2/barrierSetC2.hpp"
 31 #include "opto/addnode.hpp"
 32 #include "opto/callnode.hpp"
 33 #include "opto/cfgnode.hpp"
 34 #include "opto/compile.hpp"
 35 #include "opto/divnode.hpp"
 36 #include "opto/inlinetypenode.hpp"
 37 #include "opto/mulnode.hpp"
 38 #include "opto/phaseX.hpp"
 39 #include "opto/subnode.hpp"
 40 #include "opto/type.hpp"
 41 #include "runtime/deoptimization.hpp"
 42 
 43 class BarrierSetC2;
 44 class FastLockNode;
 45 class FastUnlockNode;
 46 class IdealKit;
 47 class LibraryCallKit;
 48 class Parse;
 49 class RootNode;
 50 
 51 //-----------------------------------------------------------------------------
 52 //----------------------------GraphKit-----------------------------------------
 53 // Toolkit for building the common sorts of subgraphs.
 54 // Does not know about bytecode parsing or type-flow results.
 55 // It is able to create graphs implementing the semantics of most
 56 // or all bytecodes, so that it can expand intrinsics and calls.
 57 // It may depend on JVMState structure, but it must not depend
 58 // on specific bytecode streams.
 59 class GraphKit : public Phase {
 60   friend class PreserveJVMState;
 61 
 62  protected:
 63   ciEnv*            _env;       // Compilation environment
 64   PhaseGVN         &_gvn;       // Some optimizations while parsing
 65   SafePointNode*    _map;       // Parser map from JVM to Nodes
 66   SafePointNode*    _exceptions;// Parser map(s) for exception state(s)
 67   int               _bci;       // JVM Bytecode Pointer
 68   ciMethod*         _method;    // JVM Current Method
 69   BarrierSetC2*     _barrier_set;
 70 #ifdef ASSERT
 71   uint              _worklist_size;
 72 #endif
 73 
 74  private:
 75   int               _sp;        // JVM Expression Stack Pointer; don't modify directly!
 76 
 77  private:
 78   SafePointNode*     map_not_null() const {
 79     assert(_map != NULL, "must call stopped() to test for reset compiler map");
 80     return _map;
 81   }
 82 
 83  public:
 84   GraphKit();                   // empty constructor
 85   GraphKit(JVMState* jvms, PhaseGVN* gvn = NULL);     // the JVM state on which to operate
 86 
 87 #ifdef ASSERT
 88   ~GraphKit() {
 89     assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms");
 90     // During incremental inlining, the Node_Array of the C->for_igvn() worklist and the IGVN
 91     // worklist are shared but the _in_worklist VectorSet is not. To avoid inconsistencies,
 92     // we should not add nodes to the _for_igvn worklist when using IGVN for the GraphKit.
 93     assert((_gvn.is_IterGVN() == NULL) || (_gvn.C->for_igvn()->size() == _worklist_size),
 94            "GraphKit should not modify _for_igvn worklist after parsing");
 95   }
 96 #endif
 97 
 98   virtual Parse*          is_Parse()          const { return NULL; }
 99   virtual LibraryCallKit* is_LibraryCallKit() const { return NULL; }
100 
101   ciEnv*        env()               const { return _env; }
102   PhaseGVN&     gvn()               const { return _gvn; }
103   void*         barrier_set_state() const { return C->barrier_set_state(); }
104 
105   void record_for_igvn(Node* n) const { _gvn.record_for_igvn(n); }
106 
107   // Handy well-known nodes:
108   Node*         null()          const { return zerocon(T_OBJECT); }
109   Node*         top()           const { return C->top(); }
110   RootNode*     root()          const { return C->root(); }
111 
112   // Create or find a constant node
113   Node* intcon(jint con)        const { return _gvn.intcon(con); }
114   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
115   Node* integercon(jlong con, BasicType bt)   const {
116     if (bt == T_INT) {
117       return intcon(checked_cast<jint>(con));
118     }
119     assert(bt == T_LONG, "basic type not an int or long");
120     return longcon(con);
121   }
122   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
123   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
124   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)
125 

346   Node* ConvL2I(Node* offset);
347   // Find out the klass of an object.
348   Node* load_object_klass(Node* object);
349   // Find out the length of an array.
350   Node* load_array_length(Node* array);
351   // Cast array allocation's length as narrow as possible.
352   // If replace_length_in_map is true, replace length with CastIINode in map.
353   // This method is invoked after creating/moving ArrayAllocationNode or in load_array_length
354   Node* array_ideal_length(AllocateArrayNode* alloc,
355                            const TypeOopPtr* oop_type,
356                            bool replace_length_in_map);
357 
358 
359   // Helper function to do a NULL pointer check or ZERO check based on type.
360   // Throw an exception if a given value is null.
361   // Return the value cast to not-null.
362   // Be clever about equivalent dominating null checks.
363   Node* null_check_common(Node* value, BasicType type,
364                           bool assert_null = false,
365                           Node* *null_control = NULL,
366                           bool speculative = false,
367                           bool is_init_check = false);
368   Node* null_check(Node* value, BasicType type = T_OBJECT) {
369     return null_check_common(value, type, false, NULL, !_gvn.type(value)->speculative_maybe_null());
370   }
371   Node* null_check_receiver() {

372     return null_check(argument(0));
373   }
374   Node* zero_check_int(Node* value) {
375     assert(value->bottom_type()->basic_type() == T_INT,
376            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
377     return null_check_common(value, T_INT);
378   }
379   Node* zero_check_long(Node* value) {
380     assert(value->bottom_type()->basic_type() == T_LONG,
381            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
382     return null_check_common(value, T_LONG);
383   }
384   // Throw an uncommon trap if a given value is __not__ null.
385   // Return the value cast to null, and be clever about dominating checks.
386   Node* null_assert(Node* value, BasicType type = T_OBJECT) {
387     return null_check_common(value, type, true, NULL, _gvn.type(value)->speculative_always_null());
388   }
389 
390   // Check if value is null and abort if it is
391   Node* must_be_not_null(Node* value, bool do_replace_in_map);

586                            unaligned, mismatched, unsafe);
587   }
588   // This is the base version which is given alias index
589   // Return the new StoreXNode
590   Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt,
591                         int adr_idx,
592                         MemNode::MemOrd,
593                         bool require_atomic_access = false,
594                         bool unaligned = false,
595                         bool mismatched = false,
596                         bool unsafe = false);
597 
598   // Perform decorated accesses
599 
600   Node* access_store_at(Node* obj,   // containing obj
601                         Node* adr,   // actual address to store val at
602                         const TypePtr* adr_type,
603                         Node* val,
604                         const Type* val_type,
605                         BasicType bt,
606                         DecoratorSet decorators,
607                         bool safe_for_replace = true);
608 
609   Node* access_load_at(Node* obj,   // containing obj
610                        Node* adr,   // actual address to load val at
611                        const TypePtr* adr_type,
612                        const Type* val_type,
613                        BasicType bt,
614                        DecoratorSet decorators,
615                        Node* ctl = NULL);
616 
617   Node* access_load(Node* adr,   // actual address to load val at
618                     const Type* val_type,
619                     BasicType bt,
620                     DecoratorSet decorators);
621 
622   Node* access_atomic_cmpxchg_val_at(Node* obj,
623                                      Node* adr,
624                                      const TypePtr* adr_type,
625                                      int alias_idx,
626                                      Node* expected_val,
627                                      Node* new_val,
628                                      const Type* value_type,
629                                      BasicType bt,
630                                      DecoratorSet decorators);
631 
632   Node* access_atomic_cmpxchg_bool_at(Node* obj,
633                                       Node* adr,
634                                       const TypePtr* adr_type,
635                                       int alias_idx,

673   void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);
674   void make_dtrace_method_entry(ciMethod* method) {
675     make_dtrace_method_entry_exit(method, true);
676   }
677   void make_dtrace_method_exit(ciMethod* method) {
678     make_dtrace_method_entry_exit(method, false);
679   }
680 
681   //--------------- stub generation -------------------
682  public:
683   void gen_stub(address C_function,
684                 const char *name,
685                 int is_fancy_jump,
686                 bool pass_tls,
687                 bool return_pc);
688 
689   //---------- help for generating calls --------------
690 
691   // Do a null check on the receiver as it would happen before the call to
692   // callee (with all arguments still on the stack).
693   Node* null_check_receiver_before_call(ciMethod* callee, bool replace_value = true) {
694     assert(!callee->is_static(), "must be a virtual method");
695     // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
696     // Use callsite signature always.
697     ciMethod* declared_method = method()->get_method_at_bci(bci());
698     const int nargs = declared_method->arg_size();
699     inc_sp(nargs);
700     Node* n = null_check_receiver();
701     dec_sp(nargs);
702     return n;
703   }
704 
705   // Fill in argument edges for the call from argument(0), argument(1), ...
706   // (The next step is to call set_edges_for_java_call.)
707   void  set_arguments_for_java_call(CallJavaNode* call, bool is_late_inline = false);
708 
709   // Fill in non-argument edges for the call.
710   // Transform the call, and update the basics: control, i_o, memory.
711   // (The next step is usually to call set_results_for_java_call.)
712   void set_edges_for_java_call(CallJavaNode* call,
713                                bool must_throw = false, bool separate_io_proj = false);
714 
715   // Finish up a java call that was started by set_edges_for_java_call.
716   // Call add_exception on any throw arising from the call.
717   // Return the call result (transformed).
718   Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false);
719 
720   // Similar to set_edges_for_java_call, but simplified for runtime calls.
721   void  set_predefined_output_for_runtime_call(Node* call) {
722     set_predefined_output_for_runtime_call(call, NULL, NULL);
723   }
724   void  set_predefined_output_for_runtime_call(Node* call,
725                                                Node* keep_mem,
726                                                const TypePtr* hook_mem);
727   Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL);

826   void merge_memory(Node* new_mem, Node* region, int new_path);
827   void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false);
828 
829   // Helper functions to build synchronizations
830   int next_monitor();
831   Node* insert_mem_bar(int opcode, Node* precedent = NULL);
832   Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL);
833   // Optional 'precedent' is appended as an extra edge, to force ordering.
834   FastLockNode* shared_lock(Node* obj);
835   void shared_unlock(Node* box, Node* obj);
836 
837   // helper functions for the fast path/slow path idioms
838   Node* fast_and_slow(Node* in, const Type *result_type, Node* null_result, IfNode* fast_test, Node* fast_result, address slow_call, const TypeFunc *slow_call_type, Node* slow_arg, Klass* ex_klass, Node* slow_result);
839 
840   // Generate an instance-of idiom.  Used by both the instance-of bytecode
841   // and the reflective instance-of call.
842   Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false);
843 
844   // Generate a check-cast idiom.  Used by both the check-cast bytecode
845   // and the array-store bytecode
846   Node* gen_checkcast(Node *subobj, Node* superkls, Node* *failure_control = NULL, bool null_free = false);
847 
848   // Inline types
849   Node* inline_type_test(Node* obj, bool is_inline = true);
850   Node* is_val_mirror(Node* mirror);
851   Node* array_lh_test(Node* kls, jint mask, jint val, bool eq = true);
852   Node* flat_array_test(Node* array_or_klass, bool flat = true);
853   Node* null_free_array_test(Node* klass, bool null_free = true);
854   Node* inline_array_null_guard(Node* ary, Node* val, int nargs, bool safe_for_replace = false);
855 
856   Node* gen_subtype_check(Node* obj, Node* superklass);
857 
858   // Exact type check used for predicted calls and casts.
859   // Rewrites (*casted_receiver) to be casted to the stronger type.
860   // (Caller is responsible for doing replace_in_map.)
861   Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
862                             Node* *casted_receiver);
863   Node* type_check(Node* recv_klass, const TypeKlassPtr* tklass, float prob);
864 
865   // Inexact type check used for predicted calls.
866   Node* subtype_check_receiver(Node* receiver, ciKlass* klass,
867                                Node** casted_receiver);
868 
869   // implementation of object creation
870   Node* set_output_for_allocation(AllocateNode* alloc,
871                                   const TypeOopPtr* oop_type,
872                                   bool deoptimize_on_exception=false);
873   Node* get_layout_helper(Node* klass_node, jint& constant_value);
874   Node* new_instance(Node* klass_node,
875                      Node* slow_test = NULL,
876                      Node* *return_size_val = NULL,
877                      bool deoptimize_on_exception = false,
878                      InlineTypeNode* inline_type_node = NULL);
879   Node* new_array(Node* klass_node, Node* count_val, int nargs,
880                   Node* *return_size_val = NULL,
881                   bool deoptimize_on_exception = false);
882 
883   // java.lang.String helpers
884   Node* load_String_length(Node* str, bool set_ctrl);
885   Node* load_String_value(Node* str, bool set_ctrl);
886   Node* load_String_coder(Node* str, bool set_ctrl);
887   void store_String_value(Node* str, Node* value);
888   void store_String_coder(Node* str, Node* value);
889   Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
890   Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
891   void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
892   void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
893 
894   // Handy for making control flow
895   IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
896     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
897     _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time
898     // Place 'if' on worklist if it will be in graph
899     if (!tst->is_Con())  record_for_igvn(iff);     // Range-check and Null-check removal is later
900     return iff;
901   }
902 
903   IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) {
904     IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
905     _gvn.transform(iff);                           // Value may be known at parse-time
906     // Place 'if' on worklist if it will be in graph
907     if (!tst->is_Con())  record_for_igvn(iff);     // Range-check and Null-check removal is later
908     return iff;
909   }
910 
911   void add_empty_predicates(int nargs = 0);
912   void add_empty_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
913 
914   Node* make_constant_from_field(ciField* field, Node* obj);
915   Node* load_mirror_from_klass(Node* klass);
916 
917   // Vector API support (implemented in vectorIntrinsics.cpp)
918   Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false);
919   Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false);
920   Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem);
921 };
922 
923 // Helper class to support building of control flow branches. Upon
924 // creation the map and sp at bci are cloned and restored upon de-
925 // struction. Typical use:
926 //
927 // { PreserveJVMState pjvms(this);
928 //   // code of new branch
929 // }
930 // // here the JVM state at bci is established
931 
932 class PreserveJVMState: public StackObj {
933  protected:
934   GraphKit*      _kit;
935 #ifdef ASSERT
< prev index next >