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

improve memory consumption ; add Z# strict unary op, ternary ?:, and type aliases #77

Merged
merged 18 commits into from
May 4, 2022

Conversation

kwantam
Copy link
Collaborator

@kwantam kwantam commented Apr 25, 2022

This PR breaks cycles between the term cache and the constant folding machinery. It also adds a couple Drop implementations that explicitly call the garbage collector (the C front-end might want one, too---not sure!)

For Z#, this adds

  • a unary operator # that strictly evaluates (i.e., constant folds) its argument. As a special case, an assignment's RHS is treated strictly if its LHS is #( ... )
  • the condition ? consequent : alternative flavor of ternary operator - exactly the same as if foo then bar else baz fi
  • typedefs: type Foo = field[7] or whatever.

Typedefs have one limitation: if a typedef Bar refers to a struct Foo in module A, then to use Bar in module B one must also import Foo.

@alex-ozdemir: before we land this PR, we should land alex-ozdemir/hashconsing#2 and then I should update Cargo.lock to point to your repo again.

kwantam and others added 16 commits April 22, 2022 15:50
This commit adds Drop instances and related functionality that force
garbage collection at life cycle end of various structs that contain
Terms.

I didn't implement Drop for Computation because its Terms are generally
moved into a converter. This means that back-ends are responsible for
garbage collecting (see new functionality in ILP, R1cs, and ABY).
also added err messages for asserts and ?: ternary support from ZoK upstream
Still missing monomorphization.
things work except that importing an alias and not its referent breaks typechecking
Copy link
Contributor

@alex-ozdemir alex-ozdemir left a comment

Choose a reason for hiding this comment

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

Looks good to me, pending the manifest reversion.

(and sorry: I didn't notice the other PR)

src/ir/term/mod.rs Show resolved Hide resolved
@kwantam
Copy link
Collaborator Author

kwantam commented Apr 26, 2022

OK, updated Cargo.lock and Cargo.toml. Assuming the build goes OK, g2g from my end!

@kwantam kwantam merged commit a3fa232 into master May 4, 2022
elefthei pushed a commit to elefthei/circ that referenced this pull request Oct 11, 2022
…type aliases (circify#77)

* update TODO

* add quiet mode to zxc

* Drop and garbage collection

This commit adds Drop instances and related functionality that force
garbage collection at life cycle end of various structs that contain
Terms.

I didn't implement Drop for Computation because its Terms are generally
moved into a converter. This means that back-ends are responsible for
garbage collecting (see new functionality in ILP, R1cs, and ABY).

* collect the cfold table, too

* prevent double-panic as a result of garbage_collect()

* z# parser: zx is a default extension too

* update Cargo.lock

* strictness un-op #()

also added err messages for asserts and ?: ternary support from ZoK upstream

* for assignments, strict rhs => strict lhs

* zsharp: type definitions WIP

Still missing monomorphization.

* type defns: generic inference

* struct monomorphization for type aliased structs

* different approach: no monomorphization, just canonicalize aliases

* canonicalize struct names

* typedef tests

things work except that importing an alias and not its referent breaks typechecking

* add error message about needing to import referent structs

* update hashconsing pointer in Cargo.toml

* maybe_garbage_collect should also return early when panicking

Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants