/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class CodeHeap : public CHeapObj<mtCode> { friendclass VMStructs; protected:
VirtualSpace _memory; // the memory holding the blocks
VirtualSpace _segmap; // the memory holding the segment map
size_t _number_of_committed_segments;
size_t _number_of_reserved_segments;
size_t _segment_size; int _log2_segment_size;
size_t _next_segment;
FreeBlock* _freelist;
FreeBlock* _last_insert_point; // last insert point in add_to_freelist
size_t _freelist_segments; // No. of segments in freelist int _freelist_length;
size_t _max_allocated_capacity; // Peak capacity that was allocated during lifetime of the heap
constchar* _name; // Name of the CodeHeap const CodeBlobType _code_blob_type; // CodeBlobType it contains int _blob_count; // Number of CodeBlobs int _nmethod_count; // Number of nmethods int _adapter_count; // Number of adapters int _full_count; // Number of times the code heap was full int _fragmentation_count; // #FreeBlock joins without fully initializing segment map elements.
enum { free_sentinel = 0xFF }; staticconstint fragmentation_limit = 10000; // defragment after that many potential fragmentations. staticconstint freelist_limit = 100; // improve insert point search if list is longer than this limit. staticchar segmap_template[free_sentinel+1];
// Memory allocation void* allocate (size_t size); // Allocate 'size' bytes in the code cache or return NULL void deallocate(void* p); // Deallocate memory // Free the tail of segments allocated by the last call to 'allocate()' which exceed 'used_size'. // ATTENTION: this is only safe to use if there was no other call to 'allocate()' after // 'p' was allocated. Only intended for freeing memory which would be otherwise // wasted after the interpreter generation because we don't know the interpreter size // beforehand and we also can't easily relocate the interpreter to a new location. void deallocate_tail(void* p, size_t used_size);
// Containment means "contained in committed space". bool contains(constvoid* p) const { return low() <= p && p < high(); } bool contains_blob(const CodeBlob* blob) const { return contains((void*)blob);
}
virtualvoid* find_start(void* p) const; // returns the block containing p or NULL virtual CodeBlob* find_blob(void* start) const;
size_t alignment_unit() const; // alignment of any block
size_t alignment_offset() const; // offset of first byte of any block, within the enclosing alignment unit static size_t header_size() { returnsizeof(HeapBlock); } // returns the header size for each heap block
size_t segment_size() const { return _segment_size; } // for CodeHeapState
HeapBlock* first_block() const; // for CodeHeapState
HeapBlock* next_block(HeapBlock* b) const; // for CodeHeapState
HeapBlock* split_block(HeapBlock* b, size_t split_seg); // split one block into two
FreeBlock* freelist() const { return _freelist; } // for CodeHeapState
size_t allocated_in_freelist() const { return _freelist_segments * CodeCacheSegmentSize; } int freelist_length() const { return _freelist_length; } // number of elements in the freelist
// returns the first block or NULL virtualvoid* first() const { return next_used(first_block()); } // returns the next block given a block p or NULL virtualvoid* next(void* p) const { return next_used(next_block(block_start(p))); }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.