1.1 --- a/src/share/vm/c1/c1_Instruction.cpp Wed Oct 09 11:05:17 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_Instruction.cpp Wed Oct 09 16:32:21 2013 +0200 1.3 @@ -104,6 +104,14 @@ 1.4 } 1.5 } 1.6 1.7 +ciType* Instruction::exact_type() const { 1.8 + ciType* t = declared_type(); 1.9 + if (t != NULL && t->is_klass()) { 1.10 + return t->as_klass()->exact_klass(); 1.11 + } 1.12 + return NULL; 1.13 +} 1.14 + 1.15 1.16 #ifndef PRODUCT 1.17 void Instruction::check_state(ValueStack* state) { 1.18 @@ -135,9 +143,7 @@ 1.19 1.20 // perform constant and interval tests on index value 1.21 bool AccessIndexed::compute_needs_range_check() { 1.22 - 1.23 if (length()) { 1.24 - 1.25 Constant* clength = length()->as_Constant(); 1.26 Constant* cindex = index()->as_Constant(); 1.27 if (clength && cindex) { 1.28 @@ -157,34 +163,8 @@ 1.29 } 1.30 1.31 1.32 -ciType* Local::exact_type() const { 1.33 - ciType* type = declared_type(); 1.34 - 1.35 - // for primitive arrays, the declared type is the exact type 1.36 - if (type->is_type_array_klass()) { 1.37 - return type; 1.38 - } else if (type->is_instance_klass()) { 1.39 - ciInstanceKlass* ik = (ciInstanceKlass*)type; 1.40 - if (ik->is_loaded() && ik->is_final() && !ik->is_interface()) { 1.41 - return type; 1.42 - } 1.43 - } else if (type->is_obj_array_klass()) { 1.44 - ciObjArrayKlass* oak = (ciObjArrayKlass*)type; 1.45 - ciType* base = oak->base_element_type(); 1.46 - if (base->is_instance_klass()) { 1.47 - ciInstanceKlass* ik = base->as_instance_klass(); 1.48 - if (ik->is_loaded() && ik->is_final()) { 1.49 - return type; 1.50 - } 1.51 - } else if (base->is_primitive_type()) { 1.52 - return type; 1.53 - } 1.54 - } 1.55 - return NULL; 1.56 -} 1.57 - 1.58 ciType* Constant::exact_type() const { 1.59 - if (type()->is_object()) { 1.60 + if (type()->is_object() && type()->as_ObjectType()->is_loaded()) { 1.61 return type()->as_ObjectType()->exact_type(); 1.62 } 1.63 return NULL; 1.64 @@ -192,19 +172,18 @@ 1.65 1.66 ciType* LoadIndexed::exact_type() const { 1.67 ciType* array_type = array()->exact_type(); 1.68 - if (array_type == NULL) { 1.69 - return NULL; 1.70 - } 1.71 - assert(array_type->is_array_klass(), "what else?"); 1.72 - ciArrayKlass* ak = (ciArrayKlass*)array_type; 1.73 + if (array_type != NULL) { 1.74 + assert(array_type->is_array_klass(), "what else?"); 1.75 + ciArrayKlass* ak = (ciArrayKlass*)array_type; 1.76 1.77 - if (ak->element_type()->is_instance_klass()) { 1.78 - ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type(); 1.79 - if (ik->is_loaded() && ik->is_final()) { 1.80 - return ik; 1.81 + if (ak->element_type()->is_instance_klass()) { 1.82 + ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type(); 1.83 + if (ik->is_loaded() && ik->is_final()) { 1.84 + return ik; 1.85 + } 1.86 } 1.87 } 1.88 - return NULL; 1.89 + return Instruction::exact_type(); 1.90 } 1.91 1.92 1.93 @@ -224,22 +203,6 @@ 1.94 } 1.95 1.96 1.97 -ciType* LoadField::exact_type() const { 1.98 - ciType* type = declared_type(); 1.99 - // for primitive arrays, the declared type is the exact type 1.100 - if (type->is_type_array_klass()) { 1.101 - return type; 1.102 - } 1.103 - if (type->is_instance_klass()) { 1.104 - ciInstanceKlass* ik = (ciInstanceKlass*)type; 1.105 - if (ik->is_loaded() && ik->is_final()) { 1.106 - return type; 1.107 - } 1.108 - } 1.109 - return NULL; 1.110 -} 1.111 - 1.112 - 1.113 ciType* NewTypeArray::exact_type() const { 1.114 return ciTypeArrayKlass::make(elt_type()); 1.115 } 1.116 @@ -264,16 +227,6 @@ 1.117 return klass(); 1.118 } 1.119 1.120 -ciType* CheckCast::exact_type() const { 1.121 - if (klass()->is_instance_klass()) { 1.122 - ciInstanceKlass* ik = (ciInstanceKlass*)klass(); 1.123 - if (ik->is_loaded() && ik->is_final()) { 1.124 - return ik; 1.125 - } 1.126 - } 1.127 - return NULL; 1.128 -} 1.129 - 1.130 // Implementation of ArithmeticOp 1.131 1.132 bool ArithmeticOp::is_commutative() const {