-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
v3: stop re-reading released worker args in the monomorphize merges #28700
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
Open
Jengro777
wants to merge
12
commits into
vlang:master
Choose a base branch
from
Jengro777:fix/28489-monomorphize-released-args
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+42
−12
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e7ac3a1
v3: stop re-reading released worker args in the monomorphize merges
Jengro777 189017f
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 5cab1b5
tests: force V3 in the scoped monomorphize regression fixture
Jengro777 1742d19
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 6580e91
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 a79afc5
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 8d6f19d
v3: copy worker declarations before publishing monomorphized specs
Jengro777 6ae3c4e
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 5f38344
Merge branch 'master' of https://github.com/vlang/v into fix/28489-mo…
Jengro777 18fa96e
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 cf8fe1c
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 8f6bdf1
Merge remote-tracking branch 'V_REPO/master' into fix/28489-monomorph…
Jengro777 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
103 changes: 103 additions & 0 deletions
103
vlib/v/compiler_tests/scoped_monomorphize_closure_test.v
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,103 @@ | ||
| import os | ||
|
|
||
| const scoped_monomorph_vexe = @VEXE | ||
| const scoped_monomorph_tests_dir = os.dir(@FILE) | ||
| const scoped_monomorph_v3_dir = os.dir(scoped_monomorph_tests_dir) | ||
| const scoped_monomorph_vlib_dir = os.dir(scoped_monomorph_v3_dir) | ||
| const scoped_monomorph_v3_src = os.join_path(scoped_monomorph_v3_dir, 'v.v') | ||
|
|
||
| $if windows { | ||
| const scoped_monomorph_bin_suffix = '.exe' | ||
| } $else { | ||
| const scoped_monomorph_bin_suffix = '' | ||
| } | ||
|
|
||
| fn scoped_monomorph_v3_bin_path() string { | ||
| return os.join_path(os.temp_dir(), 'v3_scoped_monomorphize_closure_test${scoped_monomorph_bin_suffix}') | ||
| } | ||
|
|
||
| fn scoped_monomorph_v3_bin() string { | ||
| bin := scoped_monomorph_v3_bin_path() | ||
| if os.exists(bin) { | ||
| return bin | ||
| } | ||
| // `-prealloc` is what enables `scope_parallel_workers` and the scoped | ||
| // monomorphize path, matching how the distributed compiler is built. | ||
| build := os.execute('${os.quoted_path(scoped_monomorph_vexe)} -gc none -prealloc -path "${scoped_monomorph_vlib_dir}|@vlib|@vmodules" -o ${os.quoted_path(bin)} ${os.quoted_path(scoped_monomorph_v3_src)}') | ||
| assert build.exit_code == 0, build.output | ||
| return bin | ||
| } | ||
|
|
||
| fn testsuite_begin() { | ||
| os.rm(scoped_monomorph_v3_bin_path()) or {} | ||
| } | ||
|
|
||
| // Compiler builds use `-prealloc`, and the memory-bounded monomorphize path (the | ||
| // fix for vlang/v#28564) runs for every non-empty specialization batch there. | ||
| // That path used to give two different lifted closures the same `__anon_fn_N` | ||
| // name - the module-keyed signature table then mixed their signatures up and the | ||
| // generated C did not compile - and merged specialization arguments as shallow | ||
| // `[]string` copies that still pointed into the released worker arena, so a later | ||
| // pass read freed arguments (bogus `unknown function` diagnostics or a crash). | ||
| // This is the small `veb` program from vlang/v#28489, which exercises closures | ||
| // lifted while specializing a generic helper. | ||
| fn test_scoped_monomorphize_keeps_closure_signatures_and_args() { | ||
| v3_bin := scoped_monomorph_v3_bin() | ||
| dir := os.join_path(os.temp_dir(), 'v3_scoped_monomorphize_closure') | ||
| os.rmdir_all(dir) or {} | ||
| os.mkdir_all(dir) or { panic(err) } | ||
| defer { | ||
| os.rmdir_all(dir) or {} | ||
| } | ||
| os.write_file(os.join_path(dir, 'main.v'), "module main | ||
|
|
||
| import veb | ||
|
|
||
| pub struct Ctx { | ||
| veb.Context | ||
| } | ||
|
|
||
| pub struct ModelApp { | ||
| veb.Middleware[Ctx] | ||
| veb.Controller | ||
| } | ||
|
|
||
| pub struct Item { | ||
| ModelApp | ||
| } | ||
|
|
||
| pub struct MainApp { | ||
| veb.Middleware[Ctx] | ||
| veb.Controller | ||
| } | ||
|
|
||
| fn mw() veb.MiddlewareOptions[Ctx] { | ||
| return veb.MiddlewareOptions[Ctx]{ | ||
| handler: fn (mut ctx Ctx) bool { | ||
| return true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn (mut app MainApp) common_middleware[T](mut ctrl T) { | ||
| ctrl.use(mw()) | ||
| } | ||
|
|
||
| fn (mut app MainApp) register_routes_no_auth[T, U](mut ctrl T, url_path string) { | ||
| app.common_middleware[T](mut ctrl) | ||
| app.register_controller[T, U](url_path, mut ctrl) or { panic(err) } | ||
| ctrl.route_use('/item/*', veb.encode_auto[Ctx]()) | ||
| } | ||
|
|
||
| fn main() { | ||
| mut app := &MainApp{} | ||
| app.register_routes_no_auth[Item, Ctx](mut &Item{}, '/item') | ||
| veb.run_at[MainApp, Ctx](mut app, port: 9001) or { panic(err) } | ||
| } | ||
| ") or { panic(err) } | ||
| out := os.join_path(dir, 'app${scoped_monomorph_bin_suffix}') | ||
| compile := os.execute('${os.quoted_path(v3_bin)} -nocache -o ${os.quoted_path(out)} ${os.quoted_path(dir)}') | ||
| assert compile.exit_code == 0, compile.output | ||
| assert !compile.output.contains('C compilation failed'), compile.output | ||
| assert os.is_file(out), 'the compile produced no binary' | ||
| } | ||
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
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.