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

java: remove the extra wrapping of HostContext and pass it directly #550

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

axic
Copy link
Member

@axic axic commented Oct 9, 2020

Depends on #549.

@axic axic requested review from atoulme, chfast and jrhea October 9, 2020 01:28
@axic axic changed the base branch from master to java-host-cleanup October 9, 2020 01:28
@@ -11,11 +11,6 @@
extern "C" {
#endif

struct evmc_host_context
Copy link
Member Author

Choose a reason for hiding this comment

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

The whole point of evmc_host_context is to be an opaque object from the interface perspective, and since it only needs to be valid during the scope of execute I think this change is the correct one.

@atoulme
Copy link
Collaborator

atoulme commented Oct 9, 2020

I think that's ok, not sure I grasp it entirely. I thought the point of having this organization was to pass the context when doing internal calls, but I think you're saying that's not necessary.

@axic
Copy link
Member Author

axic commented Oct 9, 2020

I think that's ok, not sure I grasp it entirely. I thought the point of having this organization was to pass the context when doing internal calls, but I think you're saying that's not necessary.

The context is needed for all the host functions, just that we can opaquely pass it around I think. We can only make this simplification because the scope is limited.

Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

Looks nice. I assume that an HostContext object is not going to be garbage collected while being the argument of execute().

@axic
Copy link
Member Author

axic commented Oct 9, 2020

Looks nice. I assume that an HostContext object is not going to be garbage collected while being the argument of execute().

That is my assumption. We are safe to do this because execute is only executed in a single place where the context's lifetime outlives that of execute, so it won't be collected. And also anything passed to the JNI has a guaranteed lifetime during that JNI call, but not beyond (unless specifically using NewGlobalRef) apparently.

@axic axic force-pushed the java-host-cleanup branch 2 times, most recently from 57cccf6 to 4b24898 Compare October 13, 2020 22:08
Base automatically changed from java-host-cleanup to master October 13, 2020 22:21
@axic axic merged commit fe40029 into master Oct 14, 2020
@axic axic deleted the java-host-context branch October 14, 2020 12:12
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