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:
@@ -37,10 +37,10 @@ project (JerryCore CXX C ASM)
|
|||||||
|
|
||||||
# Build modes
|
# Build modes
|
||||||
# Debug
|
# Debug
|
||||||
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER)
|
set(DEFINES_JERRY_DEBUG JERRY_ENABLE_PRETTY_PRINTER JERRY_DISABLE_HEAVY_DEBUG)
|
||||||
|
|
||||||
# Release
|
# Release
|
||||||
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
|
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG)
|
||||||
|
|
||||||
# Unit tests
|
# Unit tests
|
||||||
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)
|
set(DEFINES_JERRY_UNITTESTS JERRY_ENABLE_PRETTY_PRINTER)
|
||||||
|
|||||||
@@ -84,15 +84,15 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
|||||||
const char *function, /**< function name */
|
const char *function, /**< function name */
|
||||||
const uint32_t line) /** line */
|
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",
|
printf ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
|
||||||
assertion, file, function, (unsigned long) line);
|
assertion, file, function, (unsigned long) line);
|
||||||
#else /* !JERRY_NDEBUG */
|
#else /* !JERRY_NDEBUG || !JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
(void) assertion;
|
(void) assertion;
|
||||||
(void) file;
|
(void) file;
|
||||||
(void) function;
|
(void) function;
|
||||||
(void) line;
|
(void) line;
|
||||||
#endif /* JERRY_NDEBUG */
|
#endif /* JERRY_NDEBUG && JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
|
|
||||||
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
|
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
|
||||||
} /* jerry_assert_fail */
|
} /* jerry_assert_fail */
|
||||||
|
|||||||
@@ -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,
|
extern void __noreturn jerry_unimplemented (const char *comment, const char *file, const char *function,
|
||||||
const uint32_t line);
|
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)) { \
|
#define JERRY_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { \
|
||||||
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); } } while (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)
|
#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
|
#ifdef JERRY_ENABLE_LOG
|
||||||
#define JERRY_LOG(lvl, ...) \
|
#define JERRY_LOG(lvl, ...) \
|
||||||
|
|||||||
@@ -1058,7 +1058,7 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
|
|||||||
static void
|
static void
|
||||||
mem_check_heap (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 ((uint8_t*) mem_heap.first_block_p == mem_heap.heap_start);
|
||||||
JERRY_ASSERT (mem_heap.heap_size % MEM_HEAP_CHUNK_SIZE == 0);
|
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 (chunk_sizes_sum * MEM_HEAP_CHUNK_SIZE == mem_heap.heap_size);
|
||||||
JERRY_ASSERT (is_first_block_was_met);
|
JERRY_ASSERT (is_first_block_was_met);
|
||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
} /* mem_check_heap */
|
} /* mem_check_heap */
|
||||||
|
|
||||||
#ifdef MEM_STATS
|
#ifdef MEM_STATS
|
||||||
|
|||||||
@@ -181,9 +181,9 @@ mem_pool_free_chunk (mem_pool_state_t *pool_p, /**< pool */
|
|||||||
* Check pool state consistency
|
* Check pool state consistency
|
||||||
*/
|
*/
|
||||||
static void
|
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);
|
JERRY_ASSERT (pool_p->free_chunks_number <= MEM_POOL_CHUNKS_NUMBER);
|
||||||
|
|
||||||
size_t met_free_chunks_number = 0;
|
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);
|
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 */
|
} /* mem_check_pool */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ void
|
|||||||
rcs_chunked_list_t::assert_list_is_correct (void)
|
rcs_chunked_list_t::assert_list_is_correct (void)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
#ifndef JERRY_NDEBUG
|
#ifndef JERRY_DISABLE_HEAVY_DEBUG
|
||||||
for (node_t *node_iter_p = get_first ();
|
for (node_t *node_iter_p = get_first ();
|
||||||
node_iter_p != NULL;
|
node_iter_p != NULL;
|
||||||
node_iter_p = get_next (node_iter_p))
|
node_iter_p = get_next (node_iter_p))
|
||||||
@@ -308,7 +308,7 @@ const
|
|||||||
&& next_node_p != NULL
|
&& next_node_p != NULL
|
||||||
&& get_prev (next_node_p) == node_iter_p));
|
&& get_prev (next_node_p) == node_iter_p));
|
||||||
}
|
}
|
||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
} /* rcs_chunked_list_t::assert_list_is_correct */
|
} /* 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 */
|
rcs_chunked_list_t::assert_node_is_correct (const rcs_chunked_list_t::node_t* node_p) /**< the node */
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
#ifndef JERRY_NDEBUG
|
#ifndef JERRY_DISABLE_HEAVY_DEBUG
|
||||||
JERRY_ASSERT (node_p != NULL);
|
JERRY_ASSERT (node_p != NULL);
|
||||||
|
|
||||||
assert_list_is_correct ();
|
assert_list_is_correct ();
|
||||||
@@ -337,7 +337,7 @@ const
|
|||||||
}
|
}
|
||||||
|
|
||||||
JERRY_ASSERT (is_in_list);
|
JERRY_ASSERT (is_in_list);
|
||||||
#else /* JERRY_NDEBUG */
|
#else /* !JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
(void) node_p;
|
(void) node_p;
|
||||||
#endif /* JERRY_NDEBUG */
|
#endif /* JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
} /* rcs_chunked_list_t::assert_node_is_correct */
|
} /* rcs_chunked_list_t::assert_node_is_correct */
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ rcs_recordset_t::get_record_size (rcs_record_t* rec_p) /**< record */
|
|||||||
void
|
void
|
||||||
rcs_recordset_t::assert_state_is_correct (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 node_size_sum = 0;
|
||||||
size_t record_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);
|
JERRY_ASSERT (node_size_sum == record_size_sum);
|
||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_DISABLE_HEAVY_DEBUG */
|
||||||
} /* rcs_recordset_t::assert_state_is_correct */
|
} /* rcs_recordset_t::assert_state_is_correct */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ project (Jerry_Plugins CXX ASM)
|
|||||||
set(DEFINES_PLUGINS_DEBUG )
|
set(DEFINES_PLUGINS_DEBUG )
|
||||||
|
|
||||||
# Release
|
# Release
|
||||||
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG)
|
set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG)
|
||||||
|
|
||||||
# Platform-specific
|
# Platform-specific
|
||||||
# Linux
|
# Linux
|
||||||
|
|||||||
@@ -26,6 +26,13 @@
|
|||||||
|
|
||||||
using namespace std;
|
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() \
|
#define TEST_RANDOMIZE() \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
Reference in New Issue
Block a user