Add support for aborts. (#2176)

Aborts are similar to exceptions except they are not caught by catch
and finally blocks. Callbacks should honor aborts as well and return
them without processing them. Aborts are never thrown by JavaScript
code.

In the future certain events such as out-of-memory condition may
also throw aborts.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-01-30 01:13:44 +01:00
committed by yichoi
parent b548eae4ad
commit 918eb22a01
17 changed files with 477 additions and 144 deletions
+29 -1
View File
@@ -64,6 +64,19 @@ typedef enum
ECMA_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */
} ecma_init_flag_t;
/**
* JerryScript status flags.
*/
typedef enum
{
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
ECMA_STATUS_HIGH_SEV_GC = (1u << 2), /**< last gc run was a high severity run */
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
} ecma_status_flag_t;
/**
* Type of ecma value
*/
@@ -1161,12 +1174,27 @@ typedef struct
lit_utf8_size_t long_utf8_string_length; /**< length of this long utf-8 string in bytes */
} ecma_long_string_t;
/**
* Abort flag for error reference.
*/
#define ECMA_ERROR_REF_ABORT 0x1
/**
* Value for increasing or decreasing the reference counter.
*/
#define ECMA_ERROR_REF_ONE (1u << 1)
/**
* Maximum value of the reference counter.
*/
#define ECMA_ERROR_MAX_REF (UINT32_MAX - 1u)
/**
* Representation of a thrown value on API level.
*/
typedef struct
{
uint32_t refs; /**< reference counter */
uint32_t refs_and_flags; /**< reference counter */
ecma_value_t value; /**< referenced value */
} ecma_error_reference_t;