Skip to content

Commit a1e767c

Browse files
committed
Introduce JERRY_NO_HEAVY_DEBUG preprocessor definiton to speed up debug version of the engine.
Heavy debug is enabled only for unit tests. JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
1 parent 8a9633d commit a1e767c

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

jerry-core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ project (JerryCore CXX C ASM)
3737

3838
# Build modes
3939
# Debug
40-
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
40+
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER JERRY_NO_HEAVY_DEBUG)
4141

4242
# Release
43-
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
43+
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG JERRY_NO_HEAVY_DEBUG)
4444

4545
# Unit tests
4646
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)

jerry-core/mem/mem-heap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
10581058
static void
10591059
mem_check_heap (void)
10601060
{
1061-
#ifndef JERRY_NDEBUG
1061+
#ifndef JERRY_NO_HEAVY_DEBUG
10621062
JERRY_ASSERT ((uint8_t*) mem_heap.first_block_p == mem_heap.heap_start);
10631063
JERRY_ASSERT (mem_heap.heap_size % MEM_HEAP_CHUNK_SIZE == 0);
10641064

@@ -1131,7 +1131,7 @@ mem_check_heap (void)
11311131

11321132
JERRY_ASSERT (chunk_sizes_sum * MEM_HEAP_CHUNK_SIZE == mem_heap.heap_size);
11331133
JERRY_ASSERT (is_first_block_was_met);
1134-
#endif /* !JERRY_NDEBUG */
1134+
#endif /* !JERRY_NO_HEAVY_DEBUG */
11351135
} /* mem_check_heap */
11361136

11371137
#ifdef MEM_STATS

jerry-core/mem/mem-pool.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ mem_pool_free_chunk (mem_pool_state_t *pool_p, /**< pool */
181181
* Check pool state consistency
182182
*/
183183
static void
184-
mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #ifdef JERRY_NDEBUG) */
184+
mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #ifdef JERRY_NO_HEAVY_DEBUG) */
185185
{
186-
#ifndef JERRY_NDEBUG
186+
#ifndef JERRY_NO_HEAVY_DEBUG
187187
JERRY_ASSERT (pool_p->free_chunks_number <= MEM_POOL_CHUNKS_NUMBER);
188188

189189
size_t met_free_chunks_number = 0;
@@ -204,7 +204,9 @@ mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #if
204204
}
205205

206206
JERRY_ASSERT (met_free_chunks_number == pool_p->free_chunks_number);
207-
#endif /* !JERRY_NDEBUG */
207+
#else /* !JERRY_NO_HEAVY_DEBUG */
208+
(void) pool_p;
209+
#endif /* !JERRY_NO_HEAVY_DEBUG */
208210
} /* mem_check_pool */
209211

210212
/**

jerry-core/rcs/rcs-chunked-list.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void
289289
rcs_chunked_list_t::assert_list_is_correct (void)
290290
const
291291
{
292-
#ifndef JERRY_NDEBUG
292+
#ifndef JERRY_NO_HEAVY_DEBUG
293293
for (node_t *node_iter_p = get_first ();
294294
node_iter_p != NULL;
295295
node_iter_p = get_next (node_iter_p))
@@ -308,7 +308,7 @@ const
308308
&& next_node_p != NULL
309309
&& get_prev (next_node_p) == node_iter_p));
310310
}
311-
#endif /* !JERRY_NDEBUG */
311+
#endif /* !JERRY_NO_HEAVY_DEBUG */
312312
} /* rcs_chunked_list_t::assert_list_is_correct */
313313

314314
/**
@@ -318,7 +318,7 @@ void
318318
rcs_chunked_list_t::assert_node_is_correct (const rcs_chunked_list_t::node_t* node_p) /**< the node */
319319
const
320320
{
321-
#ifndef JERRY_NDEBUG
321+
#ifndef JERRY_NO_HEAVY_DEBUG
322322
JERRY_ASSERT (node_p != NULL);
323323

324324
assert_list_is_correct ();
@@ -337,7 +337,7 @@ const
337337
}
338338

339339
JERRY_ASSERT (is_in_list);
340-
#else /* JERRY_NDEBUG */
340+
#else /* !JERRY_NO_HEAVY_DEBUG */
341341
(void) node_p;
342-
#endif /* JERRY_NDEBUG */
342+
#endif /* !JERRY_NO_HEAVY_DEBUG */
343343
} /* rcs_chunked_list_t::assert_node_is_correct */

jerry-core/rcs/rcs-recordset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ rcs_recordset_t::get_record_size (rcs_record_t* rec_p) /**< record */
613613
void
614614
rcs_recordset_t::assert_state_is_correct (void)
615615
{
616-
#ifndef JERRY_NDEBUG
616+
#ifndef JERRY_NO_HEAVY_DEBUG
617617
size_t node_size_sum = 0;
618618
size_t record_size_sum = 0;
619619

@@ -658,7 +658,7 @@ rcs_recordset_t::assert_state_is_correct (void)
658658
}
659659

660660
JERRY_ASSERT (node_size_sum == record_size_sum);
661-
#endif /* !JERRY_NDEBUG */
661+
#endif /* !JERRY_NO_HEAVY_DEBUG */
662662
} /* rcs_recordset_t::assert_state_is_correct */
663663

664664
/**

tests/unit/test-common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
using namespace std;
2828

29+
#if defined (JERRY_NDEBUG) || defined (JERRY_NO_HEAVY_DEBUG)
30+
# error "defined (JERRY_NDEBUG) || defined (JERRY_NO_HEAVY_DEBUG) in a unit test"
31+
#endif /* JERRY_NDEBUG || JERRY_NO_HEAVY_DEBUG */
32+
2933
#define TEST_RANDOMIZE() \
3034
do \
3135
{ \

0 commit comments

Comments
 (0)