Cleanup code around JERRY_UNREACHABLEs (#2342)
`JERRY_UNREACHABLE`s often signal code structure that could be improved: they can usually either be rewritten to `JERRY_ASSERT`s or eliminated by restructuring loops, `if`s or `#if`s. Roughly, the only valid occurences are in default cases of `switch`es. And even they can often be merged into non-default cases. Moreover, it is dangerous to write meaningful code after `JERRY_UNREACHABLE` because it pretends as if there was a way to recover from an impossible situation. This patch rewrites/eliminates `JERRY_UNREACHABLE`s where possible and removes misleading code from after them. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -232,8 +232,11 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
|
||||
|
||||
for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
while (true)
|
||||
{
|
||||
/* The property must be present. */
|
||||
JERRY_ASSERT (entry_p - JERRY_HASH_TABLE_CONTEXT (table) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
|
||||
if (entry_p->object_cp != ECMA_NULL_POINTER && entry_p->prop_p == prop_p)
|
||||
{
|
||||
JERRY_ASSERT (entry_p->object_cp == object_cp);
|
||||
@@ -243,9 +246,6 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
|
||||
/* The property must be present. */
|
||||
JERRY_UNREACHABLE ();
|
||||
#else /* CONFIG_ECMA_LCACHE_DISABLE */
|
||||
JERRY_UNUSED (name_cp);
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
|
||||
Reference in New Issue
Block a user