Conversation
This bumps the `mir-json` submodule to bring in the changes from GaloisInc/mir-json#240. It also adds `crucible-mir` support for parsing and translating constant trait object values. (See GaloisInc/mir-json#237 for the motivation.) Because these MIR JSON changes require bumping the schema version, we must also do the same on the `crucible-mir` side.
| * `trait_id`: the `DefId` for the principal trait bound in the trait object. | ||
| This plays a similar role as the `trait_id` field in `Dynamic` types. |
There was a problem hiding this comment.
Do you think we could use a type for this field that would be compatible with trait objects without principal types? I think this would give us a better chance of avoiding schema changes when we fix #239.
There was a problem hiding this comment.
We'll likely need schema changes in other places anyway for #239. IMO it's better to be consistent for now and switch everything over at the same time.
There was a problem hiding this comment.
I think there is still a question of how exactly we should implement a fix for #239, and it's possible that the answer to that question could influence what the correct schema for trait_object should be. For instance, will the vtable that we emit for trivial trait objects have a corresponding trait definition? mir-json reserves the name "trait/0::empty[0]" for such traits (see the code here), so perhaps it would suffice to include that as the trait_id? On the other hand, this isn't a principal trait, so perhaps it would be confusing to emit this. In this case, perhaps we should emit null here?
I haven't quite figured out the answer to this question, so it's not yet clear to me what to do here.
There was a problem hiding this comment.
(Oops, I wrote that comment before I saw #240 (comment). Good to know that we came to roughly the same conclusion!)
6fdef0a to
a6c067f
Compare
This adds support for compiling constant values that are trait objects (e.g., `const X: &dyn Trait = &0u32`). Like other references to unsized values, these require adding special cases to `make_allocation_body` and `try_render_ref_opty` in order to support: * `make_allocation_body` unpacks the trait object to get the underlying type and then renders the constant based on that type. * `try_render_ref_opty` constructs a special `"trait_object"` constant that references the allocation body's `DefId`, along with the `DefId`s for the trait object's principal trait (`trait_id`) and vtable (`vtable`). These `DefId`s are used on the `crucible-mir` side to construct a trait object value when translating the MIR JSON into Crucible. (Note that trait objects without a principal trait are not yet supported. See #239 for more information on this point.) Note that because `"trait_object"` is a new part of the schema, I needed to bump the schema version number to `9`. Fixes #237.
a6c067f to
318f8c4
Compare
This bumps the `mir-json` submodule to bring in the changes from GaloisInc/mir-json#240. It also adds `crucible-mir` support for parsing and translating constant trait object values. (See GaloisInc/mir-json#237 for the motivation.) Because these MIR JSON changes require bumping the schema version, we must also do the same on the `crucible-mir` side.
This brings in the following changes via submodule bumps: * GaloisInc/mir-json#240 * GaloisInc/crucible#1736 See GaloisInc/mir-json#237 for the motivation.
GaloisInc/mir-json#240 bumps the `mir-json` schema version number to 9, which requires regenerating MIR blobs in the test suite.
This brings in the following changes via submodule bumps for the sake of supporting constant trait objects in the MIR backend: * GaloisInc/mir-json#240 * GaloisInc/crucible#1736 See GaloisInc/mir-json#237 for the motivation. In addition, this brings in the following changes to allow `crucible-llvm` to build after GaloisInc/crucible#1742: * GaloisInc/llvm-pretty#186 and GaloisInc/llvm-pretty#188 * GaloisInc/llvm-pretty-bc-parser#345
GaloisInc/mir-json#240 bumps the `mir-json` schema version number to 9, which requires regenerating MIR blobs in the test suite.
This adds support for compiling constant values that are trait objects (e.g.,
const X: &dyn Trait = &0u32). Like other references to unsized values, these require adding special cases tomake_allocation_bodyandtry_render_ref_optyin order to support:make_allocation_bodyunpacks the trait object to get the underlying type and then renders the constant based on that type.try_render_ref_optyconstructs a special"trait_object"constant that references the allocation body'sDefId, along with theDefIds for the trait object's principal trait (trait_id) and vtable (vtable). TheseDefIds are used on thecrucible-mirside to construct a trait object value when translating the MIR JSON into Crucible.(Note that trait objects without a principal trait are not yet supported. See Emit vtables for "trivial" trait objects that only contain auto traits #239 for more information on this point.)
Note that because
"trait_object"is a new part of the schema, I needed to bump the schema version number to9.Fixes #237.