Skip to content

Commit 608be9e

Browse files
committed
Introduce JERRY_DISABLE_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 608be9e

File tree

9 files changed

+30
-21
lines changed

9 files changed

+30
-21
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_DISABLE_HEAVY_DEBUG)
4141

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

4545
# Unit tests
4646
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)

jerry-core/jrt/jrt-fatals.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
8484
const char *function, /**< function name */
8585
const uint32_t line) /** line */
8686
{
87-
#ifndef JERRY_NDEBUG
87+
#if !defined (JERRY_NDEBUG) || !defined (JERRY_DISABLE_HEAVY_DEBUG)
8888
printf ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
8989
assertion, file, function, (unsigned long) line);
90-
#else /* !JERRY_NDEBUG */
90+
#else /* !JERRY_NDEBUG || !JERRY_DISABLE_HEAVY_DEBUG */
9191
(void) assertion;
9292
(void) file;
9393
(void) function;
9494
(void) line;
95-
#endif /* JERRY_NDEBUG */
95+
#endif /* JERRY_NDEBUG && JERRY_DISABLE_HEAVY_DEBUG */
9696

9797
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
9898
} /* jerry_assert_fail */

jerry-core/jrt/jrt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ extern void __noreturn jerry_unreachable (const char *comment, const char *file,
8686
extern void __noreturn jerry_unimplemented (const char *comment, const char *file, const char *function,
8787
const uint32_t line);
8888

89-
#ifndef JERRY_NDEBUG
89+
#if !defined (JERRY_NDEBUG) || !defined (JERRY_DISABLE_HEAVY_DEBUG)
9090
#define JERRY_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { \
9191
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); } } while (0)
92-
#else /* !JERRY_NDEBUG */
92+
#else /* !JERRY_NDEBUG || !JERRY_DISABLE_HEAVY_DEBUG*/
9393
#define JERRY_ASSERT(x) do { if (false) { (void)(x); } } while (0)
94-
#endif /* !JERRY_NDEBUG */
94+
#endif /* JERRY_NDEBUG && JERRY_DISABLE_HEAVY_NEBUG */
9595

9696
#ifdef JERRY_ENABLE_LOG
9797
#define JERRY_LOG(lvl, ...) \

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_DISABLE_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_DISABLE_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_DISABLE_HEAVY_DEBUG) */
185185
{
186-
#ifndef JERRY_NDEBUG
186+
#ifndef JERRY_DISABLE_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_DISABLE_HEAVY_DEBUG */
208+
(void) pool_p;
209+
#endif /* JERRY_DISABLE_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_DISABLE_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_DISABLE_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_DISABLE_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_DISABLE_HEAVY_DEBUG */
341341
(void) node_p;
342-
#endif /* JERRY_NDEBUG */
342+
#endif /* JERRY_DISABLE_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_DISABLE_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_DISABLE_HEAVY_DEBUG */
662662
} /* rcs_recordset_t::assert_state_is_correct */
663663

664664
/**

plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ project (Jerry_Plugins CXX ASM)
2323
set(DEFINES_PLUGINS_DEBUG )
2424

2525
# Release
26-
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG)
26+
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG)
2727

2828
# Platform-specific
2929
# Linux

tests/unit/test-common.h

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

2727
using namespace std;
2828

29+
/**
30+
* Verify that unit tests are built with all debug checks enabled
31+
*/
32+
#if defined (JERRY_NDEBUG) || defined (JERRY_DISABLE_HEAVY_DEBUG)
33+
# error "defined (JERRY_NDEBUG) || defined (JERRY_DISABLE_HEAVY_DEBUG) in a unit test"
34+
#endif /* JERRY_NDEBUG || JERRY_DISABLE_HEAVY_DEBUG */
35+
2936
#define TEST_RANDOMIZE() \
3037
do \
3138
{ \

0 commit comments

Comments
 (0)