src/share/vm/asm/codeBuffer.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 7535
7ae4e26cb1e0
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    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  */
    25 /*
    26  * This file has been modified by Loongson Technology in 2015. These
    27  * modifications are Copyright (c) 2015 Loongson Technology, and are made
    28  * available on the same license terms set forth above.
    29  */
    31 #ifndef SHARE_VM_ASM_CODEBUFFER_HPP
    32 #define SHARE_VM_ASM_CODEBUFFER_HPP
    34 #include "code/oopRecorder.hpp"
    35 #include "code/relocInfo.hpp"
    36 #include "utilities/debug.hpp"
    38 class CodeStrings;
    39 class PhaseCFG;
    40 class Compile;
    41 class BufferBlob;
    42 class CodeBuffer;
    43 class Label;
    45 class CodeOffsets: public StackObj {
    46 public:
    47   enum Entries { Entry,
    48                  Verified_Entry,
    49                  Frame_Complete, // Offset in the code where the frame setup is (for forte stackwalks) is complete
    50                  OSR_Entry,
    51                  Dtrace_trap = OSR_Entry,  // dtrace probes can never have an OSR entry so reuse it
    52                  Exceptions,     // Offset where exception handler lives
    53                  Deopt,          // Offset where deopt handler lives
    54                  DeoptMH,        // Offset where MethodHandle deopt handler lives
    55                  UnwindHandler,  // Offset to default unwind handler
    56                  max_Entries };
    58   // special value to note codeBlobs where profile (forte) stack walking is
    59   // always dangerous and suspect.
    61   enum { frame_never_safe = -1 };
    63 private:
    64   int _values[max_Entries];
    66 public:
    67   CodeOffsets() {
    68     _values[Entry         ] = 0;
    69     _values[Verified_Entry] = 0;
    70     _values[Frame_Complete] = frame_never_safe;
    71     _values[OSR_Entry     ] = 0;
    72     _values[Exceptions    ] = -1;
    73     _values[Deopt         ] = -1;
    74     _values[DeoptMH       ] = -1;
    75     _values[UnwindHandler ] = -1;
    76   }
    78   int value(Entries e) { return _values[e]; }
    79   void set_value(Entries e, int val) { _values[e] = val; }
    80 };
    82 // This class represents a stream of code and associated relocations.
    83 // There are a few in each CodeBuffer.
    84 // They are filled concurrently, and concatenated at the end.
    85 class CodeSection VALUE_OBJ_CLASS_SPEC {
    86   friend class CodeBuffer;
    87  public:
    88   typedef int csize_t;  // code size type; would be size_t except for history
    90  private:
    91   address     _start;           // first byte of contents (instructions)
    92   address     _mark;            // user mark, usually an instruction beginning
    93   address     _end;             // current end address
    94   address     _limit;           // last possible (allocated) end address
    95   relocInfo*  _locs_start;      // first byte of relocation information
    96   relocInfo*  _locs_end;        // first byte after relocation information
    97   relocInfo*  _locs_limit;      // first byte after relocation information buf
    98   address     _locs_point;      // last relocated position (grows upward)
    99   bool        _locs_own;        // did I allocate the locs myself?
   100   bool        _frozen;          // no more expansion of this section
   101   char        _index;           // my section number (SECT_INST, etc.)
   102   CodeBuffer* _outer;           // enclosing CodeBuffer
   104   // (Note:  _locs_point used to be called _last_reloc_offset.)
   106   CodeSection() {
   107     _start         = NULL;
   108     _mark          = NULL;
   109     _end           = NULL;
   110     _limit         = NULL;
   111     _locs_start    = NULL;
   112     _locs_end      = NULL;
   113     _locs_limit    = NULL;
   114     _locs_point    = NULL;
   115     _locs_own      = false;
   116     _frozen        = false;
   117     debug_only(_index = (char)-1);
   118     debug_only(_outer = (CodeBuffer*)badAddress);
   119   }
   121   void initialize_outer(CodeBuffer* outer, int index) {
   122     _outer = outer;
   123     _index = index;
   124   }
   126   void initialize(address start, csize_t size = 0) {
   127     assert(_start == NULL, "only one init step, please");
   128     _start         = start;
   129     _mark          = NULL;
   130     _end           = start;
   132     _limit         = start + size;
   133     _locs_point    = start;
   134   }
   136   void initialize_locs(int locs_capacity);
   137   void expand_locs(int new_capacity);
   138   void initialize_locs_from(const CodeSection* source_cs);
   140   // helper for CodeBuffer::expand()
   141   void take_over_code_from(CodeSection* cs) {
   142     _start      = cs->_start;
   143     _mark       = cs->_mark;
   144     _end        = cs->_end;
   145     _limit      = cs->_limit;
   146     _locs_point = cs->_locs_point;
   147   }
   149  public:
   150   address     start() const         { return _start; }
   151   address     mark() const          { return _mark; }
   152   address     end() const           { return _end; }
   153   address     limit() const         { return _limit; }
   154   csize_t     size() const          { return (csize_t)(_end - _start); }
   155   csize_t     mark_off() const      { assert(_mark != NULL, "not an offset");
   156                                       return (csize_t)(_mark - _start); }
   157   csize_t     capacity() const      { return (csize_t)(_limit - _start); }
   158   csize_t     remaining() const     { return (csize_t)(_limit - _end); }
   160   relocInfo*  locs_start() const    { return _locs_start; }
   161   relocInfo*  locs_end() const      { return _locs_end; }
   162   int         locs_count() const    { return (int)(_locs_end - _locs_start); }
   163   relocInfo*  locs_limit() const    { return _locs_limit; }
   164   address     locs_point() const    { return _locs_point; }
   165   csize_t     locs_point_off() const{ return (csize_t)(_locs_point - _start); }
   166   csize_t     locs_capacity() const { return (csize_t)(_locs_limit - _locs_start); }
   167   csize_t     locs_remaining()const { return (csize_t)(_locs_limit - _locs_end); }
   169   int         index() const         { return _index; }
   170   bool        is_allocated() const  { return _start != NULL; }
   171   bool        is_empty() const      { return _start == _end; }
   172   bool        is_frozen() const     { return _frozen; }
   173   bool        has_locs() const      { return _locs_end != NULL; }
   175   CodeBuffer* outer() const         { return _outer; }
   177   // is a given address in this section?  (2nd version is end-inclusive)
   178   bool contains(address pc) const   { return pc >= _start && pc <  _end; }
   179   bool contains2(address pc) const  { return pc >= _start && pc <= _end; }
   180   bool allocates(address pc) const  { return pc >= _start && pc <  _limit; }
   181   bool allocates2(address pc) const { return pc >= _start && pc <= _limit; }
   183   void    set_end(address pc)       { assert(allocates2(pc), err_msg("not in CodeBuffer memory: " PTR_FORMAT " <= " PTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit))); _end = pc; }
   184   void    set_mark(address pc)      { assert(contains2(pc), "not in codeBuffer");
   185                                       _mark = pc; }
   186   void    set_mark_off(int offset)  { assert(contains2(offset+_start),"not in codeBuffer");
   187                                       _mark = offset + _start; }
   188   void    set_mark()                { _mark = _end; }
   189   void    clear_mark()              { _mark = NULL; }
   191   void    set_locs_end(relocInfo* p) {
   192     assert(p <= locs_limit(), "locs data fits in allocated buffer");
   193     _locs_end = p;
   194   }
   195   void    set_locs_point(address pc) {
   196     assert(pc >= locs_point(), "relocation addr may not decrease");
   197     assert(allocates2(pc),     "relocation addr must be in this section");
   198     _locs_point = pc;
   199   }
   201   // Code emission
   202   void emit_int8 ( int8_t  x)  { *((int8_t*)  end()) = x; set_end(end() + sizeof(int8_t)); }
   203   void emit_int16( int16_t x)  { *((int16_t*) end()) = x; set_end(end() + sizeof(int16_t)); }
   204   void emit_int32( int32_t x)  { *((int32_t*) end()) = x; set_end(end() + sizeof(int32_t)); }
   205   void emit_int64( int64_t x)  { *((int64_t*) end()) = x; set_end(end() + sizeof(int64_t)); }
   207   void emit_float( jfloat  x)  { *((jfloat*)  end()) = x; set_end(end() + sizeof(jfloat)); }
   208   void emit_double(jdouble x)  { *((jdouble*) end()) = x; set_end(end() + sizeof(jdouble)); }
   209   void emit_address(address x) { *((address*) end()) = x; set_end(end() + sizeof(address)); }
   211   // Share a scratch buffer for relocinfo.  (Hacky; saves a resource allocation.)
   212   void initialize_shared_locs(relocInfo* buf, int length);
   214   // Manage labels and their addresses.
   215   address target(Label& L, address branch_pc);
   217   // Emit a relocation.
   218   void relocate(address at, RelocationHolder const& rspec, int format = 0);
   219   void relocate(address at,    relocInfo::relocType rtype, int format = 0) {
   220     if (rtype != relocInfo::none)
   221       relocate(at, Relocation::spec_simple(rtype), format);
   222   }
   224   // alignment requirement for starting offset
   225   // Requirements are that the instruction area and the
   226   // stubs area must start on CodeEntryAlignment, and
   227   // the ctable on sizeof(jdouble)
   228   int alignment() const             { return MAX2((int)sizeof(jdouble), (int)CodeEntryAlignment); }
   230   // Slop between sections, used only when allocating temporary BufferBlob buffers.
   231   static csize_t end_slop()         { return MAX2((int)sizeof(jdouble), (int)CodeEntryAlignment); }
   233   csize_t align_at_start(csize_t off) const { return (csize_t) align_size_up(off, alignment()); }
   235   // Mark a section frozen.  Assign its remaining space to
   236   // the following section.  It will never expand after this point.
   237   inline void freeze();         //  { _outer->freeze_section(this); }
   239   // Ensure there's enough space left in the current section.
   240   // Return true if there was an expansion.
   241   bool maybe_expand_to_ensure_remaining(csize_t amount);
   243 #ifndef PRODUCT
   244   void decode();
   245   void dump();
   246   void print(const char* name);
   247 #endif //PRODUCT
   248 };
   250 class CodeString;
   251 class CodeStrings VALUE_OBJ_CLASS_SPEC {
   252 private:
   253 #ifndef PRODUCT
   254   CodeString* _strings;
   255 #ifdef ASSERT
   256   // Becomes true after copy-out, forbids further use.
   257   bool _defunct; // Zero bit pattern is "valid", see memset call in decode_env::decode_env
   258 #endif
   259 #endif
   261   CodeString* find(intptr_t offset) const;
   262   CodeString* find_last(intptr_t offset) const;
   264   void set_null_and_invalidate() {
   265 #ifndef PRODUCT
   266     _strings = NULL;
   267 #ifdef ASSERT
   268     _defunct = true;
   269 #endif
   270 #endif
   271   }
   273 public:
   274   CodeStrings() {
   275 #ifndef PRODUCT
   276     _strings = NULL;
   277 #ifdef ASSERT
   278     _defunct = false;
   279 #endif
   280 #endif
   281   }
   283   bool is_null() {
   284 #ifdef ASSERT
   285     return _strings == NULL;
   286 #else
   287     return true;
   288 #endif
   289   }
   291   const char* add_string(const char * string) PRODUCT_RETURN_(return NULL;);
   293   void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN;
   294   void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN;
   295   // MOVE strings from other to this; invalidate other.
   296   void assign(CodeStrings& other)  PRODUCT_RETURN;
   297   // COPY strings from other to this; leave other valid.
   298   void copy(CodeStrings& other)  PRODUCT_RETURN;
   299   void free() PRODUCT_RETURN;
   300   // Guarantee that _strings are used at most once; assign invalidates a buffer.
   301   inline void check_valid() const {
   302 #ifdef ASSERT
   303     assert(!_defunct, "Use of invalid CodeStrings");
   304 #endif
   305   }
   306 };
   308 // A CodeBuffer describes a memory space into which assembly
   309 // code is generated.  This memory space usually occupies the
   310 // interior of a single BufferBlob, but in some cases it may be
   311 // an arbitrary span of memory, even outside the code cache.
   312 //
   313 // A code buffer comes in two variants:
   314 //
   315 // (1) A CodeBuffer referring to an already allocated piece of memory:
   316 //     This is used to direct 'static' code generation (e.g. for interpreter
   317 //     or stubroutine generation, etc.).  This code comes with NO relocation
   318 //     information.
   319 //
   320 // (2) A CodeBuffer referring to a piece of memory allocated when the
   321 //     CodeBuffer is allocated.  This is used for nmethod generation.
   322 //
   323 // The memory can be divided up into several parts called sections.
   324 // Each section independently accumulates code (or data) an relocations.
   325 // Sections can grow (at the expense of a reallocation of the BufferBlob
   326 // and recopying of all active sections).  When the buffered code is finally
   327 // written to an nmethod (or other CodeBlob), the contents (code, data,
   328 // and relocations) of the sections are padded to an alignment and concatenated.
   329 // Instructions and data in one section can contain relocatable references to
   330 // addresses in a sibling section.
   332 class CodeBuffer: public StackObj {
   333   friend class CodeSection;
   335  private:
   336   // CodeBuffers must be allocated on the stack except for a single
   337   // special case during expansion which is handled internally.  This
   338   // is done to guarantee proper cleanup of resources.
   339   void* operator new(size_t size) throw() { return ResourceObj::operator new(size); }
   340   void  operator delete(void* p)          { ShouldNotCallThis(); }
   342  public:
   343   typedef int csize_t;  // code size type; would be size_t except for history
   344   enum {
   345     // Here is the list of all possible sections.  The order reflects
   346     // the final layout.
   347     SECT_FIRST = 0,
   348     SECT_CONSTS = SECT_FIRST, // Non-instruction data:  Floats, jump tables, etc.
   349     SECT_INSTS,               // Executable instructions.
   350     SECT_STUBS,               // Outbound trampolines for supporting call sites.
   351     SECT_LIMIT, SECT_NONE = -1
   352   };
   354  private:
   355   enum {
   356     sect_bits = 2,      // assert (SECT_LIMIT <= (1<<sect_bits))
   357     sect_mask = (1<<sect_bits)-1
   358   };
   360   const char*  _name;
   362   CodeSection  _consts;             // constants, jump tables
   363   CodeSection  _insts;              // instructions (the main section)
   364   CodeSection  _stubs;              // stubs (call site support), deopt, exception handling
   366   CodeBuffer*  _before_expand;  // dead buffer, from before the last expansion
   368   BufferBlob*  _blob;           // optional buffer in CodeCache for generated code
   369   address      _total_start;    // first address of combined memory buffer
   370   csize_t      _total_size;     // size in bytes of combined memory buffer
   372   OopRecorder* _oop_recorder;
   373   CodeStrings  _code_strings;
   374   OopRecorder  _default_oop_recorder;  // override with initialize_oop_recorder
   375   Arena*       _overflow_arena;
   377   address      _decode_begin;   // start address for decode
   378   address      decode_begin();
   380   void initialize_misc(const char * name) {
   381     // all pointers other than code_start/end and those inside the sections
   382     assert(name != NULL, "must have a name");
   383     _name            = name;
   384     _before_expand   = NULL;
   385     _blob            = NULL;
   386     _oop_recorder    = NULL;
   387     _decode_begin    = NULL;
   388     _overflow_arena  = NULL;
   389   }
   391   void initialize(address code_start, csize_t code_size) {
   392     _consts.initialize_outer(this,  SECT_CONSTS);
   393     _insts.initialize_outer(this,   SECT_INSTS);
   394     _stubs.initialize_outer(this,   SECT_STUBS);
   395     _total_start = code_start;
   396     _total_size  = code_size;
   397     // Initialize the main section:
   398     _insts.initialize(code_start, code_size);
   399     assert(!_stubs.is_allocated(),  "no garbage here");
   400     assert(!_consts.is_allocated(), "no garbage here");
   401     _oop_recorder = &_default_oop_recorder;
   402   }
   404   void initialize_section_size(CodeSection* cs, csize_t size);
   406   void freeze_section(CodeSection* cs);
   408   // helper for CodeBuffer::expand()
   409   void take_over_code_from(CodeBuffer* cs);
   411   // ensure sections are disjoint, ordered, and contained in the blob
   412   void verify_section_allocation();
   414   // copies combined relocations to the blob, returns bytes copied
   415   // (if target is null, it is a dry run only, just for sizing)
   416   csize_t copy_relocations_to(CodeBlob* blob) const;
   418   // copies combined code to the blob (assumes relocs are already in there)
   419   void copy_code_to(CodeBlob* blob);
   421   // moves code sections to new buffer (assumes relocs are already in there)
   422   void relocate_code_to(CodeBuffer* cb) const;
   424   // set up a model of the final layout of my contents
   425   void compute_final_layout(CodeBuffer* dest) const;
   427   // Expand the given section so at least 'amount' is remaining.
   428   // Creates a new, larger BufferBlob, and rewrites the code & relocs.
   429   void expand(CodeSection* which_cs, csize_t amount);
   431   // Helper for expand.
   432   csize_t figure_expanded_capacities(CodeSection* which_cs, csize_t amount, csize_t* new_capacity);
   434  public:
   435   // (1) code buffer referring to pre-allocated instruction memory
   436   CodeBuffer(address code_start, csize_t code_size) {
   437     assert(code_start != NULL, "sanity");
   438     initialize_misc("static buffer");
   439     initialize(code_start, code_size);
   440     verify_section_allocation();
   441   }
   443   // (2) CodeBuffer referring to pre-allocated CodeBlob.
   444   CodeBuffer(CodeBlob* blob);
   446   // (3) code buffer allocating codeBlob memory for code & relocation
   447   // info but with lazy initialization.  The name must be something
   448   // informative.
   449   CodeBuffer(const char* name) {
   450     initialize_misc(name);
   451   }
   454   // (4) code buffer allocating codeBlob memory for code & relocation
   455   // info.  The name must be something informative and code_size must
   456   // include both code and stubs sizes.
   457   CodeBuffer(const char* name, csize_t code_size, csize_t locs_size) {
   458     initialize_misc(name);
   459     initialize(code_size, locs_size);
   460   }
   462   ~CodeBuffer();
   464   // Initialize a CodeBuffer constructed using constructor 3.  Using
   465   // constructor 4 is equivalent to calling constructor 3 and then
   466   // calling this method.  It's been factored out for convenience of
   467   // construction.
   468   void initialize(csize_t code_size, csize_t locs_size);
   470   CodeSection* consts()            { return &_consts; }
   471   CodeSection* insts()             { return &_insts; }
   472   CodeSection* stubs()             { return &_stubs; }
   474   // present sections in order; return NULL at end; consts is #0, etc.
   475   CodeSection* code_section(int n) {
   476     // This makes the slightly questionable but portable assumption
   477     // that the various members (_consts, _insts, _stubs, etc.) are
   478     // adjacent in the layout of CodeBuffer.
   479     CodeSection* cs = &_consts + n;
   480     assert(cs->index() == n || !cs->is_allocated(), "sanity");
   481     return cs;
   482   }
   483   const CodeSection* code_section(int n) const {  // yucky const stuff
   484     return ((CodeBuffer*)this)->code_section(n);
   485   }
   486   static const char* code_section_name(int n);
   487   int section_index_of(address addr) const;
   488   bool contains(address addr) const {
   489     // handy for debugging
   490     return section_index_of(addr) > SECT_NONE;
   491   }
   493   // A stable mapping between 'locators' (small ints) and addresses.
   494   static int locator_pos(int locator)   { return locator >> sect_bits; }
   495   static int locator_sect(int locator)  { return locator &  sect_mask; }
   496   static int locator(int pos, int sect) { return (pos << sect_bits) | sect; }
   497   int        locator(address addr) const;
   498   address    locator_address(int locator) const;
   500   // Heuristic for pre-packing the taken/not-taken bit of a predicted branch.
   501   bool is_backward_branch(Label& L);
   503   // Properties
   504   const char* name() const                  { return _name; }
   505   CodeBuffer* before_expand() const         { return _before_expand; }
   506   BufferBlob* blob() const                  { return _blob; }
   507   void    set_blob(BufferBlob* blob);
   508   void   free_blob();                       // Free the blob, if we own one.
   510   // Properties relative to the insts section:
   511   address       insts_begin() const      { return _insts.start();      }
   512   address       insts_end() const        { return _insts.end();        }
   513   void      set_insts_end(address end)   {        _insts.set_end(end); }
   514   address       insts_limit() const      { return _insts.limit();      }
   515   address       insts_mark() const       { return _insts.mark();       }
   516   void      set_insts_mark()             {        _insts.set_mark();   }
   517   void    clear_insts_mark()             {        _insts.clear_mark(); }
   519   // is there anything in the buffer other than the current section?
   520   bool    is_pure() const                { return insts_size() == total_content_size(); }
   522   // size in bytes of output so far in the insts sections
   523   csize_t insts_size() const             { return _insts.size(); }
   525   // same as insts_size(), except that it asserts there is no non-code here
   526   csize_t pure_insts_size() const        { assert(is_pure(), "no non-code");
   527                                            return insts_size(); }
   528   // capacity in bytes of the insts sections
   529   csize_t insts_capacity() const         { return _insts.capacity(); }
   531   // number of bytes remaining in the insts section
   532   csize_t insts_remaining() const        { return _insts.remaining(); }
   534   // is a given address in the insts section?  (2nd version is end-inclusive)
   535   bool insts_contains(address pc) const  { return _insts.contains(pc); }
   536   bool insts_contains2(address pc) const { return _insts.contains2(pc); }
   538   // Record any extra oops required to keep embedded metadata alive
   539   void finalize_oop_references(methodHandle method);
   541   // Allocated size in all sections, when aligned and concatenated
   542   // (this is the eventual state of the content in its final
   543   // CodeBlob).
   544   csize_t total_content_size() const;
   546   // Combined offset (relative to start of first section) of given
   547   // section, as eventually found in the final CodeBlob.
   548   csize_t total_offset_of(CodeSection* cs) const;
   550   // allocated size of all relocation data, including index, rounded up
   551   csize_t total_relocation_size() const;
   553   // allocated size of any and all recorded oops
   554   csize_t total_oop_size() const {
   555     OopRecorder* recorder = oop_recorder();
   556     return (recorder == NULL)? 0: recorder->oop_size();
   557   }
   559   // allocated size of any and all recorded metadata
   560   csize_t total_metadata_size() const {
   561     OopRecorder* recorder = oop_recorder();
   562     return (recorder == NULL)? 0: recorder->metadata_size();
   563   }
   565   // Configuration functions, called immediately after the CB is constructed.
   566   // The section sizes are subtracted from the original insts section.
   567   // Note:  Call them in reverse section order, because each steals from insts.
   568   void initialize_consts_size(csize_t size)            { initialize_section_size(&_consts,  size); }
   569   void initialize_stubs_size(csize_t size)             { initialize_section_size(&_stubs,   size); }
   570   // Override default oop recorder.
   571   void initialize_oop_recorder(OopRecorder* r);
   573   OopRecorder* oop_recorder() const   { return _oop_recorder; }
   574   CodeStrings& strings()              { return _code_strings; }
   576   void free_strings() {
   577     if (!_code_strings.is_null()) {
   578       _code_strings.free(); // sets _strings Null as a side-effect.
   579     }
   580   }
   582   // Code generation
   583   void relocate(address at, RelocationHolder const& rspec, int format = 0) {
   584     _insts.relocate(at, rspec, format);
   585   }
   586   void relocate(address at,    relocInfo::relocType rtype, int format = 0) {
   587     _insts.relocate(at, rtype, format);
   588   }
   590   // Management of overflow storage for binding of Labels.
   591   GrowableArray<int>* create_patch_overflow();
   593   // NMethod generation
   594   void copy_code_and_locs_to(CodeBlob* blob) {
   595     assert(blob != NULL, "sane");
   596     copy_relocations_to(blob);
   597     copy_code_to(blob);
   598   }
   599   void copy_values_to(nmethod* nm) {
   600     if (!oop_recorder()->is_unused()) {
   601       oop_recorder()->copy_values_to(nm);
   602     }
   603   }
   605   // Transform an address from the code in this code buffer to a specified code buffer
   606   address transform_address(const CodeBuffer &cb, address addr) const;
   608   void block_comment(intptr_t offset, const char * comment) PRODUCT_RETURN;
   609   const char* code_string(const char* str) PRODUCT_RETURN_(return NULL;);
   611   // Log a little info about section usage in the CodeBuffer
   612   void log_section_sizes(const char* name);
   614 #ifndef PRODUCT
   615  public:
   616   // Printing / Decoding
   617   // decodes from decode_begin() to code_end() and sets decode_begin to end
   618   void    decode();
   619   void    decode_all();         // decodes all the code
   620   void    skip_decode();        // sets decode_begin to code_end();
   621   void    print();
   622 #endif
   625   // The following header contains architecture-specific implementations
   626 #ifdef TARGET_ARCH_x86
   627 # include "codeBuffer_x86.hpp"
   628 #endif
   629 #ifdef TARGET_ARCH_sparc
   630 # include "codeBuffer_sparc.hpp"
   631 #endif
   632 #ifdef TARGET_ARCH_zero
   633 # include "codeBuffer_zero.hpp"
   634 #endif
   635 #ifdef TARGET_ARCH_arm
   636 # include "codeBuffer_arm.hpp"
   637 #endif
   638 #ifdef TARGET_ARCH_ppc
   639 # include "codeBuffer_ppc.hpp"
   640 #endif
   641 #ifdef TARGET_ARCH_mips
   642 # include "codeBuffer_mips.hpp"
   643 #endif
   645 };
   648 inline void CodeSection::freeze() {
   649   _outer->freeze_section(this);
   650 }
   652 inline bool CodeSection::maybe_expand_to_ensure_remaining(csize_t amount) {
   653   if (remaining() < amount) { _outer->expand(this, amount); return true; }
   654   return false;
   655 }
   657 #endif // SHARE_VM_ASM_CODEBUFFER_HPP

mercurial