Skip to content

Commit 6e1761e

Browse files
author
Ruben Ayrapetyan
committed
Introduce GC stress testing mode (-mem_stress_test prefix; for example: debug.linux-mem_stress_test).
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
1 parent d2820b2 commit 6e1761e

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ project (Jerry CXX C ASM)
154154
# Memory statistics
155155
set(MODIFIER_SUFFIX_MEMORY_STATISTICS -mem_stats)
156156

157+
# Memory management stress-test mode
158+
set(MODIFIER_SUFFIX_MEM_STRESS_TEST -mem_stress_test)
159+
157160
# Modifier lists
158161
# Linux
159162
set(MODIFIERS_LISTS_LINUX
160163
"FULL_PROFILE"
164+
"FULL_PROFILE MEM_STRESS_TEST"
161165
"COMPACT_PROFILE"
162166
"COMPACT_PROFILE_MINIMAL"
163167
"FULL_PROFILE MEMORY_STATISTICS"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export TARGET_RELEASE_MODES = release
9797

9898
export TARGET_PC_SYSTEMS = linux
9999

100-
export TARGET_PC_MODS = cp cp_minimal mem_stats
100+
export TARGET_PC_MODS = cp cp_minimal mem_stats mem_stress_test
101101

102102
export TARGET_MCU_MODS = cp cp_minimal
103103

jerry-core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ project (JerryCore CXX C ASM)
7070
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
7171
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN)
7272

73+
# Memory management stress-test mode
74+
set(DEFINES_MEM_STRESS_TEST
75+
MEM_GC_BEFORE_EACH_ALLOC)
76+
7377
# Memory statistics
7478
set(DEFINES_MEMORY_STATISTICS MEM_STATS)
7579

jerry-core/mem/mem-heap.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ mem_heap_alloc_block_try_give_memory_back (size_t size_in_bytes, /**< size of re
489489
* (one-chunked or general) */
490490
mem_heap_alloc_term_t alloc_term) /**< expected allocation term */
491491
{
492+
#ifdef MEM_GC_BEFORE_EACH_ALLOC
493+
mem_run_try_to_give_memory_back_callbacks (MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL);
494+
#endif /* MEM_GC_BEFORE_EACH_ALLOC */
495+
492496
size_t chunks = mem_get_block_chunks_count_from_data_size (size_in_bytes);
493497
if ((mem_heap_allocated_chunks + chunks) * MEM_HEAP_CHUNK_SIZE >= mem_heap_limit)
494498
{

jerry-core/mem/mem-poolman.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
* Memory pool manager implementation
2525
*/
2626

27-
#define JERRY_MEM_POOL_INTERNAL
28-
2927
#include "jrt.h"
3028
#include "jrt-libc-includes.h"
3129
#include "mem-allocator.h"
3230
#include "mem-heap.h"
3331
#include "mem-poolman.h"
3432

33+
#define MEM_ALLOCATOR_INTERNAL
34+
#include "mem-allocator-internal.h"
35+
3536
/**
3637
* Size of a pool
3738
*/
@@ -497,6 +498,10 @@ mem_pools_alloc_longpath (void)
497498
uint8_t* __attr_always_inline___
498499
mem_pools_alloc (void)
499500
{
501+
#ifdef MEM_GC_BEFORE_EACH_ALLOC
502+
mem_run_try_to_give_memory_back_callbacks (MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL);
503+
#endif /* MEM_GC_BEFORE_EACH_ALLOC */
504+
500505
mem_check_pools ();
501506

502507
do

0 commit comments

Comments
 (0)