Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The following platforms are supported, click each link below for how to build iw
- [Blog: The WAMR memory model](https://bytecodealliance.github.io/wamr.dev/blog/the-wamr-memory-model/)
- [Blog: Understand WAMR heaps](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/) and [stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
- [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
- [Memory usage tunning](./doc/memory_tune.md): the memory model and how to tune the memory usage
- [Memory usage tuning](./doc/memory_tune.md): the memory model and how to tune the memory usage
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage
- [Performance tunning](./doc/perf_tune.md): how to tune the performance
- [Performance tuning](./doc/perf_tune.md): how to tune the performance
- [Benchmarks](./tests/benchmarks): checkout these links for how to run the benchmarks: [PolyBench](./tests/benchmarks/polybench), [CoreMark](./tests/benchmarks/coremark), [Sightglass](./tests/benchmarks/sightglass), [JetStream2](./tests/benchmarks/jetstream)
- [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance): the performance and footprint data

Expand Down
68 changes: 44 additions & 24 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ endif ()
if (DEFINED WAMR_BH_VPRINTF)
add_definitions (-DBH_VPRINTF=${WAMR_BH_VPRINTF})
endif ()
if (DEFINED WAMR_BH_LOG)
add_definitions (-DBH_LOG=${WAMR_BH_LOG})
endif ()
if (WAMR_DISABLE_APP_ENTRY EQUAL 1)
message (" WAMR application entry functions excluded")
endif ()
Expand Down Expand Up @@ -421,32 +424,49 @@ if (WAMR_BUILD_STATIC_PGO EQUAL 1)
add_definitions (-DWASM_ENABLE_STATIC_PGO=1)
message (" AOT static PGO enabled")
endif ()
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
message (" Write linear memory base addr to x86 GS register disabled")
elseif (WAMR_BUILD_TARGET STREQUAL "X86_64"
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
#include <stdio.h>
#include <stdint.h>
int main() {
uint64_t value;
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
printf(\"WRGSBASE instruction is available.\\n\");
return 0;
}")
# Try to compile and run the test program
try_run (TEST_WRGSBASE_RESULT
TEST_WRGSBASE_COMPILED
${CMAKE_BINARY_DIR}/test_wrgsbase
SOURCES ${TEST_WRGSBASE_SOURCE}
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
if (NOT TEST_WRGSBASE_RESULT EQUAL 0)
if (WAMR_BUILD_TARGET STREQUAL "X86_64"
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
# disabled by user
set (DISABLE_WRITE_GS_BASE 1)
elseif (WAMR_DISABLE_WRITE_GS_BASE EQUAL 0)
# enabled by user
set (DISABLE_WRITE_GS_BASE 0)
elseif (CMAKE_CROSSCOMPILING)
# disabled in cross compilation environment
set (DISABLE_WRITE_GS_BASE 1)
else ()
# auto-detected by the compiler
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
#include <stdio.h>
#include <stdint.h>
int main() {
uint64_t value;
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
printf(\"WRGSBASE instruction is available.\\n\");
return 0;
}")
# Try to compile and run the test program
try_run (TEST_WRGSBASE_RESULT
TEST_WRGSBASE_COMPILED
${CMAKE_BINARY_DIR}/test_wrgsbase
SOURCES ${TEST_WRGSBASE_SOURCE}
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
if (TEST_WRGSBASE_RESULT EQUAL 0)
set (DISABLE_WRITE_GS_BASE 0)
else ()
set (DISABLE_WRITE_GS_BASE 1)
endif ()
endif ()
if (DISABLE_WRITE_GS_BASE EQUAL 1)
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
message (" Write linear memory base addr to x86 GS register disabled")
else ()
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=0)
message (" Write linear memory base addr to x86 GS register enabled")
endif ()
endif ()
if (WAMR_CONFIGUABLE_BOUNDS_CHECKS EQUAL 1)
Expand Down
11 changes: 11 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@
#define WASM_ENABLE_LOG 1
#endif

/* When this flag is set, WAMR will not automatically
* initialize sockets on Windows platforms. The host
* application is responsible for calling WSAStartup()
* before executing WAMR code that uses sockets, and
* calling WSACleanup() after.
* This flag passes control of socket initialization from
* WAMR to the host application. */
#ifndef WASM_ENABLE_HOST_SOCKET_INIT
#define WASM_ENABLE_HOST_SOCKET_INIT 0
#endif

#ifndef WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS
#if defined(BUILD_TARGET_X86_32) || defined(BUILD_TARGET_X86_64) \
|| defined(BUILD_TARGET_AARCH64)
Expand Down
5 changes: 2 additions & 3 deletions core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -3134,8 +3134,7 @@ resolve_execute_mode(const uint8 *buf, uint32 size, bool *p_mode,
p += 8;
while (p < p_end) {
read_uint32(p, p_end, section_type);
if (section_type <= AOT_SECTION_TYPE_SIGANATURE
|| section_type == AOT_SECTION_TYPE_TARGET_INFO) {
if (section_type <= AOT_SECTION_TYPE_SIGANATURE) {
read_uint32(p, p_end, section_size);
CHECK_BUF(p, p_end, section_size);
if (section_type == AOT_SECTION_TYPE_TARGET_INFO) {
Expand All @@ -3150,7 +3149,7 @@ resolve_execute_mode(const uint8 *buf, uint32 size, bool *p_mode,
break;
}
}
else if (section_type > AOT_SECTION_TYPE_SIGANATURE) {
else { /* section_type > AOT_SECTION_TYPE_SIGANATURE */
set_error_buf(error_buf, error_buf_size,
"resolve execute mode failed");
break;
Expand Down
17 changes: 9 additions & 8 deletions core/iwasm/aot/arch/aot_reloc_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
error_buf, error_buf_size,
"AOT module load failed: "
"relocation truncated to fit R_X86_64_PC32 failed. "
"Try using wamrc with --size-level=1 option.");
"Try using wamrc with --size-level=1 or 0 option.");
return false;
}

Expand Down Expand Up @@ -196,7 +196,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
snprintf(buf, sizeof(buf),
"AOT module load failed: "
"relocation truncated to fit %s failed. "
"Try using wamrc with --size-level=1 option.",
"Try using wamrc with --size-level=1 or 0 option.",
reloc_type == R_X86_64_32 ? "R_X86_64_32"
: "R_X86_64_32S");
set_error_buf(error_buf, error_buf_size, buf);
Expand Down Expand Up @@ -236,15 +236,16 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
target_addr -= sizeof(int32);
#endif
if ((int32)target_addr != target_addr) {
set_error_buf(error_buf, error_buf_size,
"AOT module load failed: "
"relocation truncated to fit "
set_error_buf(
error_buf, error_buf_size,
"AOT module load failed: "
"relocation truncated to fit "
#if !defined(BH_PLATFORM_WINDOWS)
"R_X86_64_PLT32 failed. "
"R_X86_64_PLT32 failed. "
#else
"IMAGE_REL_AMD64_32 failed."
"IMAGE_REL_AMD64_32 failed."
#endif
"Try using wamrc with --size-level=1 option.");
"Try using wamrc with --size-level=1 or 0 option.");
return false;
}
*(int32 *)(target_section_addr + reloc_offset) = (int32)target_addr;
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/common/wasm_c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ wasm_module_new(wasm_store_t *store, const wasm_byte_vec_t *binary)
(uint8 *)module_ex->binary->data, (uint32)module_ex->binary->size,
error_buf, (uint32)sizeof(error_buf));
if (!(module_ex->module_comm_rt)) {
LOG_ERROR(error_buf);
LOG_ERROR("%s", error_buf);
goto free_vec;
}

Expand Down Expand Up @@ -2367,7 +2367,7 @@ wasm_module_validate(wasm_store_t *store, const wasm_byte_vec_t *binary)
}
else {
ret = false;
LOG_VERBOSE(error_buf);
LOG_VERBOSE("%s", error_buf);
}

return ret;
Expand Down Expand Up @@ -3359,7 +3359,7 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params,
wasm_runtime_set_exception(func->inst_comm_rt, NULL);
if (!wasm_runtime_call_wasm(exec_env, func_comm_rt, argc, argv)) {
if (wasm_runtime_get_exception(func->inst_comm_rt)) {
LOG_DEBUG(wasm_runtime_get_exception(func->inst_comm_rt));
LOG_DEBUG("%s", wasm_runtime_get_exception(func->inst_comm_rt));
goto failed;
}
}
Expand Down Expand Up @@ -5044,7 +5044,7 @@ wasm_instance_new_with_args(wasm_store_t *store, const wasm_module_t *module,
*trap = wasm_trap_new(store, &message);
wasm_byte_vec_delete(&message);
}
LOG_DEBUG(error_buf);
LOG_DEBUG("%s", error_buf);
wasm_instance_delete_internal(instance);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/common/wasm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ wasm_native_resolve_symbol(const char *module_name, const char *field_name,
{
NativeSymbolsNode *node, *node_next;
const char *signature = NULL;
void *func_ptr = NULL, *attachment;
void *func_ptr = NULL, *attachment = NULL;

node = g_native_symbols_list;
while (node) {
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2905,7 +2905,8 @@ copy_string_array(const char *array[], uint32 array_size, char **buf_ptr,
/* We add +1 to generate null-terminated array of strings */
total_size = sizeof(char *) * ((uint64)array_size + 1);
if (total_size >= UINT32_MAX
|| (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size)))
/* total_size must be larger than 0, don' check it again */
|| !(list = wasm_runtime_malloc((uint32)total_size))
|| buf_size >= UINT32_MAX
|| (buf_size > 0 && !(buf = wasm_runtime_malloc((uint32)buf_size)))) {

Expand Down
6 changes: 3 additions & 3 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ check_utf8_str(const uint8 *str, uint32 len)
return false;
}
}
else if (chr >= 0xE1 && chr <= 0xEF) {
else { /* chr >= 0xE1 && chr <= 0xEF */
if (p[1] < 0x80 || p[1] > 0xBF || p[2] < 0x80 || p[2] > 0xBF) {
return false;
}
Expand All @@ -341,13 +341,13 @@ check_utf8_str(const uint8 *str, uint32 len)
return false;
}
}
else if (chr >= 0xF1 && chr <= 0xF3) {
else if (chr <= 0xF3) { /* and also chr >= 0xF1 */
if (p[1] < 0x80 || p[1] > 0xBF || p[2] < 0x80 || p[2] > 0xBF
|| p[3] < 0x80 || p[3] > 0xBF) {
return false;
}
}
else if (chr == 0xF4) {
else { /* chr == 0xF4 */
if (p[1] < 0x80 || p[1] > 0x8F || p[2] < 0x80 || p[2] > 0xBF
|| p[3] < 0x80 || p[3] > 0xBF) {
return false;
Expand Down
Loading