-
Notifications
You must be signed in to change notification settings - Fork 228
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
RFC: stable memory block names for globals #220
base: master
Are you sure you want to change the base?
Conversation
This redefines the [block] type to a richer namespace where block identifier can be of two disjoint kinds: blocks associated to globals, and dynamic block ids allocated at runtime. This is work in progress.
Then use it to finish updating Memory.v
…e and introduce blomega tactic
…Update the interpreter
Thanks for the proposal. I haven't had time yet to study the diff but will do soon. @andrew-appel, @jhjourdan, @robbertkrebbers, any opinions on this proposal? |
We will discuss this in the VST group and get back to you. |
Today we (@andrew-appel, @lennartberinger, @scuellar, @jeremie-koenig, @pwilke) discussed this by phone. We agree that the proposal addresses part of the problem, but does not address the problem of consistent (across compilation units) mapping of ASCII strings ("names") to AST.ident. We believe that very possibly this pull request could be a useful part of the solution to that larger problem, but we are still studying and discussing it. |
One thing @pwilke and I did not think to mention this during the call: in this pull request, the ASCII names <->
This allows us to print out a global pointer This does not really address the problem mentioned by @andrew-appel, which I understand as: What if I want to use strings that never went through the parser, therefore are not in the map? This happens anytime you use CompCert as a library rather than a self-contained compiler: in VST, when you use the output of VST/CertiKOS use things like:
Instead, we would want to use something like:
or perhaps even declare I believe we can accomplish this in the following way: In the Coq part of CompCert, we axiomatize But since we're free to use any such mapping, in the ML part, we can simply implement Using this approach, we don't need to deal with the statefulness of the table in Coq, but still get the benefits. I believe implementing this can be done independently of our changes to the block namespace. |
Here's a proof-of-concept CertiKOS@85d2b87 |
We can use "MAP with Definition" for the same effect.
In particular, use the name [AST.string_of_ident] and declare it in the same places, so that a merge would be straightforward.
At this point I thought I'd write some kind of "diff walk-through" to facilitate any digging people would want to do. The main changes occur in:
Less remarkable changes are:
The rest of the patch consists of replacing |
We can get linker errors for addresses of the form "symbol + offset" where "symbol" is in the small data area and "offset" is large enough to overflow the relative displacement from the SDA base register. To avoid this, this commit enriches `C2C.atom_is_small_data`, which is the implementation of `Asm.symbol_is_small_data` in the PPC port, with a check that the offset is within the bounds of the symbol. If it is not, `Asm.symbol_is_small_data` returns `false` and Asmgen produces an absolute addressing instead of a SDA-relative addressing. To implement the check, we record the sizes of symbols in the atom table, just like we already record their alignments.
These changes introduce a more structured namespace for memory blocks: a block id can either be a global
ident
(new), or a dynamically allocatedpositive
(as before). Using this approach, we can ensure that global environments always assign the same block name to a global identifierid
, so that for allge1
,ge2
we have:Rationale
In all work around compositional semantics, we need to ensure that the memory blocks for globals are named consistently across modules. For instance,
Our changes should make it possible to eliminate these hacks/assumptions.
Status
We have updated all of CompCert v3.2 to use this new naming scheme.
We plan to use these changes in our own ongoing work on compositional compilation, and we may tweak them further over the coming weeks. However, since these changes have a broader potential applicability and we're hoping for them to be merged into CompCert at some point, we want to collect some feedback as we go forward with that plan.
Notes:
Module Type
, making it easy to explore richer namespace structures in the future.constval
/transl_init
to abuseVptr
to store the global identifier of referenced variables, since it is now possible to use a pointer value that makes sense.val
directly in events, as demonstrated by ourglobmem-eventval
branch, which defineseventval := val
.Known remaining issue:
BMap
usingEMap
may be problematic for the performance of the interpreter. This can be easily fixed with some more work.find_symbol
with a simplerhas_symbol
boolean predicate (for example), or remove it entirely.