summaryrefslogtreecommitdiff
path: root/yjit_asm.c
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-11-04 13:05:41 -0700
committerGitHub <noreply@github.com>2021-11-04 16:05:41 -0400
commit2421527d6e4737c371bca0cf7e694f8a2a0f923d (patch)
tree90621ade7e47fab78ce7c885d55aed1c99fdc434 /yjit_asm.c
parent85b4cf16e2cae0577633c1acb1dc7413d58fcb5a (diff)
YJIT code pages refactoring for code GC (#5073)
* New code page allocation logic * Fix leaked globals * Fix leaked symbols, yjit asm tests * Make COUNTED_EXIT take a jit argument, so we can eliminate global ocb * Remove extra whitespace * Change block start_pos/end_pos to be pointers instead of uint32_t * Change branch end_pos and start_pos to end_addr, start_addr
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'yjit_asm.c')
-rw-r--r--yjit_asm.c37
1 files changed, 1 insertions, 36 deletions
diff --git a/yjit_asm.c b/yjit_asm.c
index 0d074d5e4d..49844145cb 100644
--- a/yjit_asm.c
+++ b/yjit_asm.c
@@ -147,7 +147,7 @@ static uint8_t *align_ptr(uint8_t *ptr, uint32_t multiple)
}
// Allocate a block of executable memory
-uint8_t *alloc_exec_mem(uint32_t mem_size)
+static uint8_t *alloc_exec_mem(uint32_t mem_size)
{
#ifndef _WIN32
uint8_t *mem_block;
@@ -221,41 +221,6 @@ uint8_t *alloc_exec_mem(uint32_t mem_size)
#endif
}
-// Head of the list of free code pages
-static code_page_t *freelist = NULL;
-
-// Allocate a single code page from a pool of free pages
-code_page_t *alloc_code_page(void)
-{
- // If the free list is empty
- if (!freelist) {
- // Allocate many pages at once
- uint8_t *code_chunk = alloc_exec_mem(PAGES_PER_ALLOC * CODE_PAGE_SIZE);
-
- // Do this in reverse order so we allocate our pages in order
- for (int i = PAGES_PER_ALLOC - 1; i >= 0; --i) {
- code_page_t *code_page = malloc(sizeof(code_page_t));
- code_page->mem_block = code_chunk + i * CODE_PAGE_SIZE;
- assert ((intptr_t)code_page->mem_block % CODE_PAGE_SIZE == 0);
- code_page->page_size = CODE_PAGE_SIZE;
- code_page->_next = freelist;
- freelist = code_page;
- }
- }
-
- code_page_t *free_page = freelist;
- freelist = freelist->_next;
-
- return free_page;
-}
-
-// Put a code page back into the allocation pool
-void free_code_page(code_page_t *code_page)
-{
- code_page->_next = freelist;
- freelist = code_page;
-}
-
// Initialize a code block object
void cb_init(codeblock_t *cb, uint8_t *mem_block, uint32_t mem_size)
{