-
Notifications
You must be signed in to change notification settings - Fork 4
feat(rt): handle zero-sized locals #809
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
Changes from all commits
fc12dcc
389add9
6571f0a
94f30cc
b6736e2
32e3bb1
0e8c30a
497f3e7
1c52f87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ A variant `#forceSetLocal` is provided for setting the local value without check | |
|
|
||
| ```k | ||
| syntax KItem ::= #setLocalValue( Place, Evaluation ) [strict(2)] | ||
| | #forceSetLocal ( Local , Value ) | ||
| | #forceSetLocal ( Local , Evaluation ) [strict(2)] | ||
|
|
||
| rule <k> #setLocalValue(place(local(I), .ProjectionElems), VAL) => .K ... </k> | ||
| <locals> | ||
|
|
@@ -203,7 +203,7 @@ A variant `#forceSetLocal` is provided for setting the local value without check | |
| andBool isTypedValue(LOCALS[I]) | ||
| [preserves-definedness] // valid list indexing and sort checked | ||
|
|
||
| rule <k> #forceSetLocal(local(I), MBVAL) => .K ... </k> | ||
| rule <k> #forceSetLocal(local(I), MBVAL:Value) => .K ... </k> | ||
| <locals> LOCALS => LOCALS[I <- typedValue(MBVAL, tyOfLocal(getLocal(LOCALS, I)), mutabilityOf(getLocal(LOCALS, I)))] </locals> | ||
| requires 0 <=Int I andBool I <Int size(LOCALS) | ||
| andBool isTypedLocal(LOCALS[I]) | ||
|
|
@@ -1064,6 +1064,25 @@ This eliminates any `Deref` projections from the place, and also resolves `Index | |
| // rule #projectionsFor(CtxPointerOffset(OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, projectionElemSubslice(OFFSET, ORIGIN_LENGTH, false) PROJS) | ||
| rule #projectionsFor(CtxPointerOffset( _, OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, PointerOffset(OFFSET, ORIGIN_LENGTH) PROJS) | ||
|
|
||
| // Borrowing a zero-sized local that is still `NewLocal`: initialise it, then reuse the regular rule. | ||
| rule <k> rvalueRef(REGION, KIND, place(local(I), PROJS)) | ||
| => #forceSetLocal( | ||
| local(I), | ||
| #decodeConstant( | ||
| constantKindZeroSized, | ||
| tyOfLocal(getLocal(LOCALS, I)), | ||
| lookupTy(tyOfLocal(getLocal(LOCALS, I))) | ||
| ) | ||
| ) | ||
| ~> rvalueRef(REGION, KIND, place(local(I), PROJS)) | ||
| ... | ||
| </k> | ||
| <locals> LOCALS </locals> | ||
| requires 0 <=Int I andBool I <Int size(LOCALS) | ||
| andBool isNewLocal(LOCALS[I]) | ||
| andBool #zeroSizedType(lookupTy(tyOfLocal(getLocal(LOCALS, I)))) | ||
| [preserves-definedness] // valid list indexing checked, zero-sized locals materialise trivially | ||
|
|
||
|
Comment on lines
1067
to
1085
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are very useful rules to handle the cases described in #675 .
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solved |
||
| rule <k> rvalueRef(_REGION, KIND, place(local(I), PROJS)) | ||
| => #traverseProjection(toLocal(I), getValue(LOCALS, I), PROJS, .Contexts) | ||
| ~> #forRef(#mutabilityOf(KIND), metadata(#metadataSize(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS), 0, noMetadataSize)) // TODO: Sus on this rule | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const EMPTY: () = (); | ||
|
|
||
| fn main() { | ||
| let e = (); | ||
| assert!(e == EMPTY); | ||
| } |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please create an issue to add tuple decoding?
It depends on how the layout is, maybe we can just decode the components in sequence? Or can the fields be out of order for tuples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are the issues: