Revise the usage of the global error value/exception flag (#3426)
This patch also fixes #3422. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Zoltan Herczeg
parent
7c0b1ca88a
commit
9b33fc8cbd
@@ -238,8 +238,7 @@ ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */
|
||||
error_obj_p = ecma_new_standard_error (error_type);
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
|
||||
jcontext_raise_exception (ecma_make_object_value (error_obj_p));
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_raise_standard_error */
|
||||
|
||||
@@ -333,8 +332,7 @@ ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, /**< er
|
||||
ecma_object_t *error_obj_p = ecma_new_standard_error_with_message (error_type, error_msg_p);
|
||||
ecma_deref_ecma_string (error_msg_p);
|
||||
|
||||
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
|
||||
jcontext_raise_exception (ecma_make_object_value (error_obj_p));
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_raise_standard_error_with_format */
|
||||
|
||||
|
||||
@@ -880,7 +880,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
|
||||
if (JERRY_UNLIKELY (ecma_is_value_error_reference (ret_value)))
|
||||
{
|
||||
JERRY_CONTEXT (error_value) = ecma_clear_error_reference (ret_value, true);
|
||||
ecma_raise_error_from_error_reference (ret_value);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -416,10 +416,9 @@ ecma_op_iterator_close (ecma_value_t iterator) /**< iterator value */
|
||||
/* 2. */
|
||||
ecma_value_t completion = ECMA_VALUE_EMPTY;
|
||||
|
||||
if (JERRY_CONTEXT (status_flags) & ECMA_STATUS_EXCEPTION)
|
||||
if (jcontext_has_pending_exception ())
|
||||
{
|
||||
completion = JERRY_CONTEXT (error_value);
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
|
||||
completion = jcontext_take_exception ();
|
||||
}
|
||||
|
||||
/* 3. */
|
||||
@@ -440,7 +439,7 @@ ecma_op_iterator_close (ecma_value_t iterator) /**< iterator value */
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
|
||||
jcontext_raise_exception (completion);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
@@ -454,12 +453,14 @@ ecma_op_iterator_close (ecma_value_t iterator) /**< iterator value */
|
||||
{
|
||||
if (ECMA_IS_VALUE_ERROR (inner_result))
|
||||
{
|
||||
ecma_free_value (JERRY_CONTEXT (error_value));
|
||||
JERRY_CONTEXT (error_value) = completion;
|
||||
jcontext_release_exception ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_free_value (inner_result);
|
||||
}
|
||||
|
||||
ecma_free_value (inner_result);
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
|
||||
jcontext_raise_exception (completion);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
@@ -486,7 +487,7 @@ ecma_op_iterator_close (ecma_value_t iterator) /**< iterator value */
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
|
||||
jcontext_raise_exception (completion);
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_op_iterator_close */
|
||||
|
||||
|
||||
@@ -179,8 +179,7 @@ ecma_process_promise_reaction_job (void *obj_p) /**< the job to be operated */
|
||||
{
|
||||
if (ECMA_IS_VALUE_ERROR (handler_result))
|
||||
{
|
||||
handler_result = JERRY_CONTEXT (error_value);
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
|
||||
handler_result = jcontext_take_exception ();
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
@@ -254,8 +253,7 @@ ecma_process_promise_resolve_thenable_job (void *obj_p) /**< the job to be opera
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (then_call_result))
|
||||
{
|
||||
then_call_result = JERRY_CONTEXT (error_value);
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
|
||||
then_call_result = jcontext_take_exception ();
|
||||
|
||||
ret = ecma_op_function_call (ecma_get_object_from_value (funcs->reject),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
|
||||
@@ -1232,7 +1232,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (error))
|
||||
{
|
||||
ecma_free_value (JERRY_CONTEXT (error_value));
|
||||
jcontext_release_exception ();
|
||||
return ecma_reject (is_throw);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,8 +330,7 @@ ecma_promise_resolve_handler (const ecma_value_t function, /**< the function its
|
||||
if (ECMA_IS_VALUE_ERROR (then))
|
||||
{
|
||||
/* 9. */
|
||||
then = JERRY_CONTEXT (error_value);
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
|
||||
then = jcontext_take_exception ();
|
||||
ecma_reject_promise (promise, then);
|
||||
}
|
||||
else if (!ecma_op_is_callable (then))
|
||||
@@ -551,8 +550,7 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function
|
||||
if (ECMA_IS_VALUE_ERROR (completion))
|
||||
{
|
||||
/* 10.a. */
|
||||
completion = JERRY_CONTEXT (error_value);
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
|
||||
completion = jcontext_take_exception ();
|
||||
status = ecma_op_function_call (ecma_get_object_from_value (funcs->reject),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&completion,
|
||||
|
||||
@@ -1130,7 +1130,7 @@ ecma_op_typedarray_define_index_prop (ecma_object_t *obj_p, /**< a TypedArray ob
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (error))
|
||||
{
|
||||
ecma_free_value (JERRY_CONTEXT (error_value));
|
||||
jcontext_release_exception ();
|
||||
return false;
|
||||
}
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (obj_p);
|
||||
|
||||
Reference in New Issue
Block a user