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

C API Get module from an instance #599

Merged
merged 1 commit into from
Oct 15, 2020
Merged

C API Get module from an instance #599

merged 1 commit into from
Oct 15, 2020

Conversation

gumb0
Copy link
Collaborator

@gumb0 gumb0 commented Oct 13, 2020

No description provided.

@gumb0 gumb0 changed the base branch from master to capi_func_type October 13, 2020 11:11
@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #599 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #599   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files          63       63           
  Lines        9282     9294   +12     
=======================================
+ Hits         9121     9133   +12     
  Misses        161      161           

@gumb0 gumb0 force-pushed the capi-instance-module branch 3 times, most recently from fd57d9d to 833a2b3 Compare October 13, 2020 16:42
@gumb0 gumb0 marked this pull request as ready for review October 13, 2020 16:43
@gumb0 gumb0 force-pushed the capi-instance-module branch from 833a2b3 to 20e1775 Compare October 13, 2020 16:59
@gumb0 gumb0 requested review from axic and chfast October 13, 2020 17:28
///
/// @note The returned pointer respresents non-owning, "view"-access to the module and must not be
/// passed to fizzy_free_module.
const FizzyModule* fizzy_get_instance_module(FizzyInstance* instance);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const FizzyModule* fizzy_get_instance_module(FizzyInstance* instance);
const FizzyModule* fizzy_instance_get_module(FizzyInstance* instance);

?

Copy link
Member

Choose a reason for hiding this comment

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

I think this may be better wording, but we already have get_instance_memory, so I suggest we go with what is the PR and then rename all of them at once if we want.

@axic
Copy link
Member

axic commented Oct 13, 2020

I guess this is only a "short term" workaround until we have C++ API to make all this work on the instance?

@gumb0
Copy link
Collaborator Author

gumb0 commented Oct 14, 2020

I guess this is only a "short term" workaround until we have C++ API to make all this work on the instance?

I don't know, do you imagine that we would duplicate all module inspection functions for an instance?
To me it seems better to have functions that query module defnition (function/global types, table limits, memory limits etc.) only for a module.

@gumb0 gumb0 force-pushed the capi-instance-module branch from 20e1775 to 5993c8b Compare October 14, 2020 10:12
@axic
Copy link
Member

axic commented Oct 14, 2020

I guess this is only a "short term" workaround until we have C++ API to make all this work on the instance?

I don't know, do you imagine that we would duplicate all module inspection functions for an instance?
To me it seems better to have functions that query module defnition (function/global types, table limits, memory limits etc.) only for a module.

Probably this conversation originates from where Module was consumed by instantiate, and made this harder. Now that is not consumed anymore, do we actually need this helper? Fine to have it though.

auto instance = fizzy_instantiate(module, nullptr, 0);
EXPECT_NE(instance, nullptr);

auto instance_module = fizzy_get_instance_module(instance);
Copy link
Member

Choose a reason for hiding this comment

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

How about adding EXPECT_EQ(module, instance_module) ?

@gumb0
Copy link
Collaborator Author

gumb0 commented Oct 14, 2020

I guess this is only a "short term" workaround until we have C++ API to make all this work on the instance?

I don't know, do you imagine that we would duplicate all module inspection functions for an instance?
To me it seems better to have functions that query module defnition (function/global types, table limits, memory limits etc.) only for a module.

Probably this conversation originates from where Module was consumed by instantiate, and made this harder. Now that is not consumed anymore, do we actually need this helper? Fine to have it though.

Module is still consumed.

@axic
Copy link
Member

axic commented Oct 14, 2020

Module is still consumed.

Wasn't the whole point of the unique_ptr refactoring to make it not consume it and thus be reusable for multiple instances?

@gumb0 gumb0 force-pushed the capi_func_type branch 3 times, most recently from 95246c5 to 9991225 Compare October 14, 2020 16:46
@gumb0
Copy link
Collaborator Author

gumb0 commented Oct 14, 2020

Wasn't the whole point of the unique_ptr refactoring to make it not consume it and thus be reusable for multiple instances?

No, for that it would need to be changed to shared_ptr, which for now I think would be unnecessary complication / overhead.

The point was for FizzyModule* to simply represent both owned and unowned module, and to make this helper here possible.

@gumb0 gumb0 force-pushed the capi-instance-module branch from 5993c8b to 022a155 Compare October 14, 2020 17:41
Base automatically changed from capi_func_type to master October 15, 2020 12:08
@gumb0 gumb0 force-pushed the capi-instance-module branch from 022a155 to f714cad Compare October 15, 2020 12:10
@gumb0 gumb0 merged commit e5d589a into master Oct 15, 2020
@gumb0 gumb0 deleted the capi-instance-module branch October 15, 2020 12:53
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