-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
all: various fixes for [heap]/auto-heap handling #10033
Conversation
Good work. I am waiting for the CI to be green again (I think it should be in about 30min), then I'll merge it. |
Very good! This'll build more pressure on implementing some heuristic on passing non- struct Abc {
mut:
... // some big struct (maybe bigger than cache line or bigger than the platforms number of general purpose registers)
}
struct Def {
... // some big struct - this time fully immutable
}
fn pass( a &Abc, b &Def ) ( &Abc, &Def ) {
return a, b
}
x := Abc{} // x is immutable
y := Def{} // y is immutable
_, z := pass( &x, &y ) // maybe make an exception for cases when receiver discards the value? She has to write instead the following to be correct and not use ...
fn pass( a Abc, b Def ) ( Abc, Def ) {
return a, b
}
x := Abc{} // immutable
y := Def{} // immutable
_, z := pass( x, y ) // shall be passed as pointer internally But that's inefficient as of now making |
This if a followup to #9873. In addition to those cases handled there some additional checks are performed and some features are added/fixed:
[heap]
objects could become "auto-heap" at the same timeparser
not all definitions of structs are available, yet, so the information if a type is declared[heap]
is not reliable. For this reason all decisions based on this declaration are postponed tochecker
.[heap]
it is now transferred to the heap automatically even if initialized as value object. This makes the conversion of existing code significantly simpler because only[heap]
has to be added at one single place: