diff --git a/src/share/vm/opto/type.cpp b/src/share/vm/opto/type.cpp index 1a231df98d02ff052eba6a815fbc83d16d004705..a57e3a2851ede6cce03ff27d62dd99f3fc5f6bf3 100644 --- a/src/share/vm/opto/type.cpp +++ b/src/share/vm/opto/type.cpp @@ -3753,29 +3753,22 @@ const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); } -//-----------------------------narrow_size_type------------------------------- -// Local cache for arrayOopDesc::max_array_length(etype), -// which is kind of slow (and cached elsewhere by other users). -static jint max_array_length_cache[T_CONFLICT+1]; -static jint max_array_length(BasicType etype) { - jint& cache = max_array_length_cache[etype]; - jint res = cache; - if (res == 0) { - switch (etype) { - case T_NARROWOOP: +//-----------------------------max_array_length------------------------------- +// A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization. +jint TypeAryPtr::max_array_length(BasicType etype) { + if (!is_java_primitive(etype) && !is_reference_type(etype)) { + if (etype == T_NARROWOOP) { etype = T_OBJECT; - break; - case T_NARROWKLASS: - case T_CONFLICT: - case T_ILLEGAL: - case T_VOID: - etype = T_BYTE; // will produce conservatively high value + } else if (etype == T_ILLEGAL) { // bottom[] + etype = T_BYTE; // will produce conservatively high value + } else { + fatal(err_msg("not an element type: %s", type2name(etype))); } - cache = res = arrayOopDesc::max_array_length(etype); } - return res; + return arrayOopDesc::max_array_length(etype); } +//-----------------------------narrow_size_type------------------------------- // Narrow the given size type to the index range for the given array base type. // Return NULL if the resulting int type becomes empty. const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const { diff --git a/src/share/vm/opto/type.hpp b/src/share/vm/opto/type.hpp index 88e31faca2029e343bc542f694fdb9ba57a1bcba..a9352345e098fd36b6d4d8459bf5d5a5c1996323 100644 --- a/src/share/vm/opto/type.hpp +++ b/src/share/vm/opto/type.hpp @@ -433,7 +433,6 @@ public: private: // support arrays - static const BasicType _basic_type[]; static const Type* _zero_type[T_CONFLICT+1]; static const Type* _const_basic_type[T_CONFLICT+1]; }; @@ -1154,6 +1153,8 @@ public: const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const; int stable_dimension() const; + static jint max_array_length(BasicType etype) ; + // Convenience common pre-built types. static const TypeAryPtr *RANGE; static const TypeAryPtr *OOPS; diff --git a/src/share/vm/utilities/globalDefinitions.hpp b/src/share/vm/utilities/globalDefinitions.hpp index 2659418beae3148c5c1ba9c8b6aaab27841df50b..792888a7c52bedd9b4040ee88ff3b9b6e75cb939 100644 --- a/src/share/vm/utilities/globalDefinitions.hpp +++ b/src/share/vm/utilities/globalDefinitions.hpp @@ -644,6 +644,10 @@ inline bool is_signed_subword_type(BasicType t) { return (t == T_BYTE || t == T_SHORT); } +inline bool is_reference_type(BasicType t) { + return (t == T_OBJECT || t == T_ARRAY); +} + // Convert a char from a classfile signature to a BasicType inline BasicType char2type(char c) { switch( c ) {