Skip to content

Introduce JERRY_DISABLE_HEAVY_DEBUG preprocessor definition. #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jerry-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/jrt/jrt-fatals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/jrt/jrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) \
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/mem/mem-heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions jerry-core/mem/mem-pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */

/**
Expand Down
10 changes: 5 additions & 5 deletions jerry-core/rcs/rcs-chunked-list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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 */

/**
Expand All @@ -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 ();
Expand All @@ -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 */
4 changes: 2 additions & 2 deletions jerry-core/rcs/rcs-recordset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */

/**
Expand Down
2 changes: 1 addition & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
{ \
Expand Down