< prev index next >

src/hotspot/share/ci/ciType.cpp

Print this page




  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/ciEnv.hpp"
  27 #include "ci/ciType.hpp"
  28 #include "ci/ciUtilities.inline.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "oops/oop.inline.hpp"
  32 
  33 ciType* ciType::_basic_types[T_CONFLICT+1];
  34 
  35 // ciType
  36 //
  37 // This class represents either a class (T_OBJECT), array (T_ARRAY),
  38 // or one of the primitive types such as T_INT.
  39 
  40 // ------------------------------------------------------------------
  41 // ciType::ciType
  42 //
  43 ciType::ciType(BasicType basic_type) : ciMetadata() {
  44   assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
  45   _basic_type = basic_type;
  46 }
  47 
  48 ciType::ciType(Klass* k) : ciMetadata(k) {
  49   _basic_type = k->is_array_klass() ? T_ARRAY : T_OBJECT;
  50 }
  51 
  52 
  53 // ------------------------------------------------------------------
  54 // ciType::is_subtype_of
  55 //
  56 bool ciType::is_subtype_of(ciType* type) {
  57   if (this == type)  return true;
  58   if (is_klass() && type->is_klass())
  59     return this->as_klass()->is_subtype_of(type->as_klass());
  60   return false;
  61 }
  62 
  63 // ------------------------------------------------------------------
  64 // ciType::name
  65 //
  66 // Return the name of this type
  67 const char* ciType::name() {
  68   if (is_primitive_type()) {
  69     return type2name(basic_type());


  88 // Print the name of this type
  89 void ciType::print_name_on(outputStream* st) {
  90   ResourceMark rm;
  91   st->print("%s", name());
  92 }
  93 
  94 
  95 
  96 // ------------------------------------------------------------------
  97 // ciType::java_mirror
  98 //
  99 ciInstance* ciType::java_mirror() {
 100   VM_ENTRY_MARK;
 101   return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type()));
 102 }
 103 
 104 // ------------------------------------------------------------------
 105 // ciType::box_klass
 106 //
 107 ciKlass* ciType::box_klass() {

 108   if (!is_primitive_type())  return this->as_klass();  // reference types are "self boxing"
 109 
 110   // Void is "boxed" with a null.
 111   if (basic_type() == T_VOID)  return NULL;
 112 
 113   VM_ENTRY_MARK;
 114   return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type()));
 115 }
 116 
 117 
 118 // ------------------------------------------------------------------
 119 // ciType::make
 120 //
 121 // Produce the ciType for a given primitive BasicType.
 122 // As a bonus, produce the right reference type for T_OBJECT.
 123 // Does not work on T_ARRAY.
 124 ciType* ciType::make(BasicType t) {
 125   // short, etc.
 126   // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
 127   assert((uint)t < T_CONFLICT+1, "range check");




  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/ciEnv.hpp"
  27 #include "ci/ciType.hpp"
  28 #include "ci/ciUtilities.inline.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "oops/oop.inline.hpp"
  32 
  33 ciType* ciType::_basic_types[T_CONFLICT+1];
  34 
  35 // ciType
  36 //
  37 // This class represents either a class (T_OBJECT), value (T_VALUETYPE),
  38 // array (T_ARRAY),or one of the primitive types such as T_INT.
  39 
  40 // ------------------------------------------------------------------
  41 // ciType::ciType
  42 //
  43 ciType::ciType(BasicType basic_type) : ciMetadata() {
  44   assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
  45   _basic_type = basic_type;
  46 }
  47 
  48 ciType::ciType(Klass* k) : ciMetadata(k) {
  49   _basic_type = k->is_array_klass() ? T_ARRAY : (k->is_value() ? T_VALUETYPE : T_OBJECT);
  50 }
  51 
  52 
  53 // ------------------------------------------------------------------
  54 // ciType::is_subtype_of
  55 //
  56 bool ciType::is_subtype_of(ciType* type) {
  57   if (this == type)  return true;
  58   if (is_klass() && type->is_klass())
  59     return this->as_klass()->is_subtype_of(type->as_klass());
  60   return false;
  61 }
  62 
  63 // ------------------------------------------------------------------
  64 // ciType::name
  65 //
  66 // Return the name of this type
  67 const char* ciType::name() {
  68   if (is_primitive_type()) {
  69     return type2name(basic_type());


  88 // Print the name of this type
  89 void ciType::print_name_on(outputStream* st) {
  90   ResourceMark rm;
  91   st->print("%s", name());
  92 }
  93 
  94 
  95 
  96 // ------------------------------------------------------------------
  97 // ciType::java_mirror
  98 //
  99 ciInstance* ciType::java_mirror() {
 100   VM_ENTRY_MARK;
 101   return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type()));
 102 }
 103 
 104 // ------------------------------------------------------------------
 105 // ciType::box_klass
 106 //
 107 ciKlass* ciType::box_klass() {
 108   assert(basic_type() != T_VALUETYPE, "value type boxing not yet supported");
 109   if (!is_primitive_type())  return this->as_klass();  // reference types are "self boxing"
 110 
 111   // Void is "boxed" with a null.
 112   if (basic_type() == T_VOID)  return NULL;
 113 
 114   VM_ENTRY_MARK;
 115   return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type()));
 116 }
 117 
 118 
 119 // ------------------------------------------------------------------
 120 // ciType::make
 121 //
 122 // Produce the ciType for a given primitive BasicType.
 123 // As a bonus, produce the right reference type for T_OBJECT.
 124 // Does not work on T_ARRAY.
 125 ciType* ciType::make(BasicType t) {
 126   // short, etc.
 127   // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
 128   assert((uint)t < T_CONFLICT+1, "range check");


< prev index next >