codeBuffer.hpp revision 4332
415N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 415N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 415N/A * This code is free software; you can redistribute it and/or modify it 415N/A * under the terms of the GNU General Public License version 2 only, as 415N/A * published by the Free Software Foundation. 415N/A * This code is distributed in the hope that it will be useful, but WITHOUT 415N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 415N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 415N/A * version 2 for more details (a copy is included in the LICENSE file that 415N/A * accompanied this code). 415N/A * You should have received a copy of the GNU General Public License version 415N/A * 2 along with this work; if not, write to the Free Software Foundation, 415N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 415N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 415N/A Frame_Complete,
// Offset in the code where the frame setup is (for forte stackwalks) is complete 415N/A // special value to note codeBlobs where profile (forte) stack walking is 415N/A // always dangerous and suspect. 415N/A// This class represents a stream of code and associated relocations. 415N/A// There are a few in each CodeBuffer. 415N/A// They are filled concurrently, and concatenated at the end. 415N/A typedef int csize_t;
// code size type; would be size_t except for history 415N/A // (Note: _locs_point used to be called _last_reloc_offset.) 415N/A // helper for CodeBuffer::expand() 415N/A // is a given address in this section? (2nd version is end-inclusive) 415N/A // Share a scratch buffer for relocinfo. (Hacky; saves a resource allocation.) 415N/A // Manage labels and their addresses. 415N/A // alignment requirement for starting offset 415N/A // Requirements are that the instruction area and the 415N/A // stubs area must start on CodeEntryAlignment, and 415N/A // the ctable on sizeof(jdouble) 415N/A // Slop between sections, used only when allocating temporary BufferBlob buffers. 415N/A // Mark a section frozen. Assign its remaining space to 415N/A // the following section. It will never expand after this point. 415N/A inline void freeze();
// { _outer->freeze_section(this); } 415N/A // Ensure there's enough space left in the current section. 415N/A // Return true if there was an expansion. 415N/A// A CodeBuffer describes a memory space into which assembly 415N/A// code is generated. This memory space usually occupies the 415N/A// interior of a single BufferBlob, but in some cases it may be 415N/A// an arbitrary span of memory, even outside the code cache. 415N/A// A code buffer comes in two variants: 415N/A// (1) A CodeBuffer referring to an already allocated piece of memory: 415N/A// This is used to direct 'static' code generation (e.g. for interpreter 415N/A// or stubroutine generation, etc.). This code comes with NO relocation 415N/A// (2) A CodeBuffer referring to a piece of memory allocated when the 415N/A// CodeBuffer is allocated. This is used for nmethod generation. 415N/A// The memory can be divided up into several parts called sections. 415N/A// Each section independently accumulates code (or data) an relocations. 415N/A// Sections can grow (at the expense of a reallocation of the BufferBlob 415N/A// and recopying of all active sections). When the buffered code is finally 415N/A// written to an nmethod (or other CodeBlob), the contents (code, data, 415N/A// and relocations) of the sections are padded to an alignment and concatenated. 415N/A// Instructions and data in one section can contain relocatable references to 415N/A// addresses in a sibling section. 415N/A // CodeBuffers must be allocated on the stack except for a single 415N/A // special case during expansion which is handled internally. This 415N/A // is done to guarantee proper cleanup of resources. 415N/A typedef int csize_t;
// code size type; would be size_t except for history 415N/A // Here is the list of all possible sections. The order reflects // all pointers other than code_start/end and those inside the sections // Initialize the main section: // helper for CodeBuffer::expand() // ensure sections are disjoint, ordered, and contained in the blob // copies combined relocations to the blob, returns bytes copied // (if target is null, it is a dry run only, just for sizing) // copies combined code to the blob (assumes relocs are already in there) // moves code sections to new buffer (assumes relocs are already in there) // set up a model of the final layout of my contents // Expand the given section so at least 'amount' is remaining. // Creates a new, larger BufferBlob, and rewrites the code & relocs. // (1) code buffer referring to pre-allocated instruction memory // (2) CodeBuffer referring to pre-allocated CodeBlob. // (3) code buffer allocating codeBlob memory for code & relocation // info but with lazy initialization. The name must be something // (4) code buffer allocating codeBlob memory for code & relocation // info. The name must be something informative and code_size must // include both code and stubs sizes. // Initialize a CodeBuffer constructed using constructor 3. Using // constructor 4 is equivalent to calling constructor 3 and then // calling this method. It's been factored out for convenience of // present sections in order; return NULL at end; consts is #0, etc. // This makes the slightly questionable but portable assumption // that the various members (_consts, _insts, _stubs, etc.) are // adjacent in the layout of CodeBuffer. // A stable mapping between 'locators' (small ints) and addresses. void free_blob();
// Free the blob, if we own one. // Properties relative to the insts section: // is there anything in the buffer other than the current section? // size in bytes of output so far in the insts sections // same as insts_size(), except that it asserts there is no non-code here // capacity in bytes of the insts sections // number of bytes remaining in the insts section // is a given address in the insts section? (2nd version is end-inclusive) // Allocated size in all sections, when aligned and concatenated // (this is the eventual state of the content in its final // Combined offset (relative to start of first section) of given // section, as eventually found in the final CodeBlob. // allocated size of all relocation data, including index, rounded up // allocated size of any and all recorded oops // Configuration functions, called immediately after the CB is constructed. // The section sizes are subtracted from the original insts section. // Note: Call them in reverse section order, because each steals from insts. // Override default oop recorder. // Management of overflow storage for binding of Labels. // Transform an address from the code in this code buffer to a specified code buffer // Log a little info about section usage in the CodeBuffer // decodes from decode_begin() to code_end() and sets decode_begin to end void skip_decode();
// sets decode_begin to code_end(); // The following header contains architecture-specific implementations #
endif // SHARE_VM_ASM_CODEBUFFER_HPP