Remove pseudo array object type from the project (#4643)

A new class type enum is introduced to describe the class of objects.
This enum is organized to improve property resolve and GC performance.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-04-06 18:46:48 +02:00
committed by GitHub
parent 4377ef684d
commit d85020f709
60 changed files with 1274 additions and 1212 deletions
@@ -69,14 +69,14 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar
ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
object_size + (saved_arg_count * sizeof (ecma_value_t)),
ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
ECMA_OBJECT_TYPE_CLASS);
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p;
arguments_p->header.u.pseudo_array.type = ECMA_PSEUDO_ARRAY_ARGUMENTS;
arguments_p->header.u.pseudo_array.extra_info = ECMA_ARGUMENTS_OBJECT_NO_FLAGS;
arguments_p->header.u.pseudo_array.u1.formal_params_number = formal_params_number;
arguments_p->header.u.pseudo_array.u2.arguments_number = 0;
arguments_p->header.u.cls.type = ECMA_OBJECT_CLASS_ARGUMENTS;
arguments_p->header.u.cls.u1.arguments_flags = ECMA_ARGUMENTS_OBJECT_NO_FLAGS;
arguments_p->header.u.cls.u2.formal_params_number = formal_params_number;
arguments_p->header.u.cls.u3.arguments_number = 0;
arguments_p->callee = ecma_make_object_value (func_obj_p);
ecma_value_t *argv_p = (ecma_value_t *) (((uint8_t *) obj_p) + object_size);
@@ -91,19 +91,19 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar
argv_p[i] = ECMA_VALUE_INITIALIZED;
}
arguments_p->header.u.pseudo_array.u2.arguments_number = shared_p->arg_list_len;
arguments_p->header.u.cls.u3.arguments_number = shared_p->arg_list_len;
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) obj_p;
ECMA_SET_INTERNAL_VALUE_POINTER (mapped_arguments_p->lex_env, lex_env_p);
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_MAPPED;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_MAPPED;
#if JERRY_SNAPSHOT_EXEC
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)
{
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE;
mapped_arguments_p->u.byte_code_p = (ecma_compiled_code_t *) bytecode_data_p;
}
else
@@ -168,7 +168,7 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
property_desc_p);
if (ECMA_IS_VALUE_ERROR (ret_value)
|| !(((ecma_extended_object_t *) object_p)->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED))
|| !(((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
return ret_value;
}
@@ -176,7 +176,7 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) object_p;
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index >= mapped_arguments_p->unmapped.header.u.pseudo_array.u1.formal_params_number)
if (index >= mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number)
{
return ret_value;
}
@@ -236,7 +236,7 @@ ecma_op_arguments_object_delete (ecma_object_t *object_p, /**< the object */
ecma_value_t ret_value = ecma_op_general_object_delete (object_p, property_name_p, is_throw);
if (!ecma_is_value_true (ret_value)
|| !(((ecma_extended_object_t *) object_p)->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED))
|| !(((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
return ret_value;
}
@@ -245,7 +245,7 @@ ecma_op_arguments_object_delete (ecma_object_t *object_p, /**< the object */
ecma_value_t *argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < mapped_arguments_p->unmapped.header.u.pseudo_array.u1.formal_params_number)
if (index < mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number)
{
ecma_free_value_if_not_object (argv_p[index]);
argv_p[index] = ECMA_VALUE_EMPTY;
@@ -264,15 +264,14 @@ ecma_property_t *
ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< object */
ecma_string_t *property_name_p) /**< property's name */
{
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
JERRY_ASSERT (((ecma_extended_object_t *) object_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS);
JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARGUMENTS));
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) object_p;
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
ecma_property_value_t *prop_value_p;
ecma_property_t *prop_p = NULL;
uint32_t arguments_number = arguments_p->header.u.pseudo_array.u2.arguments_number;
uint8_t flags = arguments_p->header.u.pseudo_array.extra_info;
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags;
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
@@ -300,7 +299,7 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
/* Pevent reinitialization */
if ((flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
&& index < arguments_p->header.u.pseudo_array.u1.formal_params_number)
&& index < arguments_p->header.u.cls.u2.formal_params_number)
{
argv_p[index] = ECMA_VALUE_INITIALIZED;
}
@@ -315,7 +314,7 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
if (property_name_p == ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH)
&& !(flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED))
{
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED;
prop_value_p = ecma_create_named_data_property (object_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
@@ -328,7 +327,7 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
if (property_name_p == ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE)
&& !(flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED))
{
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED;
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
@@ -355,14 +354,14 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
#if !JERRY_ESNEXT
if (property_name_p == ecma_get_magic_string (LIT_MAGIC_STRING_CALLER)
&& !(arguments_p->header.u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_CALLER_INITIALIZED))
&& !(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_CALLER_INITIALIZED))
{
if (arguments_p->header.u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED)
if (arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
return NULL;
}
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_CALLER_INITIALIZED;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_CALLER_INITIALIZED;
ecma_object_t *thrower_p = ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR_THROWER);
@@ -380,7 +379,7 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
if (property_name_p == symbol_p
&& !(flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED))
{
arguments_p->header.u.pseudo_array.extra_info |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED;
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED;
prop_value_p = ecma_create_named_data_property (object_p,
symbol_p,
@@ -408,14 +407,13 @@ ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< ar
ecma_collection_t *prop_names_p, /**< prop name collection */
ecma_property_counter_t *prop_counter_p) /**< prop counter */
{
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
JERRY_ASSERT (((ecma_extended_object_t *) obj_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS);
JERRY_ASSERT (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARGUMENTS));
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p;
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
uint32_t arguments_number = arguments_p->header.u.pseudo_array.u2.arguments_number;
uint8_t flags = arguments_p->header.u.pseudo_array.extra_info;
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags;
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
@@ -470,13 +468,13 @@ ecma_op_arguments_object_get_formal_parameter (ecma_mapped_arguments_t *mapped_a
* object */
uint32_t index) /**< formal parameter index */
{
JERRY_ASSERT (mapped_arguments_p->unmapped.header.u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED);
JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.pseudo_array.u1.formal_params_number);
JERRY_ASSERT (mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED);
JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number);
ecma_compiled_code_t *byte_code_p;
#if JERRY_SNAPSHOT_EXEC
if (mapped_arguments_p->unmapped.header.u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)
if (mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)
{
byte_code_p = mapped_arguments_p->u.byte_code_p;
}
@@ -797,7 +797,7 @@ ecma_op_create_array_iterator (ecma_object_t *obj_p, /**< array object */
return ecma_op_create_iterator_object (ecma_make_object_value (obj_p),
prototype_obj_p,
ECMA_PSEUDO_ARRAY_ITERATOR,
ECMA_OBJECT_CLASS_ARRAY_ITERATOR,
kind);
} /* ecma_op_create_array_iterator */
#endif /* JERRY_ESNEXT */
@@ -53,9 +53,10 @@ ecma_arraybuffer_new_object (uint32_t length) /**< length of the arraybuffer */
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.extra_info = ECMA_ARRAYBUFFER_INTERNAL_MEMORY;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
ext_object_p->u.class_prop.u.length = length;
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);
memset (buf, 0, length);
@@ -84,9 +85,10 @@ ecma_arraybuffer_new_object_external (uint32_t length, /**< length of the buffer
ECMA_OBJECT_TYPE_CLASS);
ecma_arraybuffer_external_info *array_object_p = (ecma_arraybuffer_external_info *) object_p;
array_object_p->extended_object.u.class_prop.extra_info = ECMA_ARRAYBUFFER_EXTERNAL_MEMORY;
array_object_p->extended_object.u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
array_object_p->extended_object.u.class_prop.u.length = length;
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;
array_object_p->free_cb = free_cb;
@@ -173,8 +175,7 @@ bool
ecma_is_arraybuffer (ecma_value_t target) /**< the target value */
{
return (ecma_is_value_object (target)
&& ecma_object_class_is (ecma_get_object_from_value (target),
LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
&& ecma_object_class_is (ecma_get_object_from_value (target), ECMA_OBJECT_CLASS_ARRAY_BUFFER));
} /* ecma_is_arraybuffer */
/**
@@ -185,10 +186,10 @@ ecma_is_arraybuffer (ecma_value_t target) /**< the target value */
uint32_t JERRY_ATTR_PURE
ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
return ecma_arraybuffer_is_detached (object_p) ? 0 : ext_object_p->u.class_prop.u.length;
return ecma_arraybuffer_is_detached (object_p) ? 0 : ext_object_p->u.cls.u3.length;
} /* ecma_arraybuffer_get_length */
/**
@@ -199,7 +200,7 @@ ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayB
extern inline lit_utf8_byte_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_arraybuffer_get_buffer (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -209,7 +210,7 @@ ecma_arraybuffer_get_buffer (ecma_object_t *object_p) /**< pointer to the ArrayB
JERRY_ASSERT (!ecma_arraybuffer_is_detached (object_p) || array_p->buffer_p == NULL);
return (lit_utf8_byte_t *) array_p->buffer_p;
}
else if (ext_object_p->u.class_prop.extra_info & ECMA_ARRAYBUFFER_DETACHED)
else if (ext_object_p->u.cls.u1.array_buffer_flags & ECMA_ARRAYBUFFER_DETACHED)
{
return NULL;
}
@@ -226,9 +227,9 @@ ecma_arraybuffer_get_buffer (ecma_object_t *object_p) /**< pointer to the ArrayB
extern inline bool JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_arraybuffer_is_detached (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER));
return (((ecma_extended_object_t *) object_p)->u.class_prop.extra_info & ECMA_ARRAYBUFFER_DETACHED) != 0;
return (((ecma_extended_object_t *) object_p)->u.cls.u1.array_buffer_flags & ECMA_ARRAYBUFFER_DETACHED) != 0;
} /* ecma_arraybuffer_is_detached */
/**
@@ -242,7 +243,7 @@ ecma_arraybuffer_is_detached (ecma_object_t *object_p) /**< pointer to the Array
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_arraybuffer_detach (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER));
if (ecma_arraybuffer_is_detached (object_p))
{
@@ -250,7 +251,7 @@ ecma_arraybuffer_detach (ecma_object_t *object_p) /**< pointer to the ArrayBuffe
}
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.extra_info |= ECMA_ARRAYBUFFER_DETACHED;
ext_object_p->u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_DETACHED;
if (ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY (ext_object_p))
{
@@ -262,7 +263,7 @@ ecma_arraybuffer_detach (ecma_object_t *object_p) /**< pointer to the ArrayBuffe
array_p->free_cb = NULL;
}
ext_object_p->u.class_prop.u.length = 0;
ext_object_p->u.cls.u3.length = 0;
array_p->buffer_p = NULL;
}
@@ -58,20 +58,20 @@ ecma_async_generator_enqueue (vm_executable_object_t *async_generator_object_p,
ecma_value_t result = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
task_p->promise = result;
ecma_value_t head = async_generator_object_p->extended_object.u.class_prop.u.head;
ecma_value_t head = async_generator_object_p->extended_object.u.cls.u3.head;
if (ECMA_IS_INTERNAL_VALUE_NULL (head))
{
ECMA_SET_INTERNAL_VALUE_POINTER (async_generator_object_p->extended_object.u.class_prop.u.head, task_p);
ECMA_SET_INTERNAL_VALUE_POINTER (async_generator_object_p->extended_object.u.cls.u3.head, task_p);
if (async_generator_object_p->extended_object.u.class_prop.extra_info & ECMA_ASYNC_GENERATOR_CALLED)
if (async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_ASYNC_GENERATOR_CALLED)
{
ecma_value_t executable_object = ecma_make_object_value ((ecma_object_t *) async_generator_object_p);
ecma_enqueue_promise_async_generator_job (executable_object);
return result;
}
async_generator_object_p->extended_object.u.class_prop.extra_info |= ECMA_ASYNC_GENERATOR_CALLED;
async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_ASYNC_GENERATOR_CALLED;
ecma_async_generator_run (async_generator_object_p);
return result;
}
@@ -190,15 +190,15 @@ ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< a
ecma_value_t
ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**< async generator */
{
JERRY_ASSERT (async_generator_object_p->extended_object.u.class_prop.class_id
== LIT_MAGIC_STRING_ASYNC_GENERATOR_UL);
JERRY_ASSERT (!ECMA_IS_INTERNAL_VALUE_NULL (async_generator_object_p->extended_object.u.class_prop.u.head));
JERRY_ASSERT (async_generator_object_p->extended_object.u.cls.type == ECMA_OBJECT_CLASS_ASYNC_GENERATOR);
JERRY_ASSERT (!ECMA_IS_INTERNAL_VALUE_NULL (async_generator_object_p->extended_object.u.cls.u3.head));
ecma_value_t head = async_generator_object_p->extended_object.u.class_prop.u.head;
ecma_value_t head = async_generator_object_p->extended_object.u.cls.u3.head;
ecma_async_generator_task_t *task_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_async_generator_task_t, head);
ecma_value_t result;
if (async_generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
if (async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags
& ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
{
switch (task_p->operation_type)
{
@@ -255,7 +255,7 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result));
async_generator_object_p->extended_object.u.class_prop.extra_info &= ECMA_AWAIT_CLEAR_MASK;
async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK;
async_generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
async_generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
@@ -283,9 +283,9 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
result = opfunc_resume_executable_object (async_generator_object_p, result);
if (async_generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
if (async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
{
JERRY_ASSERT (head == async_generator_object_p->extended_object.u.class_prop.u.head);
JERRY_ASSERT (head == async_generator_object_p->extended_object.u.cls.u3.head);
ecma_async_generator_finalize (async_generator_object_p, result);
result = ECMA_VALUE_UNDEFINED;
}
@@ -300,7 +300,7 @@ void
ecma_async_generator_finalize (vm_executable_object_t *async_generator_object_p, /**< async generator */
ecma_value_t value) /**< final value (takes reference) */
{
ecma_value_t next = async_generator_object_p->extended_object.u.class_prop.u.head;
ecma_value_t next = async_generator_object_p->extended_object.u.cls.u3.head;
ecma_async_generator_task_t *task_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_async_generator_task_t, next);
if (ECMA_IS_VALUE_ERROR (value))
@@ -318,7 +318,7 @@ ecma_async_generator_finalize (vm_executable_object_t *async_generator_object_p,
ecma_free_value (value);
next = task_p->next;
async_generator_object_p->extended_object.u.class_prop.u.head = next;
async_generator_object_p->extended_object.u.cls.u3.head = next;
jmem_heap_free_block (task_p, sizeof (ecma_async_generator_task_t));
while (!ECMA_IS_INTERNAL_VALUE_NULL (next))
@@ -339,7 +339,7 @@ ecma_async_generator_finalize (vm_executable_object_t *async_generator_object_p,
ecma_free_value_if_not_object (task_p->operation_value);
next = task_p->next;
async_generator_object_p->extended_object.u.class_prop.u.head = next;
async_generator_object_p->extended_object.u.cls.u3.head = next;
jmem_heap_free_block (task_p, sizeof (ecma_async_generator_task_t));
}
} /* ecma_async_generator_finalize */
@@ -42,7 +42,7 @@ typedef enum
* Get the state of an async yield iterator.
*/
#define ECMA_AWAIT_GET_STATE(async_generator_object_p) \
((async_generator_object_p)->extended_object.u.class_prop.extra_info >> ECMA_AWAIT_STATE_SHIFT)
((async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags >> ECMA_AWAIT_STATE_SHIFT)
/**
* Set the state of an async yield iterator.
@@ -50,10 +50,10 @@ typedef enum
#define ECMA_AWAIT_SET_STATE(async_generator_object_p, to) \
do \
{ \
uint16_t extra_info = (async_generator_object_p)->extended_object.u.class_prop.extra_info; \
uint16_t extra_info = (async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags; \
extra_info &= ((1 << ECMA_AWAIT_STATE_SHIFT) - 1); \
extra_info |= (ECMA_AWAIT_ ## to) << ECMA_AWAIT_STATE_SHIFT; \
(async_generator_object_p)->extended_object.u.class_prop.extra_info = extra_info; \
(async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags = extra_info; \
} \
while (false)
@@ -73,7 +73,7 @@ typedef enum
* Change the state of an async yield iterator.
*/
#define ECMA_AWAIT_CHANGE_STATE(async_generator_object_p, from, to) \
((async_generator_object_p)->extended_object.u.class_prop.extra_info ^= ECMA_AWAIT_CS_HELPER (from, to))
((async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags ^= ECMA_AWAIT_CS_HELPER (from, to))
ecma_value_t ecma_async_generator_enqueue (vm_executable_object_t *async_generator_object_p,
ecma_async_generator_operation_type_t operation, ecma_value_t value);
@@ -52,8 +52,9 @@ ecma_op_create_bigint_object (ecma_value_t arg) /**< argument passed to the toOb
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_BIGINT_UL;
ext_object_p->u.class_prop.u.value = ecma_copy_value (arg);
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);
} /* ecma_op_create_bigint_object */
@@ -71,8 +71,9 @@ ecma_op_create_boolean_object (ecma_value_t arg) /**< argument passed to the Boo
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_BOOLEAN_UL;
ext_object_p->u.class_prop.u.value = ecma_make_boolean_value (boolean_value);
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
if (new_target)
@@ -316,9 +316,9 @@ ecma_op_container_free_entries (ecma_object_t *object_p) /**< collection object
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
switch (map_object_p->u.class_prop.class_id)
switch (map_object_p->u.cls.u2.id)
{
#if JERRY_BUILTIN_WEAKSET
case LIT_MAGIC_STRING_WEAKSET_UL:
@@ -388,15 +388,16 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l
ECMA_OBJECT_TYPE_CLASS);
ecma_deref_object (proto_p);
ecma_extended_object_t *map_obj_p = (ecma_extended_object_t *) object_p;
map_obj_p->u.class_prop.extra_info = ECMA_CONTAINER_FLAGS_EMPTY;
map_obj_p->u.class_prop.class_id = (uint16_t) lit_id;
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;
if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_WEAKSET_UL)
{
map_obj_p->u.class_prop.extra_info |= ECMA_CONTAINER_FLAGS_WEAK;
map_obj_p->u.cls.u1.container_flags |= ECMA_CONTAINER_FLAGS_WEAK;
}
ECMA_SET_INTERNAL_VALUE_POINTER (map_obj_p->u.class_prop.u.value, container_p);
ECMA_SET_INTERNAL_VALUE_POINTER (map_obj_p->u.cls.u3.value, container_p);
ecma_value_t set_value = ecma_make_object_value (object_p);
ecma_value_t result = set_value;
@@ -564,12 +565,12 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */
{
if (ecma_is_value_object (this_arg))
{
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) ecma_get_object_from_value (this_arg);
ecma_object_t *map_object_p = ecma_get_object_from_value (this_arg);
if (ecma_get_object_type ((ecma_object_t *) map_object_p) == ECMA_OBJECT_TYPE_CLASS
&& map_object_p->u.class_prop.class_id == lit_id)
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)
{
return map_object_p;
return (ecma_extended_object_t *) map_object_p;
}
}
@@ -593,7 +594,7 @@ ecma_value_t
ecma_op_container_size (ecma_extended_object_t *map_object_p) /**< internal class id */
{
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
return ecma_make_uint32_value (ECMA_CONTAINER_GET_SIZE (container_p));
} /* ecma_op_container_size */
@@ -617,7 +618,7 @@ ecma_op_container_get (ecma_extended_object_t *map_object_p, /**< map object */
#endif /* JERRY_BUILTIN_WEAKMAP */
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
if (ECMA_CONTAINER_GET_SIZE (container_p) == 0)
{
@@ -646,10 +647,10 @@ ecma_op_container_has (ecma_extended_object_t *map_object_p, /**< map object */
lit_magic_string_id_t lit_id) /**< internal class id */
{
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
#if JERRY_BUILTIN_WEAKMAP || JERRY_BUILTIN_WEAKSET
if ((map_object_p->u.class_prop.extra_info & ECMA_CONTAINER_FLAGS_WEAK) != 0
if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0
&& !ecma_is_value_object (key_arg))
{
return ECMA_VALUE_FALSE;
@@ -704,10 +705,10 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */
lit_magic_string_id_t lit_id) /**< internal class id */
{
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
#if JERRY_BUILTIN_WEAKMAP || JERRY_BUILTIN_WEAKSET
if ((map_object_p->u.class_prop.extra_info & ECMA_CONTAINER_FLAGS_WEAK) != 0
if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0
&& !ecma_is_value_object (key_arg))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Key must be an object"));
@@ -724,7 +725,7 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */
lit_id);
#if JERRY_BUILTIN_WEAKMAP || JERRY_BUILTIN_WEAKSET
if ((map_object_p->u.class_prop.extra_info & ECMA_CONTAINER_FLAGS_WEAK) != 0)
if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0)
{
ecma_object_t *key_p = ecma_get_object_from_value (key_arg);
ecma_op_object_set_weak (key_p, (ecma_object_t *) map_object_p);
@@ -763,7 +764,7 @@ ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object
ecma_value_t ret_value = ECMA_VALUE_UNDEFINED;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
uint8_t entry_size = ecma_op_container_entry_size (lit_id);
@@ -822,7 +823,7 @@ ecma_op_container_delete (ecma_extended_object_t *map_object_p, /**< map object
lit_magic_string_id_t lit_id) /**< internal class id */
{
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id);
@@ -852,7 +853,7 @@ ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, /**< map ob
}
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id);
@@ -879,13 +880,13 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
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.class_prop.class_id);
ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.id);
JERRY_ASSERT (entry_p != NULL);
ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.class_prop.class_id);
ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.cls.u2.id);
} /* ecma_op_container_remove_weak_entry */
#if JERRY_ESNEXT
@@ -906,7 +907,7 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */
ecma_builtin_id_t proto_id, /**< prototype builtin id */
ecma_pseudo_array_type_t iterator_type, /**< iterator type */
ecma_object_class_type_t iterator_type, /**< iterator type */
ecma_iterator_kind_t kind) /**< iterator kind */
{
return ecma_op_create_iterator_object (this_arg,
@@ -923,7 +924,7 @@ ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */
static uint32_t
ecma_op_iterator_get_index (ecma_object_t *iter_obj_p) /**< iterator object pointer */
{
uint32_t index = ((ecma_extended_object_t *) iter_obj_p)->u.pseudo_array.u1.iterator_index;
uint32_t index = ((ecma_extended_object_t *) iter_obj_p)->u.cls.u2.iterator_index;
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
{
@@ -965,7 +966,7 @@ ecma_op_iterator_set_index (ecma_object_t *iter_obj_p, /**< iterator object poin
}
else
{
((ecma_extended_object_t *) iter_obj_p)->u.pseudo_array.u1.iterator_index = (uint16_t) index;
((ecma_extended_object_t *) iter_obj_p)->u.cls.u2.iterator_index = (uint16_t) index;
}
} /* ecma_op_iterator_set_index */
@@ -984,7 +985,7 @@ ecma_op_iterator_set_index (ecma_object_t *iter_obj_p, /**< iterator object poin
*/
ecma_value_t
ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
ecma_pseudo_array_type_t iterator_type) /**< type of the iterator */
ecma_object_class_type_t iterator_type) /**< type of the iterator */
{
if (!ecma_is_value_object (this_val))
{
@@ -994,13 +995,12 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
|| ext_obj_p->u.pseudo_array.type != iterator_type)
if (!ecma_object_class_is (obj_p, iterator_type))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator"));
}
ecma_value_t iterated_value = ext_obj_p->u.pseudo_array.u2.iterated_value;
ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
if (ecma_is_value_empty (iterated_value))
{
@@ -1008,22 +1008,22 @@ 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.class_prop.class_id;
lit_magic_string_id_t lit_id = map_object_p->u.cls.u2.id;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
map_object_p->u.class_prop.u.value);
map_object_p->u.cls.u3.value);
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
uint32_t index = ecma_op_iterator_get_index (obj_p);
if (index == entry_count)
{
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY;
ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY;
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
}
uint8_t entry_size = ecma_op_container_entry_size (lit_id);
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
uint8_t iterator_kind = ext_obj_p->u.cls.u1.iterator_kind;
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
ecma_value_t ret_value = ECMA_VALUE_UNDEFINED;
@@ -1136,12 +1136,12 @@ ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, /**< built
case ECMA_CONTAINER_ROUTINE_ENTRIES:
{
ecma_builtin_id_t builtin_iterator_prototype = ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE;
ecma_pseudo_array_type_t iterator_type = ECMA_PSEUDO_MAP_ITERATOR;
ecma_object_class_type_t iterator_type = ECMA_OBJECT_CLASS_MAP_ITERATOR;
if (lit_id != LIT_MAGIC_STRING_MAP_UL)
{
builtin_iterator_prototype = ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE;
iterator_type = ECMA_PSEUDO_SET_ITERATOR;
iterator_type = ECMA_OBJECT_CLASS_SET_ITERATOR;
}
ecma_iterator_kind_t kind = (ecma_iterator_kind_t) (builtin_routine_id - ECMA_CONTAINER_ROUTINE_KEYS);
@@ -71,9 +71,9 @@ void ecma_op_container_remove_weak_entry (ecma_object_t *container_p, ecma_value
void ecma_op_container_free_entries (ecma_object_t *object_p);
ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg,
ecma_builtin_id_t proto_id,
ecma_pseudo_array_type_t iterator_type,
ecma_object_class_type_t iterator_type,
ecma_iterator_kind_t kind);
ecma_value_t ecma_op_container_iterator_next (ecma_value_t this_val, ecma_pseudo_array_type_t iterator_type);
ecma_value_t ecma_op_container_iterator_next (ecma_value_t this_val, ecma_object_class_type_t iterator_type);
ecma_value_t ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, ecma_value_t this_arg,
const ecma_value_t arguments_list_p[],
lit_magic_string_id_t lit_id);
+14 -21
View File
@@ -532,21 +532,24 @@ 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;
uint16_t lit_id;
uint8_t class_type;
uint16_t class_id;
if (ecma_is_value_number (value))
{
#if JERRY_BUILTIN_NUMBER
proto_id = ECMA_BUILTIN_ID_NUMBER_PROTOTYPE;
#endif /* JERRY_BUILTIN_NUMBER */
lit_id = LIT_MAGIC_STRING_NUMBER_UL;
class_type = ECMA_OBJECT_CLASS_NUMBER;
class_id = LIT_MAGIC_STRING_NUMBER_UL;
}
else if (ecma_is_value_string (value))
{
#if JERRY_BUILTIN_STRING
proto_id = ECMA_BUILTIN_ID_STRING_PROTOTYPE;
#endif /* JERRY_BUILTIN_STRING */
lit_id = LIT_MAGIC_STRING_STRING_UL;
class_type = ECMA_OBJECT_CLASS_STRING;
class_id = LIT_MAGIC_STRING_STRING_UL;
}
else if (ecma_is_value_object (value))
{
@@ -556,7 +559,8 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
else if (ecma_is_value_symbol (value))
{
proto_id = ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE;
lit_id = LIT_MAGIC_STRING_SYMBOL_UL;
class_type = ECMA_OBJECT_CLASS_SYMBOL;
class_id = LIT_MAGIC_STRING_SYMBOL_UL;
}
#endif /* JERRY_ESNEXT */
#if JERRY_BUILTIN_BIGINT
@@ -578,33 +582,22 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
#if JERRY_BUILTIN_BOOLEAN
proto_id = ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE;
#endif /* JERRY_BUILTIN_BOOLEAN */
lit_id = LIT_MAGIC_STRING_BOOLEAN_UL;
class_type = ECMA_OBJECT_CLASS_BOOLEAN;
class_id = LIT_MAGIC_STRING_BOOLEAN_UL;
}
}
return ecma_op_create_class_object (proto_id, value, lit_id);
} /* ecma_op_to_object */
/**
* Create a ECMA_OBJECT_TYPE_CLASS object from the given arguments.
*
* @return ecma_value - constructed object
*/
ecma_value_t
ecma_op_create_class_object (ecma_builtin_id_t proto_id, /**< prototype id */
ecma_value_t value, /**< ecma value */
uint16_t class_id) /**< magic string id */
{
ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (proto_id),
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = class_id;
ext_object_p->u.class_prop.u.value = ecma_copy_value_if_not_object (value);
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);
} /* ecma_op_create_class_object */
} /* ecma_op_to_object */
/**
* FromPropertyDescriptor operation.
@@ -60,9 +60,6 @@ ecma_string_t *ecma_op_to_string (ecma_value_t value);
ecma_string_t *ecma_op_to_property_key (ecma_value_t value);
ecma_value_t ecma_op_to_object (ecma_value_t value);
bool ecma_op_is_integer (ecma_number_t value);
ecma_value_t ecma_op_create_class_object (ecma_builtin_id_t proto_id,
ecma_value_t value,
uint16_t lit_id);
ecma_value_t ecma_op_to_integer (ecma_value_t value, ecma_number_t *number_p);
ecma_value_t ecma_op_to_length (ecma_value_t value, ecma_length_t *length);
#if JERRY_ESNEXT
@@ -60,7 +60,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li
ecma_object_t *buffer_p = ecma_get_object_from_value (buffer);
if (!ecma_object_class_is (buffer_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
if (!ecma_object_class_is (buffer_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'buffer' is not an ArrayBuffer"));
}
@@ -145,8 +145,9 @@ 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.class_prop.class_id = LIT_MAGIC_STRING_DATAVIEW_UL;
dataview_obj_p->header.u.class_prop.u.length = view_byte_length;
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;
@@ -168,12 +169,11 @@ ecma_op_dataview_get_object (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_object (this_arg))
{
ecma_dataview_object_t *dataview_object_p = (ecma_dataview_object_t *) ecma_get_object_from_value (this_arg);
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
if (ecma_get_object_type (&dataview_object_p->header.object) == ECMA_OBJECT_TYPE_CLASS
&& dataview_object_p->header.u.class_prop.class_id == LIT_MAGIC_STRING_DATAVIEW_UL)
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_DATAVIEW))
{
return dataview_object_p;
return (ecma_dataview_object_t *) object_p;
}
}
@@ -254,7 +254,7 @@ ecma_op_dataview_get_set_view_value (ecma_value_t view, /**< the operation's 'vi
}
ecma_object_t *buffer_p = view_p->buffer_p;
JERRY_ASSERT (ecma_object_class_is (buffer_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
JERRY_ASSERT (ecma_object_class_is (buffer_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER));
/* 3. */
ecma_number_t get_index;
@@ -307,7 +307,7 @@ ecma_op_dataview_get_set_view_value (ecma_value_t view, /**< the operation's 'vi
uint32_t view_offset = view_p->byte_offset;
/* GetViewValue 8., SetViewValue 10. */
uint32_t view_size = view_p->header.u.class_prop.u.length;
uint32_t view_size = view_p->header.u.cls.u3.length;
/* GetViewValue 9., SetViewValue 11. */
uint8_t element_size = (uint8_t) (1 << (ecma_typedarray_helper_get_shift_size (id)));
@@ -362,10 +362,7 @@ ecma_is_dataview (ecma_value_t value) /**< the target need to be checked */
return false;
}
ecma_dataview_object_t *dataview_object_p = (ecma_dataview_object_t *) ecma_get_object_from_value (value);
return (ecma_get_object_type (&dataview_object_p->header.object) == ECMA_OBJECT_TYPE_CLASS
&& dataview_object_p->header.u.class_prop.class_id == LIT_MAGIC_STRING_DATAVIEW_UL);
return ecma_object_class_is (ecma_get_object_from_value (value), ECMA_OBJECT_CLASS_DATAVIEW);
} /* ecma_is_dataview */
/**
+2 -1
View File
@@ -154,7 +154,8 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_CLASS);
((ecma_extended_object_t *) new_error_obj_p)->u.class_prop.class_id = LIT_MAGIC_STRING_ERROR_UL;
((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)
{
@@ -132,28 +132,31 @@ ecma_create_iter_result_object (ecma_value_t value, /**< value */
ecma_value_t
ecma_op_create_iterator_object (ecma_value_t iterated_value, /**< value from create iterator */
ecma_object_t *prototype_obj_p, /**< prototype object */
ecma_pseudo_array_type_t iterator_type, /**< iterator type */
ecma_object_class_type_t iterator_type, /**< iterator type */
ecma_iterator_kind_t kind) /**< iterator kind*/
{
/* 1. */
JERRY_ASSERT (iterator_type >= ECMA_PSEUDO_ARRAY_ITERATOR
&& iterator_type <= ECMA_PSEUDO_ARRAY__MAX
&& kind < ECMA_ITERATOR__COUNT);
JERRY_ASSERT (iterator_type == ECMA_OBJECT_CLASS_ARRAY_ITERATOR
|| iterator_type == ECMA_OBJECT_CLASS_SET_ITERATOR
|| iterator_type == ECMA_OBJECT_CLASS_MAP_ITERATOR
|| iterator_type == ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR
|| iterator_type == ECMA_OBJECT_CLASS_STRING_ITERATOR);
JERRY_ASSERT (kind < ECMA_ITERATOR__COUNT);
/* 2. */
ecma_object_t *object_p = ecma_create_object (prototype_obj_p,
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
ext_obj_p->u.pseudo_array.type = (uint8_t) iterator_type;
ext_obj_p->u.cls.type = (uint8_t) iterator_type;
/* 3. */
ext_obj_p->u.pseudo_array.u2.iterated_value = iterated_value;
ext_obj_p->u.cls.u3.iterated_value = iterated_value;
/* 4. */
ext_obj_p->u.pseudo_array.u1.iterator_index = 0;
ext_obj_p->u.cls.u2.iterator_index = 0;
/* 5. */
ext_obj_p->u.pseudo_array.extra_info = (uint8_t) kind;
ext_obj_p->u.cls.u1.iterator_kind = (uint8_t) kind;
/* 6. */
return ecma_make_object_value (object_p);
@@ -46,7 +46,7 @@ typedef enum
ecma_value_t
ecma_op_create_iterator_object (ecma_value_t iterated_value,
ecma_object_t *prototype_obj_p,
ecma_pseudo_array_type_t iterator_type,
ecma_object_class_type_t iterator_type,
ecma_iterator_kind_t kind);
ecma_value_t
+13 -11
View File
@@ -183,7 +183,7 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the
{
/* 2. */
JERRY_ASSERT (ecma_object_class_is (ecma_get_object_from_value (job_p->capability),
LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
ecma_promise_capabality_t *capability_p;
capability_p = (ecma_promise_capabality_t *) ecma_get_object_from_value (job_p->capability);
@@ -192,7 +192,7 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the
{
JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL);
JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_BEFORE_REACTION_JOB,
capability_p->header.u.class_prop.u.promise,
capability_p->header.u.cls.u3.promise,
ECMA_VALUE_UNDEFINED,
JERRY_CONTEXT (promise_callback_user_p));
}
@@ -250,7 +250,7 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the
{
JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL);
JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_AFTER_REACTION_JOB,
capability_p->header.u.class_prop.u.promise,
capability_p->header.u.cls.u3.promise,
ECMA_VALUE_UNDEFINED,
JERRY_CONTEXT (promise_callback_user_p));
}
@@ -293,7 +293,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
if (ecma_job_queue_get_type (&job_p->header) == ECMA_JOB_PROMISE_ASYNC_REACTION_REJECTED)
{
if (!(executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD))
if (!(executable_object_p->extended_object.u.cls.u2.executable_obj_flags
& ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD))
{
executable_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
}
@@ -321,14 +322,14 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
}
/* Exception: Abort iterators, clear all status. */
executable_object_p->extended_object.u.class_prop.extra_info &= ECMA_AWAIT_CLEAR_MASK;
executable_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK;
executable_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
}
}
ecma_value_t result;
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
{
job_p->argument = ecma_await_continue (executable_object_p, job_p->argument);
@@ -337,7 +338,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
job_p->argument = jcontext_take_exception ();
executable_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
}
else if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
else if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags
& ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
{
/* Continue iteration. */
JERRY_ASSERT (job_p->argument == ECMA_VALUE_UNDEFINED);
@@ -356,15 +358,15 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
}
/* Clear all status. */
executable_object_p->extended_object.u.class_prop.extra_info &= ECMA_AWAIT_CLEAR_MASK;
executable_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK;
}
result = opfunc_resume_executable_object (executable_object_p, job_p->argument);
/* Argument reference has been taken by opfunc_resume_executable_object. */
job_p->argument = ECMA_VALUE_UNDEFINED;
uint16_t expected_bits = (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_ASYNC_GENERATOR_CALLED);
if ((executable_object_p->extended_object.u.class_prop.extra_info & expected_bits) == expected_bits)
const uint16_t expected_bits = (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_ASYNC_GENERATOR_CALLED);
if ((executable_object_p->extended_object.u.cls.u2.executable_obj_flags & expected_bits) == expected_bits)
{
ecma_async_generator_finalize (executable_object_p, result);
result = ECMA_VALUE_UNDEFINED;
@@ -425,7 +427,7 @@ ecma_process_promise_resolve_thenable_job (ecma_job_promise_resolve_thenable_t *
{
ecma_promise_object_t *promise_p = (ecma_promise_object_t *) ecma_get_object_from_value (job_p->promise);
promise_p->header.u.class_prop.extra_info &= (uint16_t) ~ECMA_PROMISE_ALREADY_RESOLVED;
promise_p->header.u.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_ALREADY_RESOLVED;
ecma_value_t ret = ecma_promise_run_executor ((ecma_object_t *) promise_p, job_p->then, job_p->thenable);
@@ -75,10 +75,11 @@ ecma_op_create_number_object (ecma_value_t arg) /**< argument passed to the Numb
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_NUMBER_UL;
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.class_prop.u.value = conv_to_num_completion;
ext_object_p->u.cls.u3.value = conv_to_num_completion;
#if JERRY_ESNEXT
if (new_target)
{
@@ -223,14 +223,14 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */
#else /* !JERRY_ESNEXT */
if (hint == ECMA_PREFERRED_TYPE_NO)
{
if (ecma_object_class_is (obj_p, LIT_MAGIC_STRING_DATE_UL))
hint = ECMA_PREFERRED_TYPE_NUMBER;
#if JERRY_BUILTIN_DATE
if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_DATE))
{
hint = ECMA_PREFERRED_TYPE_STRING;
}
else
{
hint = ECMA_PREFERRED_TYPE_NUMBER;
}
#endif /* JERRY_BUILTIN_DATE */
}
#endif /* JERRY_ESNEXT */
+369 -354
View File
@@ -91,41 +91,99 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL)
switch (ext_object_p->u.cls.type)
{
if (ecma_string_is_length (property_name_p))
case ECMA_OBJECT_CLASS_STRING:
{
if (options & ECMA_PROPERTY_GET_VALUE)
{
ecma_value_t prim_value_p = ext_object_p->u.class_prop.u.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
property_ref_p->virtual_value = ecma_make_uint32_value (length);
}
return ECMA_PROPERTY_VIRTUAL;
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_value_t prim_value_p = ext_object_p->u.class_prop.u.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
if (index < ecma_string_get_length (prim_value_str_p))
if (ecma_string_is_length (property_name_p))
{
if (options & ECMA_PROPERTY_GET_VALUE)
{
ecma_char_t char_at_idx = ecma_string_get_char_at_pos (prim_value_str_p, index);
ecma_string_t *char_str_p = ecma_new_ecma_string_from_code_unit (char_at_idx);
property_ref_p->virtual_value = ecma_make_string_value (char_str_p);
ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
property_ref_p->virtual_value = ecma_make_uint32_value (length);
}
return ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_VIRTUAL;
return ECMA_PROPERTY_VIRTUAL;
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
if (index < ecma_string_get_length (prim_value_str_p))
{
if (options & ECMA_PROPERTY_GET_VALUE)
{
ecma_char_t char_at_idx = ecma_string_get_char_at_pos (prim_value_str_p, index);
ecma_string_t *char_str_p = ecma_new_ecma_string_from_code_unit (char_at_idx);
property_ref_p->virtual_value = ecma_make_string_value (char_str_p);
}
return ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_VIRTUAL;
}
}
break;
}
#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))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
ecma_value_t value = ECMA_VALUE_UNDEFINED;
if (array_index < info.length)
{
uint32_t byte_pos = array_index << info.shift;
value = ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
}
if (!ecma_is_value_undefined (value))
{
if (options & ECMA_PROPERTY_GET_VALUE)
{
property_ref_p->virtual_value = value;
}
else
{
ecma_fast_free_value (value);
}
return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL;
}
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
{
ecma_deref_ecma_string (num_to_str);
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
ecma_deref_ecma_string (num_to_str);
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
}
break;
}
@@ -173,63 +231,6 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
break;
}
#if JERRY_BUILTIN_TYPEDARRAY
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
/* ES2015 9.4.5.1 */
if (ecma_object_is_typedarray (object_p))
{
if (ecma_prop_name_is_symbol (property_name_p))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
ecma_value_t value = ECMA_VALUE_UNDEFINED;
if (array_index < info.length)
{
uint32_t byte_pos = array_index << info.shift;
value = ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
}
if (!ecma_is_value_undefined (value))
{
if (options & ECMA_PROPERTY_GET_VALUE)
{
property_ref_p->virtual_value = value;
}
else
{
ecma_fast_free_value (value);
}
return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL;
}
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
{
ecma_deref_ecma_string (num_to_str);
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
ecma_deref_ecma_string (num_to_str);
}
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
default:
{
break;
@@ -255,6 +256,14 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
{
switch (type)
{
case ECMA_OBJECT_TYPE_CLASS:
{
if (((ecma_extended_object_t *) object_p)->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS)
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
}
break;
}
case ECMA_OBJECT_TYPE_FUNCTION:
{
#if !JERRY_ESNEXT
@@ -299,14 +308,6 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
property_p = ecma_op_bound_function_try_to_lazy_instantiate_property (object_p, property_name_p);
break;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
if (((ecma_extended_object_t *) object_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS)
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
}
break;
}
default:
{
break;
@@ -319,15 +320,15 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
return ECMA_PROPERTY_TYPE_NOT_FOUND;
}
}
else if (type == ECMA_OBJECT_TYPE_PSEUDO_ARRAY
&& ((ecma_extended_object_t *) object_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS
&& (((ecma_extended_object_t *) object_p)->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED))
else if (type == ECMA_OBJECT_TYPE_CLASS
&& ((ecma_extended_object_t *) object_p)->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS
&& (((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ext_object_p->u.pseudo_array.u1.formal_params_number)
if (index < ext_object_p->u.cls.u2.formal_params_number)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
@@ -445,34 +446,101 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL)
switch (ext_object_p->u.cls.type)
{
if (ecma_string_is_length (property_name_p))
case ECMA_OBJECT_CLASS_STRING:
{
ecma_value_t prim_value_p = ext_object_p->u.class_prop.u.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
return ecma_make_uint32_value (length);
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_value_t prim_value_p = ext_object_p->u.class_prop.u.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
if (index < ecma_string_get_length (prim_value_str_p))
if (ecma_string_is_length (property_name_p))
{
ecma_char_t char_at_idx = ecma_string_get_char_at_pos (prim_value_str_p, index);
return ecma_make_string_value (ecma_new_ecma_string_from_code_unit (char_at_idx));
}
}
}
ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
return ecma_make_uint32_value (length);
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
if (index < ecma_string_get_length (prim_value_str_p))
{
ecma_char_t char_at_idx = ecma_string_get_char_at_pos (prim_value_str_p, index);
return ecma_make_string_value (ecma_new_ecma_string_from_code_unit (char_at_idx));
}
}
break;
}
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
if (!(ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
break;
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ext_object_p->u.cls.u2.formal_params_number)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
ecma_value_t *argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
if (!ecma_is_value_empty (argv_p[index]))
{
ecma_string_t *name_p = ecma_op_arguments_object_get_formal_parameter (mapped_arguments_p, index);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env);
return ecma_op_get_binding_value (lex_env_p, name_p, true);
}
}
break;
}
#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))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
if (array_index >= info.length)
{
return ECMA_VALUE_UNDEFINED;
}
uint32_t byte_pos = array_index << info.shift;
return ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
{
ecma_deref_ecma_string (num_to_str);
return ECMA_VALUE_UNDEFINED;
}
ecma_deref_ecma_string (num_to_str);
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
}
break;
}
case ECMA_OBJECT_TYPE_ARRAY:
@@ -503,70 +571,6 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
break;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS
&& ext_object_p->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ext_object_p->u.pseudo_array.u1.formal_params_number)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
ecma_value_t *argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
if (!ecma_is_value_empty (argv_p[index]))
{
ecma_string_t *name_p = ecma_op_arguments_object_get_formal_parameter (mapped_arguments_p, index);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env);
return ecma_op_get_binding_value (lex_env_p, name_p, true);
}
}
}
#if JERRY_BUILTIN_TYPEDARRAY
/* ES2015 9.4.5.4 */
if (ecma_object_is_typedarray (object_p))
{
if (ecma_prop_name_is_symbol (property_name_p))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
if (array_index >= info.length)
{
return ECMA_VALUE_UNDEFINED;
}
uint32_t byte_pos = array_index << info.shift;
return ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
{
ecma_deref_ecma_string (num_to_str);
return ECMA_VALUE_UNDEFINED;
}
ecma_deref_ecma_string (num_to_str);
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
break;
}
default:
{
break;
@@ -592,6 +596,14 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
{
switch (type)
{
case ECMA_OBJECT_TYPE_CLASS:
{
if (((ecma_extended_object_t *) object_p)->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS)
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
}
break;
}
case ECMA_OBJECT_TYPE_FUNCTION:
{
#if !JERRY_ESNEXT
@@ -631,14 +643,6 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
property_p = ecma_op_bound_function_try_to_lazy_instantiate_property (object_p, property_name_p);
break;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
if (((ecma_extended_object_t *) object_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS)
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
}
break;
}
default:
{
break;
@@ -1258,6 +1262,77 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
switch (type)
{
case ECMA_OBJECT_TYPE_CLASS:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
switch (ext_object_p->u.cls.type)
{
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
if (!(ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
break;
}
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ext_object_p->u.cls.u2.formal_params_number)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
ecma_value_t *argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
if (!ecma_is_value_empty (argv_p[index]))
{
ecma_string_t *name_p = ecma_op_arguments_object_get_formal_parameter (mapped_arguments_p, index);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env);
ecma_op_set_mutable_binding (lex_env_p, name_p, value, true);
return ECMA_VALUE_TRUE;
}
}
break;
}
#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))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
if (array_index >= info.length)
{
return ECMA_VALUE_FALSE;
}
uint32_t byte_pos = array_index << info.shift;
return ecma_set_typedarray_element (info.buffer_p + byte_pos, value, info.id);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
bool is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
ecma_deref_ecma_string (num_to_str);
if (is_same)
{
return ECMA_VALUE_FALSE;
}
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
}
break;
}
case ECMA_OBJECT_TYPE_ARRAY:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -1287,68 +1362,6 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
}
JERRY_ASSERT (!ecma_op_object_is_fast_array (object_p));
break;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS
&& (ext_object_p->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED))
{
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ext_object_p->u.pseudo_array.u1.formal_params_number)
{
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
ecma_value_t *argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
if (!ecma_is_value_empty (argv_p[index]))
{
ecma_string_t *name_p = ecma_op_arguments_object_get_formal_parameter (mapped_arguments_p, index);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env);
ecma_op_set_mutable_binding (lex_env_p, name_p, value, true);
return ECMA_VALUE_TRUE;
}
}
}
#if JERRY_BUILTIN_TYPEDARRAY
/* ES2015 9.4.5.5 */
if (ecma_object_is_typedarray (object_p))
{
if (ecma_prop_name_is_symbol (property_name_p))
{
break;
}
uint32_t array_index = ecma_string_get_array_index (property_name_p);
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
if (array_index >= info.length)
{
return ECMA_VALUE_FALSE;
}
uint32_t byte_pos = array_index << info.shift;
return ecma_set_typedarray_element (info.buffer_p + byte_pos, value, info.id);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
bool is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
ecma_deref_ecma_string (num_to_str);
if (is_same)
{
return ECMA_VALUE_FALSE;
}
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
break;
}
default:
@@ -1380,19 +1393,28 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL)
switch (ext_object_p->u.cls.type)
{
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
case ECMA_OBJECT_CLASS_STRING:
{
ecma_value_t prim_value_p = ext_object_p->u.class_prop.u.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
uint32_t index = ecma_string_get_array_index (property_name_p);
if (index < ecma_string_get_length (prim_value_str_p))
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
{
return ecma_raise_readonly_assignment (property_name_p, is_throw);
ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value;
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_p);
if (index < ecma_string_get_length (prim_value_str_p))
{
return ecma_raise_readonly_assignment (property_name_p, is_throw);
}
}
break;
}
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
break;
}
}
break;
@@ -1424,14 +1446,6 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
property_p = ecma_op_bound_function_try_to_lazy_instantiate_property (object_p, property_name_p);
break;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
if (((ecma_extended_object_t *) object_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS)
{
property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p);
}
break;
}
default:
{
break;
@@ -1539,12 +1553,12 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
{
const ecma_object_type_t obj_type = ecma_get_object_type (object_p);
if (obj_type == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
if (obj_type == ECMA_OBJECT_TYPE_CLASS)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS
&& ext_object_p->u.pseudo_array.extra_info & ECMA_ARGUMENTS_OBJECT_MAPPED)
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS
&& ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
{
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
return ecma_builtin_helper_def_prop (object_p, property_name_p, value, flags);
@@ -1652,16 +1666,11 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
&& !ecma_is_lexical_environment (obj_p));
JERRY_ASSERT (property_name_p != NULL);
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARGUMENTS))
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
if (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS)
{
return ecma_op_arguments_object_delete (obj_p,
property_name_p,
is_strict);
}
return ecma_op_arguments_object_delete (obj_p,
property_name_p,
is_strict);
}
#if JERRY_BUILTIN_PROXY
@@ -1738,35 +1747,37 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
switch (type)
{
case ECMA_OBJECT_TYPE_CLASS:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
switch (ext_object_p->u.cls.type)
{
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
return ecma_op_arguments_object_define_own_property (obj_p, property_name_p, property_desc_p);
}
#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);
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
}
break;
}
case ECMA_OBJECT_TYPE_ARRAY:
{
return ecma_op_array_object_define_own_property (obj_p, property_name_p, property_desc_p);
}
#if JERRY_BUILTIN_PROXY
case ECMA_OBJECT_TYPE_PROXY:
{
return ecma_proxy_object_define_own_property (obj_p, property_name_p, property_desc_p);
}
#endif /* JERRY_BUILTIN_PROXY */
case ECMA_OBJECT_TYPE_ARRAY:
{
return ecma_op_array_object_define_own_property (obj_p, property_name_p, property_desc_p);
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
#if JERRY_BUILTIN_TYPEDARRAY
if (ecma_object_is_typedarray (obj_p))
{
return ecma_op_typedarray_define_own_property (obj_p, property_name_p, property_desc_p);
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_ESNEXT
/* All iterators are pseudo arrays */
if (((ecma_extended_object_t *) obj_p)->u.pseudo_array.type != ECMA_PSEUDO_ARRAY_ARGUMENTS)
{
break;
}
#endif /* JERRY_ESNEXT */
return ecma_op_arguments_object_define_own_property (obj_p, property_name_p, property_desc_p);
}
default:
{
break;
@@ -2158,18 +2169,32 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
{
switch (type)
{
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
case ECMA_OBJECT_TYPE_CLASS:
{
if (((ecma_extended_object_t *) obj_p)->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS)
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
switch (ext_object_p->u.cls.type)
{
ecma_op_arguments_object_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
}
case ECMA_OBJECT_CLASS_STRING:
{
ecma_op_string_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
break;
}
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
ecma_op_arguments_object_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
break;
}
#if JERRY_BUILTIN_TYPEDARRAY
if (ecma_object_is_typedarray (obj_p))
{
ecma_op_typedarray_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
}
/* 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;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
}
break;
}
case ECMA_OBJECT_TYPE_FUNCTION:
@@ -2187,17 +2212,6 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
ecma_op_bound_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
break;
}
case ECMA_OBJECT_TYPE_CLASS:
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL)
{
ecma_op_string_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
}
break;
}
case ECMA_OBJECT_TYPE_ARRAY:
{
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
@@ -2685,54 +2699,53 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
return (lit_magic_string_id_t) ext_object_p->u.class_prop.class_id;
}
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
switch (ext_obj_p->u.pseudo_array.type)
switch (ext_object_p->u.cls.type)
{
#if JERRY_BUILTIN_TYPEDARRAY
case ECMA_PSEUDO_ARRAY_TYPEDARRAY:
case ECMA_PSEUDO_ARRAY_TYPEDARRAY_WITH_INFO:
case ECMA_OBJECT_CLASS_ARGUMENTS:
{
return (lit_magic_string_id_t) ext_obj_p->u.pseudo_array.u1.class_id;
return LIT_MAGIC_STRING_ARGUMENTS_UL;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_ESNEXT
case ECMA_PSEUDO_ARRAY_ITERATOR:
case ECMA_OBJECT_CLASS_GENERATOR:
{
return LIT_MAGIC_STRING_GENERATOR_UL;
}
case ECMA_OBJECT_CLASS_ASYNC_GENERATOR:
{
return LIT_MAGIC_STRING_ASYNC_GENERATOR_UL;
}
case ECMA_OBJECT_CLASS_ARRAY_ITERATOR:
{
return LIT_MAGIC_STRING_ARRAY_ITERATOR_UL;
}
case ECMA_PSEUDO_SET_ITERATOR:
case ECMA_OBJECT_CLASS_SET_ITERATOR:
{
return LIT_MAGIC_STRING_SET_ITERATOR_UL;
}
case ECMA_PSEUDO_MAP_ITERATOR:
case ECMA_OBJECT_CLASS_MAP_ITERATOR:
{
return LIT_MAGIC_STRING_MAP_ITERATOR_UL;
}
#endif /* JERRY_ESNEXT */
#if JERRY_ESNEXT
case ECMA_PSEUDO_STRING_ITERATOR:
{
return LIT_MAGIC_STRING_STRING_ITERATOR_UL;
}
case ECMA_PSEUDO_REGEXP_STRING_ITERATOR:
#if JERRY_BUILTIN_REGEXP
case ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR:
{
return LIT_MAGIC_STRING_REGEXP_STRING_ITERATOR_UL;
}
#endif /* JERRY_ESNEXT */
default:
#endif /* JERRY_BUILTIN_REGEXP */
case ECMA_OBJECT_CLASS_STRING_ITERATOR:
{
JERRY_ASSERT (ext_obj_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS);
return LIT_MAGIC_STRING_ARGUMENTS_UL;
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 */
}
break;
return (lit_magic_string_id_t) ext_object_p->u.cls.u2.id;
}
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
@@ -2841,13 +2854,13 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
*/
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_class_is (ecma_object_t *object_p, /**< object */
uint32_t class_id) /**< class id */
ecma_object_class_type_t class_id) /**< class id */
{
if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == class_id)
if (ext_object_p->u.cls.type == (uint8_t) class_id)
{
return true;
}
@@ -2856,6 +2869,7 @@ ecma_object_class_is (ecma_object_t *object_p, /**< object */
return false;
} /* ecma_object_class_is */
#if JERRY_BUILTIN_REGEXP
/**
* Checks if the given argument has [[RegExpMatcher]] internal slot
*
@@ -2866,8 +2880,9 @@ extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_is_regexp_object (ecma_value_t arg) /**< argument */
{
return (ecma_is_value_object (arg)
&& ecma_object_class_is (ecma_get_object_from_value (arg), LIT_MAGIC_STRING_REGEXP_UL));
&& ecma_object_class_is (ecma_get_object_from_value (arg), ECMA_OBJECT_CLASS_REGEXP));
} /* ecma_object_is_regexp_object */
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_ESNEXT
/**
+3 -1
View File
@@ -100,8 +100,10 @@ ecma_collection_t *ecma_op_object_own_property_keys (ecma_object_t *obj_p);
ecma_collection_t *ecma_op_object_enumerate (ecma_object_t *obj_p);
lit_magic_string_id_t ecma_object_get_class_name (ecma_object_t *obj_p);
bool ecma_object_class_is (ecma_object_t *object_p, uint32_t class_id);
bool ecma_object_class_is (ecma_object_t *object_p, ecma_object_class_type_t class_id);
#if JERRY_BUILTIN_REGEXP
bool ecma_object_is_regexp_object (ecma_value_t arg);
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_ESNEXT
ecma_value_t ecma_op_is_concat_spreadable (ecma_value_t arg);
ecma_value_t ecma_op_is_regexp (ecma_value_t arg);
@@ -47,7 +47,7 @@
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_promise (ecma_object_t *obj_p) /**< points to object */
{
return ecma_object_class_is (obj_p, LIT_MAGIC_STRING_PROMISE_UL);
return ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_PROMISE);
} /* ecma_is_promise */
/**
@@ -63,7 +63,7 @@ ecma_promise_get_result (ecma_object_t *obj_p) /**< points to promise object */
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
return ecma_copy_value (ext_object_p->u.cls.u3.value);
} /* ecma_promise_get_result */
/**
@@ -77,9 +77,9 @@ ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
JERRY_ASSERT (ext_object_p->u.class_prop.u.value == ECMA_VALUE_UNDEFINED);
JERRY_ASSERT (ext_object_p->u.cls.u3.value == ECMA_VALUE_UNDEFINED);
ext_object_p->u.class_prop.u.value = result;
ext_object_p->u.cls.u3.value = result;
} /* ecma_promise_set_result */
/**
@@ -87,12 +87,12 @@ ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */
*
* @return the state's enum value
*/
uint16_t
uint8_t
ecma_promise_get_flags (ecma_object_t *obj_p) /**< points to promise object */
{
JERRY_ASSERT (ecma_is_promise (obj_p));
return ((ecma_extended_object_t *) obj_p)->u.class_prop.extra_info;
return ((ecma_extended_object_t *) obj_p)->u.cls.u1.promise_flags;
} /* ecma_promise_get_flags */
/**
@@ -105,10 +105,10 @@ ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */
JERRY_ASSERT (ecma_is_promise (obj_p));
JERRY_ASSERT (ecma_promise_get_flags (obj_p) & ECMA_PROMISE_IS_PENDING);
uint16_t flags_to_invert = (is_fulfilled ? (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED)
: ECMA_PROMISE_IS_PENDING);
uint8_t flags_to_invert = (is_fulfilled ? (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED)
: ECMA_PROMISE_IS_PENDING);
((ecma_extended_object_t *) obj_p)->u.class_prop.extra_info ^= flags_to_invert;
((ecma_extended_object_t *) obj_p)->u.cls.u1.promise_flags ^= flags_to_invert;
} /* ecma_promise_set_state */
/**
@@ -219,7 +219,7 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */
#if JERRY_PROMISE_CALLBACK
if (reactions->item_count == 0)
{
((ecma_extended_object_t *) obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_UNHANDLED_REJECT;
((ecma_extended_object_t *) obj_p)->u.cls.u1.promise_flags |= ECMA_PROMISE_UNHANDLED_REJECT;
if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR))
{
@@ -341,7 +341,7 @@ ecma_reject_promise_with_checks (ecma_value_t promise, /**< promise */
}
/* 5. */
((ecma_extended_object_t *) promise_obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_ALREADY_RESOLVED;
((ecma_extended_object_t *) promise_obj_p)->u.cls.u1.promise_flags |= ECMA_PROMISE_ALREADY_RESOLVED;
/* 6. */
ecma_reject_promise (promise, reason);
@@ -381,7 +381,7 @@ ecma_fulfill_promise_with_checks (ecma_value_t promise, /**< promise */
}
/* 5. */
((ecma_extended_object_t *) promise_obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_ALREADY_RESOLVED;
((ecma_extended_object_t *) promise_obj_p)->u.cls.u1.promise_flags |= ECMA_PROMISE_ALREADY_RESOLVED;
ecma_fulfill_promise (promise, value);
return ECMA_VALUE_UNDEFINED;
@@ -504,10 +504,11 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function
ECMA_OBJECT_TYPE_CLASS);
ecma_deref_object (proto_p);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_PROMISE_UL;
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_PROMISE;
/* 5 */
ext_object_p->u.class_prop.extra_info = ECMA_PROMISE_IS_PENDING;
ext_object_p->u.class_prop.u.value = ECMA_VALUE_UNDEFINED;
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. */
ecma_promise_object_t *promise_object_p = (ecma_promise_object_t *) object_p;
@@ -571,11 +572,11 @@ ecma_promise_remaining_inc_or_dec (ecma_value_t remaining, /**< the remaining co
ecma_object_t *remaining_p = ecma_get_object_from_value (remaining);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) remaining_p;
JERRY_ASSERT (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_NUMBER_UL);
JERRY_ASSERT (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_NUMBER);
JERRY_ASSERT (ecma_is_value_integer_number (ext_object_p->u.class_prop.u.value));
JERRY_ASSERT (ecma_is_value_integer_number (ext_object_p->u.cls.u3.value));
uint32_t current = (uint32_t) ecma_get_integer_from_value (ext_object_p->u.class_prop.u.value);
uint32_t current = (uint32_t) ecma_get_integer_from_value (ext_object_p->u.cls.u3.value);
if (is_inc)
{
@@ -585,7 +586,7 @@ ecma_promise_remaining_inc_or_dec (ecma_value_t remaining, /**< the remaining co
{
current--;
}
ext_object_p->u.class_prop.u.value = ecma_make_uint32_value (current);
ext_object_p->u.cls.u3.value = ecma_make_uint32_value (current);
return current;
} /* ecma_promise_remaining_inc_or_dec */
@@ -605,7 +606,9 @@ ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, /**<
{
JERRY_UNUSED (args_count);
ecma_promise_all_executor_t *executor_p = (ecma_promise_all_executor_t *) function_obj_p;
uint16_t promise_type = executor_p->header.u.class_prop.extra_info;
uint8_t promise_type = executor_p->header.u.built_in.u2.routine_flags;
promise_type = (uint8_t) (promise_type >> ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT);
/* 1 - 2. */
if (executor_p->index == 0)
@@ -710,7 +713,7 @@ ecma_op_get_capabilities_executor_cb (ecma_object_t *function_obj_p, /**< functi
/* 2-3. */
ecma_object_t *capability_obj_p = ecma_get_object_from_value (executor_p->capability);
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
/* 4. */
@@ -761,8 +764,9 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function
ECMA_OBJECT_TYPE_CLASS);
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
capability_p->header.u.class_prop.class_id = LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY;
capability_p->header.u.class_prop.u.promise = ECMA_VALUE_UNDEFINED;
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;
@@ -814,7 +818,7 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function
}
/* 10. */
capability_p->header.u.class_prop.u.promise = promise;
capability_p->header.u.cls.u3.promise = promise;
ecma_free_value (promise);
@@ -884,7 +888,7 @@ ecma_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argument */
ecma_free_value (call_ret);
ecma_value_t promise = ecma_copy_value (capability_p->header.u.class_prop.u.promise);
ecma_value_t promise = ecma_copy_value (capability_p->header.u.cls.u3.promise);
ecma_deref_object (capability_obj_p);
return promise;
@@ -905,7 +909,7 @@ ecma_promise_do_then (ecma_value_t promise, /**< the promise which call 'then' *
ecma_value_t on_rejected, /**< on_rejected function */
ecma_object_t *result_capability_obj_p) /**< promise capability */
{
JERRY_ASSERT (ecma_object_class_is (result_capability_obj_p, LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
JERRY_ASSERT (ecma_object_class_is (result_capability_obj_p, ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) result_capability_obj_p;
@@ -969,7 +973,7 @@ ecma_promise_do_then (ecma_value_t promise, /**< the promise which call 'then' *
#if JERRY_PROMISE_CALLBACK
if (ecma_promise_get_flags (promise_obj_p) & ECMA_PROMISE_UNHANDLED_REJECT)
{
promise_p->header.u.class_prop.extra_info &= (uint16_t) ~ECMA_PROMISE_UNHANDLED_REJECT;
promise_p->header.u.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT;
if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR))
{
@@ -984,7 +988,7 @@ ecma_promise_do_then (ecma_value_t promise, /**< the promise which call 'then' *
}
/* 10. */
return ecma_copy_value (capability_p->header.u.class_prop.u.promise);
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
} /* ecma_promise_do_then */
/**
@@ -1284,7 +1288,7 @@ ecma_promise_async_then (ecma_value_t promise, /**< promise object */
#if JERRY_PROMISE_CALLBACK
if (ecma_promise_get_flags (promise_obj_p) & ECMA_PROMISE_UNHANDLED_REJECT)
{
((ecma_extended_object_t *) promise_obj_p)->u.class_prop.extra_info &= (uint16_t) ~ECMA_PROMISE_UNHANDLED_REJECT;
((ecma_extended_object_t *) promise_obj_p)->u.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT;
if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR))
{
@@ -98,7 +98,7 @@ typedef struct
bool ecma_is_promise (ecma_object_t *obj_p);
ecma_value_t ecma_op_create_promise_object (ecma_value_t executor, ecma_value_t parent,
ecma_object_t *new_target_p);
uint16_t ecma_promise_get_flags (ecma_object_t *promise_p);
uint8_t ecma_promise_get_flags (ecma_object_t *promise_p);
ecma_value_t ecma_promise_get_result (ecma_object_t *promise_p);
void ecma_reject_promise (ecma_value_t promise, ecma_value_t reason);
void ecma_fulfill_promise (ecma_value_t promise, ecma_value_t value);
+10 -12
View File
@@ -244,7 +244,7 @@ ecma_op_regexp_alloc (ecma_object_t *ctr_obj_p) /**< constructor object pointer
ecma_extended_object_t *regexp_obj_p = (ecma_extended_object_t *) new_object_p;
/* Class id will be initialized after the bytecode is compiled. */
regexp_obj_p->u.class_prop.class_id = LIT_MAGIC_STRING_UNDEFINED;
regexp_obj_p->u.cls.type = ECMA_OBJECT_CLASS__MAX;
ecma_value_t status = ecma_builtin_helper_def_prop (new_object_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
@@ -268,7 +268,7 @@ ecma_op_regexp_initialize (ecma_object_t *regexp_obj_p, /**< RegExp object */
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) regexp_obj_p;
#if !JERRY_ESNEXT
if (ext_obj_p->u.class_prop.class_id == LIT_MAGIC_STRING_UNDEFINED)
if (ext_obj_p->u.cls.type == ECMA_OBJECT_CLASS__MAX)
{
/* This instance has not been initialized before. */
ecma_regexp_create_props (regexp_obj_p, pattern_str_p, flags);
@@ -284,8 +284,9 @@ ecma_op_regexp_initialize (ecma_object_t *regexp_obj_p, /**< RegExp object */
JERRY_UNUSED (flags);
#endif /* JERRY_ESNEXT */
ext_obj_p->u.class_prop.class_id = LIT_MAGIC_STRING_REGEXP_UL;
ECMA_SET_INTERNAL_VALUE_POINTER (ext_obj_p->u.class_prop.u.value, bc_p);
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 */
/**
@@ -1736,8 +1737,7 @@ ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, /**< RegExp object */
/* 9. */
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) regexp_object_p;
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t,
ext_object_p->u.class_prop.u.value);
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ext_object_p->u.cls.u3.value);
/* 3. */
lit_utf8_size_t input_size;
@@ -2452,8 +2452,7 @@ cleanup_string:
ecma_object_t *const regexp_p = ecma_get_object_from_value (this_arg);
ecma_extended_object_t *const ext_object_p = (ecma_extended_object_t *) regexp_p;
re_compiled_code_t *const bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t,
ext_object_p->u.class_prop.u.value);
re_compiled_code_t *const bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ext_object_p->u.cls.u3.value);
lit_utf8_size_t string_size;
lit_utf8_size_t string_length;
@@ -2611,8 +2610,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont
ecma_string_t *string_p, /**< source string */
ecma_value_t replace_arg) /**< replace argument */
{
const re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
re_obj_p->u.class_prop.u.value);
const re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value);
ecma_bytecode_ref ((ecma_compiled_code_t *) bc_p);
JERRY_ASSERT (bc_p != NULL);
@@ -2972,7 +2970,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
if (ecma_op_is_callable (result))
{
ecma_extended_object_t *function_p = (ecma_extended_object_t *) ecma_get_object_from_value (result);
if (ecma_object_class_is (this_obj_p, LIT_MAGIC_STRING_REGEXP_UL)
if (ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_REGEXP)
&& ecma_builtin_is_regexp_exec (function_p))
{
ecma_deref_object ((ecma_object_t *) function_p);
@@ -3016,7 +3014,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
{
ecma_free_value (result);
if (!ecma_object_class_is (this_obj_p, LIT_MAGIC_STRING_REGEXP_UL))
if (!ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_REGEXP))
{
result = ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a valid RegExp object"));
goto cleanup_results;
@@ -85,8 +85,9 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL;
ext_object_p->u.class_prop.u.value = prim_value;
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
if (new_target)
@@ -110,9 +111,9 @@ ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, /**< a String obj
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
JERRY_ASSERT (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL);
JERRY_ASSERT (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_STRING);
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ext_object_p->u.class_prop.u.value);
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ext_object_p->u.cls.u3.value);
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
@@ -90,8 +90,9 @@ ecma_op_create_symbol_object (const ecma_value_t value) /**< symbol value */
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_SYMBOL_UL;
ext_object_p->u.class_prop.u.value = ecma_copy_value (value);
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);
} /* ecma_op_create_symbol_object */
@@ -166,9 +167,9 @@ ecma_symbol_this_value (ecma_value_t this_arg) /**< this argument value */
{
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
if (ext_obj_p->u.class_prop.class_id == LIT_MAGIC_STRING_SYMBOL_UL)
if (ext_obj_p->u.cls.type == ECMA_OBJECT_CLASS_SYMBOL)
{
return ext_obj_p->u.class_prop.u.value;
return ext_obj_p->u.cls.u3.value;
}
}
}
@@ -707,7 +707,7 @@ ecma_get_typedarray_id (ecma_object_t *obj_p) /**< typedarray object **/
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
return (ecma_typedarray_type_t) ext_object_p->u.pseudo_array.extra_info;
return (ecma_typedarray_type_t) ext_object_p->u.cls.u1.typedarray_type;
} /* ecma_get_typedarray_id */
/**
@@ -784,13 +784,13 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of
ecma_object_t *object_p = ecma_create_object (proto_p,
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.pseudo_array.u1.class_id = ecma_typedarray_magic_string_list[typedarray_id];
ext_object_p->u.pseudo_array.type = ECMA_PSEUDO_ARRAY_TYPEDARRAY;
ext_object_p->u.pseudo_array.extra_info = (uint8_t) typedarray_id;
ext_object_p->u.pseudo_array.u2.arraybuffer = ecma_make_object_value (new_arraybuffer_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.u3.arraybuffer = ecma_make_object_value (new_arraybuffer_p);
ecma_deref_object (new_arraybuffer_p);
@@ -824,17 +824,17 @@ ecma_typedarray_create_object_with_buffer (ecma_object_t *arraybuffer_p, /**< th
size_t object_size = (needs_ext_typedarray_obj ? sizeof (ecma_extended_typedarray_object_t)
: sizeof (ecma_extended_object_t));
ecma_object_t *object_p = ecma_create_object (proto_p, object_size, ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
ecma_object_t *object_p = ecma_create_object (proto_p, object_size, ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.pseudo_array.u1.class_id = ecma_typedarray_magic_string_list[typedarray_id];
ext_object_p->u.pseudo_array.type = ECMA_PSEUDO_ARRAY_TYPEDARRAY;
ext_object_p->u.pseudo_array.extra_info = (uint8_t) typedarray_id;
ext_object_p->u.pseudo_array.u2.arraybuffer = ecma_make_object_value (arraybuffer_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.u3.arraybuffer = ecma_make_object_value (arraybuffer_p);
if (needs_ext_typedarray_obj)
{
ext_object_p->u.pseudo_array.type = ECMA_PSEUDO_ARRAY_TYPEDARRAY_WITH_INFO;
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY_WITH_INFO;
ecma_extended_typedarray_object_t *typedarray_info_p = (ecma_extended_typedarray_object_t *) object_p;
typedarray_info_p->array_length = array_length;
@@ -1223,7 +1223,7 @@ ecma_typedarray_get_arraybuffer (ecma_object_t *typedarray_p) /**< the pointer t
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
return ecma_get_object_from_value (ext_object_p->u.pseudo_array.u2.arraybuffer);
return ecma_get_object_from_value (ext_object_p->u.cls.u3.arraybuffer);
} /* ecma_typedarray_get_arraybuffer */
/**
@@ -1251,9 +1251,9 @@ 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.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY)
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY)
{
ecma_object_t *arraybuffer_p = ecma_get_object_from_value (ext_object_p->u.pseudo_array.u2.arraybuffer);
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);
uint8_t shift = ecma_typedarray_get_element_size_shift (typedarray_p);
@@ -1283,7 +1283,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.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY)
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_TYPEDARRAY)
{
return 0;
}
@@ -1380,7 +1380,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li
element_size_shift,
typedarray_id);
}
else if (ecma_object_class_is (obj_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
else if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
{
/* 22.2.1.5 */
ecma_object_t *arraybuffer_p = obj_p;
@@ -1498,7 +1498,7 @@ ecma_typedarray_iterators_helper (ecma_value_t this_arg, /**< this argument */
return ecma_op_create_iterator_object (this_arg,
prototype_obj_p,
ECMA_PSEUDO_ARRAY_ITERATOR,
ECMA_OBJECT_CLASS_ARRAY_ITERATOR,
kind);
} /* ecma_typedarray_iterators_helper */
@@ -1513,12 +1513,12 @@ 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_PSEUDO_ARRAY)
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.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY)
|| (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY_WITH_INFO));
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;