Normalize how the global heap pool is configured across iwasm apps (#1628)
Use the cmake variable `WAMR_BUILD_GLOBAL_HEAP_POOL` and `WAMR_BUILD_GLOBAL_HEAP_SIZE` to enable/disable the global heap pool and set its size. And set the default global heap size in core/config.h and the cmake files. As a result, the developers who build iwasm can easily enable/disable the global heap pool and change its size regardless of the iwasm implementation, without manually finding and patching the right location for that value.
This commit is contained in:
@ -262,6 +262,28 @@ if (WAMR_BUILD_LOAD_CUSTOM_SECTION EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1)
|
||||
message (" Load custom section enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GLOBAL_HEAP_POOL EQUAL 1)
|
||||
add_definitions(-DWASM_ENABLE_GLOBAL_HEAP_POOL=1)
|
||||
message (" Global heap pool enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GLOBAL_HEAP_SIZE GREATER 0)
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
message (" Custom global heap size: " ${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
else ()
|
||||
# Spec test requires more heap pool size
|
||||
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "linux-sgx")
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "100 * 1024 * 1024")
|
||||
else ()
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "300 * 1024 * 1024")
|
||||
endif ()
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
else ()
|
||||
# By default, the global heap size is of 10 MB
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "10 * 1024 * 1024")
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
endif ()
|
||||
endif ()
|
||||
if (WAMR_BUILD_STACK_GUARD_SIZE GREATER 0)
|
||||
add_definitions (-DWASM_STACK_GUARD_SIZE=${WAMR_BUILD_STACK_GUARD_SIZE})
|
||||
message (" Custom stack guard size: " ${WAMR_BUILD_STACK_GUARD_SIZE})
|
||||
|
||||
Reference in New Issue
Block a user