Rework error to use a global slot to store the error value.

This change frees up the error bit in ecma_value_t, which allows
to define 4 more value types (e.g. symbols). To keep API
compatibility we introduce a box for values with error flag.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-10-18 03:44:48 -07:00
committed by yichoi
parent 742654a3f1
commit 53cd324179
19 changed files with 582 additions and 288 deletions
+6 -2
View File
@@ -21,6 +21,7 @@
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "jcontext.h"
#include "jrt.h"
/** \addtogroup ecma ECMA
@@ -155,7 +156,8 @@ ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */
error_obj_p = ecma_new_standard_error (error_type);
}
return ecma_make_error_obj_value (error_obj_p);
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_ERROR);
} /* ecma_raise_standard_error */
#ifdef JERRY_ENABLE_ERROR_MESSAGES
@@ -242,7 +244,9 @@ 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);
return ecma_make_error_obj_value (error_obj_p);
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_ERROR);
} /* ecma_raise_standard_error_with_format */
#endif /* JERRY_ENABLE_ERROR_MESSAGES */
@@ -468,6 +468,12 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
this_arg_value,
arguments_list_p,
arguments_list_len);
if (unlikely (ecma_is_value_error_reference (ret_value)))
{
JERRY_CONTEXT (error_value) = ecma_clear_error_reference (ret_value);
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_ERROR);
}
}
else
{
+1 -1
View File
@@ -179,7 +179,7 @@ ecma_process_promise_reaction_job (void *obj_p) /**< the job to be operated */
{
if (ECMA_IS_VALUE_ERROR (handler_result))
{
handler_result = ecma_get_value_from_error_value (handler_result);
handler_result = JERRY_CONTEXT (error_value);
}
/* 7. */
@@ -24,6 +24,7 @@
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-promise-object.h"
#include "jcontext.h"
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
@@ -547,7 +548,7 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function
if (ECMA_IS_VALUE_ERROR (completion))
{
/* 10.a. */
completion = ecma_get_value_from_error_value (completion);
completion = JERRY_CONTEXT (error_value);
status = ecma_op_function_call (ecma_get_object_from_value (funcs->reject),
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
&completion,