Skip to content

Instantly share code, notes, and snippets.

Avatar
©️
 ​[object Object] :trollface:

Aaron Patterson tenderlove

©️
 ​[object Object] :trollface:
View GitHub Profile
View foo.c
page_body = (struct heap_page_body *)rb_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
/* cut.. */
page = calloc1(sizeof(struct heap_page));
/* cut.. */
assert((getpagesize() * 4) == HEAP_PAGE_ALIGN);
intptr_t page_body_end = (intptr_t)page_body + (getpagesize() * 4);
View foo.c
page_body = (struct heap_page_body *)rb_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
/* cut.. */
page = calloc1(sizeof(struct heap_page));
View read-barrier-code.rb
def segv_handler(info)
# Only triggered if someone tried to read from a MOVED location
move_all_objects_back(find_page(info.read_address))
end
def compact
register_segv_handler :segv_handler
ruby_heap.pages.each do |page|
move_objects_on(page)
View foo.c
REQUIRED_SIZE_BY_MALLOC = (sizeof(size_t) * 5),
HEAP_PAGE_SIZE = (HEAP_PAGE_ALIGN - REQUIRED_SIZE_BY_MALLOC),
View foo.c
/* assign heap_page body (contains heap_page_header and RVALUEs) */
page_body = (struct heap_page_body *)rb_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
if (page_body == 0) {
rb_memerror();
}
/* assign heap_page entry */
page = calloc1(sizeof(struct heap_page));
if (page == 0) {
rb_aligned_free(page_body);
View foo.c
struct heap_page_header {
struct heap_page *page;
};
struct heap_page_body {
struct heap_page_header header;
/* char gap[]; */
/* RVALUE values[]; */
};
View foo.c
struct heap_page_header {
struct heap_page *page;
};
struct heap_page_body {
struct heap_page_header header;
/* char gap[]; */
/* RVALUE values[]; */
};
View gist:9c40b50aa3b64a9b6e0002e99672504d
struct heap_page_header {
struct heap_page *page;
};
struct heap_page_body {
struct heap_page_header header;
/* char gap[]; */
/* RVALUE values[]; */
};
View heap_page_struct.c
struct heap_page {
short total_slots;
short free_slots;
short pinned_slots;
short final_slots;
struct {
unsigned int before_sweep : 1;
unsigned int has_remembered_objects : 1;
unsigned int has_uncollectible_shady_objects : 1;
unsigned int in_tomb : 1;
View heap_page_struct.c
struct heap_page {
short total_slots;
short free_slots;
short pinned_slots;
short final_slots;
struct {
unsigned int before_sweep : 1;
unsigned int has_remembered_objects : 1;
unsigned int has_uncollectible_shady_objects : 1;
unsigned int in_tomb : 1;
You can’t perform that action at this time.