hotspot/src/share/vm/shark/sharkContext.hpp
changeset 14622 8e94e4186d35
parent 13728 882756847a04
equal deleted inserted replaced
14621:fd9265ab0f67 14622:8e94e4186d35
    40   SharkContext(const char* name);
    40   SharkContext(const char* name);
    41 
    41 
    42  private:
    42  private:
    43   llvm::Module* _module;
    43   llvm::Module* _module;
    44 
    44 
    45 #if SHARK_LLVM_VERSION >= 27
       
    46  public:
    45  public:
    47 #else
       
    48  private:
       
    49 #endif
       
    50   llvm::Module* module() const {
    46   llvm::Module* module() const {
    51     return _module;
    47     return _module;
    52   }
    48   }
    53 
    49 
    54   // Get this thread's SharkContext
    50   // Get this thread's SharkContext
    57     return *SharkCompiler::compiler()->context();
    53     return *SharkCompiler::compiler()->context();
    58   }
    54   }
    59 
    55 
    60   // Module accessors
    56   // Module accessors
    61  public:
    57  public:
    62 #if SHARK_LLVM_VERSION < 27
       
    63   llvm::ModuleProvider* module_provider() const {
       
    64     return new llvm::ExistingModuleProvider(module());
       
    65   }
       
    66 #endif
       
    67   void add_function(llvm::Function* function) const {
    58   void add_function(llvm::Function* function) const {
    68     module()->getFunctionList().push_back(function);
    59     module()->getFunctionList().push_back(function);
    69   }
    60   }
    70   llvm::Constant* get_external(const char*               name,
    61   llvm::Constant* get_external(const char*               name,
    71                                const llvm::FunctionType* sig) {
    62                                llvm::FunctionType* sig) {
    72     return module()->getOrInsertFunction(name, sig);
    63     return module()->getOrInsertFunction(name, sig);
    73   }
    64   }
    74 
    65 
    75   // Basic types
    66   // Basic types
    76  private:
    67  private:
    77   const llvm::Type*        _void_type;
    68   llvm::Type*        _void_type;
    78   const llvm::IntegerType* _bit_type;
    69   llvm::IntegerType* _bit_type;
    79   const llvm::IntegerType* _jbyte_type;
    70   llvm::IntegerType* _jbyte_type;
    80   const llvm::IntegerType* _jshort_type;
    71   llvm::IntegerType* _jshort_type;
    81   const llvm::IntegerType* _jint_type;
    72   llvm::IntegerType* _jint_type;
    82   const llvm::IntegerType* _jlong_type;
    73   llvm::IntegerType* _jlong_type;
    83   const llvm::Type*        _jfloat_type;
    74   llvm::Type*        _jfloat_type;
    84   const llvm::Type*        _jdouble_type;
    75   llvm::Type*        _jdouble_type;
    85 
    76 
    86  public:
    77  public:
    87   const llvm::Type* void_type() const {
    78   llvm::Type* void_type() const {
    88     return _void_type;
    79     return _void_type;
    89   }
    80   }
    90   const llvm::IntegerType* bit_type() const {
    81   llvm::IntegerType* bit_type() const {
    91     return _bit_type;
    82     return _bit_type;
    92   }
    83   }
    93   const llvm::IntegerType* jbyte_type() const {
    84   llvm::IntegerType* jbyte_type() const {
    94     return _jbyte_type;
    85     return _jbyte_type;
    95   }
    86   }
    96   const llvm::IntegerType* jshort_type() const {
    87   llvm::IntegerType* jshort_type() const {
    97     return _jshort_type;
    88     return _jshort_type;
    98   }
    89   }
    99   const llvm::IntegerType* jint_type() const {
    90   llvm::IntegerType* jint_type() const {
   100     return _jint_type;
    91     return _jint_type;
   101   }
    92   }
   102   const llvm::IntegerType* jlong_type() const {
    93   llvm::IntegerType* jlong_type() const {
   103     return _jlong_type;
    94     return _jlong_type;
   104   }
    95   }
   105   const llvm::Type* jfloat_type() const {
    96   llvm::Type* jfloat_type() const {
   106     return _jfloat_type;
    97     return _jfloat_type;
   107   }
    98   }
   108   const llvm::Type* jdouble_type() const {
    99   llvm::Type* jdouble_type() const {
   109     return _jdouble_type;
   100     return _jdouble_type;
   110   }
   101   }
   111   const llvm::IntegerType* intptr_type() const {
   102   llvm::IntegerType* intptr_type() const {
   112     return LP64_ONLY(jlong_type()) NOT_LP64(jint_type());
   103     return LP64_ONLY(jlong_type()) NOT_LP64(jint_type());
   113   }
   104   }
   114 
   105 
   115   // Compound types
   106   // Compound types
   116  private:
   107  private:
   117   const llvm::PointerType*  _itableOffsetEntry_type;
   108   llvm::PointerType*  _itableOffsetEntry_type;
   118   const llvm::PointerType*  _jniEnv_type;
   109   llvm::PointerType*  _jniEnv_type;
   119   const llvm::PointerType*  _jniHandleBlock_type;
   110   llvm::PointerType*  _jniHandleBlock_type;
   120   const llvm::PointerType*  _klass_type;
   111   llvm::PointerType*  _Metadata_type;
   121   const llvm::PointerType*  _Method*_type;
   112   llvm::PointerType*  _klass_type;
   122   const llvm::ArrayType*    _monitor_type;
   113   llvm::PointerType*  _Method_type;
   123   const llvm::PointerType*  _oop_type;
   114   llvm::ArrayType*    _monitor_type;
   124   const llvm::PointerType*  _thread_type;
   115   llvm::PointerType*  _oop_type;
   125   const llvm::PointerType*  _zeroStack_type;
   116   llvm::PointerType*  _thread_type;
   126   const llvm::FunctionType* _entry_point_type;
   117   llvm::PointerType*  _zeroStack_type;
   127   const llvm::FunctionType* _osr_entry_point_type;
   118   llvm::FunctionType* _entry_point_type;
       
   119   llvm::FunctionType* _osr_entry_point_type;
   128 
   120 
   129  public:
   121  public:
   130   const llvm::PointerType* itableOffsetEntry_type() const {
   122   llvm::PointerType* itableOffsetEntry_type() const {
   131     return _itableOffsetEntry_type;
   123     return _itableOffsetEntry_type;
   132   }
   124   }
   133   const llvm::PointerType* jniEnv_type() const {
   125   llvm::PointerType* jniEnv_type() const {
   134     return _jniEnv_type;
   126     return _jniEnv_type;
   135   }
   127   }
   136   const llvm::PointerType* jniHandleBlock_type() const {
   128   llvm::PointerType* jniHandleBlock_type() const {
   137     return _jniHandleBlock_type;
   129     return _jniHandleBlock_type;
   138   }
   130   }
   139   const llvm::PointerType* klass_type() const {
   131   llvm::PointerType* Metadata_type() const {
       
   132     return _Metadata_type;
       
   133   }
       
   134   llvm::PointerType* klass_type() const {
   140     return _klass_type;
   135     return _klass_type;
   141   }
   136   }
   142   const llvm::PointerType* Method*_type() const {
   137   llvm::PointerType* Method_type() const {
   143     return _Method*_type;
   138     return _Method_type;
   144   }
   139   }
   145   const llvm::ArrayType* monitor_type() const {
   140   llvm::ArrayType* monitor_type() const {
   146     return _monitor_type;
   141     return _monitor_type;
   147   }
   142   }
   148   const llvm::PointerType* oop_type() const {
   143   llvm::PointerType* oop_type() const {
   149     return _oop_type;
   144     return _oop_type;
   150   }
   145   }
   151   const llvm::PointerType* thread_type() const {
   146   llvm::PointerType* thread_type() const {
   152     return _thread_type;
   147     return _thread_type;
   153   }
   148   }
   154   const llvm::PointerType* zeroStack_type() const {
   149   llvm::PointerType* zeroStack_type() const {
   155     return _zeroStack_type;
   150     return _zeroStack_type;
   156   }
   151   }
   157   const llvm::FunctionType* entry_point_type() const {
   152   llvm::FunctionType* entry_point_type() const {
   158     return _entry_point_type;
   153     return _entry_point_type;
   159   }
   154   }
   160   const llvm::FunctionType* osr_entry_point_type() const {
   155   llvm::FunctionType* osr_entry_point_type() const {
   161     return _osr_entry_point_type;
   156     return _osr_entry_point_type;
   162   }
   157   }
   163 
   158 
   164   // Mappings
   159   // Mappings
   165  private:
   160  private:
   166   const llvm::Type* _to_stackType[T_CONFLICT];
   161   llvm::Type* _to_stackType[T_CONFLICT];
   167   const llvm::Type* _to_arrayType[T_CONFLICT];
   162   llvm::Type* _to_arrayType[T_CONFLICT];
   168 
   163 
   169  private:
   164  private:
   170   const llvm::Type* map_type(const llvm::Type* const* table,
   165   llvm::Type* map_type(llvm::Type* const* table,
   171                              BasicType                type) const {
   166                              BasicType                type) const {
   172     assert(type >= 0 && type < T_CONFLICT, "unhandled type");
   167     assert(type >= 0 && type < T_CONFLICT, "unhandled type");
   173     const llvm::Type* result = table[type];
   168     llvm::Type* result = table[type];
   174     assert(result != NULL, "unhandled type");
   169     assert(result != NULL, "unhandled type");
   175     return result;
   170     return result;
   176   }
   171   }
   177 
   172 
   178  public:
   173  public:
   179   const llvm::Type* to_stackType(BasicType type) const {
   174   llvm::Type* to_stackType(BasicType type) const {
   180     return map_type(_to_stackType, type);
   175     return map_type(_to_stackType, type);
   181   }
   176   }
   182   const llvm::Type* to_arrayType(BasicType type) const {
   177   llvm::Type* to_arrayType(BasicType type) const {
   183     return map_type(_to_arrayType, type);
   178     return map_type(_to_arrayType, type);
   184   }
   179   }
   185 
   180 
   186   // Functions queued for freeing
   181   // Functions queued for freeing
   187  private:
   182  private: