-
Notifications
You must be signed in to change notification settings - Fork 715
Add aot_emit_aot_file.h to expose functions related to emitting AOT files #3520
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
Add aot_emit_aot_file.h to expose functions related to emitting AOT files #3520
Conversation
@XeniaLu The aot compiler related APIs have been exported in |
We are developing a PostgreSQL extension to compile WASM using AOT compiler. Due to PostgreSQL's requirement of allocating an additional 4 bytes, we prefer to allocate memory ourselves and then directly call I understand the benefits of not exposing the internal structure |
Do you mean to allocate memory for aot_file_buf with extra 4 bytes and then call aot_emit_aot_file_buf_ex? It seems that we don't need to expose structures in aot_emit_aot_file.h, but just add |
IIUC, we can make changes in struct AOTObjectData;
typedef struct AOTObjectData *aot_obj_data_t;
aot_obj_data_t
aot_obj_data_create(aot_comp_context_t comp_ctx);
void
aot_obj_data_destroy(aot_obj_data_t obj_data);
uint32_t
aot_get_aot_file_size(aot_comp_context_t comp_ctx, aot_comp_data_t comp_data,
aot_obj_data_t obj_data);
uint8 *
aot_emit_aot_file_buf(aot_comp_context_t comp_ctx, aot_comp_data_t comp_data,
uint32_t *p_aot_file_size);
bool
aot_emit_aot_file_buf_ex(aot_comp_context_t comp_ctx, aot_comp_data_t comp_data,
aot_obj_data_t obj_data, uint8_t *aot_file_buf,
uint32_t aot_file_size); |
You are right, we only need to add a typedef in |
Following your suggestion, I have submitted a separate commit to add the above codes to |
@XeniaLu Exposing some APIs is good to me and I added several minor comments. If you don't want to expose AOTObjectData pointer and the related APIs, may we can just provide a memory allocator callback for aot_emit_file_buf, like: typedef void *(*aot_file_buf_alloc_func)(uint32_t size);
uint8 *
aot_emit_aot_file_buf(aot_comp_context_t comp_ctx, aot_comp_data_t comp_data,
aot_file_buf_alloc_func alloc_func,
uint32_t *p_aot_file_size); And also refactor the current code of aot_emit_aot_file_buf, e.g. when alloc_func is NULL, we use wasm_runtime_malloc to allocate the aot file buffer. |
Got it, I kept the current approach with exposing the APIs. Thanks for your review! |
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.
LGTM
LGTM |
aot_emit_aot_file.h
aot_emit_aot_file_buf_ex
and expose through theaot_emit_aot_file.h