From 2324617928d984fd876e0911d493d83cfa856951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Borb=C3=A9ly?= Date: Fri, 17 Jun 2016 13:24:41 +0200 Subject: [PATCH] Guard assert-related functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com --- jerry-core/ecma/base/ecma-helpers-string.c | 4 ++++ jerry-core/lit/lit-literal.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c index 2de43e9a7..7ca0c2818 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.c +++ b/jerry-core/ecma/base/ecma-helpers-string.c @@ -1314,6 +1314,7 @@ ecma_get_magic_string_ex (lit_magic_string_ex_id_t id) /**< external magic strin return ecma_new_ecma_string_from_magic_string_ex_id (id); } /* ecma_get_magic_string_ex */ +#ifndef JERRY_NDEBUG /** * Long path part of ecma_is_string_magic * @@ -1338,6 +1339,7 @@ ecma_is_string_magic_longpath (const ecma_string_t *string_p, /**< ecma-string * return lit_is_utf8_string_magic (utf8_str_p, utf8_str_size, out_id_p); } /* ecma_is_string_magic_longpath */ +#endif /* !JERRY_NDEBUG */ /** * Check if passed string equals to one of magic strings @@ -1365,8 +1367,10 @@ ecma_is_string_magic (const ecma_string_t *string_p, /**< ecma-string */ * should return ecma-string with ECMA_STRING_CONTAINER_MAGIC_STRING * container type if new ecma-string's content is equal to one of magic strings. */ +#ifndef JERRY_NDEBUG JERRY_ASSERT (ecma_string_get_length (string_p) > LIT_MAGIC_STRING_LENGTH_LIMIT || !ecma_is_string_magic_longpath (string_p, out_id_p)); +#endif /* !JERRY_NDEBUG */ return false; } diff --git a/jerry-core/lit/lit-literal.c b/jerry-core/lit/lit-literal.c index ec63485ef..be2b0d3fc 100644 --- a/jerry-core/lit/lit-literal.c +++ b/jerry-core/lit/lit-literal.c @@ -266,6 +266,7 @@ lit_find_literal_by_num (const ecma_number_t num) /**< a number to search for */ return NULL; } /* lit_find_literal_by_num */ +#ifndef JERRY_NDEBUG /** * Check if literal really exists in the storage * @@ -289,6 +290,7 @@ lit_literal_exists (lit_literal_t lit) /**< literal to check for existence */ return false; } /* lit_literal_exists */ +#endif /* !JERRY_NDEBUG */ /** * Convert compressed pointer to literal @@ -299,7 +301,9 @@ lit_literal_t lit_get_literal_by_cp (lit_cpointer_t lit_cp) /**< compressed pointer to literal */ { lit_literal_t lit = lit_cpointer_decompress (lit_cp); +#ifndef JERRY_NDEBUG JERRY_ASSERT (lit_literal_exists (lit)); +#endif /* !JERRY_NDEBUG */ return lit; } /* lit_get_literal_by_cp */