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:
@@ -65,8 +65,10 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
vm_stack_top_p -= PARSER_TRY_CONTEXT_STACK_ALLOCATION;
|
||||
break;
|
||||
}
|
||||
case VM_CONTEXT_FOR_IN:
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (VM_GET_CONTEXT_TYPE (vm_stack_top_p[-1]) == VM_CONTEXT_FOR_IN);
|
||||
|
||||
ecma_collection_chunk_t *chunk_p;
|
||||
chunk_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_collection_chunk_t, vm_stack_top_p[-2]);
|
||||
uint32_t index = vm_stack_top_p[-3];
|
||||
@@ -96,11 +98,6 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
vm_stack_top_p -= PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return vm_stack_top_p;
|
||||
|
||||
Reference in New Issue
Block a user