Mercurial > hg > truffle
comparison src/share/vm/c1x/c1x_CodeInstaller.cpp @ 1931:48bbaead8b6c
Adjustments after merge with OpenJDK repository.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 16:39:35 +0100 |
parents | 6b7001391c97 |
children | 8d88c9ac9247 |
comparison
equal
deleted
inserted
replaced
1930:2d26b0046e0d | 1931:48bbaead8b6c |
---|---|
170 ciMethodObject = (ciMethod *) _env->get_object(method); | 170 ciMethodObject = (ciMethod *) _env->get_object(method); |
171 _parameter_count = method->size_of_parameters(); | 171 _parameter_count = method->size_of_parameters(); |
172 } | 172 } |
173 | 173 |
174 // (very) conservative estimate: each site needs a relocation | 174 // (very) conservative estimate: each site needs a relocation |
175 CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit); | 175 //CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit); |
176 CodeBuffer buffer(CompilerThread::current()->get_buffer_blob()); | |
176 initialize_buffer(buffer); | 177 initialize_buffer(buffer); |
177 process_exception_handlers(); | 178 process_exception_handlers(); |
178 | 179 |
179 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer | 180 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer |
180 ThreadToNativeFromVM t((JavaThread*) Thread::current()); | 181 ThreadToNativeFromVM t((JavaThread*) Thread::current()); |
190 | 191 |
191 initialize_fields(target_method); | 192 initialize_fields(target_method); |
192 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); | 193 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); |
193 | 194 |
194 // (very) conservative estimate: each site needs a relocation | 195 // (very) conservative estimate: each site needs a relocation |
195 CodeBuffer buffer("temp c1x stub", _total_size, _sites->length() * relocInfo::length_limit); | 196 CodeBuffer buffer(CompilerThread::current()->get_buffer_blob()); |
196 initialize_buffer(buffer); | 197 initialize_buffer(buffer); |
197 | 198 |
198 const char* cname = java_lang_String::as_utf8_string(_name); | 199 const char* cname = java_lang_String::as_utf8_string(_name); |
199 BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created | 200 BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created |
200 IF_TRACE_C1X_3 Disassembler::decode((CodeBlob*) blob); | 201 IF_TRACE_C1X_3 Disassembler::decode((CodeBlob*) blob); |
201 id = VmIds::addStub(blob->instructions_begin()); | 202 id = VmIds::addStub(blob->code_begin()); |
202 } | 203 } |
203 | 204 |
204 void CodeInstaller::initialize_fields(oop target_method) { | 205 void CodeInstaller::initialize_fields(oop target_method) { |
205 _citarget_method = HotSpotTargetMethod::targetMethod(target_method); | 206 _citarget_method = HotSpotTargetMethod::targetMethod(target_method); |
206 _hotspot_method = HotSpotTargetMethod::method(target_method); | 207 _hotspot_method = HotSpotTargetMethod::method(target_method); |
219 _next_call_type = MARK_INVOKE_INVALID; | 220 _next_call_type = MARK_INVOKE_INVALID; |
220 } | 221 } |
221 | 222 |
222 // perform data and call relocation on the CodeBuffer | 223 // perform data and call relocation on the CodeBuffer |
223 void CodeInstaller::initialize_buffer(CodeBuffer& buffer) { | 224 void CodeInstaller::initialize_buffer(CodeBuffer& buffer) { |
225 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); | |
226 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); | |
227 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); | |
228 buffer.initialize_stubs_size(256); | |
229 buffer.initialize_consts_size(_constants_size); | |
230 | |
224 _oop_recorder = new OopRecorder(_env->arena()); | 231 _oop_recorder = new OopRecorder(_env->arena()); |
225 _env->set_oop_recorder(_oop_recorder); | 232 _env->set_oop_recorder(_oop_recorder); |
226 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder()); | 233 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder()); |
227 _debug_recorder->set_oopmaps(new OopMapSet()); | 234 _debug_recorder->set_oopmaps(new OopMapSet()); |
228 _dependencies = new Dependencies(_env); | 235 _dependencies = new Dependencies(_env); |
230 _env->set_oop_recorder(_oop_recorder); | 237 _env->set_oop_recorder(_oop_recorder); |
231 _env->set_debug_info(_debug_recorder); | 238 _env->set_debug_info(_debug_recorder); |
232 _env->set_dependencies(_dependencies); | 239 _env->set_dependencies(_dependencies); |
233 buffer.initialize_oop_recorder(_oop_recorder); | 240 buffer.initialize_oop_recorder(_oop_recorder); |
234 | 241 |
235 buffer.initialize_consts_size(_constants_size); | |
236 _instructions = buffer.insts(); | 242 _instructions = buffer.insts(); |
237 _constants = buffer.consts(); | 243 _constants = buffer.consts(); |
238 | 244 |
239 // copy the code into the newly created CodeBuffer | 245 // copy the code into the newly created CodeBuffer |
240 memcpy(_instructions->start(), _code->base(T_BYTE), _code_size); | 246 memcpy(_instructions->start(), _code->base(T_BYTE), _code_size); |
496 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type, Assembler::call32_operand); | 502 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type, Assembler::call32_operand); |
497 break; | 503 break; |
498 } | 504 } |
499 case MARK_INVOKE_INVALID: | 505 case MARK_INVOKE_INVALID: |
500 default: | 506 default: |
501 fatal("invalid _next_call_type value") | 507 fatal("invalid _next_call_type value"); |
502 break; | 508 break; |
503 } | 509 } |
504 } | 510 } |
505 _next_call_type = MARK_INVOKE_INVALID; | 511 _next_call_type = MARK_INVOKE_INVALID; |
506 if (debug_info != NULL) { | 512 if (debug_info != NULL) { |
561 TRACE_C1X_3("relocating (oop constant) at %016x/%016x", instruction, operand); | 567 TRACE_C1X_3("relocating (oop constant) at %016x/%016x", instruction, operand); |
562 } | 568 } |
563 break; | 569 break; |
564 } | 570 } |
565 default: | 571 default: |
566 fatal("unexpected CiKind in DataPatch") | 572 fatal("unexpected CiKind in DataPatch"); |
567 break; | 573 break; |
568 } | 574 } |
569 } | 575 } |
570 | 576 |
571 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) { | 577 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) { |
643 RelocIterator iter(_instructions, (address) instruction, (address) (instruction + 1)); | 649 RelocIterator iter(_instructions, (address) instruction, (address) (instruction + 1)); |
644 relocInfo::change_reloc_info_for_address(&iter, (address) instruction, relocInfo::oop_type, relocInfo::none); | 650 relocInfo::change_reloc_info_for_address(&iter, (address) instruction, relocInfo::oop_type, relocInfo::none); |
645 break; | 651 break; |
646 } | 652 } |
647 default: | 653 default: |
648 ShouldNotReachHere() | 654 ShouldNotReachHere(); |
649 break; | 655 break; |
650 } | 656 } |
651 } | 657 } |
652 } | 658 } |
653 | 659 |