Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 4174:79c91d220d73
Use callee save area to model the saved rbp register. Remove various hacks that added the saved area size in native code.
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Thu, 29 Dec 2011 16:07:35 -0800 |
parents | 4177ddd2d1d1 |
children | 319860ae697a |
comparison
equal
deleted
inserted
replaced
4173:15b9402dc018 | 4174:79c91d220d73 |
---|---|
66 return (word & (1LL << (i % MapWordBits))) != 0; | 66 return (word & (1LL << (i % MapWordBits))) != 0; |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 // creates a hotspot oop map out of the byte arrays provided by CiDebugInfo | 70 // creates a hotspot oop map out of the byte arrays provided by CiDebugInfo |
71 static OopMap* create_oop_map(jint frame_size, jint parameter_count, oop debug_info) { | 71 static OopMap* create_oop_map(jint total_frame_size, jint parameter_count, oop debug_info) { |
72 OopMap* map = new OopMap(frame_size, parameter_count); | 72 OopMap* map = new OopMap(total_frame_size, parameter_count); |
73 oop register_map = (oop) CiDebugInfo::registerRefMap(debug_info); | 73 oop register_map = (oop) CiDebugInfo::registerRefMap(debug_info); |
74 oop frame_map = (oop) CiDebugInfo::frameRefMap(debug_info); | 74 oop frame_map = (oop) CiDebugInfo::frameRefMap(debug_info); |
75 | 75 |
76 if (register_map != NULL) { | 76 if (register_map != NULL) { |
77 assert(GraalBitMap::size(register_map) == (unsigned) NUM_CPU_REGS, "unexpected register_map length"); | 77 assert(GraalBitMap::size(register_map) == (unsigned) NUM_CPU_REGS, "unexpected register_map length"); |
85 map->set_value(reg); | 85 map->set_value(reg); |
86 } | 86 } |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 if (frame_size > 0) { | 90 for (jint i = 0; i < GraalBitMap::size(frame_map); i++) { |
91 assert(GraalBitMap::size(frame_map) == frame_size / HeapWordSize, "unexpected frame_map length"); | 91 bool is_oop = is_bit_set(frame_map, i); |
92 | 92 // hotspot stack slots are 4 bytes |
93 for (jint i = 0; i < frame_size / HeapWordSize; i++) { | 93 VMReg reg = VMRegImpl::stack2reg(i * 2); |
94 bool is_oop = is_bit_set(frame_map, i); | 94 if (is_oop) { |
95 // hotspot stack slots are 4 bytes | 95 map->set_oop(reg); |
96 VMReg reg = VMRegImpl::stack2reg(i * 2); | 96 } else { |
97 if (is_oop) { | 97 map->set_value(reg); |
98 map->set_oop(reg); | 98 } |
99 } else { | |
100 map->set_value(reg); | |
101 } | |
102 } | |
103 } else { | |
104 assert(frame_map == NULL || GraalBitMap::size(frame_map) == 0, "cannot have frame_map for frames with size 0"); | |
105 } | 99 } |
106 | 100 |
107 return map; | 101 return map; |
108 } | 102 } |
109 | 103 |
110 // TODO: finish this - graal doesn't provide any scope values at the moment | 104 // TODO: finish this - graal doesn't provide any scope values at the moment |
111 static ScopeValue* get_hotspot_value(oop value, int frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) { | 105 static ScopeValue* get_hotspot_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) { |
112 second = NULL; | 106 second = NULL; |
113 if (value == CiValue::IllegalValue()) { | 107 if (value == CiValue::IllegalValue()) { |
114 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); | 108 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); |
115 } | 109 } |
116 | 110 |
156 jint index = CiStackSlot::index(value); | 150 jint index = CiStackSlot::index(value); |
157 ScopeValue* value; | 151 ScopeValue* value; |
158 if (index >= 0) { | 152 if (index >= 0) { |
159 value = new LocationValue(Location::new_stk_loc(locationType, index * HeapWordSize)); | 153 value = new LocationValue(Location::new_stk_loc(locationType, index * HeapWordSize)); |
160 } else { | 154 } else { |
161 value = new LocationValue(Location::new_stk_loc(locationType, -(index * HeapWordSize) + frame_size)); | 155 value = new LocationValue(Location::new_stk_loc(locationType, -((index + 1) * HeapWordSize) + total_frame_size)); |
162 } | 156 } |
163 if (type == T_DOUBLE || type == T_LONG) { | 157 if (type == T_DOUBLE || type == T_LONG) { |
164 second = value; | 158 second = value; |
165 } | 159 } |
166 return value; | 160 return value; |
202 ((oop*) values->base(T_OBJECT))[i]; | 196 ((oop*) values->base(T_OBJECT))[i]; |
203 } | 197 } |
204 | 198 |
205 for (jint i = 0; i < values->length(); i++) { | 199 for (jint i = 0; i < values->length(); i++) { |
206 ScopeValue* cur_second = NULL; | 200 ScopeValue* cur_second = NULL; |
207 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], frame_size, objects, cur_second); | 201 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], total_frame_size, objects, cur_second); |
208 | 202 |
209 if (cur_second != NULL) { | 203 if (cur_second != NULL) { |
210 sv->field_values()->append(cur_second); | 204 sv->field_values()->append(cur_second); |
211 } | 205 } |
212 sv->field_values()->append(value); | 206 sv->field_values()->append(value); |
219 } | 213 } |
220 ShouldNotReachHere(); | 214 ShouldNotReachHere(); |
221 return NULL; | 215 return NULL; |
222 } | 216 } |
223 | 217 |
224 static MonitorValue* get_monitor_value(oop value, int frame_size, GrowableArray<ScopeValue*>* objects) { | 218 static MonitorValue* get_monitor_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects) { |
225 guarantee(value->is_a(CiMonitorValue::klass()), "Monitors must be of type CiMonitorValue"); | 219 guarantee(value->is_a(CiMonitorValue::klass()), "Monitors must be of type CiMonitorValue"); |
226 | 220 |
227 ScopeValue* second = NULL; | 221 ScopeValue* second = NULL; |
228 ScopeValue* owner_value = get_hotspot_value(CiMonitorValue::owner(value), frame_size, objects, second); | 222 ScopeValue* owner_value = get_hotspot_value(CiMonitorValue::owner(value), total_frame_size, objects, second); |
229 assert(second == NULL, "monitor cannot occupy two stack slots"); | 223 assert(second == NULL, "monitor cannot occupy two stack slots"); |
230 | 224 |
231 ScopeValue* lock_data_value = get_hotspot_value(CiMonitorValue::lockData(value), frame_size, objects, second); | 225 ScopeValue* lock_data_value = get_hotspot_value(CiMonitorValue::lockData(value), total_frame_size, objects, second); |
232 assert(second == NULL, "monitor cannot occupy two stack slots"); | 226 assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); |
233 assert(lock_data_value->is_location(), "invalid monitor location"); | 227 assert(lock_data_value->is_location(), "invalid monitor location"); |
234 Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); | 228 Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); |
235 | 229 |
236 bool eliminated = false; | 230 bool eliminated = false; |
237 if (CiMonitorValue::eliminated(value)) { | 231 if (CiMonitorValue::eliminated(value)) { |
279 initialize_fields(JNIHandles::resolve(target_method_obj)); | 273 initialize_fields(JNIHandles::resolve(target_method_obj)); |
280 initialize_buffer(buffer); | 274 initialize_buffer(buffer); |
281 process_exception_handlers(); | 275 process_exception_handlers(); |
282 } | 276 } |
283 | 277 |
284 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer | 278 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words |
285 methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(JNIHandles::resolve(target_method_obj))); | 279 methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(JNIHandles::resolve(target_method_obj))); |
286 { | 280 { |
287 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, | 281 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, |
288 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, install_code); | 282 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, install_code); |
289 } | 283 } |
321 _sites = (arrayOop) HotSpotTargetMethod::sites(target_method); | 315 _sites = (arrayOop) HotSpotTargetMethod::sites(target_method); |
322 _exception_handlers = (arrayOop) HotSpotTargetMethod::exceptionHandlers(target_method); | 316 _exception_handlers = (arrayOop) HotSpotTargetMethod::exceptionHandlers(target_method); |
323 | 317 |
324 _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method); | 318 _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method); |
325 _code_size = CiTargetMethod::targetCodeSize(_citarget_method); | 319 _code_size = CiTargetMethod::targetCodeSize(_citarget_method); |
326 _frame_size = CiTargetMethod::frameSize(_citarget_method); | 320 // The frame size we get from the target method does not include the return address, so add one word for it here. |
321 _total_frame_size = CiTargetMethod::frameSize(_citarget_method) + HeapWordSize; | |
327 _custom_stack_area_offset = CiTargetMethod::customStackAreaOffset(_citarget_method); | 322 _custom_stack_area_offset = CiTargetMethod::customStackAreaOffset(_citarget_method); |
328 | 323 |
329 | 324 |
330 // (very) conservative estimate: each site needs a constant section entry | 325 // (very) conservative estimate: each site needs a constant section entry |
331 _constants_size = _sites->length() * (BytesPerLong*2); | 326 _constants_size = _sites->length() * (BytesPerLong*2); |
509 for (jint i = 0; i < values->length(); i++) { | 504 for (jint i = 0; i < values->length(); i++) { |
510 ScopeValue* second = NULL; | 505 ScopeValue* second = NULL; |
511 oop value = ((oop*) values->base(T_OBJECT))[i]; | 506 oop value = ((oop*) values->base(T_OBJECT))[i]; |
512 | 507 |
513 if (i < local_count) { | 508 if (i < local_count) { |
514 ScopeValue* first = get_hotspot_value(value, _frame_size, objects, second); | 509 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second); |
515 if (second != NULL) { | 510 if (second != NULL) { |
516 locals->append(second); | 511 locals->append(second); |
517 } | 512 } |
518 locals->append(first); | 513 locals->append(first); |
519 } else if (i < local_count + expression_count) { | 514 } else if (i < local_count + expression_count) { |
520 ScopeValue* first = get_hotspot_value(value, _frame_size, objects, second); | 515 ScopeValue* first = get_hotspot_value(value, _total_frame_size, objects, second); |
521 if (second != NULL) { | 516 if (second != NULL) { |
522 expressions->append(second); | 517 expressions->append(second); |
523 } | 518 } |
524 expressions->append(first); | 519 expressions->append(first); |
525 } else { | 520 } else { |
526 monitors->append(get_monitor_value(value, _frame_size, objects)); | 521 monitors->append(get_monitor_value(value, _total_frame_size, objects)); |
527 } | 522 } |
528 if (second != NULL) { | 523 if (second != NULL) { |
529 i++; | 524 i++; |
530 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue"); | 525 assert(i < values->length(), "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"); | 526 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue"); |
553 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site); | 548 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site); |
554 assert(debug_info != NULL, "debug info expected"); | 549 assert(debug_info != NULL, "debug info expected"); |
555 | 550 |
556 // address instruction = _instructions->start() + pc_offset; | 551 // address instruction = _instructions->start() + pc_offset; |
557 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); | 552 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); |
558 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info)); | 553 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); |
559 | 554 |
560 oop code_pos = CiDebugInfo::codePos(debug_info); | 555 oop code_pos = CiDebugInfo::codePos(debug_info); |
561 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>()); | 556 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>()); |
562 | 557 |
563 _debug_recorder->end_safepoint(pc_offset); | 558 _debug_recorder->end_safepoint(pc_offset); |
664 | 659 |
665 return; | 660 return; |
666 } | 661 } |
667 | 662 |
668 if (debug_info != NULL) { | 663 if (debug_info != NULL) { |
669 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info)); | 664 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); |
670 oop code_pos = CiDebugInfo::codePos(debug_info); | 665 oop code_pos = CiDebugInfo::codePos(debug_info); |
671 record_scope(next_pc_offset, code_pos, new GrowableArray<ScopeValue*>()); | 666 record_scope(next_pc_offset, code_pos, new GrowableArray<ScopeValue*>()); |
672 } | 667 } |
673 | 668 |
674 if (runtime_call != NULL) { | 669 if (runtime_call != NULL) { |