Mercurial > hg > graal-compiler
comparison src/share/vm/c1x/c1x_CodeInstaller.cpp @ 1465:2c754f3a2722
Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Thu, 18 Nov 2010 17:27:43 +0100 |
parents | 1845386f5403 |
children | e4cd5d2de7e1 |
comparison
equal
deleted
inserted
replaced
1463:7bc14f75a077 | 1465:2c754f3a2722 |
---|---|
49 static OopMap* create_oop_map(jint frame_size, jint parameter_count, oop debug_info) { | 49 static OopMap* create_oop_map(jint frame_size, jint parameter_count, oop debug_info) { |
50 OopMap* map = new OopMap(frame_size, parameter_count); | 50 OopMap* map = new OopMap(frame_size, parameter_count); |
51 arrayOop register_map = (arrayOop) CiDebugInfo::registerRefMap(debug_info); | 51 arrayOop register_map = (arrayOop) CiDebugInfo::registerRefMap(debug_info); |
52 arrayOop frame_map = (arrayOop) CiDebugInfo::frameRefMap(debug_info); | 52 arrayOop frame_map = (arrayOop) CiDebugInfo::frameRefMap(debug_info); |
53 | 53 |
54 assert(register_map->length() == (NUM_CPU_REGS + 7) / 8, "unexpected register_map length"); | 54 if (register_map != NULL) { |
55 | 55 assert(register_map->length() == (NUM_CPU_REGS + 7) / 8, "unexpected register_map length"); |
56 for (jint i = 0; i < NUM_CPU_REGS; i++) { | 56 |
57 unsigned char byte = ((unsigned char*) register_map->base(T_BYTE))[i / 8]; | 57 for (jint i = 0; i < NUM_CPU_REGS; i++) { |
58 bool is_oop = (byte & (1 << (i % 8))) != 0; | 58 unsigned char byte = ((unsigned char*) register_map->base(T_BYTE))[i / 8]; |
59 VMReg reg = get_hotspot_reg(i); | 59 bool is_oop = (byte & (1 << (i % 8))) != 0; |
60 if (is_oop) { | 60 VMReg reg = get_hotspot_reg(i); |
61 assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?"); | 61 if (is_oop) { |
62 map->set_oop(reg); | 62 assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?"); |
63 } else { | 63 map->set_oop(reg); |
64 map->set_value(reg); | 64 } else { |
65 map->set_value(reg); | |
66 } | |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
68 if (frame_size > 0) { | 70 if (frame_size > 0) { |
69 assert(frame_map->length() == ((frame_size / HeapWordSize) + 7) / 8, "unexpected frame_map length"); | 71 assert(frame_map->length() == ((frame_size / HeapWordSize) + 7) / 8, "unexpected frame_map length"); |
136 } | 138 } |
137 } | 139 } |
138 | 140 |
139 // constructor used to create a method | 141 // constructor used to create a method |
140 CodeInstaller::CodeInstaller(oop target_method) { | 142 CodeInstaller::CodeInstaller(oop target_method) { |
141 _env = CURRENT_ENV; | 143 ciMethod *ciMethodObject = NULL; |
142 | 144 { |
143 initialize_fields(target_method); | 145 No_Safepoint_Verifier no_safepoint; |
144 assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name"); | 146 _env = CURRENT_ENV; |
145 assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved"); | 147 |
146 | 148 initialize_fields(target_method); |
147 // TODO: This is a hack.. Produce correct entries. | 149 assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name"); |
148 _offsets.set_value(CodeOffsets::Exceptions, 0); | 150 assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved"); |
149 _offsets.set_value(CodeOffsets::Deopt, 0); | 151 |
150 | 152 // TODO: This is a hack.. Produce correct entries. |
151 methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(_hotspot_method)); | 153 _offsets.set_value(CodeOffsets::Exceptions, 0); |
152 ciMethod *ciMethodObject = (ciMethod *) _env->get_object(method); | 154 _offsets.set_value(CodeOffsets::Deopt, 0); |
153 _parameter_count = method->size_of_parameters(); | 155 |
156 methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(_hotspot_method)); | |
157 ciMethodObject = (ciMethod *) _env->get_object(method); | |
158 _parameter_count = method->size_of_parameters(); | |
159 } | |
154 | 160 |
155 // (very) conservative estimate: each site needs a relocation | 161 // (very) conservative estimate: each site needs a relocation |
156 CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit); | 162 CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit); |
157 initialize_buffer(buffer); | 163 initialize_buffer(buffer); |
158 process_exception_handlers(); | 164 process_exception_handlers(); |
159 { | 165 |
160 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer | 166 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer |
161 ThreadToNativeFromVM t((JavaThread*) Thread::current()); | 167 ThreadToNativeFromVM t((JavaThread*) Thread::current()); |
162 _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, | 168 _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, |
163 &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false); | 169 &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false); |
164 } | 170 |
165 } | 171 } |
166 | 172 |
167 // constructor used to create a stub | 173 // constructor used to create a stub |
168 CodeInstaller::CodeInstaller(oop target_method, jlong& id) { | 174 CodeInstaller::CodeInstaller(oop target_method, jlong& id) { |
175 No_Safepoint_Verifier no_safepoint; | |
169 _env = CURRENT_ENV; | 176 _env = CURRENT_ENV; |
170 | 177 |
171 initialize_fields(target_method); | 178 initialize_fields(target_method); |
172 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); | 179 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); |
173 | 180 |
522 TRACE_C1X_3("relocating (Float/Long/Double) at %016x/%016x", instruction, operand); | 529 TRACE_C1X_3("relocating (Float/Long/Double) at %016x/%016x", instruction, operand); |
523 break; | 530 break; |
524 } | 531 } |
525 case 'a': { | 532 case 'a': { |
526 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); | 533 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); |
527 oop obj = CiConstant::object(constant); | 534 Handle obj = CiConstant::object(constant); |
528 | 535 |
529 if (obj->is_a(HotSpotTypeResolved::klass())) { | 536 if (obj->is_a(HotSpotTypeResolved::klass())) { |
530 *((jobject*) operand) = JNIHandles::make_local(VmIds::get<klassOop>(HotSpotTypeResolved::vmId(obj))); | 537 *((jobject*) operand) = JNIHandles::make_local(VmIds::get<klassOop>(HotSpotTypeResolved::vmId(obj))); |
531 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); | 538 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); |
532 TRACE_C1X_3("relocating (HotSpotType) at %016x/%016x", instruction, operand); | 539 TRACE_C1X_3("relocating (HotSpotType) at %016x/%016x", instruction, operand); |
533 } else { | 540 } else { |
534 assert(java_lang_boxing_object::is_instance(obj, T_LONG), "unexpected DataPatch object type"); | 541 jobject value; |
535 jlong id = obj->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG)); | 542 if (java_lang_boxing_object::is_instance(obj(), T_LONG)) { |
536 | 543 jlong id = obj->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG)); |
537 assert((id & VmIds::TYPE_MASK) == VmIds::CONSTANT, "unexpected DataPatch type"); | 544 |
538 | 545 //assert((id & VmIds::TYPE_MASK) == VmIds::CONSTANT, "unexpected DataPatch type"); |
539 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); | 546 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); |
540 | 547 if (id == VmIds::DUMMY_CONSTANT) { |
541 if (id == VmIds::DUMMY_CONSTANT) { | 548 value = (jobject) Universe::non_oop_word(); |
542 *((jobject*) operand) = (jobject) Universe::non_oop_word(); | 549 } else { |
550 value = JNIHandles::make_local(VmIds::get<oop>(id)); | |
551 } | |
543 } else { | 552 } else { |
544 *((jobject*) operand) = JNIHandles::make_local(VmIds::get<oop>(id)); | 553 value = JNIHandles::make_local(obj()); |
545 } | 554 } |
555 *((jobject*) operand) = value; | |
546 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); | 556 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); |
547 TRACE_C1X_3("relocating (oop constant) at %016x/%016x", instruction, operand); | 557 TRACE_C1X_3("relocating (oop constant) at %016x/%016x", instruction, operand); |
548 } | 558 } |
549 break; | 559 break; |
550 } | 560 } |