[PATCH] provide means to access the zone from the corresponding chunk
Paolo Bonzini
bonzini@gnu.org
Fri May 7 15:20:00 GMT 2004
This patch enables the zone collector to recover the page_entry and
alloc_zone structures from the address of an arbitrary ggc_alloc-ed
pointer. Unfortunately, while very useful, this is quite invasive.
In order to avoid substantial overhead, it changes the data
representation of the zone allocator so that the page_entry, instead of
being in malloced memory, is simply stored as a header in the page. For
small-object pages, you retrieve the page_entry by getting the beginning
of the pages; for large-object pages, the page_entry is just before the
chunk.
It also simplifies the way PCH's are written, by embedding the
page_entry struct in the PCH (since it is now a header to the PCH data).
The PCH zone however is special because it is a single big big
page_entry holding all the objects (both small and large) in the PCH.
For this reason the (unused) type field is changed so that it
distinguishes between objects from the PCH zone and from the other zone.
The patch uses new_persistent_ggc_zone from my patch at
http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00047.html but it can be
checked in independent of that patch simply by changing it to new_ggc_zone.
I can provide a follow-up patch to use this, so that the garbage_zone is
not scanned.
Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?
Paolo
2004-05-07 Paolo Bonzini <bonzini@gnu.org>
* ggc-common.c (gt_pch_save): Move call to
ggc_pch_prepare_write after the padding for the mmap-ed
area has been written.
* ggc-zone.c (enum object_type): New.
(alloc_chunk): Make type field a bit wider, and size
field a bit smaller.
(page_entry): Add u field to hold a pointer to the first chunk
or data. Remove page field. bytes is not a multiple of the
page size anymore. Make the list of entries doubly-linked.
(PAGE_ENTRY_SIZE): New.
(pch_zone): New global.
(ggc_allocated_p): Removed.
(link_page): New.
(release_pages): Replace references to page field
with u.data or u.chunks, carve the page_entry struct
out of the allocated page and decrement the bytes
field appropriately.
(init_ggc): Likewise.
(sweep_pages): Likewise.
(check_cookies): Likewise.
(ggc_collect): Likewise.
(free_page): Likewise, plus handle doubly-linked list.
(alloc_small_page): Likewise, plus remove code moved
to link_page and call it. Fix head comment.
(alloc_large_page): Likewise, plus remove code moved
to link_page and call it. Fix head comment.
(ggc_alloc_zone_1): Likewise, plus include zone name into
the debugging output, and remove code moved to link_page.
(free_chunk): Likewise, plus include zone name into
the debugging output.
(struct ggc_pch_data): Remove ggc_pch_ondisk, we write
a page_entry. Move the only field there to the struct.
Remove the (unused) written field.
(ggc_pch_count_object): Adjust.
(ggc_pch_total_size): Adjust and account for the page_entry.
(ggc_pch_this_base): Account for the space taken by the
page_entry.
(ggc_pch_prepare_write): Write a page_entry to disk.
(ggc_pch_write_object): Remove accesses to the unused
d->written field. Set type to OBJ_PCH in the written
alloc_chunk.
(ggc_pch_finish): Do not write anything.
(ggc_pch_read): Link the mmap-ed page_entry in pch_zone.
Do not create pch_zone here.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 4-gcc-move-page-entry-inside-page.patch
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20040507/bc01328f/attachment.ksh>
More information about the Gcc
mailing list