< 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 != nullptr, "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(failing() || !has_exceptions(),
 86            "unless compilation failed, user must call transfer_exceptions_into_jvms");







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

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

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

589   }
590   // This is the base version which is given alias index
591   // Return the new StoreXNode
592   Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt,
593                         int adr_idx,
594                         MemNode::MemOrd,
595                         bool require_atomic_access = false,
596                         bool unaligned = false,
597                         bool mismatched = false,
598                         bool unsafe = false,
599                         int barrier_data = 0);
600 
601   // Perform decorated accesses
602 
603   Node* access_store_at(Node* obj,   // containing obj
604                         Node* adr,   // actual address to store val at
605                         const TypePtr* adr_type,
606                         Node* val,
607                         const Type* val_type,
608                         BasicType bt,
609                         DecoratorSet decorators);

610 
611   Node* access_load_at(Node* obj,   // containing obj
612                        Node* adr,   // actual address to load val at
613                        const TypePtr* adr_type,
614                        const Type* val_type,
615                        BasicType bt,
616                        DecoratorSet decorators);

617 
618   Node* access_load(Node* adr,   // actual address to load val at
619                     const Type* val_type,
620                     BasicType bt,
621                     DecoratorSet decorators);
622 
623   Node* access_atomic_cmpxchg_val_at(Node* obj,
624                                      Node* adr,
625                                      const TypePtr* adr_type,
626                                      int alias_idx,
627                                      Node* expected_val,
628                                      Node* new_val,
629                                      const Type* value_type,
630                                      BasicType bt,
631                                      DecoratorSet decorators);
632 
633   Node* access_atomic_cmpxchg_bool_at(Node* obj,
634                                       Node* adr,
635                                       const TypePtr* adr_type,
636                                       int alias_idx,

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

827   void merge_memory(Node* new_mem, Node* region, int new_path);
828   void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false);
829 
830   // Helper functions to build synchronizations
831   int next_monitor();
832   Node* insert_mem_bar(int opcode, Node* precedent = nullptr);
833   Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = nullptr);
834   // Optional 'precedent' is appended as an extra edge, to force ordering.
835   FastLockNode* shared_lock(Node* obj);
836   void shared_unlock(Node* box, Node* obj);
837 
838   // helper functions for the fast path/slow path idioms
839   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);
840 
841   // Generate an instance-of idiom.  Used by both the instance-of bytecode
842   // and the reflective instance-of call.
843   Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false);
844 
845   // Generate a check-cast idiom.  Used by both the check-cast bytecode
846   // and the array-store bytecode
847   Node* gen_checkcast( Node *subobj, Node* superkls,
848                        Node* *failure_control = nullptr );






849 
850   Node* gen_subtype_check(Node* obj, Node* superklass);
851 
852   // Exact type check used for predicted calls and casts.
853   // Rewrites (*casted_receiver) to be casted to the stronger type.
854   // (Caller is responsible for doing replace_in_map.)
855   Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
856                             Node* *casted_receiver);

857 
858   // Inexact type check used for predicted calls.
859   Node* subtype_check_receiver(Node* receiver, ciKlass* klass,
860                                Node** casted_receiver);
861 
862   // implementation of object creation
863   Node* set_output_for_allocation(AllocateNode* alloc,
864                                   const TypeOopPtr* oop_type,
865                                   bool deoptimize_on_exception=false);
866   Node* get_layout_helper(Node* klass_node, jint& constant_value);
867   Node* new_instance(Node* klass_node,
868                      Node* slow_test = nullptr,
869                      Node* *return_size_val = nullptr,
870                      bool deoptimize_on_exception = false);

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

