310 |
310 |
311 |
311 |
312 void LIRGenerator::init() { |
312 void LIRGenerator::init() { |
313 _bs = Universe::heap()->barrier_set(); |
313 _bs = Universe::heap()->barrier_set(); |
314 #ifdef MIPS64 |
314 #ifdef MIPS64 |
315 assert(_bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind"); |
315 assert(_bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind"); |
316 CardTableModRefBS* ct = (CardTableModRefBS*)_bs; |
316 CardTableModRefBS* ct = (CardTableModRefBS*)_bs; |
317 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); |
317 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); |
318 //_card_table_base = new LIR_Const((intptr_t)ct->byte_map_base); |
318 //_card_table_base = new LIR_Const((intptr_t)ct->byte_map_base); |
319 // //FIXME, untested in 32bit. by aoqi |
319 // //FIXME, untested in 32bit. by aoqi |
320 _card_table_base = new LIR_Const(ct->byte_map_base); |
320 _card_table_base = new LIR_Const(ct->byte_map_base); |
321 #endif |
321 #endif |
322 } |
322 } |
323 |
323 |
324 |
324 |
325 void LIRGenerator::block_do_prolog(BlockBegin* block) { |
325 void LIRGenerator::block_do_prolog(BlockBegin* block) { |
526 if (index->is_constant()) { |
526 if (index->is_constant()) { |
527 #ifndef MIPS64 |
527 #ifndef MIPS64 |
528 cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info); |
528 cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info); |
529 __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch |
529 __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch |
530 #else |
530 #else |
531 LIR_Opr left = LIR_OprFact::address(new LIR_Address(buffer, java_nio_Buffer::limit_offset(),T_INT)); |
531 LIR_Opr left = LIR_OprFact::address(new LIR_Address(buffer, java_nio_Buffer::limit_offset(),T_INT)); |
532 LIR_Opr right = LIR_OprFact::intConst(index->as_jint()); |
532 LIR_Opr right = LIR_OprFact::intConst(index->as_jint()); |
533 __ null_check_for_branch(lir_cond_belowEqual, left, right, info); |
533 __ null_check_for_branch(lir_cond_belowEqual, left, right, info); |
534 __ branch(lir_cond_belowEqual,left, right ,T_INT, stub); // forward branch |
534 __ branch(lir_cond_belowEqual,left, right ,T_INT, stub); // forward branch |
535 #endif |
535 #endif |
536 } else { |
536 } else { |
537 #ifndef MIPS64 |
537 #ifndef MIPS64 |
538 cmp_reg_mem(lir_cond_aboveEqual, index, buffer, |
538 cmp_reg_mem(lir_cond_aboveEqual, index, buffer, |
539 java_nio_Buffer::limit_offset(), T_INT, info); |
539 java_nio_Buffer::limit_offset(), T_INT, info); |
714 #endif |
714 #endif |
715 |
715 |
716 #ifndef MIPS64 |
716 #ifndef MIPS64 |
717 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) { |
717 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) { |
718 #else |
718 #else |
719 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr scratch5, LIR_Opr scratch6, LIR_Opr klass_reg, CodeEmitInfo* info) { |
719 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, |
|
720 LIR_Opr scratch4, LIR_Opr scratch5, LIR_Opr scratch6,LIR_Opr klass_reg, CodeEmitInfo* info) { |
720 #endif |
721 #endif |
721 klass2reg_with_patching(klass_reg, klass, info, is_unresolved); |
722 klass2reg_with_patching(klass_reg, klass, info, is_unresolved); |
722 // If klass is not loaded we do not know if the klass has finalizers: |
723 // If klass is not loaded we do not know if the klass has finalizers: |
723 if (UseFastNewInstance && klass->is_loaded() |
724 if (UseFastNewInstance && klass->is_loaded() |
724 && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) { |
725 && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) { |
1028 __ move(data_reg, data_addr); |
1029 __ move(data_reg, data_addr); |
1029 } |
1030 } |
1030 } |
1031 } |
1031 #else |
1032 #else |
1032 void LIRGenerator::profile_branch(If* if_instr, If::Condition cond , LIR_Opr left, LIR_Opr right) { |
1033 void LIRGenerator::profile_branch(If* if_instr, If::Condition cond , LIR_Opr left, LIR_Opr right) { |
1033 if (if_instr->should_profile()) { |
1034 if (if_instr->should_profile()) { |
1034 ciMethod* method = if_instr->profiled_method(); |
1035 ciMethod* method = if_instr->profiled_method(); |
1035 assert(method != NULL, "method should be set if branch is profiled"); |
1036 assert(method != NULL, "method should be set if branch is profiled"); |
1036 ciMethodData* md = method->method_data_or_null(); |
1037 ciMethodData* md = method->method_data_or_null(); |
1037 if (md == NULL) { |
1038 if (md == NULL) { |
1038 bailout("out of memory building methodDataOop"); |
1039 bailout("out of memory building methodDataOop"); |
1039 return; |
1040 return; |
1040 } |
1041 } |
1041 ciProfileData* data = md->bci_to_data(if_instr->profiled_bci()); |
1042 ciProfileData* data = md->bci_to_data(if_instr->profiled_bci()); |
1042 assert(data != NULL, "must have profiling data"); |
1043 assert(data != NULL, "must have profiling data"); |
1043 assert(data->is_BranchData(), "need BranchData for two-way branches"); |
1044 assert(data->is_BranchData(), "need BranchData for two-way branches"); |
1044 int taken_count_offset = md->byte_offset_of_slot(data, BranchData::taken_offset()); |
1045 int taken_count_offset = md->byte_offset_of_slot(data, BranchData::taken_offset()); |
1045 int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset()); |
1046 int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset()); |
1046 if (if_instr->is_swapped()) { |
1047 if (if_instr->is_swapped()) { |
1047 int t = taken_count_offset; |
1048 int t = taken_count_offset; |
1048 taken_count_offset = not_taken_count_offset; |
1049 taken_count_offset = not_taken_count_offset; |
1049 not_taken_count_offset = t; |
1050 not_taken_count_offset = t; |
1050 } |
1051 } |
1051 LIR_Opr md_reg = new_register(T_METADATA); |
1052 LIR_Opr md_reg = new_register(T_METADATA); |
1052 __ metadata2reg(md->constant_encoding(), md_reg); |
1053 __ metadata2reg(md->constant_encoding(), md_reg); |
1053 //__ move(LIR_OprFact::oopConst(md->constant_encoding()), md_reg); |
1054 LIR_Opr data_offset_reg = new_pointer_register(); |
1054 LIR_Opr data_offset_reg = new_pointer_register(); |
1055 |
1055 |
1056 LIR_Opr opr1 = LIR_OprFact::intptrConst(taken_count_offset); |
1056 LIR_Opr opr1 = LIR_OprFact::intConst(taken_count_offset); |
1057 LIR_Opr opr2 = LIR_OprFact::intptrConst(not_taken_count_offset); |
1057 LIR_Opr opr2 = LIR_OprFact::intConst(not_taken_count_offset); |
1058 LabelObj* skip = new LabelObj(); |
1058 LabelObj* skip = new LabelObj(); |
1059 |
1059 |
1060 __ move(opr1, data_offset_reg); |
1060 __ move(opr1, data_offset_reg); |
1061 __ branch( lir_cond(cond), left, right, skip->label()); |
1061 __ branch( lir_cond(cond), left, right, skip->label()); |
1062 __ move(opr2, data_offset_reg); |
1062 __ move(opr2, data_offset_reg); |
1063 __ branch_destination(skip->label()); |
1063 __ branch_destination(skip->label()); |
1064 |
1064 |
1065 LIR_Opr data_reg = new_pointer_register(); |
1065 LIR_Opr data_reg = new_pointer_register(); |
1066 LIR_Opr tmp_reg = new_pointer_register(); |
1066 LIR_Opr tmp_reg = new_pointer_register(); |
1067 __ move(data_offset_reg, tmp_reg); |
1067 // LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, T_INT); |
1068 __ add(tmp_reg, md_reg, tmp_reg); |
1068 __ move(data_offset_reg, tmp_reg); |
1069 LIR_Address* data_addr = new LIR_Address(tmp_reg, 0, data_reg->type()); |
1069 __ add(tmp_reg, md_reg, tmp_reg); |
1070 __ move(LIR_OprFact::address(data_addr), data_reg); |
1070 LIR_Address* data_addr = new LIR_Address(tmp_reg, 0, T_INT); |
1071 LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT); |
1071 __ move(LIR_OprFact::address(data_addr), data_reg); |
1072 // Use leal instead of add to avoid destroying condition codes on x86 |
1072 LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT); |
1073 __ leal(LIR_OprFact::address(fake_incr_value), data_reg); |
1073 // Use leal instead of add to avoid destroying condition codes on x86 |
1074 __ move(data_reg, LIR_OprFact::address(data_addr)); |
1074 __ leal(LIR_OprFact::address(fake_incr_value), data_reg); |
1075 } |
1075 __ move(data_reg, LIR_OprFact::address(data_addr)); |
|
1076 } |
|
1077 } |
1076 } |
1078 |
1077 |
1079 #endif |
1078 #endif |
1080 |
1079 |
1081 // Phi technique: |
1080 // Phi technique: |
1994 if (index.result()->is_constant()) { |
1993 if (index.result()->is_constant()) { |
1995 #ifndef MIPS64 |
1994 #ifndef MIPS64 |
1996 cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info); |
1995 cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info); |
1997 __ branch(lir_cond_belowEqual, T_INT, stub); |
1996 __ branch(lir_cond_belowEqual, T_INT, stub); |
1998 #else |
1997 #else |
1999 LIR_Opr left = LIR_OprFact::address(new LIR_Address( buf.result(), |
1998 LIR_Opr left = LIR_OprFact::address(new LIR_Address( buf.result(), |
2000 java_nio_Buffer::limit_offset(),T_INT)); |
1999 java_nio_Buffer::limit_offset(),T_INT)); |
2001 LIR_Opr right = LIR_OprFact::intConst(index.result()->as_jint()); |
2000 LIR_Opr right = LIR_OprFact::intConst(index.result()->as_jint()); |
2002 __ null_check_for_branch(lir_cond_belowEqual, left, right, info); |
2001 __ null_check_for_branch(lir_cond_belowEqual, left, right, info); |
2003 __ branch(lir_cond_belowEqual,left, right ,T_INT, stub); // forward branch |
2002 __ branch(lir_cond_belowEqual,left, right ,T_INT, stub); // forward branch |
2004 |
2003 |
2005 #endif |
2004 #endif |
2006 } else { |
2005 } else { |
2007 #ifndef MIPS64 |
2006 #ifndef MIPS64 |
2008 cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf.result(), |
2007 cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf.result(), |
2009 java_nio_Buffer::limit_offset(), T_INT, info); |
2008 java_nio_Buffer::limit_offset(), T_INT, info); |
2010 __ branch(lir_cond_aboveEqual, T_INT, stub); |
2009 __ branch(lir_cond_aboveEqual, T_INT, stub); |
2011 #else |
2010 #else |
2012 LIR_Opr right = LIR_OprFact::address(new LIR_Address( buf.result(), java_nio_Buffer::limit_offset(),T_INT)); |
2011 LIR_Opr right = LIR_OprFact::address(new LIR_Address( buf.result(), java_nio_Buffer::limit_offset(),T_INT)); |
2013 LIR_Opr left = index.result(); |
2012 LIR_Opr left = index.result(); |
2014 __ null_check_for_branch(lir_cond_aboveEqual, left, right, info); |
2013 __ null_check_for_branch(lir_cond_aboveEqual, left, right, info); |
2015 __ branch(lir_cond_aboveEqual, left, right , T_INT, stub); // forward branch |
2014 __ branch(lir_cond_aboveEqual, left, right , T_INT, stub); // forward branch |
2016 #endif |
2015 #endif |
2017 } |
2016 } |
2018 __ move(index.result(), result); |
2017 __ move(index.result(), result); |
2019 } else { |
2018 } else { |
2020 // Just load the index into the result register |
2019 // Just load the index into the result register |
2824 assert(data->is_JumpData(), "need JumpData for branches"); |
2823 assert(data->is_JumpData(), "need JumpData for branches"); |
2825 offset = md->byte_offset_of_slot(data, JumpData::taken_offset()); |
2824 offset = md->byte_offset_of_slot(data, JumpData::taken_offset()); |
2826 } |
2825 } |
2827 LIR_Opr md_reg = new_register(T_METADATA); |
2826 LIR_Opr md_reg = new_register(T_METADATA); |
2828 __ metadata2reg(md->constant_encoding(), md_reg); |
2827 __ metadata2reg(md->constant_encoding(), md_reg); |
2829 |
|
2830 increment_counter(new LIR_Address(md_reg, offset, |
2828 increment_counter(new LIR_Address(md_reg, offset, |
2831 NOT_LP64(T_INT) LP64_ONLY(T_LONG)), DataLayout::counter_increment); |
2829 NOT_LP64(T_INT) LP64_ONLY(T_LONG)), DataLayout::counter_increment); |
2832 } |
2830 } |
2833 |
2831 |
2834 // emit phi-instruction move after safepoint since this simplifies |
2832 // emit phi-instruction move after safepoint since this simplifies |