src/share/vm/asm/assembler.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8004250 Sdiff src/share/vm/asm

src/share/vm/asm/assembler.hpp

Print this page




 199 // The Assembler is generating code into a CodeBuffer.
 200 class AbstractAssembler : public ResourceObj  {
 201   friend class Label;
 202 
 203  protected:
 204   CodeSection* _code_section;          // section within the code buffer
 205   OopRecorder* _oop_recorder;          // support for relocInfo::oop_type
 206 
 207   // Code emission & accessing
 208   address addr_at(int pos) const { return code_section()->start() + pos; }
 209 
 210 
 211   // This routine is called with a label is used for an address.
 212   // Labels and displacements truck in offsets, but target must return a PC.
 213   address target(Label& L)             { return code_section()->target(L, pc()); }
 214 
 215   bool is8bit(int x) const             { return -0x80 <= x && x < 0x80; }
 216   bool isByte(int x) const             { return 0 <= x && x < 0x100; }
 217   bool isShiftCount(int x) const       { return 0 <= x && x < 32; }
 218 
 219   void emit_int8(   int8_t  x) { code_section()->emit_int8(   x); }
 220   void emit_int16(  int16_t x) { code_section()->emit_int16(  x); }
 221   void emit_int32(  int32_t x) { code_section()->emit_int32(  x); }
 222   void emit_int64(  int64_t x) { code_section()->emit_int64(  x); }
 223 
 224   void emit_float(  jfloat  x) { code_section()->emit_float(  x); }
 225   void emit_double( jdouble x) { code_section()->emit_double( x); }
 226   void emit_address(address x) { code_section()->emit_address(x); }
 227 
 228   void emit_byte(int x)  { emit_int8 (x); }  // deprecated
 229   void emit_word(int x)  { emit_int16(x); }  // deprecated
 230   void emit_long(jint x) { emit_int32(x); }  // deprecated
 231 
 232   // Instruction boundaries (required when emitting relocatable values).
 233   class InstructionMark: public StackObj {
 234    private:
 235     AbstractAssembler* _assm;
 236 
 237    public:
 238     InstructionMark(AbstractAssembler* assm) : _assm(assm) {
 239       assert(assm->inst_mark() == NULL, "overlapping instructions");
 240       _assm->set_inst_mark();
 241     }
 242     ~InstructionMark() {
 243       _assm->clear_inst_mark();
 244     }
 245   };
 246   friend class InstructionMark;
 247 #ifdef ASSERT
 248   // Make it return true on platforms which need to verify


 271   };
 272 #else
 273   // Dummy in product.
 274   class ShortBranchVerifier: public StackObj {
 275    public:
 276     ShortBranchVerifier(AbstractAssembler* assm) {}
 277   };
 278 #endif
 279 
 280   // Label functions
 281   void print(Label& L);
 282 
 283  public:
 284 
 285   // Creation
 286   AbstractAssembler(CodeBuffer* code);
 287 
 288   // ensure buf contains all code (call this before using/copying the code)
 289   void flush();
 290 









 291   // min and max values for signed immediate ranges
 292   static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1))    ; }
 293   static int max_simm(int nbits) { return  (intptr_t(1) << (nbits - 1)) - 1; }
 294 
 295   // Define some:
 296   static int min_simm10() { return min_simm(10); }
 297   static int min_simm13() { return min_simm(13); }
 298   static int min_simm16() { return min_simm(16); }
 299 
 300   // Test if x is within signed immediate range for nbits
 301   static bool is_simm(intptr_t x, int nbits) { return min_simm(nbits) <= x && x <= max_simm(nbits); }
 302 
 303   // Define some:
 304   static bool is_simm5( intptr_t x) { return is_simm(x, 5 ); }
 305   static bool is_simm8( intptr_t x) { return is_simm(x, 8 ); }
 306   static bool is_simm10(intptr_t x) { return is_simm(x, 10); }
 307   static bool is_simm11(intptr_t x) { return is_simm(x, 11); }
 308   static bool is_simm12(intptr_t x) { return is_simm(x, 12); }
 309   static bool is_simm13(intptr_t x) { return is_simm(x, 13); }
 310   static bool is_simm16(intptr_t x) { return is_simm(x, 16); }
 311   static bool is_simm26(intptr_t x) { return is_simm(x, 26); }
 312   static bool is_simm32(intptr_t x) { return is_simm(x, 32); }
 313 
 314   // Accessors
 315   CodeSection*  code_section() const   { return _code_section; }
 316   CodeBuffer*   code()         const   { return code_section()->outer(); }
 317   int           sect()         const   { return code_section()->index(); }
 318   address       pc()           const   { return code_section()->end();   }
 319   int           offset()       const   { return code_section()->size();  }
 320   int           locator()      const   { return CodeBuffer::locator(offset(), sect()); }
 321 
 322   OopRecorder*  oop_recorder() const   { return _oop_recorder; }
 323   void      set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
 324 
 325   address       inst_mark() const { return code_section()->mark();       }
 326   void      set_inst_mark()       {        code_section()->set_mark();   }
 327   void    clear_inst_mark()       {        code_section()->clear_mark(); }
 328 
 329   // Constants in code
 330   void a_byte(int x);
 331   void a_long(jint x);
 332   void relocate(RelocationHolder const& rspec, int format = 0) {
 333     assert(!pd_check_instruction_mark()
 334         || inst_mark() == NULL || inst_mark() == code_section()->end(),
 335         "call relocate() between instructions");
 336     code_section()->relocate(code_section()->end(), rspec, format);
 337   }
 338   void relocate(   relocInfo::relocType rtype, int format = 0) {
 339     code_section()->relocate(code_section()->end(), rtype, format);
 340   }
 341 
 342   static int code_fill_byte();         // used to pad out odd-sized code buffers
 343 
 344   // Associate a comment with the current offset.  It will be printed
 345   // along with the disassembly when printing nmethods.  Currently
 346   // only supported in the instruction section of the code buffer.
 347   void block_comment(const char* comment);
 348 
 349   // Label functions
 350   void bind(Label& L); // binds an unbound label L to the current code position
 351 




 199 // The Assembler is generating code into a CodeBuffer.
 200 class AbstractAssembler : public ResourceObj  {
 201   friend class Label;
 202 
 203  protected:
 204   CodeSection* _code_section;          // section within the code buffer
 205   OopRecorder* _oop_recorder;          // support for relocInfo::oop_type
 206 
 207   // Code emission & accessing
 208   address addr_at(int pos) const { return code_section()->start() + pos; }
 209 
 210 
 211   // This routine is called with a label is used for an address.
 212   // Labels and displacements truck in offsets, but target must return a PC.
 213   address target(Label& L)             { return code_section()->target(L, pc()); }
 214 
 215   bool is8bit(int x) const             { return -0x80 <= x && x < 0x80; }
 216   bool isByte(int x) const             { return 0 <= x && x < 0x100; }
 217   bool isShiftCount(int x) const       { return 0 <= x && x < 32; }
 218 










 219   void emit_word(int x)  { emit_int16(x); }  // deprecated
 220   void emit_long(jint x) { emit_int32(x); }  // deprecated
 221 
 222   // Instruction boundaries (required when emitting relocatable values).
 223   class InstructionMark: public StackObj {
 224    private:
 225     AbstractAssembler* _assm;
 226 
 227    public:
 228     InstructionMark(AbstractAssembler* assm) : _assm(assm) {
 229       assert(assm->inst_mark() == NULL, "overlapping instructions");
 230       _assm->set_inst_mark();
 231     }
 232     ~InstructionMark() {
 233       _assm->clear_inst_mark();
 234     }
 235   };
 236   friend class InstructionMark;
 237 #ifdef ASSERT
 238   // Make it return true on platforms which need to verify


 261   };
 262 #else
 263   // Dummy in product.
 264   class ShortBranchVerifier: public StackObj {
 265    public:
 266     ShortBranchVerifier(AbstractAssembler* assm) {}
 267   };
 268 #endif
 269 
 270   // Label functions
 271   void print(Label& L);
 272 
 273  public:
 274 
 275   // Creation
 276   AbstractAssembler(CodeBuffer* code);
 277 
 278   // ensure buf contains all code (call this before using/copying the code)
 279   void flush();
 280 
 281   void emit_int8(   int8_t  x) { code_section()->emit_int8(   x); }
 282   void emit_int16(  int16_t x) { code_section()->emit_int16(  x); }
 283   void emit_int32(  int32_t x) { code_section()->emit_int32(  x); }
 284   void emit_int64(  int64_t x) { code_section()->emit_int64(  x); }
 285 
 286   void emit_float(  jfloat  x) { code_section()->emit_float(  x); }
 287   void emit_double( jdouble x) { code_section()->emit_double( x); }
 288   void emit_address(address x) { code_section()->emit_address(x); }
 289 
 290   // min and max values for signed immediate ranges
 291   static int min_simm(int nbits) { return -(intptr_t(1) << (nbits - 1))    ; }
 292   static int max_simm(int nbits) { return  (intptr_t(1) << (nbits - 1)) - 1; }
 293 
 294   // Define some:
 295   static int min_simm10() { return min_simm(10); }
 296   static int min_simm13() { return min_simm(13); }
 297   static int min_simm16() { return min_simm(16); }
 298 
 299   // Test if x is within signed immediate range for nbits
 300   static bool is_simm(intptr_t x, int nbits) { return min_simm(nbits) <= x && x <= max_simm(nbits); }
 301 
 302   // Define some:
 303   static bool is_simm5( intptr_t x) { return is_simm(x, 5 ); }
 304   static bool is_simm8( intptr_t x) { return is_simm(x, 8 ); }
 305   static bool is_simm10(intptr_t x) { return is_simm(x, 10); }
 306   static bool is_simm11(intptr_t x) { return is_simm(x, 11); }
 307   static bool is_simm12(intptr_t x) { return is_simm(x, 12); }
 308   static bool is_simm13(intptr_t x) { return is_simm(x, 13); }
 309   static bool is_simm16(intptr_t x) { return is_simm(x, 16); }
 310   static bool is_simm26(intptr_t x) { return is_simm(x, 26); }
 311   static bool is_simm32(intptr_t x) { return is_simm(x, 32); }
 312 
 313   // Accessors
 314   CodeSection*  code_section() const   { return _code_section; }
 315   CodeBuffer*   code()         const   { return code_section()->outer(); }
 316   int           sect()         const   { return code_section()->index(); }
 317   address       pc()           const   { return code_section()->end();   }
 318   int           offset()       const   { return code_section()->size();  }
 319   int           locator()      const   { return CodeBuffer::locator(offset(), sect()); }
 320 
 321   OopRecorder*  oop_recorder() const   { return _oop_recorder; }
 322   void      set_oop_recorder(OopRecorder* r) { _oop_recorder = r; }
 323 
 324   address       inst_mark() const { return code_section()->mark();       }
 325   void      set_inst_mark()       {        code_section()->set_mark();   }
 326   void    clear_inst_mark()       {        code_section()->clear_mark(); }
 327 
 328   // Constants in code


 329   void relocate(RelocationHolder const& rspec, int format = 0) {
 330     assert(!pd_check_instruction_mark()
 331         || inst_mark() == NULL || inst_mark() == code_section()->end(),
 332         "call relocate() between instructions");
 333     code_section()->relocate(code_section()->end(), rspec, format);
 334   }
 335   void relocate(   relocInfo::relocType rtype, int format = 0) {
 336     code_section()->relocate(code_section()->end(), rtype, format);
 337   }
 338 
 339   static int code_fill_byte();         // used to pad out odd-sized code buffers
 340 
 341   // Associate a comment with the current offset.  It will be printed
 342   // along with the disassembly when printing nmethods.  Currently
 343   // only supported in the instruction section of the code buffer.
 344   void block_comment(const char* comment);
 345 
 346   // Label functions
 347   void bind(Label& L); // binds an unbound label L to the current code position
 348 


src/share/vm/asm/assembler.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File