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

Handle lifetime tracking in GC targets #12

Closed
shadaj opened this issue Jul 9, 2021 · 0 comments · Fixed by #162 or #164
Closed

Handle lifetime tracking in GC targets #12

shadaj opened this issue Jul 9, 2021 · 0 comments · Fixed by #162 or #164
Assignees
Labels
safety Uncertain implications on code safety
Milestone

Comments

@shadaj
Copy link
Member

shadaj commented Jul 9, 2021

For targets like JavaScript, we can introduce special references between diplomat objects that ensure they are kept around according to lifetime constraints.

For example, if we have

struct Foo(...)
struct Bar<'f>(...)

impl <'f> Bar<'f> {
  fn new(foo: &'f Foo) -> Bar<'f> {
    ...
  }
}

then the JavaScript type for Bar should have an additional field diplomat_lifetime_f, which is used to hold a reference to the Foo passed into the constructor

class Bar {
  static new(foo) {
    ...
    const out = new Bar(wasm.Bar_new(foo.underlying));
    out.diplomat_lifetime_f = foo;
    ...
    return out;
  }
}
@sffc sffc added the safety Uncertain implications on code safety label Aug 3, 2021
@Manishearth Manishearth added this to the Q4 milestone Sep 27, 2021
@Manishearth Manishearth self-assigned this Sep 27, 2021
@Manishearth Manishearth moved this to Todo in Manish's tracker Dec 7, 2021
This was referenced May 26, 2022
Repository owner moved this from Todo to Done in Manish's tracker Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safety Uncertain implications on code safety
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants