-
Notifications
You must be signed in to change notification settings - Fork 824
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
Added context trampoline into runtime #481
Conversation
bors try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is a good start. See comments.
lib/runtime-c-api/src/trampoline.rs
Outdated
ctx: *const c_void, | ||
) -> usize { | ||
let b = &mut *(b as *mut TrampolineBufferBuilder); | ||
b.add_function(f as *const CallTarget, ctx as *const CallContext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check that ctx
isn't a null pointer. Use update_last_error
to raise an error accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, check that f
and b
aren't null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to check null pointers explicitly that way?
It's easy to debug SIGSEGV's caused by null pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what we did in the other function, it's debatable :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks super great to my eye!
/// and passes the array into `target` as the second argument when called. The first argument | ||
/// of `target` is the `context` specified here. | ||
/// | ||
/// Note that non-integer parameters/variadic functions are not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it support floats (I think it does not matter since the bits can be interpreted as a float, but I prefer to ask)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Floats are passed in different registers and it would be very complex to handle this case. I think it's better to just support integer parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So trampoline doesn't work with floats. It's important to know!
bors r+ |
Based on #450