mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Remove class id storing for class objects (#4645)
The two bytes which stored the id is free to use. Currently the only exception is containers. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
2381078e80
commit
ef35c0329c
@ -486,7 +486,6 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_SCRIPT;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_SCRIPT_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, bytecode_data_p);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
@ -1254,6 +1253,75 @@ jerry_value_get_type (const jerry_value_t value) /**< input value to check */
|
||||
}
|
||||
} /* jerry_value_get_type */
|
||||
|
||||
/**
|
||||
* Used by jerry_object_get_type to get the type of class objects
|
||||
*/
|
||||
static const uint8_t jerry_class_object_type[] =
|
||||
{
|
||||
/* These objects require custom property resolving. */
|
||||
JERRY_OBJECT_TYPE_STRING, /**< type of ECMA_OBJECT_CLASS_STRING */
|
||||
JERRY_OBJECT_TYPE_ARGUMENTS, /**< type of ECMA_OBJECT_CLASS_ARGUMENTS */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
JERRY_OBJECT_TYPE_TYPEDARRAY, /**< type of ECMA_OBJECT_CLASS_TYPEDARRAY */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_GENERATOR */
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_ARRAY_ITERATOR */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_SET_ITERATOR */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_MAP_ITERATOR */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
|
||||
#endif
|
||||
#if JERRY_BUILTIN_PROMISE
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
|
||||
#endif /* JERRY_BUILTIN_PROMISE */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_DATAVIEW */
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
JERRY_OBJECT_TYPE_CONTAINER, /**< type of ECMA_OBJECT_CLASS_CONTAINER */
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
/* Normal objects. */
|
||||
JERRY_OBJECT_TYPE_BOOLEAN, /**< type of ECMA_OBJECT_CLASS_BOOLEAN */
|
||||
JERRY_OBJECT_TYPE_NUMBER, /**< type of ECMA_OBJECT_CLASS_NUMBER */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_ERROR */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_INTERNAL_OBJECT */
|
||||
#if JERRY_PARSER
|
||||
JERRY_OBJECT_TYPE_SCRIPT, /**< type of ECMA_OBJECT_CLASS_SCRIPT */
|
||||
#endif /* JERRY_PARSER */
|
||||
#if JERRY_BUILTIN_DATE
|
||||
JERRY_OBJECT_TYPE_DATE, /**< type of ECMA_OBJECT_CLASS_DATE */
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
JERRY_OBJECT_TYPE_REGEXP, /**< type of ECMA_OBJECT_CLASS_REGEXP */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_OBJECT_TYPE_SYMBOL, /**< type of ECMA_OBJECT_CLASS_SYMBOL */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_STRING_ITERATOR */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_ARRAY_BUFFER */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
JERRY_OBJECT_TYPE_BIGINT, /**< type of ECMA_OBJECT_CLASS_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
JERRY_OBJECT_TYPE_WEAKREF, /**< type of ECMA_OBJECT_CLASS_WEAKREF */
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
};
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (jerry_class_object_type) == ECMA_OBJECT_CLASS__MAX,
|
||||
jerry_class_object_type_must_have_object_class_max_elements);
|
||||
|
||||
/**
|
||||
* Get the object type of the given value
|
||||
*
|
||||
@ -1293,101 +1361,8 @@ jerry_object_get_type (const jerry_value_t value) /**< input value to check */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
case ECMA_OBJECT_TYPE_CLASS:
|
||||
{
|
||||
switch (ext_obj_p->u.cls.type)
|
||||
{
|
||||
case ECMA_OBJECT_CLASS_ARGUMENTS:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_ARGUMENTS;
|
||||
}
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_TYPEDARRAY;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_PARSER
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_SCRIPT;
|
||||
}
|
||||
#endif /* JERRY_PARSER */
|
||||
case ECMA_OBJECT_CLASS_BOOLEAN:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_BOOLEAN;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_STRING:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_STRING;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_NUMBER:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_NUMBER;
|
||||
}
|
||||
#if JERRY_BUILTIN_DATE
|
||||
case ECMA_OBJECT_CLASS_DATE:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_DATE;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
case ECMA_OBJECT_CLASS_REGEXP:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_REGEXP;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_ESNEXT
|
||||
case ECMA_OBJECT_CLASS_SYMBOL:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_SYMBOL;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_GENERATOR:
|
||||
case ECMA_OBJECT_CLASS_ASYNC_GENERATOR:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_GENERATOR;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_ARRAY_ITERATOR:
|
||||
#if JERRY_BUILTIN_SET
|
||||
case ECMA_OBJECT_CLASS_SET_ITERATOR:
|
||||
#endif /* JERRY_BUILTIN_SET */
|
||||
#if JERRY_BUILTIN_MAP
|
||||
case ECMA_OBJECT_CLASS_MAP_ITERATOR:
|
||||
#endif /* JERRY_BUILTIN_MAP */
|
||||
case ECMA_OBJECT_CLASS_STRING_ITERATOR:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_ITERATOR;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
case ECMA_OBJECT_CLASS_MODULE:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_MODULE;
|
||||
}
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_CONTAINER;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
case ECMA_OBJECT_CLASS_BIGINT:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_BIGINT;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
case ECMA_OBJECT_CLASS_WEAKREF:
|
||||
{
|
||||
return JERRY_OBJECT_TYPE_WEAKREF;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
JERRY_ASSERT (ext_obj_p->u.cls.type < ECMA_OBJECT_CLASS__MAX);
|
||||
return jerry_class_object_type[ext_obj_p->u.cls.type];
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -3386,7 +3361,6 @@ jerry_set_internal_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
ecma_extended_object_t *container_p = (ecma_extended_object_t *) internal_object_p;
|
||||
container_p->u.cls.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT;
|
||||
container_p->u.cls.u2.id = LIT_MAGIC_STRING_OBJECT_UL;
|
||||
}
|
||||
|
||||
value_p->value = ecma_make_object_value (internal_object_p);
|
||||
@ -6108,7 +6082,7 @@ jerry_get_container_type (const jerry_value_t value) /**< the container object *
|
||||
|
||||
if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_CONTAINER))
|
||||
{
|
||||
switch (((ecma_extended_object_t *) obj_p)->u.cls.u2.id)
|
||||
switch (((ecma_extended_object_t *) obj_p)->u.cls.u2.container_id)
|
||||
{
|
||||
#if JERRY_BUILTIN_MAP
|
||||
case LIT_MAGIC_STRING_MAP_UL:
|
||||
|
||||
@ -728,7 +728,6 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
}
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_typedarray_get_arraybuffer (object_p));
|
||||
break;
|
||||
@ -770,28 +769,28 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
#if JERRY_BUILTIN_MAP
|
||||
if (ext_object_p->u.cls.u2.id == LIT_MAGIC_STRING_MAP_UL)
|
||||
if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_MAP_UL)
|
||||
{
|
||||
ecma_gc_mark_map_object (object_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_MAP */
|
||||
#if JERRY_BUILTIN_WEAKMAP
|
||||
if (ext_object_p->u.cls.u2.id == LIT_MAGIC_STRING_WEAKMAP_UL)
|
||||
if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL)
|
||||
{
|
||||
ecma_gc_mark_weakmap_object (object_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_WEAKMAP */
|
||||
#if JERRY_BUILTIN_SET
|
||||
if (ext_object_p->u.cls.u2.id == LIT_MAGIC_STRING_SET_UL)
|
||||
if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_SET_UL)
|
||||
{
|
||||
ecma_gc_mark_set_object (object_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_SET */
|
||||
#if JERRY_BUILTIN_WEAKSET
|
||||
JERRY_ASSERT (ext_object_p->u.cls.u2.id == LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
JERRY_ASSERT (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
#endif /* JERRY_BUILTIN_WEAKSET */
|
||||
break;
|
||||
}
|
||||
@ -1591,9 +1590,12 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
break;
|
||||
}
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
{
|
||||
ext_object_size = sizeof (ecma_extended_typedarray_object_t);
|
||||
if (ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED)
|
||||
{
|
||||
ext_object_size = sizeof (ecma_extended_typedarray_object_t);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
@ -698,6 +698,10 @@ typedef enum
|
||||
|
||||
/**
|
||||
* Types of objects with class property.
|
||||
*
|
||||
* Note:
|
||||
* when this type is changed, both ecma_class_object_magic_string_id
|
||||
* and jerry_class_object_type must be updated as well
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@ -706,7 +710,6 @@ typedef enum
|
||||
ECMA_OBJECT_CLASS_ARGUMENTS, /**< Arguments object (10.6) */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_OBJECT_CLASS_TYPEDARRAY, /**< TypedArray which does NOT need extra space to store length and offset */
|
||||
ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO, /**< TypedArray which NEEDS extra space to store length and offset */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
@ -1037,10 +1040,10 @@ typedef struct
|
||||
uint8_t regexp_string_iterator_flags; /**< flags for RegExp string iterator */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_PROMISE
|
||||
uint8_t promise_flags; /**< flags for Promise objects */
|
||||
uint8_t promise_flags; /**< Promise object flags */
|
||||
#endif /* JERRY_BUILTIN_PROMISE */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
uint8_t container_flags; /**< flags for container objects */
|
||||
uint8_t container_flags; /**< container object flags */
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
uint8_t array_buffer_flags; /**< ArrayBuffer flags */
|
||||
@ -1052,11 +1055,17 @@ typedef struct
|
||||
*/
|
||||
union
|
||||
{
|
||||
/* The ecma_object_get_class_name must handle those types which does not use id. */
|
||||
uint16_t id; /**< magic string id of the class */
|
||||
uint16_t formal_params_number; /**< for arguments: formal parameters number */
|
||||
#if JERRY_ESNEXT
|
||||
uint16_t iterator_index; /**< for %Iterator%: [[%Iterator%NextIndex]] property */
|
||||
uint16_t executable_obj_flags; /**< executable object flags */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
uint16_t container_id; /**< magic string id of a container */
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
uint16_t typedarray_flags; /**< typed array object flags */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
} u2;
|
||||
/**
|
||||
* Description of 32 bit / value. These extra fields depend on the type.
|
||||
@ -1064,14 +1073,22 @@ typedef struct
|
||||
union
|
||||
{
|
||||
ecma_value_t value; /**< value of the object (e.g. boolean, number, string, etc.) */
|
||||
#if !JERRY_ESNEXT
|
||||
ecma_value_t date; /**< Date object [[DateValue]] internal property */
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
ecma_value_t target; /**< [[ProxyTarget]] or [[WeakRefTarget]] internal property */
|
||||
ecma_value_t head; /**< points to the async generator task queue head item */
|
||||
#if JERRY_BUILTIN_PROMISE
|
||||
ecma_value_t promise; /**< PromiseCapability[[Promise]] internal slot */
|
||||
ecma_value_t arraybuffer; /**< for typedarray: internal arraybuffer */
|
||||
#endif /* JERRY_BUILTIN_PROMISE */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ecma_value_t arraybuffer; /**< for typedarray: ArrayBuffer reference */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_ESNEXT
|
||||
ecma_value_t head; /**< points to the async generator task queue head item */
|
||||
ecma_value_t iterated_value; /**< for %Iterator%: [[IteratedObject]] property */
|
||||
ecma_value_t spread_value; /**< for spread object: spreaded element */
|
||||
int32_t tza; /**< TimeZone adjustment for date objects */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
uint32_t length; /**< length related property (e.g. length of ArrayBuffer) */
|
||||
uint32_t arguments_number; /**< for arguments: arguments number */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
@ -2031,14 +2048,22 @@ typedef enum
|
||||
} ecma_typedarray_type_t;
|
||||
|
||||
/**
|
||||
* Extra information for ArrayBuffers.
|
||||
* TypedArray flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ARRAYBUFFER_INTERNAL_MEMORY = 0u, /* ArrayBuffer memory is handled internally. */
|
||||
ECMA_TYPEDARRAY_IS_EXTENDED = (1u << 0), /* an ecma_extended_typedarray_object_t is allocated for the TypedArray */
|
||||
} ecma_typedarray_flag_t;
|
||||
|
||||
/**
|
||||
* ArrayBuffers flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ARRAYBUFFER_INTERNAL_MEMORY = 0u, /* ArrayBuffer memory is handled internally. */
|
||||
ECMA_ARRAYBUFFER_EXTERNAL_MEMORY = (1u << 0), /* ArrayBuffer created via jerry_create_arraybuffer_external. */
|
||||
ECMA_ARRAYBUFFER_DETACHED = (1u << 1), /* ArrayBuffer has been detached */
|
||||
} ecma_arraybuffer_extra_flag_t;
|
||||
ECMA_ARRAYBUFFER_DETACHED = (1u << 1), /* ArrayBuffer has been detached */
|
||||
} ecma_arraybuffer_flag_t;
|
||||
|
||||
/**
|
||||
* Check whether the ArrayBuffer has external underlying buffer
|
||||
@ -2058,7 +2083,7 @@ typedef struct
|
||||
{
|
||||
ecma_extended_object_t extended_object; /**< extended object part */
|
||||
void *buffer_p; /**< external buffer pointer */
|
||||
ecma_object_native_free_callback_t free_cb; /**< the free callback for the above buffer pointer */
|
||||
ecma_object_native_free_callback_t free_cb; /**< the free callback for the above buffer pointer */
|
||||
} ecma_arraybuffer_external_info;
|
||||
|
||||
/**
|
||||
|
||||
@ -739,7 +739,6 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
ecma_date_object_t *date_object_p = (ecma_date_object_t *) obj_p;
|
||||
date_object_p->header.u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
date_object_p->header.u.cls.u1.date_flags = ECMA_DATE_TZA_NONE;
|
||||
date_object_p->header.u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
date_object_p->header.u.cls.u3.tza = 0;
|
||||
date_object_p->date_value = tv;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
@ -751,7 +750,6 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.date, date_value_p);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -82,7 +82,6 @@ ecma_builtin_weakref_dispatch_construct (const ecma_value_t *arguments_list_p, /
|
||||
ecma_deref_object (proto_p);
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_WEAKREF;
|
||||
ext_obj_p->u.cls.u2.id = LIT_MAGIC_STRING_WEAKREF_UL;
|
||||
ext_obj_p->u.cls.u3.target = arguments_list_p[0];
|
||||
ecma_op_object_set_weak (ecma_get_object_from_value (arguments_list_p[0]), object_p);
|
||||
|
||||
|
||||
@ -464,7 +464,6 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_STRING;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_STRING_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
break;
|
||||
}
|
||||
@ -477,7 +476,6 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_NUMBER;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_make_integer_value (0);
|
||||
break;
|
||||
}
|
||||
@ -490,7 +488,6 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BOOLEAN;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
ext_object_p->u.cls.u3.value = ECMA_VALUE_FALSE;
|
||||
break;
|
||||
}
|
||||
@ -504,7 +501,6 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
|
||||
ecma_number_t *prim_prop_num_value_p = ecma_alloc_number ();
|
||||
*prim_prop_num_value_p = ecma_number_make_nan ();
|
||||
@ -520,7 +516,6 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_REGEXP_UL;
|
||||
|
||||
re_compiled_code_t *bc_p = re_compile_bytecode (ecma_get_magic_string (LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP),
|
||||
RE_FLAG_EMPTY);
|
||||
|
||||
@ -1863,8 +1863,8 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id,
|
||||
}
|
||||
case ECMA_TYPEDARRAY_PROTOTYPE_ROUTINE_TO_STRING_TAG_GETTER:
|
||||
{
|
||||
ecma_extended_object_t *obj_p = (ecma_extended_object_t *) typedarray_p;
|
||||
return ecma_make_magic_string_value (obj_p->u.cls.u2.id);
|
||||
ecma_extended_object_t *object_p = (ecma_extended_object_t *) typedarray_p;
|
||||
return ecma_make_magic_string_value (ecma_get_typedarray_magic_string_id (object_p->u.cls.u1.typedarray_type));
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@ -55,7 +55,6 @@ ecma_arraybuffer_new_object (uint32_t length) /**< length of the arraybuffer */
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_ARRAY_BUFFER;
|
||||
ext_object_p->u.cls.u1.array_buffer_flags = ECMA_ARRAYBUFFER_INTERNAL_MEMORY;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
|
||||
ext_object_p->u.cls.u3.length = length;
|
||||
|
||||
lit_utf8_byte_t *buf = (lit_utf8_byte_t *) (ext_object_p + 1);
|
||||
@ -87,7 +86,6 @@ ecma_arraybuffer_new_object_external (uint32_t length, /**< length of the buffer
|
||||
ecma_arraybuffer_external_info *array_object_p = (ecma_arraybuffer_external_info *) object_p;
|
||||
array_object_p->extended_object.u.cls.type = ECMA_OBJECT_CLASS_ARRAY_BUFFER;
|
||||
array_object_p->extended_object.u.cls.u1.array_buffer_flags = ECMA_ARRAYBUFFER_EXTERNAL_MEMORY;
|
||||
array_object_p->extended_object.u.cls.u2.id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
|
||||
array_object_p->extended_object.u.cls.u3.length = length;
|
||||
|
||||
array_object_p->buffer_p = buffer_p;
|
||||
|
||||
@ -53,7 +53,6 @@ ecma_op_create_bigint_object (ecma_value_t arg) /**< argument passed to the toOb
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BIGINT;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_BIGINT_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_copy_value (arg);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
|
||||
@ -72,7 +72,6 @@ ecma_op_create_boolean_object (ecma_value_t arg) /**< argument passed to the Boo
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BOOLEAN;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_make_boolean_value (boolean_value);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@ -318,7 +318,7 @@ ecma_op_container_free_entries (ecma_object_t *object_p) /**< collection object
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
|
||||
switch (map_object_p->u.cls.u2.id)
|
||||
switch (map_object_p->u.cls.u2.container_id)
|
||||
{
|
||||
#if JERRY_BUILTIN_WEAKSET
|
||||
case LIT_MAGIC_STRING_WEAKSET_UL:
|
||||
@ -390,7 +390,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l
|
||||
ecma_extended_object_t *map_obj_p = (ecma_extended_object_t *) object_p;
|
||||
map_obj_p->u.cls.type = ECMA_OBJECT_CLASS_CONTAINER;
|
||||
map_obj_p->u.cls.u1.container_flags = ECMA_CONTAINER_FLAGS_EMPTY;
|
||||
map_obj_p->u.cls.u2.id = (uint16_t) lit_id;
|
||||
map_obj_p->u.cls.u2.container_id = (uint16_t) lit_id;
|
||||
|
||||
if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_WEAKSET_UL)
|
||||
{
|
||||
@ -568,7 +568,7 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_object_t *map_object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (map_object_p, ECMA_OBJECT_CLASS_CONTAINER)
|
||||
&& ((ecma_extended_object_t *) map_object_p)->u.cls.u2.id == lit_id)
|
||||
&& ((ecma_extended_object_t *) map_object_p)->u.cls.u2.container_id == lit_id)
|
||||
{
|
||||
return (ecma_extended_object_t *) map_object_p;
|
||||
}
|
||||
@ -882,11 +882,11 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.id);
|
||||
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id);
|
||||
|
||||
JERRY_ASSERT (entry_p != NULL);
|
||||
|
||||
ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.cls.u2.id);
|
||||
ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.cls.u2.container_id);
|
||||
} /* ecma_op_container_remove_weak_entry */
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@ -1008,7 +1008,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
}
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) (ecma_get_object_from_value (iterated_value));
|
||||
lit_magic_string_id_t lit_id = map_object_p->u.cls.u2.id;
|
||||
lit_magic_string_id_t lit_id = map_object_p->u.cls.u2.container_id;
|
||||
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
|
||||
@ -533,7 +533,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
ecma_builtin_id_t proto_id = ECMA_BUILTIN_ID_OBJECT_PROTOTYPE;
|
||||
uint8_t class_type;
|
||||
uint16_t class_id;
|
||||
|
||||
if (ecma_is_value_number (value))
|
||||
{
|
||||
@ -541,7 +540,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
proto_id = ECMA_BUILTIN_ID_NUMBER_PROTOTYPE;
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
class_type = ECMA_OBJECT_CLASS_NUMBER;
|
||||
class_id = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
}
|
||||
else if (ecma_is_value_string (value))
|
||||
{
|
||||
@ -549,7 +547,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
proto_id = ECMA_BUILTIN_ID_STRING_PROTOTYPE;
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
class_type = ECMA_OBJECT_CLASS_STRING;
|
||||
class_id = LIT_MAGIC_STRING_STRING_UL;
|
||||
}
|
||||
else if (ecma_is_value_object (value))
|
||||
{
|
||||
@ -560,7 +557,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
proto_id = ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE;
|
||||
class_type = ECMA_OBJECT_CLASS_SYMBOL;
|
||||
class_id = LIT_MAGIC_STRING_SYMBOL_UL;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@ -583,7 +579,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
proto_id = ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE;
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
class_type = ECMA_OBJECT_CLASS_BOOLEAN;
|
||||
class_id = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,7 +588,6 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = class_type;
|
||||
ext_object_p->u.cls.u2.id = class_id;
|
||||
ext_object_p->u.cls.u3.value = ecma_copy_value_if_not_object (value);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
|
||||
@ -146,7 +146,6 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li
|
||||
/* 11 - 14. */
|
||||
ecma_dataview_object_t *dataview_obj_p = (ecma_dataview_object_t *) object_p;
|
||||
dataview_obj_p->header.u.cls.type = ECMA_OBJECT_CLASS_DATAVIEW;
|
||||
dataview_obj_p->header.u.cls.u2.id = LIT_MAGIC_STRING_DATAVIEW_UL;
|
||||
dataview_obj_p->header.u.cls.u3.length = view_byte_length;
|
||||
dataview_obj_p->buffer_p = buffer_p;
|
||||
dataview_obj_p->byte_offset = (uint32_t) offset;
|
||||
|
||||
@ -155,7 +155,6 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
((ecma_extended_object_t *) new_error_obj_p)->u.cls.type = ECMA_OBJECT_CLASS_ERROR;
|
||||
((ecma_extended_object_t *) new_error_obj_p)->u.cls.u2.id = LIT_MAGIC_STRING_ERROR_UL;
|
||||
|
||||
if (message_string_p != NULL)
|
||||
{
|
||||
|
||||
@ -76,7 +76,6 @@ ecma_op_create_number_object (ecma_value_t arg) /**< argument passed to the Numb
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_NUMBER;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
|
||||
/* Pass reference (no need to free conv_to_num_completion). */
|
||||
ext_object_p->u.cls.u3.value = conv_to_num_completion;
|
||||
|
||||
@ -133,7 +133,6 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.1 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
if (ecma_prop_name_is_symbol (property_name_p))
|
||||
{
|
||||
@ -504,7 +503,6 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.4 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
if (ecma_prop_name_is_symbol (property_name_p))
|
||||
{
|
||||
@ -1296,7 +1294,6 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.5 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
if (ecma_prop_name_is_symbol (property_name_p))
|
||||
{
|
||||
@ -1760,7 +1757,6 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.1 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
return ecma_op_typedarray_define_own_property (obj_p, property_name_p, property_desc_p);
|
||||
}
|
||||
@ -2188,7 +2184,6 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.1 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO:
|
||||
{
|
||||
ecma_op_typedarray_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
break;
|
||||
@ -2679,6 +2674,75 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
} /* ecma_object_check_class_name_is_object */
|
||||
|
||||
/**
|
||||
* Used by ecma_object_get_class_name to get the magic string id of class objects
|
||||
*/
|
||||
static const uint16_t ecma_class_object_magic_string_id[] =
|
||||
{
|
||||
/* These objects require custom property resolving. */
|
||||
LIT_MAGIC_STRING_STRING_UL, /**< magic string id of ECMA_OBJECT_CLASS_STRING */
|
||||
LIT_MAGIC_STRING_ARGUMENTS_UL, /**< magic string id of ECMA_OBJECT_CLASS_ARGUMENTS */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
LIT_MAGIC_STRING__EMPTY, /**< ECMA_OBJECT_CLASS_TYPEDARRAY needs special resolver */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
LIT_MAGIC_STRING_GENERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_GENERATOR */
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */
|
||||
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_ARRAY_ITERATOR */
|
||||
LIT_MAGIC_STRING_SET_ITERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_SET_ITERATOR */
|
||||
LIT_MAGIC_STRING_MAP_ITERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_MAP_ITERATOR */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
LIT_MAGIC_STRING_REGEXP_STRING_ITERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
LIT_MAGIC_STRING_MODULE_UL, /**< magic string id of ECMA_OBJECT_CLASS_MODULE */
|
||||
#endif
|
||||
#if JERRY_BUILTIN_PROMISE
|
||||
LIT_MAGIC_STRING_PROMISE_UL, /**< magic string id of ECMA_OBJECT_CLASS_PROMISE */
|
||||
LIT_MAGIC_STRING_OBJECT_UL, /**< magic string id of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
|
||||
#endif /* JERRY_BUILTIN_PROMISE */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL, /**< magic string id of ECMA_OBJECT_CLASS_DATAVIEW */
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
LIT_MAGIC_STRING__EMPTY, /**< magic string id of ECMA_OBJECT_CLASS_CONTAINER needs special resolver */
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
/* Normal objects. */
|
||||
LIT_MAGIC_STRING_BOOLEAN_UL, /**< magic string id of ECMA_OBJECT_CLASS_BOOLEAN */
|
||||
LIT_MAGIC_STRING_NUMBER_UL, /**< magic string id of ECMA_OBJECT_CLASS_NUMBER */
|
||||
LIT_MAGIC_STRING_ERROR_UL, /**< magic string id of ECMA_OBJECT_CLASS_ERROR */
|
||||
LIT_MAGIC_STRING_OBJECT_UL, /**< magic string id of ECMA_OBJECT_CLASS_INTERNAL_OBJECT */
|
||||
#if JERRY_PARSER
|
||||
LIT_MAGIC_STRING_SCRIPT_UL, /**< magic string id of ECMA_OBJECT_CLASS_SCRIPT */
|
||||
#endif /* JERRY_PARSER */
|
||||
#if JERRY_BUILTIN_DATE
|
||||
LIT_MAGIC_STRING_DATE_UL, /**< magic string id of ECMA_OBJECT_CLASS_DATE */
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
LIT_MAGIC_STRING_REGEXP_UL, /**< magic string id of ECMA_OBJECT_CLASS_REGEXP */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_ESNEXT
|
||||
LIT_MAGIC_STRING_SYMBOL_UL, /**< magic string id of ECMA_OBJECT_CLASS_SYMBOL */
|
||||
LIT_MAGIC_STRING_STRING_ITERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_STRING_ITERATOR */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL, /**< magic string id of ECMA_OBJECT_CLASS_ARRAY_BUFFER */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
LIT_MAGIC_STRING_BIGINT_UL, /**< magic string id of ECMA_OBJECT_CLASS_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
LIT_MAGIC_STRING_WEAKREF_UL, /**< magic string id of ECMA_OBJECT_CLASS_WEAKREF */
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
};
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_class_object_magic_string_id) == ECMA_OBJECT_CLASS__MAX * sizeof (uint16_t),
|
||||
ecma_class_object_magic_string_id_must_have_object_class_max_elements);
|
||||
|
||||
/**
|
||||
* Get [[Class]] string of specified object
|
||||
*
|
||||
@ -2701,51 +2765,28 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
|
||||
|
||||
switch (ext_object_p->u.cls.type)
|
||||
{
|
||||
case ECMA_OBJECT_CLASS_ARGUMENTS:
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
{
|
||||
return LIT_MAGIC_STRING_ARGUMENTS_UL;
|
||||
return ecma_get_typedarray_magic_string_id (ext_object_p->u.cls.u1.typedarray_type);
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
case ECMA_OBJECT_CLASS_GENERATOR:
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
return LIT_MAGIC_STRING_GENERATOR_UL;
|
||||
return (lit_magic_string_id_t) ext_object_p->u.cls.u2.container_id;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_ASYNC_GENERATOR:
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
default:
|
||||
{
|
||||
return LIT_MAGIC_STRING_ASYNC_GENERATOR_UL;
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_ARRAY_ITERATOR:
|
||||
{
|
||||
return LIT_MAGIC_STRING_ARRAY_ITERATOR_UL;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_SET_ITERATOR:
|
||||
{
|
||||
return LIT_MAGIC_STRING_SET_ITERATOR_UL;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_MAP_ITERATOR:
|
||||
{
|
||||
return LIT_MAGIC_STRING_MAP_ITERATOR_UL;
|
||||
}
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
case ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR:
|
||||
{
|
||||
return LIT_MAGIC_STRING_REGEXP_STRING_ITERATOR_UL;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
case ECMA_OBJECT_CLASS_STRING_ITERATOR:
|
||||
{
|
||||
return LIT_MAGIC_STRING_STRING_ITERATOR_UL;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
case ECMA_OBJECT_CLASS_MODULE:
|
||||
{
|
||||
return LIT_MAGIC_STRING_MODULE_UL;
|
||||
}
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
}
|
||||
|
||||
return (lit_magic_string_id_t) ext_object_p->u.cls.u2.id;
|
||||
JERRY_ASSERT (ext_object_p->u.cls.type < ECMA_OBJECT_CLASS__MAX);
|
||||
JERRY_ASSERT (ecma_class_object_magic_string_id[ext_object_p->u.cls.type] != LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
return (lit_magic_string_id_t) ecma_class_object_magic_string_id[ext_object_p->u.cls.type];
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
|
||||
|
||||
@ -507,7 +507,6 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_PROMISE;
|
||||
/* 5 */
|
||||
ext_object_p->u.cls.u1.promise_flags = ECMA_PROMISE_IS_PENDING;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_PROMISE_UL;
|
||||
ext_object_p->u.cls.u3.value = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
/* 6-8. */
|
||||
@ -765,7 +764,6 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function
|
||||
|
||||
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
|
||||
capability_p->header.u.cls.type = ECMA_OBJECT_CLASS_PROMISE_CAPABILITY;
|
||||
capability_p->header.u.cls.u2.id = LIT_MAGIC_STRING_OBJECT_UL;
|
||||
capability_p->header.u.cls.u3.promise = ECMA_VALUE_UNDEFINED;
|
||||
capability_p->resolve = ECMA_VALUE_UNDEFINED;
|
||||
capability_p->reject = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
@ -285,7 +285,6 @@ ecma_op_regexp_initialize (ecma_object_t *regexp_obj_p, /**< RegExp object */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP;
|
||||
ext_obj_p->u.cls.u2.id = LIT_MAGIC_STRING_REGEXP_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_obj_p->u.cls.u3.value, bc_p);
|
||||
} /* ecma_op_regexp_initialize */
|
||||
|
||||
|
||||
@ -86,7 +86,6 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_STRING;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_STRING_UL;
|
||||
ext_object_p->u.cls.u3.value = prim_value;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@ -91,7 +91,6 @@ ecma_op_create_symbol_object (const ecma_value_t value) /**< symbol value */
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_SYMBOL;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_SYMBOL_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_copy_value (value);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
|
||||
@ -604,6 +604,17 @@ static const uint16_t ecma_typedarray_magic_string_list[] =
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the magic string id of a typedarray
|
||||
*
|
||||
* @return magic string
|
||||
*/
|
||||
extern inline lit_magic_string_id_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_typedarray_magic_string_id (ecma_typedarray_type_t typedarray_id)
|
||||
{
|
||||
return (lit_magic_string_id_t) ecma_typedarray_magic_string_list[typedarray_id];
|
||||
} /* ecma_get_typedarray_magic_string_id */
|
||||
|
||||
/**
|
||||
* Get typedarray's getter function callback
|
||||
*
|
||||
@ -789,7 +800,7 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY;
|
||||
ext_object_p->u.cls.u1.typedarray_type = (uint8_t) typedarray_id;
|
||||
ext_object_p->u.cls.u2.id = ecma_typedarray_magic_string_list[typedarray_id];
|
||||
ext_object_p->u.cls.u2.typedarray_flags = 0;
|
||||
ext_object_p->u.cls.u3.arraybuffer = ecma_make_object_value (new_arraybuffer_p);
|
||||
|
||||
ecma_deref_object (new_arraybuffer_p);
|
||||
@ -829,12 +840,12 @@ ecma_typedarray_create_object_with_buffer (ecma_object_t *arraybuffer_p, /**< th
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY;
|
||||
ext_object_p->u.cls.u1.typedarray_type = (uint8_t) typedarray_id;
|
||||
ext_object_p->u.cls.u2.id = ecma_typedarray_magic_string_list[typedarray_id];
|
||||
ext_object_p->u.cls.u2.typedarray_flags = 0;
|
||||
ext_object_p->u.cls.u3.arraybuffer = ecma_make_object_value (arraybuffer_p);
|
||||
|
||||
if (needs_ext_typedarray_obj)
|
||||
{
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO;
|
||||
ext_object_p->u.cls.u2.typedarray_flags |= ECMA_TYPEDARRAY_IS_EXTENDED;
|
||||
|
||||
ecma_extended_typedarray_object_t *typedarray_info_p = (ecma_extended_typedarray_object_t *) object_p;
|
||||
typedarray_info_p->array_length = array_length;
|
||||
@ -1251,7 +1262,7 @@ ecma_typedarray_get_length (ecma_object_t *typedarray_p) /**< the pointer to the
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY)
|
||||
if (!(ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED))
|
||||
{
|
||||
ecma_object_t *arraybuffer_p = ecma_get_object_from_value (ext_object_p->u.cls.u3.arraybuffer);
|
||||
uint32_t buffer_length = ecma_arraybuffer_get_length (arraybuffer_p);
|
||||
@ -1283,7 +1294,7 @@ ecma_typedarray_get_offset (ecma_object_t *typedarray_p) /**< the pointer to the
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY)
|
||||
if (!(ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1513,15 +1524,7 @@ ecma_object_is_typedarray (ecma_object_t *obj_p) /**< the target object need to
|
||||
{
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
|
||||
|
||||
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
return (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY
|
||||
|| ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO);
|
||||
}
|
||||
|
||||
return false;
|
||||
return ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_TYPEDARRAY);
|
||||
} /* ecma_object_is_typedarray */
|
||||
|
||||
/**
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
uint8_t ecma_typedarray_helper_get_shift_size (ecma_typedarray_type_t typedarray_id);
|
||||
lit_magic_string_id_t ecma_get_typedarray_magic_string_id (ecma_typedarray_type_t typedarray_id);
|
||||
ecma_typedarray_getter_fn_t ecma_get_typedarray_getter_fn (ecma_typedarray_type_t typedarray_id);
|
||||
ecma_typedarray_setter_fn_t ecma_get_typedarray_setter_fn (ecma_typedarray_type_t typedarray_id);
|
||||
ecma_value_t ecma_get_typedarray_element (lit_utf8_byte_t *src_p,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user