NAME ^

src/gc/resources.c - Allocate and deallocate tracked resources

DESCRIPTION ^

Parrot Memory Management Code ^

alloc_new_block

Allocate a new memory block. We allocate the larger of the requested size or the default size. The given text is used for debugging.

mem_allocate

Allocates memory for headers.

Alignment problems history:

See http://archive.develooper.com/perl6-internals%40perl.org/msg12310.html for details.

- return aligned pointer *if needed* - return strings et al at unaligned i.e. void* boundaries - remember alignment in a buffer header bit use this in compaction code - reduce alignment to a reasonable value i.e. MALLOC_ALIGNMENT aka 2*sizeof (size_t) or just 8 (TODO make a config hint)

Buffer memory layout:

                    +-----------------+
                    |  ref_count   |f |    # GC header
  obj->bufstart  -> +-----------------+
                    |  data           |
                    v                 v

 * if PObj_is_COWable is set, then we have
   - a ref_count, {inc,dec}remented by 2 always
   - the lo bit 'f' means 'is being forwarded" - what TAIL_flag was

 * if PObj_align_FLAG is set, obj->bufstart is aligned like discussed above
 * obj->buflen is the usable length excluding the optional GC part.
buffer_location

TODO: Not yet documented!!!

debug_print_buf

TODO: Not yet documented!!!

Compaction Code ^

compact_pool

Compact the buffer pool.

Parrot_go_collect

Go do a GC run. This only scans the string pools and compacts them, it doesn't check for string liveness.

aligned_size

TODO: Not yet documented!!!

aligned_mem

TODO: Not yet documented!!!

aligned_string_size

TODO: Not yet documented!!!

Parrot_in_memory_pool

TODO: Not yet documented!!!

Parrot Re/Allocate Code ^

Parrot_reallocate

Reallocate the Buffer's buffer memory to the given size. The allocated buffer will not shrink. If the buffer was allocated with Parrot_allocate_aligned the new buffer will also be aligned. As with all reallocation, the new buffer might have moved and the additional memory is not cleared.

Parrot_reallocate_string

Reallocate the STRING's buffer memory to the given size. The allocated buffer will not shrink. This function sets also str->strstart to the new buffer location, str->bufused is not changed.

Parrot_allocate

Allocate buffer memory for the given Buffer pointer. The size has to be a multiple of the word size. PObj_buflen will be set to exactly the given size.

Parrot_allocate_aligned

Like above, except the size will be rounded up and the address of the buffer will have the same alignment as a pointer returned by malloc(3) suitable to hold e.g. a FLOATVAL array.

Parrot_allocate_string

Allocate the STRING's buffer memory to the given size. The allocated buffer maybe slightly bigger than the given size. This function sets also str->strstart to the new buffer location, str->bufused is not changed.

new_memory_pool

Create a new memory pool.

Parrot_initialize_memory_pools

Initialize the managed memory pools.

Parrot_destroy_memory_pools

Destroys the memory pools.

merge_pools

TODO: Not yet documented!!!

Parrot_merge_memory_pools

Merge the memory pools of source_interp into dest_interp.

SEE ALSO ^

include/parrot/resources.h, src/gc/memory.c.

HISTORY ^

Initial version by Dan on 2001.10.2.


parrot