forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process gc preserve #58
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fe1772d
Processing gc preserve regions differently, transitively pinning root…
4b36001
Merge branch 'v1.9.2+RAI' into feature/process-gc-preserve
udesou 480b89d
Fixing merge conflict
udesou ed66d4b
Cleanup
udesou 0558e64
Removing code that fails llvm assertion
udesou c4c04d3
Restore optimisation that removes GCPreserve calls
udesou 1b3d0de
Clarifying code about pushing objects as gc preserve roots
udesou 83d551b
Fixing stock build
udesou 01f2f24
Skip gc-page-profiler.c when using mmtk
udesou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -570,6 +570,53 @@ JL_DLLEXPORT void jl_gc_array_ptr_copy(jl_array_t *dest, void **dest_p, jl_array | |||
mmtk_memory_region_copy(&ptls->mmtk_mutator, jl_array_owner(src), src_p, jl_array_owner(dest), dest_p, n); | ||||
} | ||||
|
||||
#define jl_p_gcpreserve_stack (jl_current_task->gcpreserve_stack) | ||||
|
||||
// This macro currently uses malloc instead of alloca because this function will exit | ||||
// after pushing the roots into the gc_preserve_stack, which means that the preserve_begin function's | ||||
// stack frame will be destroyed (together with its alloca variables). When we support lowering this code | ||||
// inside the same function that is doing the preserve_begin/preserve_end calls we should be able to simple use allocas. | ||||
// Note also that we use a separate stack for gc preserve roots to avoid the possibility of calling free | ||||
// on a stack that has been allocated with alloca instead of malloc, which could happen depending on the order in which | ||||
// JL_GC_POP() and jl_gc_preserve_end_hook() occurs. | ||||
|
||||
#define JL_GC_PUSHARGS_PRESERVE_ROOT_OBJS(rts_var,n) \ | ||||
rts_var = ((jl_value_t**)malloc(((n)+2)*sizeof(jl_value_t*)))+2; \ | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These need to be clarified.
|
||||
((void**)rts_var)[-2] = (void*)JL_GC_ENCODE_PUSHARGS(n); \ | ||||
((void**)rts_var)[-1] = jl_p_gcpreserve_stack; \ | ||||
memset((void*)rts_var, 0, (n)*sizeof(jl_value_t*)); \ | ||||
jl_p_gcpreserve_stack = (jl_gcframe_t*)&(((void**)rts_var)[-2]); \ | ||||
|
||||
#define JL_GC_POP_PRESERVE_ROOT_OBJS() \ | ||||
jl_gcframe_t *curr = jl_p_gcpreserve_stack; \ | ||||
if(curr) { \ | ||||
(jl_p_gcpreserve_stack = jl_p_gcpreserve_stack->prev); \ | ||||
free(curr); \ | ||||
} | ||||
|
||||
// Add each argument as a tpin root object. | ||||
// However, we cannot use JL_GC_PUSH and JL_GC_POP since the slots should live | ||||
// beyond this function. Instead, we maintain a tpin stack by mallocing/freeing | ||||
// the frames for each of the preserve regions we encounter | ||||
JL_DLLEXPORT void jl_gc_preserve_begin_hook(int n, ...) JL_NOTSAFEPOINT | ||||
{ | ||||
jl_value_t** frame; | ||||
JL_GC_PUSHARGS_PRESERVE_ROOT_OBJS(frame, n); | ||||
if (n == 0) return; | ||||
|
||||
va_list args; | ||||
va_start(args, n); | ||||
for (int i = 0; i < n; i++) { | ||||
frame[i] = va_arg(args, jl_value_t *); | ||||
} | ||||
va_end(args); | ||||
} | ||||
|
||||
JL_DLLEXPORT void jl_gc_preserve_end_hook(void) JL_NOTSAFEPOINT | ||||
{ | ||||
JL_GC_POP_PRESERVE_ROOT_OBJS(); | ||||
} | ||||
|
||||
// No inline write barrier -- only used for debugging | ||||
JL_DLLEXPORT void jl_gc_wb1_noinline(const void *parent) JL_NOTSAFEPOINT | ||||
{ | ||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GCPreserveBeginHook
is only compiled whenMMTK_GC
is set, but this code here is executed for all the builds. The stock build would fail in this case. Same forGCPreserveEndHook
below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. It turns out that the stock build was already broken because of a file not being compiled in
Makefile
, but I've fixed that too and now both builds (stock and MMTk) should work fine.