-
Notifications
You must be signed in to change notification settings - Fork 22
Allocate block-exceeding tokens directly in the old generation #1219
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5eab976
Allocate block-exceeding tokens directly in the old generation
Robertorosmaninho 57a861a
Add a GC regression test for large tokens
Robertorosmaninho 97957ec
Update comment in init_with_len function
Robertorosmaninho 2a97375
Refine comments on token allocation in alloc.cpp
Robertorosmaninho bf509f4
Select the allocation arena by reference in kore_alloc_token
Robertorosmaninho 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Regression test for the large-token young-generation GC bug. | ||
| // | ||
| // A String token whose payload exceeds BLOCK_SIZE (1 MiB) is flagged NOT_YOUNG by | ||
| // init_with_len, but kore_alloc_token used to place it in the young semispace anyway. | ||
| // The collector never migrates a NOT_YOUNG object out of the young from-space (which is | ||
| // reclaimed on every collection), so such a token dangled: a later allocation overwrote | ||
| // its bytes and a subsequent collection walked a corrupted header. | ||
| // | ||
| // This definition (a) builds a single > 1 MiB String token, (b) keeps it live in the | ||
| // <keep> cell across (c) heavy subsequent allocation that forces collections and reuses | ||
| // the abandoned region, then (d) reads the token's length back. On the buggy runtime the | ||
| // length is corrupted (or the run crashes); with the fix the token lives in the old | ||
| // generation and its length survives intact. | ||
| module TEST | ||
| imports STRING-BUFFER | ||
| imports INT | ||
| imports STRING | ||
| imports MAP | ||
|
|
||
| configuration <T> | ||
| <k> $PGM:Pgm </k> | ||
| <buffer> .StringBuffer </buffer> | ||
| <keep> "":String </keep> | ||
| <m> .Map </m> | ||
| </T> | ||
|
|
||
| syntax Cmd ::= appendN(Int, String) | ||
| | freeze() | ||
| | churn(Int) | ||
| syntax Pgm ::= List{Cmd,";"} | ||
|
|
||
| // Build a > 1 MiB buffer by appending S, I times. | ||
| rule <k> appendN(I, S) ; Cmds => appendN(I -Int 1, S) ; Cmds </k> | ||
| <buffer> SB => SB +String S </buffer> | ||
| requires I >Int 0 | ||
| rule <k> appendN(I, _) ; Cmds => Cmds </k> | ||
| requires I ==Int 0 | ||
|
|
||
| // Materialize the buffer as one > 1 MiB String token and stash it as a live GC root. | ||
| rule <k> freeze() ; Cmds => Cmds </k> | ||
| <buffer> SB </buffer> | ||
| <keep> _ => StringBuffer2String(SB) </keep> | ||
|
|
||
| // Allocate heavily to force collections after freeze() and reuse the abandoned region. | ||
| rule <k> churn(I) ; Cmds => churn(I -Int 1) ; Cmds </k> | ||
| <m> M => M [ Int2String(I) <- I ] </m> | ||
| requires I >Int 0 | ||
| rule <k> churn(I) ; Cmds => Cmds </k> | ||
| requires I ==Int 0 | ||
|
|
||
| // Read the kept token back: its length must have survived the collections intact. | ||
| // Clear the bulky cells so the checked output stays small. | ||
| rule <k> .Pgm => lengthString(S) </k> | ||
| <keep> S => "" </keep> | ||
| <buffer> _ => .StringBuffer </buffer> | ||
| <m> _ => .Map </m> | ||
| endmodule |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.