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
This commit is contained in:
Andrey Shitov
2015-06-15 17:04:44 +03:00
parent d803c3bc82
commit a293e21147
9 changed files with 30 additions and 21 deletions
+2 -2
View File
@@ -37,10 +37,10 @@ project (JerryCore CXX C ASM)
# Build modes
# Debug
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER JERRY_DISABLE_HEAVY_DEBUG)
# Release
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG)
# Unit tests
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)
+3 -3
View File
@@ -84,15 +84,15 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
const char *function, /**< function name */
const uint32_t line) /** line */
{
#ifndef JERRY_NDEBUG
#if !defined (JERRY_NDEBUG) || !defined (JERRY_DISABLE_HEAVY_DEBUG)
printf ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
assertion, file, function, (unsigned long) line);
#else /* !JERRY_NDEBUG */
#else /* !JERRY_NDEBUG || !JERRY_DISABLE_HEAVY_DEBUG */
(void) assertion;
(void) file;
(void) function;
(void) line;
#endif /* JERRY_NDEBUG */
#endif /* JERRY_NDEBUG && JERRY_DISABLE_HEAVY_DEBUG */
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_assert_fail */
+3 -3
View File
@@ -86,12 +86,12 @@ extern void __noreturn jerry_unreachable (const char *comment, const char *file,
extern void __noreturn jerry_unimplemented (const char *comment, const char *file, const char *function,
const uint32_t line);
#ifndef JERRY_NDEBUG
#if !defined (JERRY_NDEBUG) || !defined (JERRY_DISABLE_HEAVY_DEBUG)
#define JERRY_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { \
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); } } while (0)
#else /* !JERRY_NDEBUG */
#else /* !JERRY_NDEBUG || !JERRY_DISABLE_HEAVY_DEBUG*/
#define JERRY_ASSERT(x) do { if (false) { (void)(x); } } while (0)
#endif /* !JERRY_NDEBUG */
#endif /* JERRY_NDEBUG && JERRY_DISABLE_HEAVY_NEBUG */
#ifdef JERRY_ENABLE_LOG
#define JERRY_LOG(lvl, ...) \
+2 -2
View File
@@ -1058,7 +1058,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
static void
mem_check_heap (void)
{
#ifndef JERRY_NDEBUG
#ifndef JERRY_DISABLE_HEAVY_DEBUG
JERRY_ASSERT ((uint8_t*) mem_heap.first_block_p == mem_heap.heap_start);
JERRY_ASSERT (mem_heap.heap_size % MEM_HEAP_CHUNK_SIZE == 0);
@@ -1131,7 +1131,7 @@ mem_check_heap (void)
JERRY_ASSERT (chunk_sizes_sum * MEM_HEAP_CHUNK_SIZE == mem_heap.heap_size);
JERRY_ASSERT (is_first_block_was_met);
#endif /* !JERRY_NDEBUG */
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
} /* mem_check_heap */
#ifdef MEM_STATS
+5 -3
View File
@@ -181,9 +181,9 @@ mem_pool_free_chunk (mem_pool_state_t *pool_p, /**< pool */
* Check pool state consistency
*/
static void
mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #ifdef JERRY_NDEBUG) */
mem_check_pool (mem_pool_state_t __attr_unused___ *pool_p) /**< pool (unused #ifdef JERRY_DISABLE_HEAVY_DEBUG) */
{
#ifndef JERRY_NDEBUG
#ifndef JERRY_DISABLE_HEAVY_DEBUG
JERRY_ASSERT (pool_p->free_chunks_number <= MEM_POOL_CHUNKS_NUMBER);
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
}
JERRY_ASSERT (met_free_chunks_number == pool_p->free_chunks_number);
#endif /* !JERRY_NDEBUG */
#else /* !JERRY_DISABLE_HEAVY_DEBUG */
(void) pool_p;
#endif /* JERRY_DISABLE_HEAVY_DEBUG */
} /* mem_check_pool */
/**
+5 -5
View File
@@ -289,7 +289,7 @@ void
rcs_chunked_list_t::assert_list_is_correct (void)
const
{
#ifndef JERRY_NDEBUG
#ifndef JERRY_DISABLE_HEAVY_DEBUG
for (node_t *node_iter_p = get_first ();
node_iter_p != NULL;
node_iter_p = get_next (node_iter_p))
@@ -308,7 +308,7 @@ const
&& next_node_p != NULL
&& get_prev (next_node_p) == node_iter_p));
}
#endif /* !JERRY_NDEBUG */
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
} /* rcs_chunked_list_t::assert_list_is_correct */
/**
@@ -318,7 +318,7 @@ void
rcs_chunked_list_t::assert_node_is_correct (const rcs_chunked_list_t::node_t* node_p) /**< the node */
const
{
#ifndef JERRY_NDEBUG
#ifndef JERRY_DISABLE_HEAVY_DEBUG
JERRY_ASSERT (node_p != NULL);
assert_list_is_correct ();
@@ -337,7 +337,7 @@ const
}
JERRY_ASSERT (is_in_list);
#else /* JERRY_NDEBUG */
#else /* !JERRY_DISABLE_HEAVY_DEBUG */
(void) node_p;
#endif /* JERRY_NDEBUG */
#endif /* JERRY_DISABLE_HEAVY_DEBUG */
} /* rcs_chunked_list_t::assert_node_is_correct */
+2 -2
View File
@@ -613,7 +613,7 @@ rcs_recordset_t::get_record_size (rcs_record_t* rec_p) /**< record */
void
rcs_recordset_t::assert_state_is_correct (void)
{
#ifndef JERRY_NDEBUG
#ifndef JERRY_DISABLE_HEAVY_DEBUG
size_t node_size_sum = 0;
size_t record_size_sum = 0;
@@ -658,7 +658,7 @@ rcs_recordset_t::assert_state_is_correct (void)
}
JERRY_ASSERT (node_size_sum == record_size_sum);
#endif /* !JERRY_NDEBUG */
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
} /* rcs_recordset_t::assert_state_is_correct */
/**
+1 -1
View File
@@ -23,7 +23,7 @@ project (Jerry_Plugins CXX ASM)
set(DEFINES_PLUGINS_DEBUG )
# Release
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG)
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG)
# Platform-specific
# Linux
+7
View File
@@ -26,6 +26,13 @@
using namespace std;
/**
* Verify that unit tests are built with all debug checks enabled
*/
#if defined (JERRY_NDEBUG) || defined (JERRY_DISABLE_HEAVY_DEBUG)
# error "defined (JERRY_NDEBUG) || defined (JERRY_DISABLE_HEAVY_DEBUG) in a unit test"
#endif /* JERRY_NDEBUG || JERRY_DISABLE_HEAVY_DEBUG */
#define TEST_RANDOMIZE() \
do \
{ \