Skip to content
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

feat: parenthetical syntax for cycles etc. #4608

Draft
wants to merge 79 commits into
base: master
Choose a base branch
from
Draft

Conversation

ggreif
Copy link
Contributor

@ggreif ggreif commented Jul 10, 2024

ICCallPrim (and friends) should carry the fragment to set the SystemCyclesAddPrim while the call is being set up towards the replica.

Parentheticals

  • now: (with cycles = 42_000_000) Actor.call(param)
  • later: (with timeout = 10)
    ic0.call_with_best_effort_response : (timeout_seconds : i32) -> ()
  • maybe: (with receiveMax = 50_000) (to limit the response size)
  • maybe: (with resend = true; resendDelay = 3) when SYS_TRANSIENT reject response (like Unix EINTR)
  • support feat(system-api): add call_cycles_add128_up_to ic#1158
  • usecase (with memoryLimit = 1G) ActorClass(<args>)

TODOs:

  • test one-ways
  • typecheck
    • warn when an attribute is moot
    • cycles : Nat for canister sends (self and raw sends too)
  • async blocks
  • ICCallPrim, see top

@@ -312,14 +312,16 @@ let funcE name sort ctrl typ_binds args typs exp =
note = Note.{ def with typ; eff = T.Triv };
}

let recordE' = ref (fun _ -> nullE ()) (* gets correctly filled below *)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use and to allow mutual recursion

begin match e1.it, env with
| VarE f1, { tail_pos = true;
info = Some { func; typ_binds; temps; label; tail_called } }
when f1 = func && are_generic_insts typ_binds insts ->
tail_called := true;
(blockE (assignEs temps (exp env e2)) (breakE label (unitE ()))).it
| _,_-> PrimE (CallPrim insts, [exp env e1; exp env e2])
| _,_-> PrimE (CallPrim (insts, pars), [exp env e1; exp env e2])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| _,_-> PrimE (CallPrim (insts, pars), [exp env e1; exp env e2])
| _,_-> PrimE (CallPrim (insts, exp env pars), [exp env e1; exp env e2])

ggreif added 10 commits July 10, 2024 15:55
unfortunately it doesn't arrive in the `async.ml`
at least now I get
> ingress Err: IC0504: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai violated contract: ic0_call_cycles_add128 called when no call is under construction.
we should use the system call though, instead of
assigning to `@cycles`, as that will go away
@ggreif ggreif changed the title WIP: surface syntax for parentheticals feat: parenthetical syntax for cycles etc. Jul 10, 2024
@ggreif ggreif self-assigned this Jul 10, 2024
@ggreif ggreif added the language design Requires design work label Jul 10, 2024
@@ -108,6 +111,7 @@ let primE prim es =
| SystemCyclesAcceptPrim -> T.nat
| DeserializePrim ts -> T.seq ts
| DeserializeOptPrim ts -> T.Opt (T.seq ts)
| ICCyclesPrim -> T.(Opt (Obj (Object, [{ lab = "cycles"; typ = nat; src = empty_src}])))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a common place for these types?

src/ir_def/ir_effect.ml Outdated Show resolved Hide resolved
@@ -24,8 +24,8 @@ module ConRenaming = E.Make(struct type t = con let compare = Cons.compare end)

(* Helpers *)

let selfcallE ts e1 e2 e3 e4 =
{ it = SelfCallE (ts, e1, e2, e3, e4);
let selfcallE (cyc : exp) ts e1 e2 e3 e4 =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let selfcallE (cyc : exp) ts e1 e2 e3 e4 =
let selfcallE cyc ts e1 e2 e3 e4 =

@@ -82,6 +82,11 @@ let new_nary_async_reply ts =
(* construct the n-ary async value, coercing the continuation, if necessary *)
let nary_async =
let coerce u =
(*<<<<<<< gabor/parentheticals
let k = fresh_var "k" (contT u T.unit) in
Copy link
Contributor Author

@ggreif ggreif Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will land with #4615.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language design Requires design work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants