Mercurial > hg > truffle
comparison src/share/vm/c1/c1_LIRGenerator.cpp @ 2014:4de5f4101cfd
Merge
author | iveresov |
---|---|
date | Wed, 08 Dec 2010 17:50:49 -0800 |
parents | 5ddfcf4b079e |
children | 06f017f7daa7 037c727f35fb df307487d610 |
comparison
equal
deleted
inserted
replaced
1990:401fbd7ff77c | 2014:4de5f4101cfd |
---|---|
834 | 834 |
835 void LIRGenerator::profile_branch(If* if_instr, If::Condition cond) { | 835 void LIRGenerator::profile_branch(If* if_instr, If::Condition cond) { |
836 if (if_instr->should_profile()) { | 836 if (if_instr->should_profile()) { |
837 ciMethod* method = if_instr->profiled_method(); | 837 ciMethod* method = if_instr->profiled_method(); |
838 assert(method != NULL, "method should be set if branch is profiled"); | 838 assert(method != NULL, "method should be set if branch is profiled"); |
839 ciMethodData* md = method->method_data(); | 839 ciMethodData* md = method->method_data_or_null(); |
840 if (md == NULL) { | 840 assert(md != NULL, "Sanity"); |
841 bailout("out of memory building methodDataOop"); | |
842 return; | |
843 } | |
844 ciProfileData* data = md->bci_to_data(if_instr->profiled_bci()); | 841 ciProfileData* data = md->bci_to_data(if_instr->profiled_bci()); |
845 assert(data != NULL, "must have profiling data"); | 842 assert(data != NULL, "must have profiling data"); |
846 assert(data->is_BranchData(), "need BranchData for two-way branches"); | 843 assert(data->is_BranchData(), "need BranchData for two-way branches"); |
847 int taken_count_offset = md->byte_offset_of_slot(data, BranchData::taken_offset()); | 844 int taken_count_offset = md->byte_offset_of_slot(data, BranchData::taken_offset()); |
848 int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset()); | 845 int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset()); |
862 data_offset_reg); | 859 data_offset_reg); |
863 | 860 |
864 // MDO cells are intptr_t, so the data_reg width is arch-dependent. | 861 // MDO cells are intptr_t, so the data_reg width is arch-dependent. |
865 LIR_Opr data_reg = new_pointer_register(); | 862 LIR_Opr data_reg = new_pointer_register(); |
866 LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type()); | 863 LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type()); |
867 __ move(LIR_OprFact::address(data_addr), data_reg); | 864 __ move(data_addr, data_reg); |
868 // Use leal instead of add to avoid destroying condition codes on x86 | 865 // Use leal instead of add to avoid destroying condition codes on x86 |
869 LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT); | 866 LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT); |
870 __ leal(LIR_OprFact::address(fake_incr_value), data_reg); | 867 __ leal(LIR_OprFact::address(fake_incr_value), data_reg); |
871 __ move(data_reg, LIR_OprFact::address(data_addr)); | 868 __ move(data_reg, data_addr); |
872 } | 869 } |
873 } | 870 } |
874 | 871 |
875 // Phi technique: | 872 // Phi technique: |
876 // This is about passing live values from one basic block to the other. | 873 // This is about passing live values from one basic block to the other. |
1007 // handlers, so assign operands manually here | 1004 // handlers, so assign operands manually here |
1008 for_each_phi_fun(block(), phi, | 1005 for_each_phi_fun(block(), phi, |
1009 operand_for_instruction(phi)); | 1006 operand_for_instruction(phi)); |
1010 | 1007 |
1011 LIR_Opr thread_reg = getThreadPointer(); | 1008 LIR_Opr thread_reg = getThreadPointer(); |
1012 __ move(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT), | 1009 __ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT), |
1013 exceptionOopOpr()); | 1010 exceptionOopOpr()); |
1014 __ move(LIR_OprFact::oopConst(NULL), | 1011 __ move_wide(LIR_OprFact::oopConst(NULL), |
1015 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT)); | 1012 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT)); |
1016 __ move(LIR_OprFact::oopConst(NULL), | 1013 __ move_wide(LIR_OprFact::oopConst(NULL), |
1017 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_pc_offset()), T_OBJECT)); | 1014 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_pc_offset()), T_OBJECT)); |
1018 | 1015 |
1019 LIR_Opr result = new_register(T_OBJECT); | 1016 LIR_Opr result = new_register(T_OBJECT); |
1020 __ move(exceptionOopOpr(), result); | 1017 __ move(exceptionOopOpr(), result); |
1021 set_result(x, result); | 1018 set_result(x, result); |
1022 } | 1019 } |
1083 | 1080 |
1084 | 1081 |
1085 void LIRGenerator::do_Return(Return* x) { | 1082 void LIRGenerator::do_Return(Return* x) { |
1086 if (compilation()->env()->dtrace_method_probes()) { | 1083 if (compilation()->env()->dtrace_method_probes()) { |
1087 BasicTypeList signature; | 1084 BasicTypeList signature; |
1088 signature.append(T_INT); // thread | 1085 signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread |
1089 signature.append(T_OBJECT); // methodOop | 1086 signature.append(T_OBJECT); // methodOop |
1090 LIR_OprList* args = new LIR_OprList(); | 1087 LIR_OprList* args = new LIR_OprList(); |
1091 args->append(getThreadPointer()); | 1088 args->append(getThreadPointer()); |
1092 LIR_Opr meth = new_register(T_OBJECT); | 1089 LIR_Opr meth = new_register(T_OBJECT); |
1093 __ oop2reg(method()->constant_encoding(), meth); | 1090 __ oop2reg(method()->constant_encoding(), meth); |
1120 CodeEmitInfo* info = NULL; | 1117 CodeEmitInfo* info = NULL; |
1121 if (x->needs_null_check()) { | 1118 if (x->needs_null_check()) { |
1122 info = state_for(x); | 1119 info = state_for(x); |
1123 } | 1120 } |
1124 __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_OBJECT), result, info); | 1121 __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_OBJECT), result, info); |
1125 __ move(new LIR_Address(result, Klass::java_mirror_offset_in_bytes() + | 1122 __ move_wide(new LIR_Address(result, Klass::java_mirror_offset_in_bytes() + |
1126 klassOopDesc::klass_part_offset_in_bytes(), T_OBJECT), result); | 1123 klassOopDesc::klass_part_offset_in_bytes(), T_OBJECT), result); |
1127 } | 1124 } |
1128 | 1125 |
1129 | 1126 |
1130 // Example: Thread.currentThread() | 1127 // Example: Thread.currentThread() |
1131 void LIRGenerator::do_currentThread(Intrinsic* x) { | 1128 void LIRGenerator::do_currentThread(Intrinsic* x) { |
1132 assert(x->number_of_arguments() == 0, "wrong type"); | 1129 assert(x->number_of_arguments() == 0, "wrong type"); |
1133 LIR_Opr reg = rlock_result(x); | 1130 LIR_Opr reg = rlock_result(x); |
1134 __ load(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_OBJECT), reg); | 1131 __ move_wide(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_OBJECT), reg); |
1135 } | 1132 } |
1136 | 1133 |
1137 | 1134 |
1138 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) { | 1135 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) { |
1139 assert(x->number_of_arguments() == 1, "wrong type"); | 1136 assert(x->number_of_arguments() == 1, "wrong type"); |
1906 } | 1903 } |
1907 | 1904 |
1908 if (x->may_be_unaligned() && (dst_type == T_LONG || dst_type == T_DOUBLE)) { | 1905 if (x->may_be_unaligned() && (dst_type == T_LONG || dst_type == T_DOUBLE)) { |
1909 __ unaligned_move(addr, reg); | 1906 __ unaligned_move(addr, reg); |
1910 } else { | 1907 } else { |
1911 __ move(addr, reg); | 1908 if (dst_type == T_OBJECT && x->is_wide()) { |
1909 __ move_wide(addr, reg); | |
1910 } else { | |
1911 __ move(addr, reg); | |
1912 } | |
1912 } | 1913 } |
1913 } | 1914 } |
1914 | 1915 |
1915 | 1916 |
1916 void LIRGenerator::do_UnsafePutRaw(UnsafePutRaw* x) { | 1917 void LIRGenerator::do_UnsafePutRaw(UnsafePutRaw* x) { |
2213 | 2214 |
2214 // Gotos can be folded Ifs, handle this case. | 2215 // Gotos can be folded Ifs, handle this case. |
2215 if (x->should_profile()) { | 2216 if (x->should_profile()) { |
2216 ciMethod* method = x->profiled_method(); | 2217 ciMethod* method = x->profiled_method(); |
2217 assert(method != NULL, "method should be set if branch is profiled"); | 2218 assert(method != NULL, "method should be set if branch is profiled"); |
2218 ciMethodData* md = method->method_data(); | 2219 ciMethodData* md = method->method_data_or_null(); |
2219 if (md == NULL) { | 2220 assert(md != NULL, "Sanity"); |
2220 bailout("out of memory building methodDataOop"); | |
2221 return; | |
2222 } | |
2223 ciProfileData* data = md->bci_to_data(x->profiled_bci()); | 2221 ciProfileData* data = md->bci_to_data(x->profiled_bci()); |
2224 assert(data != NULL, "must have profiling data"); | 2222 assert(data != NULL, "must have profiling data"); |
2225 int offset; | 2223 int offset; |
2226 if (x->direction() == Goto::taken) { | 2224 if (x->direction() == Goto::taken) { |
2227 assert(data->is_BranchData(), "need BranchData for two-way branches"); | 2225 assert(data->is_BranchData(), "need BranchData for two-way branches"); |
2285 java_index += type2size[t]; | 2283 java_index += type2size[t]; |
2286 } | 2284 } |
2287 | 2285 |
2288 if (compilation()->env()->dtrace_method_probes()) { | 2286 if (compilation()->env()->dtrace_method_probes()) { |
2289 BasicTypeList signature; | 2287 BasicTypeList signature; |
2290 signature.append(T_INT); // thread | 2288 signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread |
2291 signature.append(T_OBJECT); // methodOop | 2289 signature.append(T_OBJECT); // methodOop |
2292 LIR_OprList* args = new LIR_OprList(); | 2290 LIR_OprList* args = new LIR_OprList(); |
2293 args->append(getThreadPointer()); | 2291 args->append(getThreadPointer()); |
2294 LIR_Opr meth = new_register(T_OBJECT); | 2292 LIR_Opr meth = new_register(T_OBJECT); |
2295 __ oop2reg(method()->constant_encoding(), meth); | 2293 __ oop2reg(method()->constant_encoding(), meth); |
2350 if (loc->is_register()) { | 2348 if (loc->is_register()) { |
2351 param->load_item_force(loc); | 2349 param->load_item_force(loc); |
2352 } else { | 2350 } else { |
2353 LIR_Address* addr = loc->as_address_ptr(); | 2351 LIR_Address* addr = loc->as_address_ptr(); |
2354 param->load_for_store(addr->type()); | 2352 param->load_for_store(addr->type()); |
2355 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) { | 2353 if (addr->type() == T_OBJECT) { |
2356 __ unaligned_move(param->result(), addr); | 2354 __ move_wide(param->result(), addr); |
2357 } else { | 2355 } else |
2358 __ move(param->result(), addr); | 2356 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) { |
2359 } | 2357 __ unaligned_move(param->result(), addr); |
2358 } else { | |
2359 __ move(param->result(), addr); | |
2360 } | |
2360 } | 2361 } |
2361 } | 2362 } |
2362 | 2363 |
2363 if (x->has_receiver()) { | 2364 if (x->has_receiver()) { |
2364 LIRItem* receiver = args->at(0); | 2365 LIRItem* receiver = args->at(0); |
2366 if (loc->is_register()) { | 2367 if (loc->is_register()) { |
2367 receiver->load_item_force(loc); | 2368 receiver->load_item_force(loc); |
2368 } else { | 2369 } else { |
2369 assert(loc->is_address(), "just checking"); | 2370 assert(loc->is_address(), "just checking"); |
2370 receiver->load_for_store(T_OBJECT); | 2371 receiver->load_for_store(T_OBJECT); |
2371 __ move(receiver->result(), loc); | 2372 __ move_wide(receiver->result(), loc->as_address_ptr()); |
2372 } | 2373 } |
2373 } | 2374 } |
2374 } | 2375 } |
2375 | 2376 |
2376 | 2377 |
2714 __ oop2reg(method->constant_encoding(), counter_holder); | 2715 __ oop2reg(method->constant_encoding(), counter_holder); |
2715 meth = counter_holder; | 2716 meth = counter_holder; |
2716 } else if (level == CompLevel_full_profile) { | 2717 } else if (level == CompLevel_full_profile) { |
2717 offset = in_bytes(backedge ? methodDataOopDesc::backedge_counter_offset() : | 2718 offset = in_bytes(backedge ? methodDataOopDesc::backedge_counter_offset() : |
2718 methodDataOopDesc::invocation_counter_offset()); | 2719 methodDataOopDesc::invocation_counter_offset()); |
2719 __ oop2reg(method->method_data()->constant_encoding(), counter_holder); | 2720 ciMethodData* md = method->method_data_or_null(); |
2721 assert(md != NULL, "Sanity"); | |
2722 __ oop2reg(md->constant_encoding(), counter_holder); | |
2720 meth = new_register(T_OBJECT); | 2723 meth = new_register(T_OBJECT); |
2721 __ oop2reg(method->constant_encoding(), meth); | 2724 __ oop2reg(method->constant_encoding(), meth); |
2722 } else { | 2725 } else { |
2723 ShouldNotReachHere(); | 2726 ShouldNotReachHere(); |
2724 } | 2727 } |