src/share/vm/shark/sharkBuilder.hpp

Print this page
rev 3810 : [mq]: shark.patch


  40 
  41 class SharkBuilder : public llvm::IRBuilder<> {
  42   friend class SharkCompileInvariants;
  43 
  44  public:
  45   SharkBuilder(SharkCodeBuffer* code_buffer);
  46 
  47   // The code buffer we are building into.
  48  private:
  49   SharkCodeBuffer* _code_buffer;
  50 
  51  protected:
  52   SharkCodeBuffer* code_buffer() const {
  53     return _code_buffer;
  54   }
  55 
  56   // Helpers for accessing structures.
  57  public:
  58   llvm::Value* CreateAddressOfStructEntry(llvm::Value* base,
  59                                           ByteSize offset,
  60                                           const llvm::Type* type,
  61                                           const char *name = "");
  62   llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base,
  63                                            ByteSize offset,
  64                                            const llvm::Type* type,
  65                                            const char *name = "");
  66 
  67   // Helpers for accessing arrays.
  68  public:
  69   llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop);
  70   llvm::Value* CreateArrayAddress(llvm::Value*      arrayoop,
  71                                   const llvm::Type* element_type,
  72                                   int               element_bytes,
  73                                   ByteSize          base_offset,
  74                                   llvm::Value*      index,
  75                                   const char*       name = "");
  76   llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,
  77                                   BasicType    basic_type,
  78                                   ByteSize     base_offset,
  79                                   llvm::Value* index,
  80                                   const char*  name = "");
  81   llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,
  82                                   BasicType    basic_type,
  83                                   llvm::Value* index,
  84                                   const char*  name = "");
  85 
  86   // Helpers for creating intrinsics and external functions.
  87  private:
  88   static const llvm::Type* make_type(char type, bool void_ok);
  89   static const llvm::FunctionType* make_ftype(const char* params,
  90                                               const char* ret);
  91   llvm::Value* make_function(const char* name,
  92                              const char* params,
  93                              const char* ret);
  94   llvm::Value* make_function(address     func,
  95                              const char* params,
  96                              const char* ret);
  97 
  98   // Intrinsics and external functions, part 1: VM calls.
  99   //   These are functions declared with JRT_ENTRY and JRT_EXIT,
 100   //   macros which flip the thread from _thread_in_Java to
 101   //   _thread_in_vm and back.  VM calls always safepoint, and can
 102   //   therefore throw exceptions.  VM calls require of setup and
 103   //   teardown, and must be called with SharkTopLevelBlock::call_vm.
 104  public:
 105   llvm::Value* find_exception_handler();
 106   llvm::Value* monitorenter();
 107   llvm::Value* monitorexit();
 108   llvm::Value* new_instance();
 109   llvm::Value* newarray();


 156   //   may throw exceptions, but the state is _thread_in_native_trans.
 157  public:
 158   llvm::Value* check_special_condition_for_native_trans();
 159 
 160   // Intrinsics and external functions, part 5: Low-level non-VM calls.
 161   //   These have the same caveats as the high-level non-VM calls
 162   //   above.  They are not accessed directly; rather, you should
 163   //   access them via the various Create* methods below.
 164  private:
 165   llvm::Value* cmpxchg_int();
 166   llvm::Value* cmpxchg_ptr();
 167   llvm::Value* frame_address();
 168   llvm::Value* memory_barrier();
 169   llvm::Value* memset();
 170   llvm::Value* unimplemented();
 171   llvm::Value* should_not_reach_here();
 172   llvm::Value* dump();
 173 
 174   // Public interface to low-level non-VM calls.
 175  public:
 176   llvm::CallInst* CreateCmpxchgInt(llvm::Value* exchange_value,
 177                                    llvm::Value* dst,
 178                                    llvm::Value* compare_value);
 179   llvm::CallInst* CreateCmpxchgPtr(llvm::Value* exchange_value,
 180                                    llvm::Value* dst,
 181                                    llvm::Value* compare_value);
 182   llvm::CallInst* CreateGetFrameAddress();
 183   llvm::CallInst* CreateMemoryBarrier(int flags);
 184   llvm::CallInst* CreateMemset(llvm::Value* dst,
 185                                llvm::Value* value,
 186                                llvm::Value* len,
 187                                llvm::Value* align);
 188   llvm::CallInst* CreateUnimplemented(const char* file, int line);
 189   llvm::CallInst* CreateShouldNotReachHere(const char* file, int line);
 190   NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value));
 191 
 192   // Flags for CreateMemoryBarrier.
 193  public:
 194   enum BarrierFlags {
 195     BARRIER_LOADLOAD   = 1,
 196     BARRIER_LOADSTORE  = 2,
 197     BARRIER_STORELOAD  = 4,
 198     BARRIER_STORESTORE = 8
 199   };
 200 
 201   // HotSpot memory barriers
 202  public:
 203   void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field);
 204 
 205   // Helpers for accessing the code buffer.
 206  public:
 207   llvm::Value* code_buffer_address(int offset);
 208   llvm::Value* CreateInlineOop(jobject object, const char* name = "");
 209   llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") {
 210     return CreateInlineOop(object->constant_encoding(), name);
 211   }





 212   llvm::Value* CreateInlineData(void*             data,
 213                                 size_t            size,
 214                                 const llvm::Type* type,
 215                                 const char*       name = "");
 216 
 217   // Helpers for creating basic blocks.
 218   // NB don't use unless SharkFunction::CreateBlock is unavailable.
 219   // XXX these are hacky and should be removed.
 220  public:
 221   llvm::BasicBlock* GetBlockInsertionPoint() const;
 222   llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip,
 223                                 const char*       name="") const;
 224 };
 225 
 226 #endif // SHARE_VM_SHARK_SHARKBUILDER_HPP


  40 
  41 class SharkBuilder : public llvm::IRBuilder<> {
  42   friend class SharkCompileInvariants;
  43 
  44  public:
  45   SharkBuilder(SharkCodeBuffer* code_buffer);
  46 
  47   // The code buffer we are building into.
  48  private:
  49   SharkCodeBuffer* _code_buffer;
  50 
  51  protected:
  52   SharkCodeBuffer* code_buffer() const {
  53     return _code_buffer;
  54   }
  55 
  56   // Helpers for accessing structures.
  57  public:
  58   llvm::Value* CreateAddressOfStructEntry(llvm::Value* base,
  59                                           ByteSize offset,
  60                                           llvm::Type* type,
  61                                           const char *name = "");
  62   llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base,
  63                                            ByteSize offset,
  64                                            llvm::Type* type,
  65                                            const char *name = "");
  66 
  67   // Helpers for accessing arrays.
  68  public:
  69   llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop);
  70   llvm::Value* CreateArrayAddress(llvm::Value*      arrayoop,
  71                                   llvm::Type* element_type,
  72                                   int               element_bytes,
  73                                   ByteSize          base_offset,
  74                                   llvm::Value*      index,
  75                                   const char*       name = "");
  76   llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,
  77                                   BasicType    basic_type,
  78                                   ByteSize     base_offset,
  79                                   llvm::Value* index,
  80                                   const char*  name = "");
  81   llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,
  82                                   BasicType    basic_type,
  83                                   llvm::Value* index,
  84                                   const char*  name = "");
  85 
  86   // Helpers for creating intrinsics and external functions.
  87  private:
  88   static llvm::Type* make_type(char type, bool void_ok);
  89   static llvm::FunctionType* make_ftype(const char* params,
  90                                               const char* ret);
  91   llvm::Value* make_function(const char* name,
  92                              const char* params,
  93                              const char* ret);
  94   llvm::Value* make_function(address     func,
  95                              const char* params,
  96                              const char* ret);
  97 
  98   // Intrinsics and external functions, part 1: VM calls.
  99   //   These are functions declared with JRT_ENTRY and JRT_EXIT,
 100   //   macros which flip the thread from _thread_in_Java to
 101   //   _thread_in_vm and back.  VM calls always safepoint, and can
 102   //   therefore throw exceptions.  VM calls require of setup and
 103   //   teardown, and must be called with SharkTopLevelBlock::call_vm.
 104  public:
 105   llvm::Value* find_exception_handler();
 106   llvm::Value* monitorenter();
 107   llvm::Value* monitorexit();
 108   llvm::Value* new_instance();
 109   llvm::Value* newarray();


 156   //   may throw exceptions, but the state is _thread_in_native_trans.
 157  public:
 158   llvm::Value* check_special_condition_for_native_trans();
 159 
 160   // Intrinsics and external functions, part 5: Low-level non-VM calls.
 161   //   These have the same caveats as the high-level non-VM calls
 162   //   above.  They are not accessed directly; rather, you should
 163   //   access them via the various Create* methods below.
 164  private:
 165   llvm::Value* cmpxchg_int();
 166   llvm::Value* cmpxchg_ptr();
 167   llvm::Value* frame_address();
 168   llvm::Value* memory_barrier();
 169   llvm::Value* memset();
 170   llvm::Value* unimplemented();
 171   llvm::Value* should_not_reach_here();
 172   llvm::Value* dump();
 173 
 174   // Public interface to low-level non-VM calls.
 175  public:






 176   llvm::CallInst* CreateGetFrameAddress();

 177   llvm::CallInst* CreateMemset(llvm::Value* dst,
 178                                llvm::Value* value,
 179                                llvm::Value* len,
 180                                llvm::Value* align);
 181   llvm::CallInst* CreateUnimplemented(const char* file, int line);
 182   llvm::CallInst* CreateShouldNotReachHere(const char* file, int line);
 183   NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value));
 184 
 185   // Flags for CreateMemoryBarrier.
 186  public:
 187   enum BarrierFlags {
 188     BARRIER_LOADLOAD   = 1,
 189     BARRIER_LOADSTORE  = 2,
 190     BARRIER_STORELOAD  = 4,
 191     BARRIER_STORESTORE = 8
 192   };
 193 
 194   // HotSpot memory barriers
 195  public:
 196   void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field);
 197 
 198   // Helpers for accessing the code buffer.
 199  public:
 200   llvm::Value* code_buffer_address(int offset);
 201   llvm::Value* CreateInlineOop(jobject object, const char* name = "");
 202   llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") {
 203     return CreateInlineOop(object->constant_encoding(), name);
 204   }
 205 
 206   llvm::Value* CreateInlineMetadata(Metadata* metadata, llvm::PointerType* type, const char* name = "");
 207   llvm::Value* CreateInlineMetadata(ciMetadata* metadata, llvm::PointerType* type, const char* name = "") {
 208     return CreateInlineMetadata(metadata->constant_encoding(), type, name);
 209   }
 210   llvm::Value* CreateInlineData(void*             data,
 211                                 size_t            size,
 212                                 llvm::Type* type,
 213                                 const char*       name = "");
 214 
 215   // Helpers for creating basic blocks.
 216   // NB don't use unless SharkFunction::CreateBlock is unavailable.
 217   // XXX these are hacky and should be removed.
 218  public:
 219   llvm::BasicBlock* GetBlockInsertionPoint() const;
 220   llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip,
 221                                 const char*       name="") const;
 222 };
 223 
 224 #endif // SHARE_VM_SHARK_SHARKBUILDER_HPP