907 
908   // Vector API support (implemented in vectorIntrinsics.cpp)
909   Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false);
910   Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false);
911   Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem);
912 };
913 
914 // Helper class to support building of control flow branches. Upon
915 // creation the map and sp at bci are cloned and restored upon de-
916 // struction. Typical use:
917 //
918 // { PreserveJVMState pjvms(this);
919 //   // code of new branch
920 // }
921 // // here the JVM state at bci is established
922 
923 class PreserveJVMState: public StackObj {
924  protected:
925   GraphKit*      _kit;
926 #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 != nullptr, "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 = nullptr);     // the JVM state on which to operate
 86 
 87 #ifdef ASSERT
 88   ~GraphKit() {
 89     assert(failing() || !has_exceptions(),
 90            "unless compilation failed, user must call transfer_exceptions_into_jvms");
 91 #if 0
 92     // During incremental inlining, the Node_Array of the C->for_igvn() worklist and the IGVN
 93     // worklist are shared but the _in_worklist VectorSet is not. To avoid inconsistencies,
 94     // we should not add nodes to the _for_igvn worklist when using IGVN for the GraphKit.
 95     assert((_gvn.is_IterGVN() == nullptr) || (_gvn.C->for_igvn()->size() == _worklist_size),
 96            "GraphKit should not modify _for_igvn worklist after parsing");
 97 #endif
 98   }
 99 #endif
100 
101   virtual Parse*          is_Parse()          const { return nullptr; }
102   virtual LibraryCallKit* is_LibraryCallKit() const { return nullptr; }
103 
104   ciEnv*        env()               const { return _env; }
105   PhaseGVN&     gvn()               const { return _gvn; }
106   void*         barrier_set_state() const { return C->barrier_set_state(); }
107 
108   void record_for_igvn(Node* n) const { _gvn.record_for_igvn(n); }
109   void remove_for_igvn(Node* n) const { C->remove_for_igvn(n); }
110 
111   // Handy well-known nodes:
112   Node*         null()          const { return zerocon(T_OBJECT); }
113   Node*         top()           const { return C->top(); }
114   RootNode*     root()          const { return C->root(); }
115 
116   // Create or find a constant node
117   Node* intcon(jint con)        const { return _gvn.intcon(con); }
118   Node* longcon(jlong con)      const { return _gvn.longcon(con); }
119   Node* integercon(jlong con, BasicType bt)   const {
120     if (bt == T_INT) {
121       return intcon(checked_cast<jint>(con));
122     }
123     assert(bt == T_LONG, "basic type not an int or long");
124     return longcon(con);
125   }
126   Node* makecon(const Type *t)  const { return _gvn.makecon(t); }
127   Node* zerocon(BasicType bt)   const { return _gvn.zerocon(bt); }
128   // (See also macro MakeConX in type.hpp, which uses intcon or longcon.)

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

381     return null_check(argument(0));
382   }
383   Node* zero_check_int(Node* value) {
384     assert(value->bottom_type()->basic_type() == T_INT,
385            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
386     return null_check_common(value, T_INT);
387   }
388   Node* zero_check_long(Node* value) {
389     assert(value->bottom_type()->basic_type() == T_LONG,
390            "wrong type: %s", type2name(value->bottom_type()->basic_type()));
391     return null_check_common(value, T_LONG);
392   }
393   // Throw an uncommon trap if a given value is __not__ null.
394   // Return the value cast to null, and be clever about dominating checks.
395   Node* null_assert(Node* value, BasicType type = T_OBJECT) {
396     return null_check_common(value, type, true, nullptr, _gvn.type(value)->speculative_always_null());
397   }
398 
399   // Check if value is null and abort if it is
400   Node* must_be_not_null(Node* value, bool do_replace_in_map);

600   }
601   // This is the base version which is given alias index
602   // Return the new StoreXNode
603   Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt,
604                         int adr_idx,
605                         MemNode::MemOrd,
606                         bool require_atomic_access = false,
607                         bool unaligned = false,
608                         bool mismatched = false,
609                         bool unsafe = false,
610                         int barrier_data = 0);
611 
612   // Perform decorated accesses
613 
614   Node* access_store_at(Node* obj,   // containing obj
615                         Node* adr,   // actual address to store val at
616                         const TypePtr* adr_type,
617                         Node* val,
618                         const Type* val_type,
619                         BasicType bt,
620                         DecoratorSet decorators,
621                         bool safe_for_replace = true);
622 
623   Node* access_load_at(Node* obj,   // containing obj
624                        Node* adr,   // actual address to load val at
625                        const TypePtr* adr_type,
626                        const Type* val_type,
627                        BasicType bt,
628                        DecoratorSet decorators,
629                        Node* ctl = nullptr);
630 
631   Node* access_load(Node* adr,   // actual address to load val at
632                     const Type* val_type,
633                     BasicType bt,
634                     DecoratorSet decorators);
635 
636   Node* access_atomic_cmpxchg_val_at(Node* obj,
637                                      Node* adr,
638                                      const TypePtr* adr_type,
639                                      int alias_idx,
640                                      Node* expected_val,
641                                      Node* new_val,
642                                      const Type* value_type,
643                                      BasicType bt,
644                                      DecoratorSet decorators);
645 
646   Node* access_atomic_cmpxchg_bool_at(Node* obj,
647                                       Node* adr,
648                                       const TypePtr* adr_type,
649                                       int alias_idx,

701                 bool return_pc);
702 
703   //---------- help for generating calls --------------
704 
705   // Do a null check on the receiver as it would happen before the call to
706   // callee (with all arguments still on the stack).
707   Node* null_check_receiver_before_call(ciMethod* callee) {
708     assert(!callee->is_static(), "must be a virtual method");
709     // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
710     // Use callsite signature always.
711     ciMethod* declared_method = method()->get_method_at_bci(bci());
712     const int nargs = declared_method->arg_size();
713     inc_sp(nargs);
714     Node* n = null_check_receiver();
715     dec_sp(nargs);
716     return n;
717   }
718 
719   // Fill in argument edges for the call from argument(0), argument(1), ...
720   // (The next step is to call set_edges_for_java_call.)
721   void  set_arguments_for_java_call(CallJavaNode* call, bool is_late_inline = false);
722 
723   // Fill in non-argument edges for the call.
724   // Transform the call, and update the basics: control, i_o, memory.
725   // (The next step is usually to call set_results_for_java_call.)
726   void set_edges_for_java_call(CallJavaNode* call,
727                                bool must_throw = false, bool separate_io_proj = false);
728 
729   // Finish up a java call that was started by set_edges_for_java_call.
730   // Call add_exception on any throw arising from the call.
731   // Return the call result (transformed).
732   Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false);
733 
734   // Similar to set_edges_for_java_call, but simplified for runtime calls.
735   void  set_predefined_output_for_runtime_call(Node* call) {
736     set_predefined_output_for_runtime_call(call, nullptr, nullptr);
737   }
738   void  set_predefined_output_for_runtime_call(Node* call,
739                                                Node* keep_mem,
740                                                const TypePtr* hook_mem);
741   Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = nullptr);

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