< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciMethodData.hpp"
  27 #include "ci/ciTypeFlow.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "compiler/compileLog.hpp"


  31 #include "libadt/dict.hpp"
  32 #include "memory/oopFactory.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/instanceMirrorKlass.hpp"
  36 #include "oops/objArrayKlass.hpp"
  37 #include "oops/typeArrayKlass.hpp"
  38 #include "opto/matcher.hpp"
  39 #include "opto/node.hpp"
  40 #include "opto/opcodes.hpp"
  41 #include "opto/type.hpp"
  42 
  43 // Portions of code courtesy of Clifford Click
  44 
  45 // Optimization - Graph Style
  46 
  47 // Dictionary of types shared among compilations.
  48 Dict* Type::_shared_type_dict = NULL;
  49 
  50 // Array which maps compiler types to Basic Types


4055 //------------------------------cast_to_ptr_type-------------------------------
4056 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4057   if( ptr == _ptr ) return this;
4058   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4059 }
4060 
4061 
4062 //-----------------------------cast_to_exactness-------------------------------
4063 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4064   if( klass_is_exact == _klass_is_exact ) return this;
4065   if (!UseExactTypes)  return this;
4066   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4067   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4068 }
4069 
4070 //-----------------------------cast_to_instance_id----------------------------
4071 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4072   if( instance_id == _instance_id ) return this;
4073   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4074 }

4075 
4076 //-----------------------------narrow_size_type-------------------------------
4077 // Local cache for arrayOopDesc::max_array_length(etype),
4078 // which is kind of slow (and cached elsewhere by other users).
4079 static jint max_array_length_cache[T_CONFLICT+1];
4080 static jint max_array_length(BasicType etype) {
4081   jint& cache = max_array_length_cache[etype];
4082   jint res = cache;
4083   if (res == 0) {
4084     switch (etype) {
4085     case T_NARROWOOP:
4086       etype = T_OBJECT;
4087       break;
4088     case T_NARROWKLASS:
4089     case T_CONFLICT:
4090     case T_ILLEGAL:
4091     case T_VOID:
4092       etype = T_BYTE;           // will produce conservatively high value
4093       break;
4094     default:




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciMethodData.hpp"
  27 #include "ci/ciTypeFlow.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "gc/shared/barrierSet.hpp"
  32 #include "gc/shared/c2/barrierSetC2.hpp"
  33 #include "libadt/dict.hpp"
  34 #include "memory/oopFactory.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "oops/instanceKlass.hpp"
  37 #include "oops/instanceMirrorKlass.hpp"
  38 #include "oops/objArrayKlass.hpp"
  39 #include "oops/typeArrayKlass.hpp"
  40 #include "opto/matcher.hpp"
  41 #include "opto/node.hpp"
  42 #include "opto/opcodes.hpp"
  43 #include "opto/type.hpp"
  44 
  45 // Portions of code courtesy of Clifford Click
  46 
  47 // Optimization - Graph Style
  48 
  49 // Dictionary of types shared among compilations.
  50 Dict* Type::_shared_type_dict = NULL;
  51 
  52 // Array which maps compiler types to Basic Types


4057 //------------------------------cast_to_ptr_type-------------------------------
4058 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4059   if( ptr == _ptr ) return this;
4060   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4061 }
4062 
4063 
4064 //-----------------------------cast_to_exactness-------------------------------
4065 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4066   if( klass_is_exact == _klass_is_exact ) return this;
4067   if (!UseExactTypes)  return this;
4068   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4069   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4070 }
4071 
4072 //-----------------------------cast_to_instance_id----------------------------
4073 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4074   if( instance_id == _instance_id ) return this;
4075   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4076 }
4077 
4078 
4079 //-----------------------------narrow_size_type-------------------------------
4080 // Local cache for arrayOopDesc::max_array_length(etype),
4081 // which is kind of slow (and cached elsewhere by other users).
4082 static jint max_array_length_cache[T_CONFLICT+1];
4083 static jint max_array_length(BasicType etype) {
4084   jint& cache = max_array_length_cache[etype];
4085   jint res = cache;
4086   if (res == 0) {
4087     switch (etype) {
4088     case T_NARROWOOP:
4089       etype = T_OBJECT;
4090       break;
4091     case T_NARROWKLASS:
4092     case T_CONFLICT:
4093     case T_ILLEGAL:
4094     case T_VOID:
4095       etype = T_BYTE;           // will produce conservatively high value
4096       break;
4097     default:


< prev index next >