comparison src/share/vm/graal/graalCodeInstaller.cpp @ 3090:536528f48708

more escape analysis work: debug info
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 28 Jun 2011 19:14:28 +0200
parents b7f45b37dd43
children bee93b329be2
comparison
equal deleted inserted replaced
3089:05b8a7787aaf 3090:536528f48708
105 105
106 return map; 106 return map;
107 } 107 }
108 108
109 // TODO: finish this - graal doesn't provide any scope values at the moment 109 // TODO: finish this - graal doesn't provide any scope values at the moment
110 static ScopeValue* get_hotspot_value(oop value, int frame_size, ScopeValue* &second) { 110 static ScopeValue* get_hotspot_value(oop value, int frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) {
111 second = NULL; 111 second = NULL;
112 if (value == CiValue::IllegalValue()) { 112 if (value == CiValue::IllegalValue()) {
113 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); 113 return new LocationValue(Location::new_stk_loc(Location::invalid, 0));
114 } 114 }
115 115
180 } 180 }
181 } else if (type == T_ADDRESS) { 181 } else if (type == T_ADDRESS) {
182 return new ConstantLongValue(prim); 182 return new ConstantLongValue(prim);
183 } 183 }
184 tty->print("%i", type); 184 tty->print("%i", type);
185 } else if (value->is_a(CiVirtualObject::klass())) {
186 oop type = CiVirtualObject::type(value);
187 int id = CiVirtualObject::id(value);
188 ciKlass* klass = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)));
189 assert(klass->is_instance_klass() || klass->is_array_klass(), "Not supported allocation.");
190
191 for (jint i = 0; i < objects->length(); i++) {
192 ObjectValue* obj = (ObjectValue*) objects->at(i);
193 if (obj->id() == id) {
194 return obj;
195 }
196 }
197
198 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(klass->constant_encoding()));
199
200 arrayOop values = (arrayOop) CiVirtualObject::values(value);
201 for (jint i = 0; i < values->length(); i++) {
202 ((oop*) values->base(T_OBJECT))[i];
203 }
204
205 for (jint i = 0; i < values->length(); i++) {
206 ScopeValue* second = NULL;
207 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], frame_size, objects, second);
208
209 // if (second != NULL) {
210 // sv->field_values()->append(second);
211 // }
212 sv->field_values()->append(value);
213 }
214
215 // uint first_ind = spobj->first_index();
216 // for (uint i = 0; i < spobj->n_fields(); i++) {
217 // Node* fld_node = sfn->in(first_ind+i);
218 // (void)FillLocArray(sv->field_values()->length(), sfn, fld_node, sv->field_values(), objs);
219 // }
220 // scval = sv;
221
222 objects->append(sv);
223 return sv;
185 } else { 224 } else {
186 value->klass()->print(); 225 value->klass()->print();
187 value->print(); 226 value->print();
188 } 227 }
189 ShouldNotReachHere(); 228 ShouldNotReachHere();
419 } 458 }
420 } 459 }
421 460
422 } 461 }
423 462
424 void CodeInstaller::record_scope(jint pc_offset, oop code_pos) { 463 void CodeInstaller::record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects) {
425 oop caller_pos = CiCodePos::caller(code_pos); 464 oop caller_pos = CiCodePos::caller(code_pos);
426 if (caller_pos != NULL) { 465 if (caller_pos != NULL) {
427 record_scope(pc_offset, caller_pos); 466 record_scope(pc_offset, caller_pos, objects);
428 } 467 }
429 oop frame = NULL; 468 oop frame = NULL;
430 if (code_pos->klass()->klass_part()->name() == vmSymbols::com_sun_cri_ci_CiFrame()) { 469 if (code_pos->klass()->klass_part()->name() == vmSymbols::com_sun_cri_ci_CiFrame()) {
431 frame = code_pos; 470 frame = code_pos;
432 } 471 }
464 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); 503 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
465 } 504 }
466 505
467 for (jint i = 0; i < values->length(); i++) { 506 for (jint i = 0; i < values->length(); i++) {
468 ScopeValue* second = NULL; 507 ScopeValue* second = NULL;
469 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], _frame_size, second); 508 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], _frame_size, objects, second);
470 509
471 if (i < local_count) { 510 if (i < local_count) {
472 if (second != NULL) { 511 if (second != NULL) {
473 locals->append(second); 512 locals->append(second);
474 } 513 }
490 i++; 529 i++;
491 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue"); 530 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue");
492 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue"); 531 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue");
493 } 532 }
494 } 533 }
534
535 _debug_recorder->dump_object_pool(objects);
536
495 DebugToken* locals_token = _debug_recorder->create_scope_values(locals); 537 DebugToken* locals_token = _debug_recorder->create_scope_values(locals);
496 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions); 538 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions);
497 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors); 539 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors);
498 540
499 bool throw_exception = false; 541 bool throw_exception = false;
514 // address instruction = _instructions->start() + pc_offset; 556 // address instruction = _instructions->start() + pc_offset;
515 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); 557 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
516 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info)); 558 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info));
517 559
518 oop code_pos = CiDebugInfo::codePos(debug_info); 560 oop code_pos = CiDebugInfo::codePos(debug_info);
519 record_scope(pc_offset, code_pos); 561 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>());
520 562
521 _debug_recorder->end_safepoint(pc_offset); 563 _debug_recorder->end_safepoint(pc_offset);
522 } 564 }
523 565
524 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) { 566 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) {
535 jint next_pc_offset = pc_offset + NativeCall::instruction_size; 577 jint next_pc_offset = pc_offset + NativeCall::instruction_size;
536 578
537 if (debug_info != NULL) { 579 if (debug_info != NULL) {
538 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info)); 580 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info));
539 oop code_pos = CiDebugInfo::codePos(debug_info); 581 oop code_pos = CiDebugInfo::codePos(debug_info);
540 record_scope(next_pc_offset, code_pos); 582 record_scope(next_pc_offset, code_pos, new GrowableArray<ScopeValue*>());
541 } 583 }
542 584
543 if (runtime_call != NULL) { 585 if (runtime_call != NULL) {
544 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); 586 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
545 if (runtime_call == CiRuntimeCall::Debug()) { 587 if (runtime_call == CiRuntimeCall::Debug()) {