Mercurial > hg > truffle
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 18172:c59612b9d110
Use arrayOop subclasses in graalJavaAccess
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 24 Oct 2014 12:45:27 -0700 |
parents | f55f2d400797 |
children | 8c079b8d0446 |
comparison
equal
deleted
inserted
replaced
18171:9bb816169777 | 18172:c59612b9d110 |
---|---|
59 | 59 |
60 const int MapWordBits = 64; | 60 const int MapWordBits = 64; |
61 | 61 |
62 static bool is_bit_set(oop bitset, int i) { | 62 static bool is_bit_set(oop bitset, int i) { |
63 jint words_idx = i / MapWordBits; | 63 jint words_idx = i / MapWordBits; |
64 arrayOop words = (arrayOop) BitSet::words(bitset); | 64 typeArrayOop words = BitSet::words(bitset); |
65 assert(words_idx >= 0 && words_idx < words->length(), "unexpected index"); | 65 assert(words_idx >= 0 && words_idx < words->length(), "unexpected index"); |
66 jlong word = ((jlong*) words->base(T_LONG))[words_idx]; | 66 jlong word = words->long_at(words_idx); |
67 return (word & (1LL << (i % MapWordBits))) != 0; | 67 return (word & (1LL << (i % MapWordBits))) != 0; |
68 } | 68 } |
69 | 69 |
70 static int bitset_size(oop bitset) { | 70 static int bitset_size(oop bitset) { |
71 arrayOop arr = (arrayOop) BitSet::words(bitset); | 71 typeArrayOop arr = BitSet::words(bitset); |
72 return arr->length() * MapWordBits; | 72 return arr->length() * MapWordBits; |
73 } | 73 } |
74 | 74 |
75 static void set_vmreg_oops(OopMap* map, VMReg reg, oop bitset, int idx) { | 75 static void set_vmreg_oops(OopMap* map, VMReg reg, oop bitset, int idx) { |
76 bool is_oop = is_bit_set(bitset, 3 * idx); | 76 bool is_oop = is_bit_set(bitset, 3 * idx); |
127 VMReg reg = VMRegImpl::stack2reg(i * VMRegImpl::slots_per_word); | 127 VMReg reg = VMRegImpl::stack2reg(i * VMRegImpl::slots_per_word); |
128 set_vmreg_oops(map, reg, frame_map, i); | 128 set_vmreg_oops(map, reg, frame_map, i); |
129 } | 129 } |
130 | 130 |
131 if (callee_save_info != NULL) { | 131 if (callee_save_info != NULL) { |
132 objArrayOop registers = (objArrayOop) RegisterSaveLayout::registers(callee_save_info); | 132 objArrayOop registers = RegisterSaveLayout::registers(callee_save_info); |
133 arrayOop slots = (arrayOop) RegisterSaveLayout::slots(callee_save_info); | 133 typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info); |
134 for (jint i = 0; i < slots->length(); i++) { | 134 for (jint i = 0; i < slots->length(); i++) { |
135 oop graal_reg = registers->obj_at(i); | 135 oop graal_reg = registers->obj_at(i); |
136 jint graal_reg_number = code_Register::number(graal_reg); | 136 jint graal_reg_number = code_Register::number(graal_reg); |
137 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(graal_reg_number); | 137 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(graal_reg_number); |
138 // HotSpot stack slots are 4 bytes | 138 // HotSpot stack slots are 4 bytes |
139 jint graal_slot = ((jint*) slots->base(T_INT))[i]; | 139 jint graal_slot = slots->int_at(i); |
140 jint hotspot_slot = graal_slot * VMRegImpl::slots_per_word; | 140 jint hotspot_slot = graal_slot * VMRegImpl::slots_per_word; |
141 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); | 141 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); |
142 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); | 142 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); |
143 #ifdef _LP64 | 143 #ifdef _LP64 |
144 // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) | 144 // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) |
316 } | 316 } |
317 | 317 |
318 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); | 318 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); |
319 objects->append(sv); | 319 objects->append(sv); |
320 | 320 |
321 arrayOop values = (arrayOop) VirtualObject::values(value); | 321 objArrayOop values = VirtualObject::values(value); |
322 for (jint i = 0; i < values->length(); i++) { | 322 for (jint i = 0; i < values->length(); i++) { |
323 ScopeValue* cur_second = NULL; | 323 ScopeValue* cur_second = NULL; |
324 oop object = ((objArrayOop) (values))->obj_at(i); | 324 oop object = values->obj_at(i); |
325 ScopeValue* value = get_scope_value(object, total_frame_size, objects, cur_second, oop_recorder); | 325 ScopeValue* value = get_scope_value(object, total_frame_size, objects, cur_second, oop_recorder); |
326 | 326 |
327 if (isLongArray && cur_second == NULL) { | 327 if (isLongArray && cur_second == NULL) { |
328 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. | 328 // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
329 // add an int 0 constant | 329 // add an int 0 constant |
372 void CodeInstaller::initialize_assumptions(oop compiled_code) { | 372 void CodeInstaller::initialize_assumptions(oop compiled_code) { |
373 _oop_recorder = new OopRecorder(&_arena, true); | 373 _oop_recorder = new OopRecorder(&_arena, true); |
374 _dependencies = new Dependencies(&_arena, _oop_recorder); | 374 _dependencies = new Dependencies(&_arena, _oop_recorder); |
375 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompiledCode::comp(compiled_code)); | 375 Handle assumptions_handle = CompilationResult::assumptions(HotSpotCompiledCode::comp(compiled_code)); |
376 if (!assumptions_handle.is_null()) { | 376 if (!assumptions_handle.is_null()) { |
377 objArrayHandle assumptions(Thread::current(), (objArrayOop)Assumptions::list(assumptions_handle())); | 377 objArrayHandle assumptions(Thread::current(), Assumptions::list(assumptions_handle())); |
378 int length = assumptions->length(); | 378 int length = assumptions->length(); |
379 for (int i = 0; i < length; ++i) { | 379 for (int i = 0; i < length; ++i) { |
380 Handle assumption = assumptions->obj_at(i); | 380 Handle assumption = assumptions->obj_at(i); |
381 if (!assumption.is_null()) { | 381 if (!assumption.is_null()) { |
382 if (assumption->klass() == Assumptions_MethodContents::klass()) { | 382 if (assumption->klass() == Assumptions_MethodContents::klass()) { |
477 _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result); | 477 _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result); |
478 | 478 |
479 // Pre-calculate the constants section size. This is required for PC-relative addressing. | 479 // Pre-calculate the constants section size. This is required for PC-relative addressing. |
480 _data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); | 480 _data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); |
481 guarantee(DataSection::sectionAlignment(data_section()) <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); | 481 guarantee(DataSection::sectionAlignment(data_section()) <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); |
482 arrayHandle data = (arrayOop) DataSection::data(data_section()); | 482 typeArrayHandle data = DataSection::data(data_section()); |
483 _constants_size = data->length(); | 483 _constants_size = data->length(); |
484 if (_constants_size > 0) { | 484 if (_constants_size > 0) { |
485 _constants_size = align_size_up(_constants_size, _constants->alignment()); | 485 _constants_size = align_size_up(_constants_size, _constants->alignment()); |
486 } | 486 } |
487 | 487 |
488 #ifndef PRODUCT | 488 #ifndef PRODUCT |
489 _comments_handle = JNIHandles::make_local((arrayOop) HotSpotCompiledCode::comments(compiled_code)); | 489 _comments_handle = JNIHandles::make_local(HotSpotCompiledCode::comments(compiled_code)); |
490 #endif | 490 #endif |
491 | 491 |
492 _next_call_type = INVOKE_INVALID; | 492 _next_call_type = INVOKE_INVALID; |
493 } | 493 } |
494 | 494 |
539 memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); | 539 memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); |
540 _instructions->set_end(end_pc); | 540 _instructions->set_end(end_pc); |
541 | 541 |
542 // copy the constant data into the newly created CodeBuffer | 542 // copy the constant data into the newly created CodeBuffer |
543 address end_data = _constants->start() + _constants_size; | 543 address end_data = _constants->start() + _constants_size; |
544 typeArrayHandle data((typeArrayOop) DataSection::data(data_section())); | 544 typeArrayHandle data(DataSection::data(data_section())); |
545 memcpy(_constants->start(), data->base(T_BYTE), data->length()); | 545 memcpy(_constants->start(), data->base(T_BYTE), data->length()); |
546 _constants->set_end(end_data); | 546 _constants->set_end(end_data); |
547 | 547 |
548 | 548 |
549 objArrayHandle patches = (objArrayOop) DataSection::patches(data_section()); | 549 objArrayHandle patches = DataSection::patches(data_section()); |
550 for (int i = 0; i < patches->length(); i++) { | 550 for (int i = 0; i < patches->length(); i++) { |
551 Handle patch = patches->obj_at(i); | 551 Handle patch = patches->obj_at(i); |
552 Handle data = CompilationResult_DataPatch::data(patch); | 552 Handle data = CompilationResult_DataPatch::data(patch); |
553 if (data->is_a(MetaspaceData::klass())) { | 553 if (data->is_a(MetaspaceData::klass())) { |
554 record_metadata_in_patch(data(), _oop_recorder); | 554 record_metadata_in_patch(data(), _oop_recorder); |
741 | 741 |
742 if (frame != NULL) { | 742 if (frame != NULL) { |
743 jint local_count = BytecodeFrame::numLocals(frame); | 743 jint local_count = BytecodeFrame::numLocals(frame); |
744 jint expression_count = BytecodeFrame::numStack(frame); | 744 jint expression_count = BytecodeFrame::numStack(frame); |
745 jint monitor_count = BytecodeFrame::numLocks(frame); | 745 jint monitor_count = BytecodeFrame::numLocks(frame); |
746 arrayOop values = (arrayOop) BytecodeFrame::values(frame); | 746 objArrayOop values = BytecodeFrame::values(frame); |
747 | 747 |
748 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); | 748 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); |
749 | 749 |
750 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); | 750 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); |
751 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); | 751 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); |
756 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); | 756 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
757 } | 757 } |
758 | 758 |
759 for (jint i = 0; i < values->length(); i++) { | 759 for (jint i = 0; i < values->length(); i++) { |
760 ScopeValue* second = NULL; | 760 ScopeValue* second = NULL; |
761 oop value=((objArrayOop) (values))->obj_at(i); | 761 oop value= values->obj_at(i); |
762 if (i < local_count) { | 762 if (i < local_count) { |
763 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); | 763 ScopeValue* first = get_scope_value(value, _total_frame_size, objects, second, _oop_recorder); |
764 if (second != NULL) { | 764 if (second != NULL) { |
765 locals->append(second); | 765 locals->append(second); |
766 } | 766 } |
775 monitors->append(get_monitor_value(value, _total_frame_size, objects, _oop_recorder)); | 775 monitors->append(get_monitor_value(value, _total_frame_size, objects, _oop_recorder)); |
776 } | 776 } |
777 if (second != NULL) { | 777 if (second != NULL) { |
778 i++; | 778 i++; |
779 assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); | 779 assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); |
780 assert(((objArrayOop) (values))->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); | 780 assert(values->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); |
781 } | 781 } |
782 } | 782 } |
783 | 783 |
784 _debug_recorder->dump_object_pool(objects); | 784 _debug_recorder->dump_object_pool(objects); |
785 | 785 |