mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Remove exit completion value type.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
parent
447358cd4a
commit
06dffdec8f
@ -120,8 +120,6 @@ typedef enum
|
||||
* }
|
||||
*/
|
||||
ECMA_COMPLETION_TYPE_THROW, /**< completion with throw */
|
||||
ECMA_COMPLETION_TYPE_EXIT, /**< implementation-defined completion type
|
||||
for finishing script execution */
|
||||
ECMA_COMPLETION_TYPE_META /**< implementation-defined completion type
|
||||
for meta opcode */
|
||||
} ecma_completion_type_t;
|
||||
|
||||
@ -534,7 +534,6 @@ ecma_make_completion_value (ecma_completion_type_t type, /**< type */
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT
|
||||
|| (type == ECMA_COMPLETION_TYPE_META
|
||||
&& ecma_is_value_empty (value)));
|
||||
|
||||
@ -628,21 +627,6 @@ ecma_make_return_completion_value (ecma_value_t value) /**< value */
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, value);
|
||||
} /* ecma_make_return_completion_value */
|
||||
|
||||
/**
|
||||
* Exit completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attr_const___ __attr_always_inline___
|
||||
ecma_make_exit_completion_value (bool is_successful) /**< does completion value indicate
|
||||
successfulness completion
|
||||
of script execution (true) or not (false) */
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_EXIT,
|
||||
ecma_make_simple_value (is_successful ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE));
|
||||
} /* ecma_make_exit_completion_value */
|
||||
|
||||
/**
|
||||
* Meta completion value constructor
|
||||
*
|
||||
@ -685,8 +669,7 @@ ecma_get_completion_value_value (ecma_completion_value_t completion_value) /**<
|
||||
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
@ -752,8 +735,7 @@ ecma_copy_completion_value (ecma_completion_value_t value) /**< completion value
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_JUMP
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|| type == ECMA_COMPLETION_TYPE_JUMP);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
@ -778,12 +760,6 @@ ecma_free_completion_value (ecma_completion_value_t completion_value) /**< compl
|
||||
ecma_free_value (v, true);
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_EXIT:
|
||||
{
|
||||
ecma_value_t v = ecma_get_completion_value_value_field (completion_value);
|
||||
JERRY_ASSERT (ecma_get_value_type_field (v) == ECMA_TYPE_SIMPLE);
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_JUMP:
|
||||
{
|
||||
break;
|
||||
@ -831,27 +807,6 @@ ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_RETURN);
|
||||
} /* ecma_is_completion_value_return */
|
||||
|
||||
/**
|
||||
* Check if the completion value is exit value.
|
||||
*
|
||||
* @return true - if the completion type is exit,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attr_const___ __attr_always_inline___
|
||||
ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_EXIT)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ecma_get_completion_value_value_field (value)));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_exit */
|
||||
|
||||
/**
|
||||
* Check if the completion value is meta value.
|
||||
*
|
||||
|
||||
@ -82,7 +82,6 @@ extern ecma_completion_value_t ecma_make_throw_completion_value (ecma_value_t va
|
||||
extern ecma_completion_value_t ecma_make_throw_obj_completion_value (ecma_object_t *exception_p);
|
||||
extern ecma_completion_value_t ecma_make_empty_completion_value (void);
|
||||
extern ecma_completion_value_t ecma_make_return_completion_value (ecma_value_t value);
|
||||
extern ecma_completion_value_t ecma_make_exit_completion_value (bool is_successful);
|
||||
extern ecma_completion_value_t ecma_make_meta_completion_value (void);
|
||||
extern ecma_completion_value_t ecma_make_jump_completion_value (opcode_counter_t target);
|
||||
extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value);
|
||||
@ -100,7 +99,6 @@ extern void ecma_free_completion_value (ecma_completion_value_t completion_value
|
||||
extern bool ecma_is_completion_value_normal (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_throw (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_return (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_exit (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_meta (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_jump (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value,
|
||||
|
||||
@ -696,8 +696,7 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
|
||||
|
||||
ecma_deref_ecma_string (n_str_p);
|
||||
|
||||
if (unlikely (ecma_is_completion_value_throw (completion)
|
||||
|| ecma_is_completion_value_exit (completion)))
|
||||
if (unlikely (ecma_is_completion_value_throw (completion)))
|
||||
{
|
||||
ret_value = completion;
|
||||
break;
|
||||
@ -722,8 +721,7 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
|
||||
num_length_value,
|
||||
true);
|
||||
|
||||
if (unlikely (ecma_is_completion_value_throw (completion)
|
||||
|| ecma_is_completion_value_exit (completion)))
|
||||
if (unlikely (ecma_is_completion_value_throw (completion)))
|
||||
{
|
||||
ret_value = completion;
|
||||
|
||||
|
||||
@ -146,8 +146,7 @@ ecma_op_eval_chars_buffer (const ecma_char_t *code_p, /**< code characters buffe
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (completion)
|
||||
|| ecma_is_completion_value_exit (completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (completion));
|
||||
}
|
||||
|
||||
ecma_deref_object (lex_env_p);
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
#define ECMA_TRY_CATCH(var, op, return_value) \
|
||||
JERRY_ASSERT (return_value == ecma_make_empty_completion_value ()); \
|
||||
ecma_completion_value_t var ## _completion = op; \
|
||||
if (unlikely (ecma_is_completion_value_throw (var ## _completion) \
|
||||
|| ecma_is_completion_value_exit (var ## _completion))) \
|
||||
if (unlikely (ecma_is_completion_value_throw (var ## _completion))) \
|
||||
{ \
|
||||
return_value = var ## _completion; \
|
||||
} \
|
||||
|
||||
@ -36,9 +36,8 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_COMPLETION_CODE_OK = 0, /**< successful completion */
|
||||
JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION = 1, /**< exception occured and it was not handled */
|
||||
JERRY_COMPLETION_CODE_FAILED_ASSERTION_IN_SCRIPT = 2 /**< assertion, performed by script, failed */
|
||||
JERRY_COMPLETION_CODE_OK = 0, /**< successful completion */
|
||||
JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION = 1, /**< exception occured and it was not handled */
|
||||
} jerry_completion_code_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -1113,16 +1113,9 @@ jerry_api_eval (const char *source_p, /**< source code */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_exit (completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
if (ecma_is_value_true (ecma_get_completion_value_value (completion)))
|
||||
{
|
||||
status = JERRY_COMPLETION_CODE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = JERRY_COMPLETION_CODE_FAILED_ASSERTION_IN_SCRIPT;
|
||||
}
|
||||
status = JERRY_COMPLETION_CODE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2599,12 +2599,6 @@ dump_retval (operand op)
|
||||
dump_single_address (getop_retval, op);
|
||||
}
|
||||
|
||||
void
|
||||
dump_exit (void)
|
||||
{
|
||||
serializer_dump_op_meta (create_op_meta_000 (getop_exitval (0)));
|
||||
}
|
||||
|
||||
void
|
||||
dumper_init (void)
|
||||
{
|
||||
|
||||
@ -234,6 +234,5 @@ void rewrite_reg_var_decl (void);
|
||||
|
||||
void dump_ret (void);
|
||||
void dump_retval (operand op);
|
||||
void dump_exit (void);
|
||||
|
||||
#endif /* OPCODES_DUMPER_H */
|
||||
|
||||
@ -3102,7 +3102,7 @@ parser_parse_program (const char *source_p, /**< source code buffer */
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_exit ();
|
||||
dump_ret ();
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
|
||||
@ -318,7 +318,6 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table
|
||||
change_uid (om, lit_ids, 0x100);
|
||||
break;
|
||||
}
|
||||
case OPCODE (exitval):
|
||||
case OPCODE (ret):
|
||||
case OPCODE (try_block):
|
||||
case OPCODE (jmp_up):
|
||||
@ -458,7 +457,6 @@ count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index)
|
||||
insert_uids_to_lit_id_map (om, 0x100);
|
||||
break;
|
||||
}
|
||||
case OPCODE (exitval):
|
||||
case OPCODE (ret):
|
||||
case OPCODE (try_block):
|
||||
case OPCODE (jmp_up):
|
||||
|
||||
@ -46,11 +46,6 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->opcodes_p, int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
{
|
||||
return try_completion;
|
||||
}
|
||||
|
||||
if (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH)
|
||||
{
|
||||
const opcode_counter_t catch_end_oc = (opcode_counter_t) (
|
||||
@ -106,11 +101,6 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
next_opcode = vm_get_opcode (int_data->opcodes_p, int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
{
|
||||
return try_completion;
|
||||
}
|
||||
|
||||
if (next_opcode.data.meta.type == OPCODE_META_TYPE_FINALLY)
|
||||
{
|
||||
const opcode_counter_t finally_end_oc = (opcode_counter_t) (
|
||||
|
||||
@ -253,7 +253,9 @@ opfunc_for_in (opcode_t opdata, /**< operation data */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (!ecma_is_completion_value_normal (for_in_body_completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (for_in_body_completion)
|
||||
|| ecma_is_completion_value_return (for_in_body_completion)
|
||||
|| ecma_is_completion_value_jump (for_in_body_completion));
|
||||
JERRY_ASSERT (int_data_p->pos <= for_in_body_end_oc);
|
||||
|
||||
ret_value = for_in_body_completion;
|
||||
|
||||
@ -42,7 +42,7 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
||||
{
|
||||
ecma_completion_value_t evaluate_arg_completion = vm_loop (int_data, NULL);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluate_arg_completion))
|
||||
if (ecma_is_completion_value_empty (evaluate_arg_completion))
|
||||
{
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->opcodes_p, int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
@ -58,16 +58,17 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (get_arg_completion));
|
||||
|
||||
ret_value = get_arg_completion;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_value = evaluate_arg_completion;
|
||||
}
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (evaluate_arg_completion));
|
||||
|
||||
ret_value = evaluate_arg_completion;
|
||||
|
||||
if (!ecma_is_completion_value_empty (ret_value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -991,10 +991,8 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
|
||||
{
|
||||
ecma_completion_value_t evaluate_prop_completion = vm_loop (int_data, NULL);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluate_prop_completion))
|
||||
if (ecma_is_completion_value_empty (evaluate_prop_completion))
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (evaluate_prop_completion));
|
||||
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->opcodes_p, int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
@ -1109,7 +1107,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (!ecma_is_completion_value_normal (evaluate_prop_completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (evaluate_prop_completion));
|
||||
|
||||
completion = evaluate_prop_completion;
|
||||
|
||||
@ -1123,6 +1121,8 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (completion));
|
||||
|
||||
ret_value = completion;
|
||||
}
|
||||
|
||||
@ -1276,29 +1276,6 @@ opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */
|
||||
return ret_value;
|
||||
} /* opfunc_prop_setter */
|
||||
|
||||
/**
|
||||
* Exit from script with specified status code:
|
||||
* 0 - for successful completion
|
||||
* 1 - to indicate failure.
|
||||
*
|
||||
* Note: this is not ECMA specification-defined, but internal
|
||||
* implementation-defined opcode for end of script
|
||||
* and assertions inside of unit tests.
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
opfunc_exitval (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data __attr_unused___) /**< interpreter context */
|
||||
{
|
||||
JERRY_ASSERT (opdata.data.exitval.status_code == 0
|
||||
|| opdata.data.exitval.status_code == 1);
|
||||
|
||||
return ecma_make_exit_completion_value (opdata.data.exitval.status_code == 0);
|
||||
} /* opfunc_exitval */
|
||||
|
||||
/**
|
||||
* 'Logical NOT Operator' opcode handler.
|
||||
*
|
||||
@ -1419,7 +1396,9 @@ opfunc_with (opcode_t opdata, /**< operation data */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (!ecma_is_completion_value_normal (with_completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (with_completion)
|
||||
|| ecma_is_completion_value_return (with_completion)
|
||||
|| ecma_is_completion_value_jump (with_completion));
|
||||
JERRY_ASSERT (int_data->pos <= with_end_oc);
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +176,6 @@ opcode_counter_t read_meta_opcode_counter (opcode_meta_type expected_type, int_d
|
||||
p##_3 (a, construct_n, lhs, name_lit_idx, arg_list) \
|
||||
p##_2 (a, func_decl_n, name_lit_idx, arg_list) \
|
||||
p##_3 (a, func_expr_n, lhs, name_lit_idx, arg_list) \
|
||||
p##_1 (a, exitval, status_code) \
|
||||
p##_1 (a, retval, ret_value) \
|
||||
p##_0 (a, ret)
|
||||
|
||||
|
||||
@ -222,7 +222,6 @@ pp_op_meta (const opcode_t *opcodes_p,
|
||||
PP_OP (reg_var_decl, "var %s .. %s;");
|
||||
PP_OP (var_decl, "var %s;");
|
||||
PP_OP (nop, ";");
|
||||
PP_OP (exitval, "exit %d;");
|
||||
PP_OP (retval, "return %s;");
|
||||
PP_OP (ret, "ret;");
|
||||
PP_OP (prop_getter, "%s = %s[%s];");
|
||||
|
||||
@ -396,16 +396,11 @@ vm_run_global (void)
|
||||
|
||||
jerry_completion_code_t ret_code;
|
||||
|
||||
if (ecma_is_completion_value_exit (completion))
|
||||
if (ecma_is_completion_value_return (completion))
|
||||
{
|
||||
if (ecma_is_value_true (ecma_get_completion_value_value (completion)))
|
||||
{
|
||||
ret_code = JERRY_COMPLETION_CODE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_code = JERRY_COMPLETION_CODE_FAILED_ASSERTION_IN_SCRIPT;
|
||||
}
|
||||
JERRY_ASSERT (ecma_is_value_undefined (ecma_get_completion_value_value (completion)));
|
||||
|
||||
ret_code = JERRY_COMPLETION_CODE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -560,10 +555,8 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */
|
||||
|
||||
completion = vm_loop (&int_data, NULL);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (completion)
|
||||
|| ecma_is_completion_value_throw (completion)
|
||||
|| ecma_is_completion_value_return (completion)
|
||||
|| ecma_is_completion_value_exit (completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_throw (completion)
|
||||
|| ecma_is_completion_value_return (completion));
|
||||
|
||||
vm_top_context_p = prev_context_p;
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ main (int __attr_unused___ argc,
|
||||
getop_var_decl (0), // var a;
|
||||
getop_assignment (130, 1, 1), // $tmp0 = 1;
|
||||
getop_assignment (0, 6, 130), // a = $tmp0;
|
||||
getop_exitval (0) // exit 0;
|
||||
getop_ret () // return;
|
||||
};
|
||||
|
||||
JERRY_ASSERT (opcodes_equal (opcodes_p, opcodes, 5));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user