125 // Implementation of IRScope
126 BlockBegin* IRScope::build_graph(Compilation* compilation, int osr_bci) {
127 GraphBuilder gm(compilation, this);
128 NOT_PRODUCT(if (PrintValueNumbering && Verbose) gm.print_stats());
129 if (compilation->bailed_out()) return nullptr;
130 return gm.start();
131 }
132
133
134 IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph)
135 : _compilation(compilation)
136 , _callees(2)
137 , _requires_phi_function(method->max_locals())
138 {
139 _caller = caller;
140 _level = caller == nullptr ? 0 : caller->level() + 1;
141 _method = method;
142 _xhandlers = new XHandlers(method);
143 _number_of_locks = 0;
144 _monitor_pairing_ok = method->has_balanced_monitors();
145 _wrote_final = false;
146 _wrote_fields = false;
147 _wrote_volatile = false;
148 _wrote_stable = false;
149 _start = nullptr;
150
151 if (osr_bci != -1) {
152 // selective creation of phi functions is not possibel in osr-methods
153 _requires_phi_function.set_range(0, method->max_locals());
154 }
155
156 assert(method->holder()->is_loaded() , "method holder must be loaded");
157
158 // build graph if monitor pairing is ok
159 if (create_graph && monitor_pairing_ok()) _start = build_graph(compilation, osr_bci);
160 }
161
162
163 int IRScope::max_stack() const {
164 int my_max = method()->max_stack();
165 int callee_max = 0;
166 for (int i = 0; i < number_of_callees(); i++) {
167 callee_max = MAX2(callee_max, callee_no(i)->max_stack());
168 }
169 return my_max + callee_max;
170 }
171
172
173 bool IRScopeDebugInfo::should_reexecute() {
174 ciMethod* cur_method = scope()->method();
175 int cur_bci = bci();
176 if (cur_method != nullptr && cur_bci != SynchronizationEntryBCI) {
177 Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
178 return Interpreter::bytecode_should_reexecute(code);
179 } else
180 return false;
181 }
182
183
184 // Implementation of CodeEmitInfo
185
186 // Stack must be NON-null
187 CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception)
188 : _scope_debug_info(nullptr)
189 , _scope(stack->scope())
190 , _exception_handlers(exception_handlers)
191 , _oop_map(nullptr)
192 , _stack(stack)
193 , _deoptimize_on_exception(deoptimize_on_exception)
195 assert(_stack != nullptr, "must be non null");
196 }
197
198
199 CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
200 : _scope_debug_info(nullptr)
201 , _scope(info->_scope)
202 , _exception_handlers(nullptr)
203 , _oop_map(nullptr)
204 , _stack(stack == nullptr ? info->_stack : stack)
205 , _deoptimize_on_exception(info->_deoptimize_on_exception)
206 , _force_reexecute(info->_force_reexecute) {
207
208 // deep copy of exception handlers
209 if (info->_exception_handlers != nullptr) {
210 _exception_handlers = new XHandlers(info->_exception_handlers);
211 }
212 }
213
214
215 void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset) {
216 // record the safepoint before recording the debug info for enclosing scopes
217 recorder->add_safepoint(pc_offset, _oop_map->deep_copy());
218 bool reexecute = _force_reexecute || _scope_debug_info->should_reexecute();
219 _scope_debug_info->record_debug_info(recorder, pc_offset, reexecute);
220 recorder->end_safepoint(pc_offset);
221 }
222
223
224 void CodeEmitInfo::add_register_oop(LIR_Opr opr) {
225 assert(_oop_map != nullptr, "oop map must already exist");
226 assert(opr->is_single_cpu(), "should not call otherwise");
227
228 VMReg name = frame_map()->regname(opr);
229 _oop_map->set_oop(name);
230 }
231
232 // Mirror the stack size calculation in the deopt code
233 // How much stack space would we need at this point in the program in
234 // case of deoptimization?
235 int CodeEmitInfo::interpreter_frame_size() const {
236 ValueStack* state = _stack;
237 int size = 0;
238 int callee_parameters = 0;
239 int callee_locals = 0;
|
125 // Implementation of IRScope
126 BlockBegin* IRScope::build_graph(Compilation* compilation, int osr_bci) {
127 GraphBuilder gm(compilation, this);
128 NOT_PRODUCT(if (PrintValueNumbering && Verbose) gm.print_stats());
129 if (compilation->bailed_out()) return nullptr;
130 return gm.start();
131 }
132
133
134 IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph)
135 : _compilation(compilation)
136 , _callees(2)
137 , _requires_phi_function(method->max_locals())
138 {
139 _caller = caller;
140 _level = caller == nullptr ? 0 : caller->level() + 1;
141 _method = method;
142 _xhandlers = new XHandlers(method);
143 _number_of_locks = 0;
144 _monitor_pairing_ok = method->has_balanced_monitors();
145 _wrote_non_strict_final = false;
146 _wrote_fields = false;
147 _wrote_volatile = false;
148 _wrote_stable = false;
149 _start = nullptr;
150
151 if (osr_bci != -1) {
152 // selective creation of phi functions is not possibel in osr-methods
153 _requires_phi_function.set_range(0, method->max_locals());
154 }
155
156 assert(method->holder()->is_loaded() , "method holder must be loaded");
157
158 // build graph if monitor pairing is ok
159 if (create_graph && monitor_pairing_ok()) _start = build_graph(compilation, osr_bci);
160 }
161
162
163 int IRScope::max_stack() const {
164 int my_max = method()->max_stack();
165 int callee_max = 0;
166 for (int i = 0; i < number_of_callees(); i++) {
167 callee_max = MAX2(callee_max, callee_no(i)->max_stack());
168 }
169 return my_max + callee_max;
170 }
171
172
173 bool IRScopeDebugInfo::should_reexecute() {
174 if (_should_reexecute) {
175 return true;
176 }
177 ciMethod* cur_method = scope()->method();
178 int cur_bci = bci();
179 if (cur_method != nullptr && cur_bci != SynchronizationEntryBCI) {
180 Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
181 return Interpreter::bytecode_should_reexecute(code);
182 } else
183 return false;
184 }
185
186
187 // Implementation of CodeEmitInfo
188
189 // Stack must be NON-null
190 CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception)
191 : _scope_debug_info(nullptr)
192 , _scope(stack->scope())
193 , _exception_handlers(exception_handlers)
194 , _oop_map(nullptr)
195 , _stack(stack)
196 , _deoptimize_on_exception(deoptimize_on_exception)
198 assert(_stack != nullptr, "must be non null");
199 }
200
201
202 CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
203 : _scope_debug_info(nullptr)
204 , _scope(info->_scope)
205 , _exception_handlers(nullptr)
206 , _oop_map(nullptr)
207 , _stack(stack == nullptr ? info->_stack : stack)
208 , _deoptimize_on_exception(info->_deoptimize_on_exception)
209 , _force_reexecute(info->_force_reexecute) {
210
211 // deep copy of exception handlers
212 if (info->_exception_handlers != nullptr) {
213 _exception_handlers = new XHandlers(info->_exception_handlers);
214 }
215 }
216
217
218 void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool maybe_return_as_fields) {
219 // record the safepoint before recording the debug info for enclosing scopes
220 recorder->add_safepoint(pc_offset, _oop_map->deep_copy());
221 bool reexecute = _force_reexecute || _scope_debug_info->should_reexecute();
222 _scope_debug_info->record_debug_info(recorder, pc_offset, reexecute, maybe_return_as_fields);
223 recorder->end_safepoint(pc_offset);
224 }
225
226
227 void CodeEmitInfo::add_register_oop(LIR_Opr opr) {
228 assert(_oop_map != nullptr, "oop map must already exist");
229 assert(opr->is_single_cpu(), "should not call otherwise");
230
231 VMReg name = frame_map()->regname(opr);
232 _oop_map->set_oop(name);
233 }
234
235 // Mirror the stack size calculation in the deopt code
236 // How much stack space would we need at this point in the program in
237 // case of deoptimization?
238 int CodeEmitInfo::interpreter_frame_size() const {
239 ValueStack* state = _stack;
240 int size = 0;
241 int callee_parameters = 0;
242 int callee_locals = 0;
|