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);
580 }
581 // This is the base version which is given alias index
582 // Return the new StoreXNode
583 Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt,
584 int adr_idx,
585 MemNode::MemOrd,
586 bool require_atomic_access = false,
587 bool unaligned = false,
588 bool mismatched = false,
589 bool unsafe = false,
590 int barrier_data = 0);
591
592 // Perform decorated accesses
593
594 Node* access_store_at(Node* obj, // containing obj
595 Node* adr, // actual address to store val at
596 const TypePtr* adr_type,
597 Node* val,
598 const Type* val_type,
599 BasicType bt,
600 DecoratorSet decorators);
601
602 Node* access_load_at(Node* obj, // containing obj
603 Node* adr, // actual address to load val at
604 const TypePtr* adr_type,
605 const Type* val_type,
606 BasicType bt,
607 DecoratorSet decorators);
608
609 Node* access_load(Node* adr, // actual address to load val at
610 const Type* val_type,
611 BasicType bt,
612 DecoratorSet decorators);
613
614 Node* access_atomic_cmpxchg_val_at(Node* obj,
615 Node* adr,
616 const TypePtr* adr_type,
617 int alias_idx,
618 Node* expected_val,
619 Node* new_val,
620 const Type* value_type,
621 BasicType bt,
622 DecoratorSet decorators);
623
624 Node* access_atomic_cmpxchg_bool_at(Node* obj,
625 Node* adr,
626 const TypePtr* adr_type,
627 int alias_idx,
665 void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);
666 void make_dtrace_method_entry(ciMethod* method) {
667 make_dtrace_method_entry_exit(method, true);
668 }
669 void make_dtrace_method_exit(ciMethod* method) {
670 make_dtrace_method_entry_exit(method, false);
671 }
672
673 //--------------- stub generation -------------------
674 public:
675 void gen_stub(address C_function,
676 const char *name,
677 int is_fancy_jump,
678 bool pass_tls,
679 bool return_pc);
680
681 //---------- help for generating calls --------------
682
683 // Do a null check on the receiver as it would happen before the call to
684 // callee (with all arguments still on the stack).
685 Node* null_check_receiver_before_call(ciMethod* callee) {
686 assert(!callee->is_static(), "must be a virtual method");
687 // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
688 // Use callsite signature always.
689 ciMethod* declared_method = method()->get_method_at_bci(bci());
690 const int nargs = declared_method->arg_size();
691 inc_sp(nargs);
692 Node* n = null_check_receiver();
693 dec_sp(nargs);
694 return n;
695 }
696
697 // Fill in argument edges for the call from argument(0), argument(1), ...
698 // (The next step is to call set_edges_for_java_call.)
699 void set_arguments_for_java_call(CallJavaNode* call);
700
701 // Fill in non-argument edges for the call.
702 // Transform the call, and update the basics: control, i_o, memory.
703 // (The next step is usually to call set_results_for_java_call.)
704 void set_edges_for_java_call(CallJavaNode* call,
705 bool must_throw = false, bool separate_io_proj = false);
706
707 // Finish up a java call that was started by set_edges_for_java_call.
708 // Call add_exception on any throw arising from the call.
709 // Return the call result (transformed).
710 Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false);
711
712 // Similar to set_edges_for_java_call, but simplified for runtime calls.
713 void set_predefined_output_for_runtime_call(Node* call) {
714 set_predefined_output_for_runtime_call(call, NULL, NULL);
715 }
716 void set_predefined_output_for_runtime_call(Node* call,
717 Node* keep_mem,
718 const TypePtr* hook_mem);
719 Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL);
818 void merge_memory(Node* new_mem, Node* region, int new_path);
819 void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false);
820
821 // Helper functions to build synchronizations
822 int next_monitor();
823 Node* insert_mem_bar(int opcode, Node* precedent = NULL);
824 Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL);
825 // Optional 'precedent' is appended as an extra edge, to force ordering.
826 FastLockNode* shared_lock(Node* obj);
827 void shared_unlock(Node* box, Node* obj);
828
829 // helper functions for the fast path/slow path idioms
830 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);
831
832 // Generate an instance-of idiom. Used by both the instance-of bytecode
833 // and the reflective instance-of call.
834 Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false);
835
836 // Generate a check-cast idiom. Used by both the check-cast bytecode
837 // and the array-store bytecode
838 Node* gen_checkcast( Node *subobj, Node* superkls,
839 Node* *failure_control = NULL );
840
841 Node* gen_subtype_check(Node* obj, Node* superklass);
842
843 // Exact type check used for predicted calls and casts.
844 // Rewrites (*casted_receiver) to be casted to the stronger type.
845 // (Caller is responsible for doing replace_in_map.)
846 Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
847 Node* *casted_receiver);
848
849 // Inexact type check used for predicted calls.
850 Node* subtype_check_receiver(Node* receiver, ciKlass* klass,
851 Node** casted_receiver);
852
853 // implementation of object creation
854 Node* set_output_for_allocation(AllocateNode* alloc,
855 const TypeOopPtr* oop_type,
856 bool deoptimize_on_exception=false);
857 Node* get_layout_helper(Node* klass_node, jint& constant_value);
858 Node* new_instance(Node* klass_node,
859 Node* slow_test = NULL,
860 Node* *return_size_val = NULL,
861 bool deoptimize_on_exception = false);
862 Node* new_array(Node* klass_node, Node* count_val, int nargs,
863 Node* *return_size_val = NULL,
864 bool deoptimize_on_exception = false);
865
866 // java.lang.String helpers
867 Node* load_String_length(Node* str, bool set_ctrl);
868 Node* load_String_value(Node* str, bool set_ctrl);
869 Node* load_String_coder(Node* str, bool set_ctrl);
870 void store_String_value(Node* str, Node* value);
871 void store_String_coder(Node* str, Node* value);
872 Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
873 Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
874 void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
875 void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
876
877 // Handy for making control flow
878 IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
879 IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
880 _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time
881 // Place 'if' on worklist if it will be in graph
882 if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later
883 return iff;
884 }
885
886 IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) {
887 IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
888 _gvn.transform(iff); // Value may be known at parse-time
889 // Place 'if' on worklist if it will be in graph
890 if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later
891 return iff;
892 }
893
894 void add_empty_predicates(int nargs = 0);
895 void add_empty_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
896
897 Node* make_constant_from_field(ciField* field, Node* obj);
898
899 // Vector API support (implemented in vectorIntrinsics.cpp)
900 Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false);
901 Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false);
902 Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem);
903 };
904
905 // Helper class to support building of control flow branches. Upon
906 // creation the map and sp at bci are cloned and restored upon de-
907 // struction. Typical use:
908 //
909 // { PreserveJVMState pjvms(this);
910 // // code of new branch
911 // }
912 // // here the JVM state at bci is established
913
914 class PreserveJVMState: public StackObj {
915 protected:
916 GraphKit* _kit;
917 #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);
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 bool safe_for_replace = true);
611
612 Node* access_load_at(Node* obj, // containing obj
613 Node* adr, // actual address to load val at
614 const TypePtr* adr_type,
615 const Type* val_type,
616 BasicType bt,
617 DecoratorSet decorators,
618 Node* ctl = NULL);
619
620 Node* access_load(Node* adr, // actual address to load val at
621 const Type* val_type,
622 BasicType bt,
623 DecoratorSet decorators);
624
625 Node* access_atomic_cmpxchg_val_at(Node* obj,
626 Node* adr,
627 const TypePtr* adr_type,
628 int alias_idx,
629 Node* expected_val,
630 Node* new_val,
631 const Type* value_type,
632 BasicType bt,
633 DecoratorSet decorators);
634
635 Node* access_atomic_cmpxchg_bool_at(Node* obj,
636 Node* adr,
637 const TypePtr* adr_type,
638 int alias_idx,
676 void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);
677 void make_dtrace_method_entry(ciMethod* method) {
678 make_dtrace_method_entry_exit(method, true);
679 }
680 void make_dtrace_method_exit(ciMethod* method) {
681 make_dtrace_method_entry_exit(method, false);
682 }
683
684 //--------------- stub generation -------------------
685 public:
686 void gen_stub(address C_function,
687 const char *name,
688 int is_fancy_jump,
689 bool pass_tls,
690 bool return_pc);
691
692 //---------- help for generating calls --------------
693
694 // Do a null check on the receiver as it would happen before the call to
695 // callee (with all arguments still on the stack).
696 Node* null_check_receiver_before_call(ciMethod* callee, bool replace_value = true) {
697 assert(!callee->is_static(), "must be a virtual method");
698 // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
699 // Use callsite signature always.
700 ciMethod* declared_method = method()->get_method_at_bci(bci());
701 const int nargs = declared_method->arg_size();
702 inc_sp(nargs);
703 Node* n = null_check_receiver();
704 dec_sp(nargs);
705 return n;
706 }
707
708 // Fill in argument edges for the call from argument(0), argument(1), ...
709 // (The next step is to call set_edges_for_java_call.)
710 void set_arguments_for_java_call(CallJavaNode* call, bool is_late_inline = false);
711
712 // Fill in non-argument edges for the call.
713 // Transform the call, and update the basics: control, i_o, memory.
714 // (The next step is usually to call set_results_for_java_call.)
715 void set_edges_for_java_call(CallJavaNode* call,
716 bool must_throw = false, bool separate_io_proj = false);
717
718 // Finish up a java call that was started by set_edges_for_java_call.
719 // Call add_exception on any throw arising from the call.
720 // Return the call result (transformed).
721 Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false);
722
723 // Similar to set_edges_for_java_call, but simplified for runtime calls.
724 void set_predefined_output_for_runtime_call(Node* call) {
725 set_predefined_output_for_runtime_call(call, NULL, NULL);
726 }
727 void set_predefined_output_for_runtime_call(Node* call,
728 Node* keep_mem,
729 const TypePtr* hook_mem);
730 Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL);
829 void merge_memory(Node* new_mem, Node* region, int new_path);
830 void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false);
831
832 // Helper functions to build synchronizations
833 int next_monitor();
834 Node* insert_mem_bar(int opcode, Node* precedent = NULL);
835 Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL);
836 // Optional 'precedent' is appended as an extra edge, to force ordering.
837 FastLockNode* shared_lock(Node* obj);
838 void shared_unlock(Node* box, Node* obj);
839
840 // helper functions for the fast path/slow path idioms
841 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);
842
843 // Generate an instance-of idiom. Used by both the instance-of bytecode
844 // and the reflective instance-of call.
845 Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false);
846
847 // Generate a check-cast idiom. Used by both the check-cast bytecode
848 // and the array-store bytecode
849 Node* gen_checkcast(Node *subobj, Node* superkls, Node* *failure_control = NULL, bool null_free = false);
850
851 // Inline types
852 Node* inline_type_test(Node* obj, bool is_inline = true);
853 Node* is_val_mirror(Node* mirror);
854 Node* array_lh_test(Node* kls, jint mask, jint val, bool eq = true);
855 Node* flat_array_test(Node* array_or_klass, bool flat = true);
856 Node* null_free_array_test(Node* klass, bool null_free = true);
857 Node* inline_array_null_guard(Node* ary, Node* val, int nargs, bool safe_for_replace = false);
858
859 Node* gen_subtype_check(Node* obj, Node* superklass);
860
861 // Exact type check used for predicted calls and casts.
862 // Rewrites (*casted_receiver) to be casted to the stronger type.
863 // (Caller is responsible for doing replace_in_map.)
864 Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob,
865 Node* *casted_receiver);
866 Node* type_check(Node* recv_klass, const TypeKlassPtr* tklass, float prob);
867
868 // Inexact type check used for predicted calls.
869 Node* subtype_check_receiver(Node* receiver, ciKlass* klass,
870 Node** casted_receiver);
871
872 // implementation of object creation
873 Node* set_output_for_allocation(AllocateNode* alloc,
874 const TypeOopPtr* oop_type,
875 bool deoptimize_on_exception=false);
876 Node* get_layout_helper(Node* klass_node, jint& constant_value);
877 Node* new_instance(Node* klass_node,
878 Node* slow_test = NULL,
879 Node* *return_size_val = NULL,
880 bool deoptimize_on_exception = false,
881 InlineTypeNode* inline_type_node = NULL);
882 Node* new_array(Node* klass_node, Node* count_val, int nargs,
883 Node* *return_size_val = NULL,
884 bool deoptimize_on_exception = false);
885
886 // java.lang.String helpers
887 Node* load_String_length(Node* str, bool set_ctrl);
888 Node* load_String_value(Node* str, bool set_ctrl);
889 Node* load_String_coder(Node* str, bool set_ctrl);
890 void store_String_value(Node* str, Node* value);
891 void store_String_coder(Node* str, Node* value);
892 Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
893 Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
894 void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
895 void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count);
896
897 // Handy for making control flow
898 IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) {
899 IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
900 _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time
901 // Place 'if' on worklist if it will be in graph
902 if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later
903 return iff;
904 }
905
906 IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) {
907 IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's
908 _gvn.transform(iff); // Value may be known at parse-time
909 // Place 'if' on worklist if it will be in graph
910 if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later
911 return iff;
912 }
913
914 void add_empty_predicates(int nargs = 0);
915 void add_empty_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
916
917 Node* make_constant_from_field(ciField* field, Node* obj);
918 Node* load_mirror_from_klass(Node* klass);
919
920 // Vector API support (implemented in vectorIntrinsics.cpp)
921 Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false);
922 Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false);
923 Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem);
924 };
925
926 // Helper class to support building of control flow branches. Upon
927 // creation the map and sp at bci are cloned and restored upon de-
928 // struction. Typical use:
929 //
930 // { PreserveJVMState pjvms(this);
931 // // code of new branch
932 // }
933 // // here the JVM state at bci is established
934
935 class PreserveJVMState: public StackObj {
936 protected:
937 GraphKit* _kit;
938 #ifdef ASSERT
|