Commit Graph

3 Commits

Author SHA1 Message Date
John McCall
1d764fd6b4 Synthesize modify accessors for resilient global variables.
rdar://32936947
2018-11-01 19:28:50 -04:00
Slava Pestov
9c3ccc9855 Sema: Plumb through resiliently-accessed global variables
My recent changes added "resiliently-sized" global variables, where a
global in one module is defined to be of a type from another module,
and the type's size is not known at compile time.

This patch adds the other half of the equation: when accessing a
global variable defined by another module, we want to use accessors
since we want to resiliently change global variables from stored to
computed and vice versa.

The main complication here is that the synthesized accessors are not
part of any IterableDeclContext, and require some special-casing in
SILGen and Serialization. There might be simplifications possible here.

For testing and because of how the resilience code works right now,
I added the @_fixed_layout attribute to global variables. In the
future, we probably will not give users a way to promise that a
stored global variable will always remain stored; or perhaps we will
hang this off of a different attribute, once we finalize the precise
set of attributes exposed for resilience.

There's probably some other stuff with lazy and observers I need to
think about here; leaving that for later.
2016-01-15 21:34:54 -08:00
Slava Pestov
627c906ef3 SILGen: Emit alloc_global when initializing global variables
It is still not clear to me when we access global variables from other
modules directly, versus using accessors; it seems to be controlled
by the -sil-serialize-all flag, rather than any language feature.

Until/if we add a @_fixed_layout equivalent for globals, I can't really
test direct access of globals from other modules; when we figure out
the story here I'll be able to add more tests and also tighten up
some isResilient() checks in the global code, but what's in there now
seems to work.
2016-01-08 19:56:00 -08:00