Skip to content

Commit 6a64368

Browse files
authored
chore: merge origin master & update p/spl-token.md (#897)
- #893 - #892 - #894 - #896 - [update spl/p-token.md to use #execTerminatorCall](39ce2a6) - #898
2 parents e9bba40 + 9f3c509 commit 6a64368

File tree

47 files changed

+507
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+507
-382
lines changed

deps/pyproject-build-systems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
795a980d25301e5133eca37adae37283ec3c8e66
1+
042904167604c681a090c07eb6967b4dd4dae88c

deps/stable-mir-json

Submodule stable-mir-json updated 31 files

deps/stable-mir-json_release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20a1bbdfc1fb36fb19539d0d4d91f5a437be7de6
1+
626e8fed0470078c4d980b6b5b503a3aceb355ec

deps/uv2nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c8cf711802cb00b2e05d5c54d3486fce7bfc8f7c
1+
4cca323a547a1aaa9b94929c4901bed5343eafe8

deps/uv_release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.9
1+
0.9.14

flake.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
flake-utils.url = "github:numtide/flake-utils";
88

9-
stable-mir-json-flake.url = "github:runtimeverification/stable-mir-json/20a1bbdfc1fb36fb19539d0d4d91f5a437be7de6";
9+
stable-mir-json-flake.url = "github:runtimeverification/stable-mir-json/626e8fed0470078c4d980b6b5b503a3aceb355ec";
1010
stable-mir-json-flake = {
1111
inputs.nixpkgs.follows = "nixpkgs";
1212
inputs.flake-utils.follows = "flake-utils";
@@ -18,7 +18,7 @@
1818
inputs.nixpkgs.follows = "nixpkgs";
1919
};
2020

21-
uv2nix.url = "github:pyproject-nix/uv2nix/c8cf711802cb00b2e05d5c54d3486fce7bfc8f7c";
21+
uv2nix.url = "github:pyproject-nix/uv2nix/4cca323a547a1aaa9b94929c4901bed5343eafe8";
2222
# uv2nix requires a newer version of nixpkgs
2323
# therefore, we pin uv2nix specifically to a newer version of nixpkgs
2424
# until we replaced our stale version of nixpkgs with an upstream one as well
@@ -27,7 +27,7 @@
2727
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
2828
uv2nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
2929
# uv2nix.inputs.nixpkgs.follows = "nixpkgs";
30-
pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/795a980d25301e5133eca37adae37283ec3c8e66";
30+
pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/042904167604c681a090c07eb6967b4dd4dae88c";
3131
pyproject-build-systems = {
3232
inputs.nixpkgs.follows = "uv2nix/nixpkgs";
3333
inputs.uv2nix.follows = "uv2nix";

kmir/src/kmir/kdist/mir-semantics/kmir.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -308,21 +308,33 @@ The call stack is not necessarily empty at this point so it is left untouched.
308308
`Call` is calling another function, setting up its stack frame and
309309
where the returned result should go.
310310

311-
312311
```k
313-
// Intrinsic function call - execute directly without state switching
314-
rule [termCallIntrinsic]: <k> #execTerminator(terminator(terminatorKindCall(FUNC, ARGS, DEST, TARGET, _UNWIND), _SPAN)) ~> _
315-
=>
316-
#execIntrinsic(lookupFunction(#tyOfCall(FUNC)), ARGS, DEST) ~> #continueAt(TARGET)
312+
syntax KItem ::= #execTerminatorCall(fty: Ty, func: MonoItemKind, args: Operands, destination: Place, target: MaybeBasicBlockIdx, unwind: UnwindAction)
313+
314+
rule <k> #execTerminator(terminator(terminatorKindCall(operandConstant(constOperand(_, _, mirConst(constantKindZeroSized, Ty, _))), ARGS, DEST, TARGET, UNWIND), _SPAN))
315+
=> #execTerminatorCall(Ty, lookupFunction(Ty), ARGS, DEST, TARGET, UNWIND)
316+
...
317317
</k>
318-
requires isIntrinsicFunction(lookupFunction(#tyOfCall(FUNC)))
318+
319+
rule <k> #execTerminator(terminator(terminatorKindCall(operandMove(place(local(I), .ProjectionElems)), ARGS, DEST, TARGET, UNWIND), _SPAN))
320+
=> #execTerminatorCall(tyOfLocal(getLocal(LOCALS, I)), lookupFunction(tyOfLocal(getLocal(LOCALS, I))), ARGS, DEST, TARGET, UNWIND)
321+
...
322+
</k>
323+
<locals> LOCALS </locals>
324+
325+
// Intrinsic function call - execute directly without state switching
326+
rule [termCallIntrinsic]:
327+
<k> #execTerminatorCall(_, FUNC, ARGS, DEST, TARGET, _UNWIND) ~> _
328+
=> #execIntrinsic(FUNC, ARGS, DEST) ~> #continueAt(TARGET)
329+
</k>
330+
requires isIntrinsicFunction(FUNC)
319331
320332
// Regular function call - full state switching and stack setup
321-
rule [termCallFunction]: <k> #execTerminator(terminator(terminatorKindCall(FUNC, ARGS, DEST, TARGET, UNWIND), _SPAN)) ~> _
322-
=>
323-
#setUpCalleeData(lookupFunction(#tyOfCall(FUNC)), ARGS)
333+
rule [termCallFunction]:
334+
<k> #execTerminatorCall(FTY, FUNC, ARGS, DEST, TARGET, UNWIND) ~> _
335+
=> #setUpCalleeData(FUNC, ARGS)
324336
</k>
325-
<currentFunc> CALLER => #tyOfCall(FUNC) </currentFunc>
337+
<currentFunc> CALLER => FTY </currentFunc>
326338
<currentFrame>
327339
<currentBody> _ </currentBody>
328340
<caller> OLDCALLER => CALLER </caller>
@@ -332,7 +344,7 @@ where the returned result should go.
332344
<locals> LOCALS </locals>
333345
</currentFrame>
334346
<stack> STACK => ListItem(StackFrame(OLDCALLER, OLDDEST, OLDTARGET, OLDUNWIND, LOCALS)) STACK </stack>
335-
requires notBool isIntrinsicFunction(lookupFunction(#tyOfCall(FUNC)))
347+
requires notBool isIntrinsicFunction(FUNC)
336348
337349
syntax Bool ::= isIntrinsicFunction(MonoItemKind) [function]
338350
rule isIntrinsicFunction(IntrinsicFunction(_)) => true
@@ -341,11 +353,6 @@ where the returned result should go.
341353
syntax KItem ::= #continueAt(MaybeBasicBlockIdx)
342354
rule <k> #continueAt(someBasicBlockIdx(TARGET)) => #execBlockIdx(TARGET) ... </k>
343355
rule <k> #continueAt(noBasicBlockIdx) => .K ... </k>
344-
345-
syntax Ty ::= #tyOfCall( Operand ) [function, total]
346-
347-
rule #tyOfCall(operandConstant(constOperand(_, _, mirConst(constantKindZeroSized, Ty, _)))) => Ty
348-
rule #tyOfCall(_) => ty(-1) [owise] // copy, move, non-zero size: not supported
349356
```
350357

351358
The local data has to be set up for the call, which requires information about the local variables of a call. This step is separate from the above call stack setup because it needs to retrieve the locals declaration from the body. Arguments to the call are `Operands` which refer to the old locals (`OLDLOCALS` below), and the data is either _copied_ into the new locals using `#setArgs`, or it needs to be _shared_ via references.
@@ -415,7 +422,8 @@ An operand may be a `Reference` (the only way a function could access another fu
415422
andBool isTypedValue(CALLERLOCALS[I])
416423
[preserves-definedness] // valid list indexing checked
417424
418-
rule <k> #setArgFromStack(IDX, operandMove(place(local(I), .ProjectionElems)))
425+
// TODO: This is not safe, need to add more checks to this.
426+
rule <k> #setArgFromStack(IDX, operandMove(place(local(I), _)))
419427
=>
420428
#setLocalValue(place(local(IDX), .ProjectionElems), #incrementRef(getValue(CALLERLOCALS, I)))
421429
...

kmir/src/kmir/kdist/mir-semantics/rt/data.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ Constant operands are simply decoded according to their type.
130130
requires typeInfoVoidType =/=K lookupTy(TY)
131131
```
132132

133+
Function pointers are zero-sized constants whose `Ty` is a key in the function table instaed of the type table.
134+
135+
```k
136+
rule <k> operandConstant(constOperand(_, _, mirConst(constantKindZeroSized, ty(ID) #as TY, _)))
137+
=> FunPtr(TY)
138+
...
139+
</k>
140+
requires typeInfoVoidType ==K lookupTy(TY) // not a valid type info
141+
andBool lookupFunction(TY) =/=K monoItemFn(symbol("** UNKNOWN FUNCTION **"), defId(ID), noBody ) // valid function Ty
142+
```
143+
133144
### Copying and Moving
134145

135146
When an operand is `Copied` by a read, the original remains valid (see `false` passed to `#readProjection`).

kmir/src/kmir/kdist/mir-semantics/rt/value.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ The special `Moved` value represents values that have been used and should not b
5151
[symbol(Value::PtrLocal)]
5252
// pointer to a local TypedValue (on the stack)
5353
// fields are the same as in Reference
54+
| FunPtr ( Ty )
55+
// function pointer, created by operandConstant only. Ty is a key in the function table
5456
| AllocRef ( AllocId , ProjectionElems , Metadata )
5557
[symbol(Value::AllocRef)]
5658
// reference to static allocation, by AllocId, possibly projected, carrying metadata if applicable

0 commit comments

Comments
 (0)