< prev index next >

src/share/vm/opto/type.hpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 #ifndef SHARE_VM_OPTO_TYPE_HPP
  26 #define SHARE_VM_OPTO_TYPE_HPP
  27 
  28 #include "opto/adlcVMDeps.hpp"
  29 #include "runtime/handles.hpp"

  30 
  31 // Portions of code courtesy of Clifford Click
  32 
  33 // Optimization - Graph Style
  34 
  35 
  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  40 // The complete lattice is described below.  Subtypes have no relationship to
  41 // up or down in the lattice; that is entirely determined by the behavior of
  42 // the MEET/JOIN functions.
  43 
  44 class Dict;
  45 class Type;
  46 class   TypeD;
  47 class   TypeF;
  48 class   TypeInt;
  49 class   TypeLong;


 118   };
 119 
 120   // Signal values for offsets from a base pointer
 121   enum OFFSET_SIGNALS {
 122     OffsetTop = -2000000000,    // undefined offset
 123     OffsetBot = -2000000001     // any possible offset
 124   };
 125 
 126   // Min and max WIDEN values.
 127   enum WIDEN {
 128     WidenMin = 0,
 129     WidenMax = 3
 130   };
 131 
 132 private:
 133   typedef struct {
 134     const TYPES                dual_type;
 135     const BasicType            basic_type;
 136     const char*                msg;
 137     const bool                 isa_oop;
 138     const int                  ideal_reg;
 139     const relocInfo::relocType reloc;
 140   } TypeInfo;
 141 
 142   // Dictionary of types shared among compilations.
 143   static Dict* _shared_type_dict;
 144   static TypeInfo _type_info[];
 145 
 146   static int uhash( const Type *const t );
 147   // Structural equality check.  Assumes that cmp() has already compared
 148   // the _base types and thus knows it can cast 't' appropriately.
 149   virtual bool eq( const Type *t ) const;
 150 
 151   // Top-level hash-table of types
 152   static Dict *type_dict() {
 153     return Compile::current()->type_dict();
 154   }
 155 
 156   // DUAL operation: reflect around lattice centerline.  Used instead of
 157   // join to ensure my lattice is symmetric up and down.  Dual is computed
 158   // lazily, on demand, and cached in _dual.


 391     if (type == T_VOID || type >= T_CONFLICT)
 392       return false;
 393     else
 394       return (this == _zero_type[type]);
 395   }
 396 
 397   // Convenience common pre-built types.
 398   static const Type *ABIO;
 399   static const Type *BOTTOM;
 400   static const Type *CONTROL;
 401   static const Type *DOUBLE;
 402   static const Type *FLOAT;
 403   static const Type *HALF;
 404   static const Type *MEMORY;
 405   static const Type *MULTI;
 406   static const Type *RETURN_ADDRESS;
 407   static const Type *TOP;
 408 
 409   // Mapping from compiler type to VM BasicType
 410   BasicType basic_type() const       { return _type_info[_base].basic_type; }
 411   int ideal_reg() const              { return _type_info[_base].ideal_reg; }
 412   const char* msg() const            { return _type_info[_base].msg; }
 413   bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
 414   relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
 415 
 416   // Mapping from CI type system to compiler type:
 417   static const Type* get_typeflow_type(ciType* type);
 418 
 419   static const Type* make_from_constant(ciConstant constant,
 420                                         bool require_constant = false,
 421                                         int stable_dimension = 0,
 422                                         bool is_narrow = false,
 423                                         bool is_autobox_cache = false);
 424 
 425   static const Type* make_constant_from_field(ciInstance* holder,
 426                                               int off,
 427                                               bool is_unsigned_load,
 428                                               BasicType loadbt);
 429 
 430   static const Type* make_constant_from_field(ciField* field,
 431                                               ciInstance* holder,




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 #ifndef SHARE_VM_OPTO_TYPE_HPP
  26 #define SHARE_VM_OPTO_TYPE_HPP
  27 
  28 #include "opto/adlcVMDeps.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "opto/opcodes.hpp"
  31 
  32 // Portions of code courtesy of Clifford Click
  33 
  34 // Optimization - Graph Style
  35 
  36 
  37 // This class defines a Type lattice.  The lattice is used in the constant
  38 // propagation algorithms, and for some type-checking of the iloc code.
  39 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  40 // float & double precision constants, sets of data-labels and code-labels.
  41 // The complete lattice is described below.  Subtypes have no relationship to
  42 // up or down in the lattice; that is entirely determined by the behavior of
  43 // the MEET/JOIN functions.
  44 
  45 class Dict;
  46 class Type;
  47 class   TypeD;
  48 class   TypeF;
  49 class   TypeInt;
  50 class   TypeLong;


 119   };
 120 
 121   // Signal values for offsets from a base pointer
 122   enum OFFSET_SIGNALS {
 123     OffsetTop = -2000000000,    // undefined offset
 124     OffsetBot = -2000000001     // any possible offset
 125   };
 126 
 127   // Min and max WIDEN values.
 128   enum WIDEN {
 129     WidenMin = 0,
 130     WidenMax = 3
 131   };
 132 
 133 private:
 134   typedef struct {
 135     const TYPES                dual_type;
 136     const BasicType            basic_type;
 137     const char*                msg;
 138     const bool                 isa_oop;
 139     const Opcodes              ideal_reg;
 140     const relocInfo::relocType reloc;
 141   } TypeInfo;
 142 
 143   // Dictionary of types shared among compilations.
 144   static Dict* _shared_type_dict;
 145   static TypeInfo _type_info[];
 146 
 147   static int uhash( const Type *const t );
 148   // Structural equality check.  Assumes that cmp() has already compared
 149   // the _base types and thus knows it can cast 't' appropriately.
 150   virtual bool eq( const Type *t ) const;
 151 
 152   // Top-level hash-table of types
 153   static Dict *type_dict() {
 154     return Compile::current()->type_dict();
 155   }
 156 
 157   // DUAL operation: reflect around lattice centerline.  Used instead of
 158   // join to ensure my lattice is symmetric up and down.  Dual is computed
 159   // lazily, on demand, and cached in _dual.


 392     if (type == T_VOID || type >= T_CONFLICT)
 393       return false;
 394     else
 395       return (this == _zero_type[type]);
 396   }
 397 
 398   // Convenience common pre-built types.
 399   static const Type *ABIO;
 400   static const Type *BOTTOM;
 401   static const Type *CONTROL;
 402   static const Type *DOUBLE;
 403   static const Type *FLOAT;
 404   static const Type *HALF;
 405   static const Type *MEMORY;
 406   static const Type *MULTI;
 407   static const Type *RETURN_ADDRESS;
 408   static const Type *TOP;
 409 
 410   // Mapping from compiler type to VM BasicType
 411   BasicType basic_type() const       { return _type_info[_base].basic_type; }
 412   Opcodes ideal_reg() const          { return _type_info[_base].ideal_reg; }
 413   const char* msg() const            { return _type_info[_base].msg; }
 414   bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
 415   relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
 416 
 417   // Mapping from CI type system to compiler type:
 418   static const Type* get_typeflow_type(ciType* type);
 419 
 420   static const Type* make_from_constant(ciConstant constant,
 421                                         bool require_constant = false,
 422                                         int stable_dimension = 0,
 423                                         bool is_narrow = false,
 424                                         bool is_autobox_cache = false);
 425 
 426   static const Type* make_constant_from_field(ciInstance* holder,
 427                                               int off,
 428                                               bool is_unsigned_load,
 429                                               BasicType loadbt);
 430 
 431   static const Type* make_constant_from_field(ciField* field,
 432                                               ciInstance* holder,


< prev index next >