hotspot/src/share/vm/ci/ciConstant.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot-comp Sdiff hotspot/src/share/vm/ci

hotspot/src/share/vm/ci/ciConstant.hpp

Print this page
rev 4966 : imported patch webrev.01


  24 
  25 #ifndef SHARE_VM_CI_CICONSTANT_HPP
  26 #define SHARE_VM_CI_CICONSTANT_HPP
  27 
  28 #include "ci/ciClassList.hpp"
  29 #include "ci/ciNullObject.hpp"
  30 
  31 // ciConstant
  32 //
  33 // This class represents a constant value.
  34 class ciConstant VALUE_OBJ_CLASS_SPEC {
  35   friend class VMStructs;
  36 private:
  37   friend class ciEnv;
  38   friend class ciField;
  39 
  40   BasicType _type;
  41   union {
  42     jint      _int;
  43     jlong     _long;
  44     jint      _long_half[2];
  45     jfloat    _float;
  46     jdouble   _double;
  47     ciObject* _object;
  48   } _value;
  49 
  50 public:
  51 
  52   ciConstant() {
  53     _type = T_ILLEGAL; _value._long = -1;
  54   }
  55   ciConstant(BasicType type, jint value) {
  56     assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
  57            "using the wrong ciConstant constructor");
  58     _type = type; _value._int = value;
  59   }
  60   ciConstant(jlong value) {
  61     _type = T_LONG; _value._long = value;
  62   }
  63   ciConstant(jfloat value) {
  64     _type = T_FLOAT; _value._float = value;


  94            basic_type() == T_INT, "wrong type");
  95     return _value._int;
  96   }
  97   jlong     as_long() {
  98     assert(basic_type() == T_LONG, "wrong type");
  99     return _value._long;
 100   }
 101   jfloat    as_float() {
 102     assert(basic_type() == T_FLOAT, "wrong type");
 103     return _value._float;
 104   }
 105   jdouble   as_double() {
 106     assert(basic_type() == T_DOUBLE, "wrong type");
 107     return _value._double;
 108   }
 109   ciObject* as_object() const {
 110     assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
 111     return _value._object;
 112   }
 113 














 114   // Debugging output
 115   void print();
 116 };
 117 
 118 #endif // SHARE_VM_CI_CICONSTANT_HPP


  24 
  25 #ifndef SHARE_VM_CI_CICONSTANT_HPP
  26 #define SHARE_VM_CI_CICONSTANT_HPP
  27 
  28 #include "ci/ciClassList.hpp"
  29 #include "ci/ciNullObject.hpp"
  30 
  31 // ciConstant
  32 //
  33 // This class represents a constant value.
  34 class ciConstant VALUE_OBJ_CLASS_SPEC {
  35   friend class VMStructs;
  36 private:
  37   friend class ciEnv;
  38   friend class ciField;
  39 
  40   BasicType _type;
  41   union {
  42     jint      _int;
  43     jlong     _long;

  44     jfloat    _float;
  45     jdouble   _double;
  46     ciObject* _object;
  47   } _value;
  48 
  49 public:
  50 
  51   ciConstant() {
  52     _type = T_ILLEGAL; _value._long = -1;
  53   }
  54   ciConstant(BasicType type, jint value) {
  55     assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
  56            "using the wrong ciConstant constructor");
  57     _type = type; _value._int = value;
  58   }
  59   ciConstant(jlong value) {
  60     _type = T_LONG; _value._long = value;
  61   }
  62   ciConstant(jfloat value) {
  63     _type = T_FLOAT; _value._float = value;


  93            basic_type() == T_INT, "wrong type");
  94     return _value._int;
  95   }
  96   jlong     as_long() {
  97     assert(basic_type() == T_LONG, "wrong type");
  98     return _value._long;
  99   }
 100   jfloat    as_float() {
 101     assert(basic_type() == T_FLOAT, "wrong type");
 102     return _value._float;
 103   }
 104   jdouble   as_double() {
 105     assert(basic_type() == T_DOUBLE, "wrong type");
 106     return _value._double;
 107   }
 108   ciObject* as_object() const {
 109     assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
 110     return _value._object;
 111   }
 112 
 113   bool      is_null_or_zero() const {
 114     if (!is_java_primitive(basic_type())) {
 115       return as_object()->is_null_object();
 116     } else if (type2size[basic_type()] == 1) {
 117       // treat float bits as int, to avoid comparison with -0 and NaN
 118       return (_value._int == 0);
 119     } else if (type2size[basic_type()] == 2) {
 120       // treat double bits as long, to avoid comparison with -0 and NaN
 121       return (_value._long == 0);
 122     } else {
 123       return false;
 124     }
 125   }
 126 
 127   // Debugging output
 128   void print();
 129 };
 130 
 131 #endif // SHARE_VM_CI_CICONSTANT_HPP
hotspot/src/share/vm/ci/ciConstant.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File