From bc0ca7be5d1081e8a1115b870237f8d3f19b32d9 Mon Sep 17 00:00:00 2001 From: SaeHie Park Date: Sat, 11 Jul 2015 22:46:13 +0900 Subject: [PATCH] Add heap size limit to solve #342 JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com --- CMakeLists.txt | 1 + jerry-core/CMakeLists.txt | 6 ++++++ jerry-core/config.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97a983973..3399ea1c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ project (Jerry CXX C ASM) set(EXTERNAL_LIBC_INTERFACE "UNDEFINED" CACHE STRING "Path to external libc include directory") set(EXTERNAL_LIBS_INTERFACE "UNDEFINED" CACHE STRING "Path to external libraries' include directory") + set(EXTERNAL_MEM_HEAP_SIZE_KB "256" CACHE STRING "Size of memory heap, in kilobytes") else() message(FATAL_ERROR "Platform '${PLATFORM}' is not supported") endif() diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index 0e797264e..826ea256f 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -88,6 +88,12 @@ project (JerryCore CXX C ASM) math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024") set(DEFINES_JERRY_MCU_STM32F4 CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K}) + # External + if(DEFINED EXTERNAL_MEM_HEAP_SIZE_KB) + math(EXPR MEM_HEAP_AREA_SIZE_EXTERNAL "${EXTERNAL_MEM_HEAP_SIZE_KB} * 1024") + set(DEFINES_JERRY_EXTERNAL CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_EXTERNAL}) + endif() + # Include directories set(INCLUDE_CORE ${CMAKE_SOURCE_DIR}/jerry-core diff --git a/jerry-core/config.h b/jerry-core/config.h index 249574910..b28205080 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -53,6 +53,8 @@ */ #ifndef CONFIG_MEM_HEAP_AREA_SIZE # define CONFIG_MEM_HEAP_AREA_SIZE (256 * 1024) +#elif CONFIG_MEM_HEAP_AREA_SIZE > (256 * 1024) +# error "Currently, maximum 256 kilobytes heap size is supported" #endif /* !CONFIG_MEM_HEAP_AREA_SIZE */ /**