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

[instantiation linking] Refactor wasm_runtime_instantiate() #3893

Open
wants to merge 15 commits into
base: dev/instantiate_linking
Choose a base branch
from

Conversation

lum1n0us
Copy link
Collaborator

@lum1n0us lum1n0us commented Nov 1, 2024

based #3845 and #3887

@lum1n0us lum1n0us force-pushed the fix/optimize_runtime_instantiate branch from 4016457 to 36646a0 Compare November 1, 2024 15:49
@lum1n0us lum1n0us changed the title Refactor wasm_runtime_instantiate() [instantiation linking] Refactor wasm_runtime_instantiate() Nov 3, 2024
@lum1n0us lum1n0us marked this pull request as ready for review November 3, 2024 07:52
@lum1n0us lum1n0us force-pushed the fix/optimize_runtime_instantiate branch 5 times, most recently from edddd11 to f261840 Compare November 4, 2024 07:14
@lum1n0us lum1n0us force-pushed the fix/optimize_runtime_instantiate branch from f261840 to b71bee8 Compare November 4, 2024 07:48

WASM_RUNTIME_API_EXTERN void
WASM_RUNTIME_API_EXTERN
void
Copy link
Contributor

@bnason-nf bnason-nf Nov 8, 2024

Choose a reason for hiding this comment

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

Is there a reason to have the return type on a separate line here?

@@ -300,15 +296,15 @@ memory_instantiate(const WASMModule *module, WASMModuleInstance *parent,
uint8 *aux_heap_base_global_data, char *error_buf,
uint32 error_buf_size)
{
bh_assert(memory != NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we were sticking with declarations at the top of the block for compatibility with older C standards? This puts code before the declarations.

Copy link
Collaborator Author

@lum1n0us lum1n0us Nov 11, 2024

Choose a reason for hiding this comment

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

After careful observation, I've come to understand that it is Ok to relax the restrictions on where variable declarations are placed. All the compilers and products we're aware of won't have an issue with this change. However, if you're aware of any exceptions, please inform me.

The benefit is clear. Code readability will improve if we move variable declarations closer to where they are used.

@wenyongh

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, I am for this new approach.


total_size = sizeof(WASMMemoryInstance *) * (uint64)memory_count;

if (!(memories = runtime_malloc(total_size, error_buf, error_buf_size))) {
return NULL;
}

memory = module_inst->global_table_data.memory_instances;
WASMMemoryInstance *memory =
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as previous comment, are we ok with declarations not being at the top?

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 addressed by the previous discussion.

@@ -11,6 +11,7 @@ find_path(WASISDK_HOME
REQUIRED
)


Copy link
Contributor

Choose a reason for hiding this comment

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

This looks extraneous?

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved.

- Remove unnecessary blank line in FindWASISDK.cmake for improved readability
- Format function declaration for wasm_runtime_destroy_imports for consistency
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.

2 participants