/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#ifndef SHARE_VM_MEMORY_HEAP_HPP
#define SHARE_VM_MEMORY_HEAP_HPP
#include "memory/allocation.hpp"
#include "runtime/virtualspace.hpp"
// Blocks
friend class VMStructs;
public:
struct Header {
};
protected:
union {
// pad to 0 mod 8
};
public:
// Initialization
// Accessors
};
friend class VMStructs;
protected:
public:
// Initialization
// Merging
// Accessors
};
friend class VMStructs;
private:
int _log2_segment_size;
// Helper functions
size_t number_of_segments(size_t size) const { return (size + _segment_size - 1) >> _log2_segment_size; }
HeapBlock* block_at(size_t i) const { return (HeapBlock*)(_memory.low() + (i << _log2_segment_size)); }
// Freelist management helpers
void merge_right (FreeBlock* a);
// Toplevel freelist management
void add_to_freelist(HeapBlock *b);
// Iteration helpers
HeapBlock* first_block() const;
HeapBlock* block_start(void* p) const;
// to perform additional actions on creation of executable code
public:
CodeHeap();
// Heap extents
void release(); // releases all allocated memory
void clear(); // clears all heap contents
// Memory allocation
void deallocate(void* p); // deallocates a block
// Attributes
void* find_start(void* p) const; // returns the block containing p or NULL
size_t alignment_offset() const; // offset of first byte of any block, within the enclosing alignment unit
// Returns reserved area high and low addresses
// Iteration
// returns the first block or NULL
// returns the next block given a block p or NULL
// Statistics
size_t max_capacity() const;
size_t allocated_capacity() const;
size_t largest_free_block() const;
// Debugging
void verify();
};
#endif // SHARE_VM_MEMORY_HEAP_HPP