Skip to content

Remove of exit completion value type #246

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 2 commits into from
Jun 29, 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
2 changes: 0 additions & 2 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 2 additions & 47 deletions jerry-core/ecma/base/ecma-helpers-value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

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

Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 0 additions & 2 deletions jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions jerry-core/ecma/operations/ecma-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions jerry-core/ecma/operations/ecma-try-catch-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
} \
Expand Down
5 changes: 2 additions & 3 deletions jerry-core/jerry-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
13 changes: 3 additions & 10 deletions jerry-core/jerry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,16 +1113,9 @@ jerry_api_eval (const char *source_p, /**< source code */
}
else
{
JERRY_ASSERT (ecma_is_completion_value_exit (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;
}
JERRY_ASSERT (ecma_is_completion_value_empty (completion));

status = JERRY_COMPLETION_CODE_OK;
}
}

Expand Down
19 changes: 0 additions & 19 deletions jerry-core/parser/js/opcodes-dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,19 +755,6 @@ dumper_finish_scope (void)
STACK_DROP (temp_names, 1);
}

bool
dumper_is_intrinsic (operand /* obj */)
{
return false;
}

operand
dump_intrinsic (operand /* obj */, operand /* arg */)
{
JERRY_UNREACHABLE ();
return dump_undefined_assignment_res ();
}

/**
* Check that byte-code operand refers to 'eval' string
*
Expand Down Expand Up @@ -2612,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)
{
Expand Down
4 changes: 0 additions & 4 deletions jerry-core/parser/js/opcodes-dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ void dumper_new_statement (void);
void dumper_new_scope (void);
void dumper_finish_scope (void);

bool dumper_is_intrinsic (operand);
operand dump_intrinsic (operand, operand);

extern bool dumper_is_eval_literal (operand);

void dump_boolean_assignment (operand, bool);
Expand Down Expand Up @@ -237,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 */
12 changes: 1 addition & 11 deletions jerry-core/parser/js/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
case VARG_CALL_EXPR:
{
current_token_must_be (TOK_OPEN_PAREN);
if (dumper_is_intrinsic (obj))
{
break;
}

opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY;

Expand Down Expand Up @@ -557,12 +553,6 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
case VARG_CALL_EXPR:
{
op = parse_assignment_expression (true);
if (dumper_is_intrinsic (obj))
{
operand res = dump_intrinsic (obj, op);
token_after_newlines_must_be (close_tt);
return res;
}
break;
}
case VARG_OBJ_DECL:
Expand Down Expand Up @@ -3112,7 +3102,7 @@ parser_parse_program (const char *source_p, /**< source code buffer */
}
else
{
dump_exit ();
dump_ret ();
}

#ifndef JERRY_NDEBUG
Expand Down
2 changes: 0 additions & 2 deletions jerry-core/parser/js/scopes-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand 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):
Expand Down
10 changes: 0 additions & 10 deletions jerry-core/vm/opcodes-ecma-try-catch-finally.cpp
Original file line number Diff line number Diff line change
Expand 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) (
Expand Down Expand Up @@ -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) (
Expand Down
4 changes: 3 additions & 1 deletion jerry-core/vm/opcodes-for-in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions jerry-core/vm/opcodes-varg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
{
JERRY_ASSERT (ecma_is_completion_value_throw (evaluate_arg_completion));

ret_value = evaluate_arg_completion;
}

if (!ecma_is_completion_value_empty (ret_value))
{
break;
}

Expand Down
Loading