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 pointer arguments in lifting #6

Open
chc4 opened this issue Sep 12, 2021 · 0 comments
Open

Handle pointer arguments in lifting #6

chc4 opened this issue Sep 12, 2021 · 0 comments

Comments

@chc4
Copy link
Owner

chc4 commented Sep 12, 2021

Related to #2, but on the lifting side: if we have a closure like so:

struct MyStruct {
    a: usize,
    b: usize,
    c: usize
}

jit.speedup(|env: MyStruct| { env.a += 1; env.a })

it's implemented as something like fn(clos: c_void, env: &MyStruct) { env->a++; env->a }: that is, the structure is behind a pointer (we optimize away all loads from clos, which is the closed environment).

We want to tell the lifter that the argument is a JitValue::Ref(JitValue::Struct(vec![JitValue::Value, JitValue::Value, JitValue::Value]), mem::size_of<MyStruct>()) - that is, that it's a pointer to a struct made up of some symbolic value members. This would allow us to do partial application and optimization with the struct's members instead of having to emit Cranelift load/stores for everything.

We might want to annotate the struct MyStruct with a #[derive(JitInput)] or something? Dunno.

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

No branches or pull requests

1 participant