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

Implement function erasure #5576

Merged
merged 68 commits into from
Jul 17, 2023
Merged

Implement function erasure #5576

merged 68 commits into from
Jul 17, 2023

Conversation

ayazhafiz
Copy link
Member

@ayazhafiz ayazhafiz commented Jun 20, 2023

Implements type-erasure of closures, as an alternative to lambda sets for compiling functions.

See the description of erasure here: https://www.notion.so/rwx/Type-Erasure-a3ed13ef1305422eba00dbda026e52b3?pvs=4

The current implementation supports only global function erasure, and is internal-only. You can compile a roc program with erased functions using a debug compiler and setting ROC_ERASE=1.

The implementation is incomplete but I would like to merge this in, as we need it regardless, and the diff is quite large. Currently unsupported:

  • Compilation to any backend besides LLVM
  • Injection of the refcounting functions for erased cells
  • Erased functions interop with glue

@ayazhafiz ayazhafiz marked this pull request as ready for review July 12, 2023 21:11
@ayazhafiz ayazhafiz changed the title Spike erasure Implement function erasure Jul 12, 2023
Copy link
Contributor

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

oof, that's a lot. left some things to look at in a follow-up

Comment on lines +1450 to +1455
let box1_is_null = env
.builder
.build_is_null(box1.into_pointer_value(), "box1_is_null");
let check_box2_is_null = ctx.append_basic_block(parent, "check_if_box2_is_null");
let return_false = ctx.append_basic_block(parent, "return_false");
let compare_inner_values = ctx.append_basic_block(parent, "compare_inner_values");
Copy link
Contributor

Choose a reason for hiding this comment

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

this adds an extra block. you could just do the null checks, bitwise or, and then jump based on that right?

}

impl<T> SubsSlice<T> {
pub fn empty() -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

could be a const fn now I think.

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