src/share/vm/asm/codeBuffer.hpp

changeset 2103
3e8fbc61cee8
parent 2044
f4f596978298
child 2117
0878d7bae69f
     1.1 --- a/src/share/vm/asm/codeBuffer.hpp	Mon Aug 23 09:09:36 2010 -0700
     1.2 +++ b/src/share/vm/asm/codeBuffer.hpp	Wed Aug 25 05:27:54 2010 -0700
     1.3 @@ -186,6 +186,12 @@
     1.4      _locs_point = pc;
     1.5    }
     1.6  
     1.7 +  // Code emission
     1.8 +  void emit_int8 (int8_t  x) { *((int8_t*)  end()) = x; set_end(end() + 1); }
     1.9 +  void emit_int16(int16_t x) { *((int16_t*) end()) = x; set_end(end() + 2); }
    1.10 +  void emit_int32(int32_t x) { *((int32_t*) end()) = x; set_end(end() + 4); }
    1.11 +  void emit_int64(int64_t x) { *((int64_t*) end()) = x; set_end(end() + 8); }
    1.12 +
    1.13    // Share a scratch buffer for relocinfo.  (Hacky; saves a resource allocation.)
    1.14    void initialize_shared_locs(relocInfo* buf, int length);
    1.15  
    1.16 @@ -374,9 +380,17 @@
    1.17  
    1.18   public:
    1.19    // (1) code buffer referring to pre-allocated instruction memory
    1.20 -  CodeBuffer(address code_start, csize_t code_size);
    1.21 +  CodeBuffer(address code_start, csize_t code_size) {
    1.22 +    assert(code_start != NULL, "sanity");
    1.23 +    initialize_misc("static buffer");
    1.24 +    initialize(code_start, code_size);
    1.25 +    assert(verify_section_allocation(), "initial use of buffer OK");
    1.26 +  }
    1.27  
    1.28 -  // (2) code buffer allocating codeBlob memory for code & relocation
    1.29 +  // (2) CodeBuffer referring to pre-allocated CodeBlob.
    1.30 +  CodeBuffer(CodeBlob* blob);
    1.31 +
    1.32 +  // (3) code buffer allocating codeBlob memory for code & relocation
    1.33    // info but with lazy initialization.  The name must be something
    1.34    // informative.
    1.35    CodeBuffer(const char* name) {
    1.36 @@ -384,7 +398,7 @@
    1.37    }
    1.38  
    1.39  
    1.40 -  // (3) code buffer allocating codeBlob memory for code & relocation
    1.41 +  // (4) code buffer allocating codeBlob memory for code & relocation
    1.42    // info.  The name must be something informative and code_size must
    1.43    // include both code and stubs sizes.
    1.44    CodeBuffer(const char* name, csize_t code_size, csize_t locs_size) {
    1.45 @@ -394,8 +408,8 @@
    1.46  
    1.47    ~CodeBuffer();
    1.48  
    1.49 -  // Initialize a CodeBuffer constructed using constructor 2.  Using
    1.50 -  // constructor 3 is equivalent to calling constructor 2 and then
    1.51 +  // Initialize a CodeBuffer constructed using constructor 3.  Using
    1.52 +  // constructor 4 is equivalent to calling constructor 3 and then
    1.53    // calling this method.  It's been factored out for convenience of
    1.54    // construction.
    1.55    void initialize(csize_t code_size, csize_t locs_size);
    1.56 @@ -438,36 +452,37 @@
    1.57    void   free_blob();                       // Free the blob, if we own one.
    1.58  
    1.59    // Properties relative to the insts section:
    1.60 -  address code_begin() const            { return _insts.start(); }
    1.61 -  address code_end() const              { return _insts.end();   }
    1.62 -  void set_code_end(address end)        { _insts.set_end(end); }
    1.63 -  address code_limit() const            { return _insts.limit(); }
    1.64 -  address inst_mark() const             { return _insts.mark(); }
    1.65 -  void set_inst_mark()                  { _insts.set_mark(); }
    1.66 -  void clear_inst_mark()                { _insts.clear_mark(); }
    1.67 +  address       insts_begin() const      { return _insts.start();      }
    1.68 +  address       insts_end() const        { return _insts.end();        }
    1.69 +  void      set_insts_end(address end)   {        _insts.set_end(end); }
    1.70 +  address       insts_limit() const      { return _insts.limit();      }
    1.71 +  address       insts_mark() const       { return _insts.mark();       }
    1.72 +  void      set_insts_mark()             {        _insts.set_mark();   }
    1.73 +  void    clear_insts_mark()             {        _insts.clear_mark(); }
    1.74  
    1.75    // is there anything in the buffer other than the current section?
    1.76 -  bool    is_pure() const               { return code_size() == total_code_size(); }
    1.77 +  bool    is_pure() const                { return insts_size() == total_content_size(); }
    1.78  
    1.79    // size in bytes of output so far in the insts sections
    1.80 -  csize_t code_size() const             { return _insts.size(); }
    1.81 +  csize_t insts_size() const             { return _insts.size(); }
    1.82  
    1.83 -  // same as code_size(), except that it asserts there is no non-code here
    1.84 -  csize_t pure_code_size() const        { assert(is_pure(), "no non-code");
    1.85 -                                          return code_size(); }
    1.86 +  // same as insts_size(), except that it asserts there is no non-code here
    1.87 +  csize_t pure_insts_size() const        { assert(is_pure(), "no non-code");
    1.88 +                                           return insts_size(); }
    1.89    // capacity in bytes of the insts sections
    1.90 -  csize_t code_capacity() const         { return _insts.capacity(); }
    1.91 +  csize_t insts_capacity() const         { return _insts.capacity(); }
    1.92  
    1.93    // number of bytes remaining in the insts section
    1.94 -  csize_t code_remaining() const        { return _insts.remaining(); }
    1.95 +  csize_t insts_remaining() const        { return _insts.remaining(); }
    1.96  
    1.97    // is a given address in the insts section?  (2nd version is end-inclusive)
    1.98 -  bool code_contains(address pc) const  { return _insts.contains(pc); }
    1.99 -  bool code_contains2(address pc) const { return _insts.contains2(pc); }
   1.100 +  bool insts_contains(address pc) const  { return _insts.contains(pc); }
   1.101 +  bool insts_contains2(address pc) const { return _insts.contains2(pc); }
   1.102  
   1.103 -  // allocated size of code in all sections, when aligned and concatenated
   1.104 -  // (this is the eventual state of the code in its final CodeBlob)
   1.105 -  csize_t total_code_size() const;
   1.106 +  // Allocated size in all sections, when aligned and concatenated
   1.107 +  // (this is the eventual state of the content in its final
   1.108 +  // CodeBlob).
   1.109 +  csize_t total_content_size() const;
   1.110  
   1.111    // combined offset (relative to start of insts) of given address,
   1.112    // as eventually found in the final CodeBlob

mercurial