-
Notifications
You must be signed in to change notification settings - Fork 728
xip: Lookup float constants from table to reduce relocations #894
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
Changes from 3 commits
241edb7
f3a6b3b
f988d4f
bdc4721
cd5a06f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -465,6 +465,12 @@ get_native_symbol_by_name(const char *name) | |
| return func; | ||
| } | ||
|
|
||
| static bool | ||
| str2uint32(const char *buf, uint32 *p_res); | ||
|
|
||
| static bool | ||
| str2uint64(const char *buf, uint64 *p_res); | ||
|
|
||
| static bool | ||
| load_native_symbol_section(const uint8 *buf, const uint8 *buf_end, | ||
| AOTModule *module, bool is_load_from_file_buf, | ||
|
|
@@ -487,11 +493,35 @@ load_native_symbol_section(const uint8 *buf, const uint8 *buf_end, | |
|
|
||
| for (i = cnt - 1; i >= 0; i--) { | ||
| read_string(p, p_end, symbol); | ||
| module->native_symbol_list[i] = get_native_symbol_by_name(symbol); | ||
| if (module->native_symbol_list[i] == NULL) { | ||
| set_error_buf_v(error_buf, error_buf_size, | ||
| "missing native symbol: %s", symbol); | ||
| goto fail; | ||
| if (!strncmp(symbol, "i32#", 4)) { | ||
| uint32 u32; | ||
| if (!str2uint32(symbol + 4, &u32)) { | ||
| set_error_buf_v(error_buf, error_buf_size, | ||
| "resolve symbol %s failed", symbol); | ||
| goto fail; | ||
| } | ||
| *(uint32 *)(&module->native_symbol_list[i]) = u32; | ||
| } | ||
| else if (!strncmp(symbol, "i64#", 4)) { | ||
| uint64 u64; | ||
| if (!str2uint64(symbol + 4, &u64)) { | ||
| set_error_buf_v(error_buf, error_buf_size, | ||
| "resolve symbol %s failed", symbol); | ||
| goto fail; | ||
| } | ||
| *(uint64 *)(&module->native_symbol_list[i]) = u64; | ||
| } | ||
| else if (!strncmp(symbol, "__ignore", 8)) { | ||
| continue; | ||
| } | ||
| else { | ||
| module->native_symbol_list[i] = | ||
| get_native_symbol_by_name(symbol); | ||
| if (module->native_symbol_list[i] == NULL) { | ||
| set_error_buf_v(error_buf, error_buf_size, | ||
| "missing native symbol: %s", symbol); | ||
| goto fail; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1711,7 +1741,6 @@ is_literal_relocation(const char *reloc_sec_name) | |
| return !strcmp(reloc_sec_name, ".rela.literal"); | ||
| } | ||
|
|
||
| #if defined(BH_PLATFORM_WINDOWS) | ||
| static bool | ||
| str2uint32(const char *buf, uint32 *p_res) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the difference between
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lum1n0us Seems the result of str2uint32 is a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is raw int bits of f32 and f64. |
||
| { | ||
|
|
@@ -1757,7 +1786,6 @@ str2uint64(const char *buf, uint64 *p_res) | |
| *p_res = res; | ||
| return true; | ||
| } | ||
| #endif | ||
|
|
||
| static bool | ||
| do_text_relocation(AOTModule *module, AOTRelocationGroup *group, | ||
|
|
||
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.
may let i32 be renamed n32. less confusion over i representing integer and f representing float.
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.
has renamed to "f32#"