25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "compiler/compileLog.hpp" |
26 #include "compiler/compileLog.hpp" |
27 #include "interpreter/linkResolver.hpp" |
27 #include "interpreter/linkResolver.hpp" |
28 #include "oops/method.hpp" |
28 #include "oops/method.hpp" |
29 #include "opto/addnode.hpp" |
29 #include "opto/addnode.hpp" |
|
30 #include "opto/c2compiler.hpp" |
30 #include "opto/idealGraphPrinter.hpp" |
31 #include "opto/idealGraphPrinter.hpp" |
31 #include "opto/locknode.hpp" |
32 #include "opto/locknode.hpp" |
32 #include "opto/memnode.hpp" |
33 #include "opto/memnode.hpp" |
33 #include "opto/parse.hpp" |
34 #include "opto/parse.hpp" |
34 #include "opto/rootnode.hpp" |
35 #include "opto/rootnode.hpp" |
986 } |
987 } |
987 |
988 |
988 if (tf()->range()->cnt() > TypeFunc::Parms) { |
989 if (tf()->range()->cnt() > TypeFunc::Parms) { |
989 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms); |
990 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms); |
990 Node* ret_phi = _gvn.transform( _exits.argument(0) ); |
991 Node* ret_phi = _gvn.transform( _exits.argument(0) ); |
991 assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty(), "return value must be well defined"); |
992 if (!_exits.control()->is_top() && _gvn.type(ret_phi)->empty()) { |
|
993 // In case of concurrent class loading, the type we set for the |
|
994 // ret_phi in build_exits() may have been too optimistic and the |
|
995 // ret_phi may be top now. |
|
996 // Otherwise, we've encountered an error and have to mark the method as |
|
997 // not compilable. Just using an assertion instead would be dangerous |
|
998 // as this could lead to an infinite compile loop in non-debug builds. |
|
999 { |
|
1000 MutexLockerEx ml(Compile_lock, Mutex::_no_safepoint_check_flag); |
|
1001 if (C->env()->system_dictionary_modification_counter_changed()) { |
|
1002 C->record_failure(C2Compiler::retry_class_loading_during_parsing()); |
|
1003 } else { |
|
1004 C->record_method_not_compilable("Can't determine return type."); |
|
1005 } |
|
1006 } |
|
1007 return; |
|
1008 } |
992 if (ret_type->isa_int()) { |
1009 if (ret_type->isa_int()) { |
993 BasicType ret_bt = method()->return_type()->basic_type(); |
1010 BasicType ret_bt = method()->return_type()->basic_type(); |
994 ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn); |
1011 ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn); |
995 } |
1012 } |
996 _exits.push_node(ret_type->basic_type(), ret_phi); |
1013 _exits.push_node(ret_type->basic_type(), ret_phi); |
2114 // If returning oops to an interface-return, there is a silent free |
2131 // If returning oops to an interface-return, there is a silent free |
2115 // cast from oop to interface allowed by the Verifier. Make it explicit |
2132 // cast from oop to interface allowed by the Verifier. Make it explicit |
2116 // here. |
2133 // here. |
2117 Node* phi = _exits.argument(0); |
2134 Node* phi = _exits.argument(0); |
2118 const TypeInstPtr *tr = phi->bottom_type()->isa_instptr(); |
2135 const TypeInstPtr *tr = phi->bottom_type()->isa_instptr(); |
2119 if( tr && tr->klass()->is_loaded() && |
2136 if (tr && tr->klass()->is_loaded() && |
2120 tr->klass()->is_interface() ) { |
2137 tr->klass()->is_interface()) { |
2121 const TypeInstPtr *tp = value->bottom_type()->isa_instptr(); |
2138 const TypeInstPtr *tp = value->bottom_type()->isa_instptr(); |
2122 if (tp && tp->klass()->is_loaded() && |
2139 if (tp && tp->klass()->is_loaded() && |
2123 !tp->klass()->is_interface()) { |
2140 !tp->klass()->is_interface()) { |
2124 // sharpen the type eagerly; this eases certain assert checking |
2141 // sharpen the type eagerly; this eases certain assert checking |
2125 if (tp->higher_equal(TypeInstPtr::NOTNULL)) |
2142 if (tp->higher_equal(TypeInstPtr::NOTNULL)) |
2126 tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr(); |
2143 tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr(); |
2127 value = _gvn.transform(new (C) CheckCastPPNode(0,value,tr)); |
2144 value = _gvn.transform(new (C) CheckCastPPNode(0, value, tr)); |
|
2145 } |
|
2146 } else { |
|
2147 // Also handle returns of oop-arrays to an arrays-of-interface return |
|
2148 const TypeInstPtr* phi_tip; |
|
2149 const TypeInstPtr* val_tip; |
|
2150 Type::get_arrays_base_elements(phi->bottom_type(), value->bottom_type(), &phi_tip, &val_tip); |
|
2151 if (phi_tip != NULL && phi_tip->is_loaded() && phi_tip->klass()->is_interface() && |
|
2152 val_tip != NULL && val_tip->is_loaded() && !val_tip->klass()->is_interface()) { |
|
2153 value = _gvn.transform(new (C) CheckCastPPNode(0, value, phi->bottom_type())); |
2128 } |
2154 } |
2129 } |
2155 } |
2130 phi->add_req(value); |
2156 phi->add_req(value); |
2131 } |
2157 } |
2132 |
2158 |