191 // Figure out whether we have to preserve expression stack elements
192 // for parent scopes, and if so, how many
193 IRScope* cur_scope = this;
194 while (cur_scope != NULL && !cur_scope->xhandlers()->has_handlers()) {
195 cur_scope = cur_scope->caller();
196 }
197 _lock_stack_size = (cur_scope == NULL ? 0 :
198 (cur_scope->caller_state() == NULL ? 0 :
199 cur_scope->caller_state()->stack_size()));
200 }
201
202 int IRScope::top_scope_bci() const {
203 assert(!is_top_scope(), "no correct answer for top scope possible");
204 const IRScope* scope = this;
205 while (!scope->caller()->is_top_scope()) {
206 scope = scope->caller();
207 }
208 return scope->caller_bci();
209 }
210
211
212
213 // Implementation of CodeEmitInfo
214
215 // Stack must be NON-null
216 CodeEmitInfo::CodeEmitInfo(int bci, ValueStack* stack, XHandlers* exception_handlers)
217 : _scope(stack->scope())
218 , _bci(bci)
219 , _scope_debug_info(NULL)
220 , _oop_map(NULL)
221 , _stack(stack)
222 , _exception_handlers(exception_handlers)
223 , _next(NULL)
224 , _id(-1) {
225 assert(_stack != NULL, "must be non null");
226 assert(_bci == SynchronizationEntryBCI || Bytecodes::is_defined(scope()->method()->java_code_at_bci(_bci)), "make sure bci points at a real bytecode");
227 }
228
229
230 CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, bool lock_stack_only)
236 if (lock_stack_only) {
237 if (info->_stack != NULL) {
238 _stack = info->_stack->copy_locks();
239 } else {
240 _stack = NULL;
241 }
242 } else {
243 _stack = info->_stack;
244 }
245
246 // deep copy of exception handlers
247 if (info->_exception_handlers != NULL) {
248 _exception_handlers = new XHandlers(info->_exception_handlers);
249 }
250 }
251
252
253 void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset) {
254 // record the safepoint before recording the debug info for enclosing scopes
255 recorder->add_safepoint(pc_offset, _oop_map->deep_copy());
256 _scope_debug_info->record_debug_info(recorder, pc_offset);
257 recorder->end_safepoint(pc_offset);
258 }
259
260
261 void CodeEmitInfo::add_register_oop(LIR_Opr opr) {
262 assert(_oop_map != NULL, "oop map must already exist");
263 assert(opr->is_single_cpu(), "should not call otherwise");
264
265 int frame_size = frame_map()->framesize();
266 int arg_count = frame_map()->oop_map_arg_count();
267 VMReg name = frame_map()->regname(opr);
268 _oop_map->set_oop(name);
269 }
270
271
272
273
274 // Implementation of IR
275
276 IR::IR(Compilation* compilation, ciMethod* method, int osr_bci) :
|
191 // Figure out whether we have to preserve expression stack elements
192 // for parent scopes, and if so, how many
193 IRScope* cur_scope = this;
194 while (cur_scope != NULL && !cur_scope->xhandlers()->has_handlers()) {
195 cur_scope = cur_scope->caller();
196 }
197 _lock_stack_size = (cur_scope == NULL ? 0 :
198 (cur_scope->caller_state() == NULL ? 0 :
199 cur_scope->caller_state()->stack_size()));
200 }
201
202 int IRScope::top_scope_bci() const {
203 assert(!is_top_scope(), "no correct answer for top scope possible");
204 const IRScope* scope = this;
205 while (!scope->caller()->is_top_scope()) {
206 scope = scope->caller();
207 }
208 return scope->caller_bci();
209 }
210
211 bool IRScopeDebugInfo::should_reexecute() {
212 ciMethod* cur_method = scope()->method();
213 int cur_bci = bci();
214 if (cur_method != NULL && cur_bci != SynchronizationEntryBCI) {
215 Bytecodes::Code code = cur_method->java_code_at_bci(cur_bci);
216 return Interpreter::bytecodes_to_reexecute(code);
217 } else
218 return false;
219 }
220
221
222 // Implementation of CodeEmitInfo
223
224 // Stack must be NON-null
225 CodeEmitInfo::CodeEmitInfo(int bci, ValueStack* stack, XHandlers* exception_handlers)
226 : _scope(stack->scope())
227 , _bci(bci)
228 , _scope_debug_info(NULL)
229 , _oop_map(NULL)
230 , _stack(stack)
231 , _exception_handlers(exception_handlers)
232 , _next(NULL)
233 , _id(-1) {
234 assert(_stack != NULL, "must be non null");
235 assert(_bci == SynchronizationEntryBCI || Bytecodes::is_defined(scope()->method()->java_code_at_bci(_bci)), "make sure bci points at a real bytecode");
236 }
237
238
239 CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, bool lock_stack_only)
245 if (lock_stack_only) {
246 if (info->_stack != NULL) {
247 _stack = info->_stack->copy_locks();
248 } else {
249 _stack = NULL;
250 }
251 } else {
252 _stack = info->_stack;
253 }
254
255 // deep copy of exception handlers
256 if (info->_exception_handlers != NULL) {
257 _exception_handlers = new XHandlers(info->_exception_handlers);
258 }
259 }
260
261
262 void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset) {
263 // record the safepoint before recording the debug info for enclosing scopes
264 recorder->add_safepoint(pc_offset, _oop_map->deep_copy());
265 _scope_debug_info->record_debug_info(recorder, pc_offset, true/*topmost*/);
266 recorder->end_safepoint(pc_offset);
267 }
268
269
270 void CodeEmitInfo::add_register_oop(LIR_Opr opr) {
271 assert(_oop_map != NULL, "oop map must already exist");
272 assert(opr->is_single_cpu(), "should not call otherwise");
273
274 int frame_size = frame_map()->framesize();
275 int arg_count = frame_map()->oop_map_arg_count();
276 VMReg name = frame_map()->regname(opr);
277 _oop_map->set_oop(name);
278 }
279
280
281
282
283 // Implementation of IR
284
285 IR::IR(Compilation* compilation, ciMethod* method, int osr_bci) :
|