Skip to content

Commit

Permalink
Enable shrunk memory by default and add related configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
lum1n0us committed Jan 6, 2025
1 parent 1807eec commit d187f67
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 152 deletions.
12 changes: 12 additions & 0 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ if (WAMR_BUILD_LINUX_PERF EQUAL 1)
endif ()
endif ()

if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
# Enable shrunk memory by default
set (WAMR_BUILD_SHRUNK_MEMORY 1)
endif ()

########################################

message ("-- Build Configurations:")
Expand Down Expand Up @@ -599,3 +604,10 @@ endif()
if (NOT WAMR_BUILD_SANITIZER STREQUAL "")
message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled")
endif ()
if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1)
message (" Shrunk memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
message (" Shrunk memory disable")
endif ()
4 changes: 4 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,8 @@
#define WASM_ENABLE_SHARED_HEAP 0
#endif

#ifndef WASM_ENABLE_SHRUNK_MEMORY
#define WASM_ENABLE_SHRUNK_MEMORY 1
#endif

#endif /* end of _CONFIG_H_ */
2 changes: 2 additions & 0 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -6159,6 +6159,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
WASMMemoryImport *memory_import;
WASMMemory *memory;

#if WASM_ENABLE_SHRUNK_MEMORY != 0
if (aux_data_end_global && aux_heap_base_global
&& aux_stack_top_global) {
uint64 init_memory_size;
Expand Down Expand Up @@ -6196,6 +6197,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
}
#endif

#if WASM_ENABLE_MULTI_MODULE == 0
if (module->import_memory_count) {
Expand Down
Loading

0 comments on commit d187f67

Please sign in to comment.