46 return (offset == 0)? ptr: basic_plus_adr(base, ptr, MakeConX(offset));
47 }
48 Node* basic_plus_adr(Node* base, Node* offset) {
49 return basic_plus_adr(base, base, offset);
50 }
51 Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) {
52 Node* adr = new AddPNode(base, ptr, offset);
53 return transform_later(adr);
54 }
55 Node* transform_later(Node* n) {
56 // equivalent to _gvn.transform in GraphKit, Ideal, etc.
57 _igvn.register_new_node_with_optimizer(n);
58 return n;
59 }
60 void set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr);
61 Node* make_load( Node* ctl, Node* mem, Node* base, int offset,
62 const Type* value_type, BasicType bt);
63 Node* make_store(Node* ctl, Node* mem, Node* base, int offset,
64 Node* value, BasicType bt);
65
66 private:
67 // projections extracted from a call node
68 ProjNode *_fallthroughproj;
69 ProjNode *_fallthroughcatchproj;
70 ProjNode *_ioproj_fallthrough;
71 ProjNode *_ioproj_catchall;
72 ProjNode *_catchallcatchproj;
73 ProjNode *_memproj_fallthrough;
74 ProjNode *_memproj_catchall;
75 ProjNode *_resproj;
76
77 // Additional data collected during macro expansion
78 bool _has_locks;
79
80 void expand_allocate(AllocateNode *alloc);
81 void expand_allocate_array(AllocateArrayNode *alloc);
82 void expand_allocate_common(AllocateNode* alloc,
83 Node* length,
84 const TypeFunc* slow_call_type,
85 address slow_call_address);
86 Node *value_from_mem(Node *mem, Node *ctl, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc);
87 Node *value_from_mem_phi(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc, Node_Stack *value_phis, int level);
88
89 bool eliminate_boxing_node(CallStaticJavaNode *boxing);
90 bool eliminate_allocate_node(AllocateNode *alloc);
91 bool can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints);
92 bool scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints_done);
93 void process_users_of_allocation(CallNode *alloc);
94
95 void eliminate_gc_barrier(Node *p2x);
96 void mark_eliminated_box(Node* box, Node* obj);
97 void mark_eliminated_locking_nodes(AbstractLockNode *alock);
98 bool eliminate_locking_node(AbstractLockNode *alock);
99 void expand_lock_node(LockNode *lock);
100 void expand_unlock_node(UnlockNode *unlock);
101
102 // More helper methods modeled after GraphKit for array copy
103 void insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent = NULL);
104 Node* array_element_address(Node* ary, Node* idx, BasicType elembt);
105 Node* ConvI2L(Node* offset);
106 Node* make_leaf_call(Node* ctrl, Node* mem,
107 const TypeFunc* call_type, address call_addr,
108 const char* call_name,
109 const TypePtr* adr_type,
110 Node* parm0 = NULL, Node* parm1 = NULL,
111 Node* parm2 = NULL, Node* parm3 = NULL,
112 Node* parm4 = NULL, Node* parm5 = NULL,
113 Node* parm6 = NULL, Node* parm7 = NULL);
114
115 // helper methods modeled after LibraryCallKit for array copy
116 Node* generate_guard(Node** ctrl, Node* test, RegionNode* region, float true_prob);
117 Node* generate_slow_guard(Node** ctrl, Node* test, RegionNode* region);
118 void generate_negative_guard(Node** ctrl, Node* index, RegionNode* region);
119 void generate_limit_guard(Node** ctrl, Node* offset, Node* subseq_length, Node* array_length, RegionNode* region);
120
121 // More helper methods for array copy
122 Node* generate_nonpositive_guard(Node** ctrl, Node* index, bool never_negative);
123 void finish_arraycopy_call(Node* call, Node** ctrl, MergeMemNode** mem, const TypePtr* adr_type);
124 address basictype2arraycopy(BasicType t,
125 Node* src_offset,
126 Node* dest_offset,
127 bool disjoint_bases,
128 const char* &name,
129 bool dest_uninitialized);
130 Node* generate_arraycopy(ArrayCopyNode *ac,
131 AllocateArrayNode* alloc,
132 Node** ctrl, MergeMemNode* mem, Node** io,
133 const TypePtr* adr_type,
134 BasicType basic_elem_type,
135 Node* src, Node* src_offset,
136 Node* dest, Node* dest_offset,
137 Node* copy_length,
138 bool disjoint_bases = false,
139 bool length_never_negative = false,
140 RegionNode* slow_region = NULL);
141 void generate_clear_array(Node* ctrl, MergeMemNode* merge_mem,
142 const TypePtr* adr_type,
143 Node* dest,
144 BasicType basic_elem_type,
145 Node* slice_idx,
146 Node* slice_len,
147 Node* dest_size);
148 bool generate_block_arraycopy(Node** ctrl, MergeMemNode** mem, Node* io,
149 const TypePtr* adr_type,
|
46 return (offset == 0)? ptr: basic_plus_adr(base, ptr, MakeConX(offset));
47 }
48 Node* basic_plus_adr(Node* base, Node* offset) {
49 return basic_plus_adr(base, base, offset);
50 }
51 Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) {
52 Node* adr = new AddPNode(base, ptr, offset);
53 return transform_later(adr);
54 }
55 Node* transform_later(Node* n) {
56 // equivalent to _gvn.transform in GraphKit, Ideal, etc.
57 _igvn.register_new_node_with_optimizer(n);
58 return n;
59 }
60 void set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr);
61 Node* make_load( Node* ctl, Node* mem, Node* base, int offset,
62 const Type* value_type, BasicType bt);
63 Node* make_store(Node* ctl, Node* mem, Node* base, int offset,
64 Node* value, BasicType bt);
65
66 Node* make_leaf_call(Node* ctrl, Node* mem,
67 const TypeFunc* call_type, address call_addr,
68 const char* call_name,
69 const TypePtr* adr_type,
70 Node* parm0 = NULL, Node* parm1 = NULL,
71 Node* parm2 = NULL, Node* parm3 = NULL,
72 Node* parm4 = NULL, Node* parm5 = NULL,
73 Node* parm6 = NULL, Node* parm7 = NULL);
74
75 address basictype2arraycopy(BasicType t,
76 Node* src_offset,
77 Node* dest_offset,
78 bool disjoint_bases,
79 const char* &name,
80 bool dest_uninitialized);
81
82 private:
83 // projections extracted from a call node
84 ProjNode *_fallthroughproj;
85 ProjNode *_fallthroughcatchproj;
86 ProjNode *_ioproj_fallthrough;
87 ProjNode *_ioproj_catchall;
88 ProjNode *_catchallcatchproj;
89 ProjNode *_memproj_fallthrough;
90 ProjNode *_memproj_catchall;
91 ProjNode *_resproj;
92
93 // Additional data collected during macro expansion
94 bool _has_locks;
95
96 void expand_allocate(AllocateNode *alloc);
97 void expand_allocate_array(AllocateArrayNode *alloc);
98 void expand_allocate_common(AllocateNode* alloc,
99 Node* length,
100 const TypeFunc* slow_call_type,
101 address slow_call_address);
102 Node *value_from_mem(Node *mem, Node *ctl, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc);
103 Node *value_from_mem_phi(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc, Node_Stack *value_phis, int level);
104
105 bool eliminate_boxing_node(CallStaticJavaNode *boxing);
106 bool eliminate_allocate_node(AllocateNode *alloc);
107 bool can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints);
108 bool scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints_done);
109 void process_users_of_allocation(CallNode *alloc);
110
111 void eliminate_gc_barrier(Node *p2x);
112 void mark_eliminated_box(Node* box, Node* obj);
113 void mark_eliminated_locking_nodes(AbstractLockNode *alock);
114 bool eliminate_locking_node(AbstractLockNode *alock);
115 void expand_lock_node(LockNode *lock);
116 void expand_unlock_node(UnlockNode *unlock);
117
118 // More helper methods modeled after GraphKit for array copy
119 void insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent = NULL);
120 Node* array_element_address(Node* ary, Node* idx, BasicType elembt);
121 Node* ConvI2L(Node* offset);
122
123 // helper methods modeled after LibraryCallKit for array copy
124 Node* generate_guard(Node** ctrl, Node* test, RegionNode* region, float true_prob);
125 Node* generate_slow_guard(Node** ctrl, Node* test, RegionNode* region);
126 void generate_negative_guard(Node** ctrl, Node* index, RegionNode* region);
127 void generate_limit_guard(Node** ctrl, Node* offset, Node* subseq_length, Node* array_length, RegionNode* region);
128
129 // More helper methods for array copy
130 Node* generate_nonpositive_guard(Node** ctrl, Node* index, bool never_negative);
131 void finish_arraycopy_call(Node* call, Node** ctrl, MergeMemNode** mem, const TypePtr* adr_type);
132 Node* generate_arraycopy(ArrayCopyNode *ac,
133 AllocateArrayNode* alloc,
134 Node** ctrl, MergeMemNode* mem, Node** io,
135 const TypePtr* adr_type,
136 BasicType basic_elem_type,
137 Node* src, Node* src_offset,
138 Node* dest, Node* dest_offset,
139 Node* copy_length,
140 bool disjoint_bases = false,
141 bool length_never_negative = false,
142 RegionNode* slow_region = NULL);
143 void generate_clear_array(Node* ctrl, MergeMemNode* merge_mem,
144 const TypePtr* adr_type,
145 Node* dest,
146 BasicType basic_elem_type,
147 Node* slice_idx,
148 Node* slice_len,
149 Node* dest_size);
150 bool generate_block_arraycopy(Node** ctrl, MergeMemNode** mem, Node* io,
151 const TypePtr* adr_type,
|