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

Added context trampoline into runtime #481

Merged
merged 11 commits into from
Jun 5, 2019
Merged

Added context trampoline into runtime #481

merged 11 commits into from
Jun 5, 2019

Conversation

syrusakbary
Copy link
Member

Based on #450

@syrusakbary
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Jun 3, 2019
@bors
Copy link
Contributor

bors bot commented Jun 3, 2019

Copy link
Contributor

@Hywan Hywan left a 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 Show resolved Hide resolved
lib/runtime-c-api/src/trampoline.rs Show resolved Hide resolved
ctx: *const c_void,
) -> usize {
let b = &mut *(b as *mut TrampolineBufferBuilder);
b.add_function(f as *const CallTarget, ctx as *const CallContext)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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 :-).

lib/runtime-c-api/src/trampoline.rs Outdated Show resolved Hide resolved
lib/runtime-core/src/trampoline_x64.rs Outdated Show resolved Hide resolved
lib/runtime-core/src/trampoline_x64.rs Show resolved Hide resolved
lib/runtime-core/src/trampoline_x64.rs Show resolved Hide resolved
Copy link
Contributor

@Hywan Hywan left a 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.
Copy link
Contributor

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)?

Copy link
Contributor

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.

Copy link
Contributor

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!

@losfair
Copy link
Contributor

losfair commented Jun 5, 2019

bors r+

bors bot added a commit that referenced this pull request Jun 5, 2019
481: Added context trampoline into runtime r=losfair a=syrusakbary

Based on #450 

Co-authored-by: losfair <zhy20000919@hotmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 5, 2019

@bors bors bot merged commit 66dcec9 into master Jun 5, 2019
@bors bors bot deleted the feature/trampoline branch June 5, 2019 11:49
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.

3 participants