diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c index 60f8023fd0..d7e19dd645 100644 --- a/jerry-core/api/jerryscript.c +++ b/jerry-core/api/jerryscript.c @@ -5993,7 +5993,7 @@ jerry_arraybuffer_external (uint8_t *buffer_p, /**< the backing store used by th if (buffer_p != NULL) { - arraybuffer_pointer_p->extended_object.u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED; + arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; arraybuffer_pointer_p->buffer_p = buffer_p; } } @@ -6081,7 +6081,7 @@ jerry_shared_arraybuffer_external (uint8_t *buffer_p, /**< the backing store use if (buffer_p != NULL) { - shared_arraybuffer_pointer_p->extended_object.u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED; + shared_arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; shared_arraybuffer_pointer_p->buffer_p = buffer_p; } } @@ -6529,7 +6529,7 @@ jerry_dataview_buffer (const jerry_value_t value, /**< DataView to get the array if (byte_length != NULL) { - *byte_length = dataview_p->header.u.cls.u3.length; + *byte_length = dataview_p->header.u.clz.dataview.length; } ecma_object_t *arraybuffer_p = dataview_p->buffer_p; diff --git a/jerry-core/ecma/base/ecma-gc.c b/jerry-core/ecma/base/ecma-gc.c index 0cba365dee..1a9f9e3863 100644 --- a/jerry-core/ecma/base/ecma-gc.c +++ b/jerry-core/ecma/base/ecma-gc.c @@ -208,7 +208,7 @@ ecma_gc_mark_arguments_object (ecma_extended_object_t *ext_object_p) /**< argume ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1); - if (ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED) + if (ext_object_p->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; argv_p = (ecma_value_t *) (mapped_arguments_p + 1); @@ -216,7 +216,7 @@ ecma_gc_mark_arguments_object (ecma_extended_object_t *ext_object_p) /**< argume ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env)); } - uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number; + uint32_t arguments_number = arguments_p->header.u.clz.arguments.number; for (uint32_t i = 0; i < arguments_number; i++) { @@ -1336,13 +1336,13 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments size_t object_size = sizeof (ecma_unmapped_arguments_t); - if (ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED) + if (ext_object_p->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; object_size = sizeof (ecma_mapped_arguments_t); #if JERRY_SNAPSHOT_EXEC - if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)) + if (!(mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)) #endif /* JERRY_SNAPSHOT_EXEC */ { ecma_compiled_code_t *byte_code_p = @@ -1354,14 +1354,15 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments ecma_value_t *argv_p = (ecma_value_t *) (((uint8_t *) ext_object_p) + object_size); ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) ext_object_p; - uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number; + uint32_t arguments_number = arguments_p->header.u.clz.arguments.number; for (uint32_t i = 0; i < arguments_number; i++) { ecma_free_value_if_not_object (argv_p[i]); } - uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number); + uint32_t saved_argument_count = + JERRY_MAX (arguments_number, arguments_p->header.u.clz.arguments.formal_params_number); return object_size + (saved_argument_count * sizeof (ecma_value_t)); } /* ecma_free_arguments_object */ @@ -1781,7 +1782,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ #if JERRY_BUILTIN_TYPEDARRAY case ECMA_OBJECT_CLASS_TYPEDARRAY: { - if (ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED) + if (ext_object_p->u.clz.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED) { ext_object_size = sizeof (ecma_extended_typedarray_object_t); } @@ -1858,7 +1859,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ { if (!(ECMA_ARRAYBUFFER_GET_FLAGS (ext_object_p) & ECMA_ARRAYBUFFER_HAS_POINTER)) { - ext_object_size += ext_object_p->u.cls.u3.length; + ext_object_size += ext_object_p->u.clz.arraybuffer.length; break; } diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 75c70e196b..d685aa963d 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -1025,7 +1025,6 @@ typedef struct */ union { - uint8_t arguments_flags; /**< arguments object flags */ uint8_t error_type; /**< jerry_error_t type of native error objects */ #if JERRY_BUILTIN_DATE uint8_t date_flags; /**< flags for date objects */ @@ -1039,17 +1038,12 @@ typedef struct #if JERRY_BUILTIN_CONTAINER uint8_t container_flags; /**< container object flags */ #endif /* JERRY_BUILTIN_CONTAINER */ -#if JERRY_BUILTIN_TYPEDARRAY - uint8_t array_buffer_flags; /**< ArrayBuffer flags */ - uint8_t typedarray_type; /**< type of typed array */ -#endif /* JERRY_BUILTIN_TYPEDARRAY */ } u1; /** * Description of 16 bit extra fields. These extra fields depend on the type. */ union { - uint16_t formal_params_number; /**< for arguments: formal parameters number */ #if JERRY_MODULE_SYSTEM uint16_t module_flags; /**< Module flags */ #endif /* JERRY_MODULE_SYSTEM */ @@ -1058,9 +1052,6 @@ typedef struct #if JERRY_BUILTIN_CONTAINER uint16_t container_id; /**< magic string id of a container */ #endif /* JERRY_BUILTIN_CONTAINER */ -#if JERRY_BUILTIN_TYPEDARRAY - uint16_t typedarray_flags; /**< typed array object flags */ -#endif /* JERRY_BUILTIN_TYPEDARRAY */ } u2; /** * Description of 32 bit / value. These extra fields depend on the type. @@ -1069,23 +1060,63 @@ typedef struct { ecma_value_t value; /**< value of the object (e.g. boolean, number, string, etc.) */ ecma_value_t target; /**< [[ProxyTarget]] or [[WeakRefTarget]] internal property */ -#if JERRY_BUILTIN_TYPEDARRAY - ecma_value_t arraybuffer; /**< for typedarray: ArrayBuffer reference */ -#endif /* JERRY_BUILTIN_TYPEDARRAY */ ecma_value_t head; /**< points to the async generator task queue head item */ ecma_value_t iterated_value; /**< for %Iterator%: [[IteratedObject]] property */ ecma_value_t promise; /**< PromiseCapability[[Promise]] internal slot */ ecma_value_t sync_iterator; /**< IteratorRecord [[Iterator]] internal slot for AsyncFromSyncIterator */ ecma_value_t spread_value; /**< for spread object: spreaded element */ int32_t tza; /**< TimeZone adjustment for date objects */ - uint32_t length; /**< length related property (e.g. length of ArrayBuffer) */ - uint32_t arguments_number; /**< for arguments: arguments number */ #if JERRY_MODULE_SYSTEM uint32_t dfs_ancestor_index; /**< module dfs ancestor index (ES2020 15.2.1.16) */ #endif /* JERRY_MODULE_SYSTEM */ } u3; } cls; + union + { + /** + * Fields can only used by Arguments Exotic Object + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< arguments object flags */ + uint16_t formal_params_number; /**< for arguments: formal parameters number */ + uint32_t number; /**< for arguments: arguments number */ + } arguments; +#if JERRY_BUILTIN_TYPEDARRAY + /** + * Fields can only used by ArrayBuffer Object + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< ArrayBuffer flags */ + uint32_t length; /**< length of ArrayBuffer */ + } arraybuffer; + /** + * Fields can only used by TypedArray Object + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t type; /**< type of typed array */ + uint16_t flags; /**< typed array object flags */ + ecma_value_t arraybuffer; /**< for typedarray: ArrayBuffer reference */ + } typedarray; +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_DATAVIEW + /** + * Fields can only used by DataView Object + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint32_t length; /**< length of DataView */ + } dataview; +#endif /* JERRY_BUILTIN_DATAVIEW */ + } clz; + /** * Description of function objects. */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c index 6cb9ba3a65..1ec775797c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c @@ -124,7 +124,7 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this { return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } - return ecma_make_uint32_value (obj_p->header.u.cls.u3.length); + return ecma_make_uint32_value (obj_p->header.u.clz.arraybuffer.length); } default: { diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c index 553cffda74..40b3797092 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c @@ -2086,7 +2086,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id, case ECMA_TYPEDARRAY_PROTOTYPE_ROUTINE_TO_STRING_TAG_GETTER: { ecma_extended_object_t *object_p = (ecma_extended_object_t *) typedarray_p; - return ecma_make_magic_string_value (ecma_get_typedarray_magic_string_id (object_p->u.cls.u1.typedarray_type)); + return ecma_make_magic_string_value (ecma_get_typedarray_magic_string_id (object_p->u.clz.typedarray.type)); } default: { diff --git a/jerry-core/ecma/operations/ecma-arguments-object.c b/jerry-core/ecma/operations/ecma-arguments-object.c index fd0c679804..e4fc5cb552 100644 --- a/jerry-core/ecma/operations/ecma-arguments-object.c +++ b/jerry-core/ecma/operations/ecma-arguments-object.c @@ -76,9 +76,9 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p; 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->header.u.clz.arguments.flags = ECMA_ARGUMENTS_OBJECT_NO_FLAGS; + arguments_p->header.u.clz.arguments.formal_params_number = formal_params_number; + arguments_p->header.u.clz.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); @@ -93,19 +93,19 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar argv_p[i] = ECMA_VALUE_UNDEFINED; } - arguments_p->header.u.cls.u3.arguments_number = shared_p->arg_list_len; + arguments_p->header.u.clz.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.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_MAPPED; + arguments_p->header.u.clz.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.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE; + arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE; mapped_arguments_p->u.byte_code_p = (ecma_compiled_code_t *) bytecode_data_p; } else @@ -166,7 +166,7 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p); if (ECMA_IS_VALUE_ERROR (ret_value) - || !(((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) + || !(((ecma_extended_object_t *) object_p)->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) { return ret_value; } @@ -174,7 +174,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.cls.u2.formal_params_number) + if (index >= mapped_arguments_p->unmapped.header.u.clz.arguments.formal_params_number) { return ret_value; } @@ -228,8 +228,8 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1); ecma_property_value_t *prop_value_p; ecma_property_t *prop_p; - uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number; - uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags; + uint32_t arguments_number = arguments_p->header.u.clz.arguments.number; + uint8_t flags = arguments_p->header.u.clz.arguments.flags; if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED) { @@ -327,27 +327,27 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, /**< the ob if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_LENGTH)) { - JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED)); + JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED)); - arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED; + arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED; return; } if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_CALLEE)) { - JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED)); - JERRY_ASSERT (arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED); + JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED)); + JERRY_ASSERT (arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED); - arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED; + arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED; return; } if (ecma_prop_name_is_symbol (property_name_p)) { - JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED)); + JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED)); JERRY_ASSERT (ecma_op_compare_string_to_global_symbol (property_name_p, LIT_GLOBAL_SYMBOL_ITERATOR)); - arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED; + arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED; return; } @@ -355,7 +355,7 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, /**< the ob ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1); - if (arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED) + if (arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED) { argv_p = (ecma_value_t *) (((ecma_mapped_arguments_t *) object_p) + 1); } @@ -378,8 +378,8 @@ ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< ar ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p; - uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number; - uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags; + uint32_t arguments_number = arguments_p->header.u.clz.arguments.number; + uint8_t flags = arguments_p->header.u.clz.arguments.flags; if (!(filter & JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES)) { @@ -434,13 +434,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.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED); - JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number); + JERRY_ASSERT (mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED); + JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.clz.arguments.formal_params_number); ecma_compiled_code_t *byte_code_p; #if JERRY_SNAPSHOT_EXEC - if (mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE) + if (mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE) { byte_code_p = mapped_arguments_p->u.byte_code_p; } diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index 3a436d1f80..34d6f97b95 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -65,8 +65,8 @@ ecma_arraybuffer_create_object (uint8_t type, /**< type of the arraybuffer */ ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = type; - ext_object_p->u.cls.u1.array_buffer_flags = ECMA_ARRAYBUFFER_ALLOCATED; - ext_object_p->u.cls.u3.length = length; + ext_object_p->u.clz.arraybuffer.flags = ECMA_ARRAYBUFFER_ALLOCATED; + ext_object_p->u.clz.arraybuffer.length = length; memset ((uint8_t *) (ext_object_p + 1), 0, length); return object_p; @@ -99,8 +99,8 @@ ecma_arraybuffer_create_object_with_buffer (uint8_t type, /**< type of the array ecma_arraybuffer_pointer_t *arraybuffer_pointer_p = (ecma_arraybuffer_pointer_t *) object_p; arraybuffer_pointer_p->extended_object.u.cls.type = type; - arraybuffer_pointer_p->extended_object.u.cls.u1.array_buffer_flags = ECMA_ARRAYBUFFER_HAS_POINTER; - arraybuffer_pointer_p->extended_object.u.cls.u3.length = length; + arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.flags = ECMA_ARRAYBUFFER_HAS_POINTER; + arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.length = length; arraybuffer_pointer_p->buffer_p = NULL; arraybuffer_pointer_p->arraybuffer_user_p = NULL; @@ -139,11 +139,11 @@ ecma_arraybuffer_allocate_buffer (ecma_object_t *arraybuffer_p) /**< ArrayBuffer if (ECMA_ARRAYBUFFER_GET_FLAGS (arraybuffer_p) & ECMA_ARRAYBUFFER_DETACHED) { - extended_object_p->u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED; + extended_object_p->u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; return ECMA_VALUE_UNDEFINED; } - uint32_t arraybuffer_length = extended_object_p->u.cls.u3.length; + uint32_t arraybuffer_length = extended_object_p->u.clz.arraybuffer.length; ecma_arraybuffer_pointer_t *arraybuffer_pointer_p = (ecma_arraybuffer_pointer_t *) arraybuffer_p; jerry_arraybuffer_allocate_cb_t arraybuffer_allocate_callback = JERRY_CONTEXT (arraybuffer_allocate_callback); uint8_t *buffer_p; @@ -175,7 +175,7 @@ ecma_arraybuffer_allocate_buffer (ecma_object_t *arraybuffer_p) /**< ArrayBuffer } arraybuffer_pointer_p->buffer_p = buffer_p; - extended_object_p->u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED; + extended_object_p->u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; memset (buffer_p, 0, arraybuffer_length); return ECMA_VALUE_UNDEFINED; @@ -212,7 +212,7 @@ ecma_arraybuffer_release_buffer (ecma_object_t *arraybuffer_p) /**< ArrayBuffer return; } - uint32_t arraybuffer_length = arraybuffer_pointer_p->extended_object.u.cls.u3.length; + uint32_t arraybuffer_length = arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.length; if (free_callback == NULL) { @@ -329,7 +329,7 @@ ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayB || ecma_object_is_shared_arraybuffer (object_p)); 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.cls.u3.length; + return ecma_arraybuffer_is_detached (object_p) ? 0 : ext_object_p->u.clz.arraybuffer.length; } /* ecma_arraybuffer_get_length */ /** @@ -386,14 +386,14 @@ 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.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_DETACHED; + ext_object_p->u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_DETACHED; if (!(ECMA_ARRAYBUFFER_GET_FLAGS (object_p) & ECMA_ARRAYBUFFER_ALLOCATED)) { return true; } - ext_object_p->u.cls.u1.array_buffer_flags &= (uint8_t) ~ECMA_ARRAYBUFFER_ALLOCATED; + ext_object_p->u.clz.arraybuffer.flags &= (uint8_t) ~ECMA_ARRAYBUFFER_ALLOCATED; if (!(ECMA_ARRAYBUFFER_GET_FLAGS (object_p) & ECMA_ARRAYBUFFER_HAS_POINTER)) { diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.h b/jerry-core/ecma/operations/ecma-arraybuffer-object.h index 6dc28b59bc..16c41160ae 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.h +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.h @@ -31,7 +31,7 @@ * Get array buffer flags. */ #define ECMA_ARRAYBUFFER_GET_FLAGS(arraybuffer_p) \ - (((ecma_extended_object_t *) (arraybuffer_p))->u.cls.u1.array_buffer_flags) + (((ecma_extended_object_t *) (arraybuffer_p))->u.clz.arraybuffer.flags) /** * Check whether the backing store is allocated for an array buffer. diff --git a/jerry-core/ecma/operations/ecma-dataview-object.c b/jerry-core/ecma/operations/ecma-dataview-object.c index db2ae0a68b..6b361f3547 100644 --- a/jerry-core/ecma/operations/ecma-dataview-object.c +++ b/jerry-core/ecma/operations/ecma-dataview-object.c @@ -149,7 +149,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 11 - 14. */ ecma_dataview_object_t *dataview_obj_p = (ecma_dataview_object_t *) object_p; dataview_obj_p->header.u.cls.type = ECMA_OBJECT_CLASS_DATAVIEW; - dataview_obj_p->header.u.cls.u3.length = view_byte_length; + dataview_obj_p->header.u.clz.dataview.length = view_byte_length; dataview_obj_p->buffer_p = buffer_p; dataview_obj_p->byte_offset = (uint32_t) offset; @@ -315,7 +315,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.cls.u3.length; + uint32_t view_size = view_p->header.u.clz.dataview.length; /* GetViewValue 9., SetViewValue 11. */ uint8_t element_size = (uint8_t) (1 << (ecma_typedarray_helper_get_shift_size (id))); diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index f06a307d8e..ef7bc221a1 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -342,13 +342,13 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ } 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 *) object_p)->u.clz.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.cls.u2.formal_params_number) + if (index < ext_object_p->u.clz.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -507,14 +507,14 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */ } case ECMA_OBJECT_CLASS_ARGUMENTS: { - if (!(ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) + if (!(ext_object_p->u.clz.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) + if (index < ext_object_p->u.clz.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -1287,14 +1287,14 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ { case ECMA_OBJECT_CLASS_ARGUMENTS: { - if (!(ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) + if (!(ext_object_p->u.clz.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) + if (index < ext_object_p->u.clz.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -1560,7 +1560,7 @@ 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.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS - && ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED) + && ext_object_p->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED) { const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW; return ecma_builtin_helper_def_prop (object_p, property_name_p, value, flags); @@ -2816,7 +2816,7 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ #if JERRY_BUILTIN_TYPEDARRAY case ECMA_OBJECT_CLASS_TYPEDARRAY: { - return ecma_get_typedarray_magic_string_id (ext_object_p->u.cls.u1.typedarray_type); + return ecma_get_typedarray_magic_string_id (ext_object_p->u.clz.typedarray.type); } #endif /* JERRY_BUILTIN_TYPEDARRAY */ #if JERRY_BUILTIN_CONTAINER diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index c4c4f41052..80349932ab 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -765,7 +765,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.cls.u1.typedarray_type; + return (ecma_typedarray_type_t) ext_object_p->u.clz.typedarray.type; } /* ecma_get_typedarray_id */ /** @@ -860,9 +860,9 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY; - ext_object_p->u.cls.u1.typedarray_type = (uint8_t) typedarray_id; - ext_object_p->u.cls.u2.typedarray_flags = 0; - ext_object_p->u.cls.u3.arraybuffer = ecma_make_object_value (new_arraybuffer_p); + ext_object_p->u.clz.typedarray.type = (uint8_t) typedarray_id; + ext_object_p->u.clz.typedarray.flags = 0; + ext_object_p->u.clz.typedarray.arraybuffer = ecma_make_object_value (new_arraybuffer_p); ecma_deref_object (new_arraybuffer_p); @@ -1527,7 +1527,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.cls.u3.arraybuffer); + return ecma_get_object_from_value (ext_object_p->u.clz.typedarray.arraybuffer); } /* ecma_typedarray_get_arraybuffer */ /** @@ -1555,11 +1555,11 @@ ecma_typedarray_get_length (ecma_object_t *typedarray_p) /**< the pointer to the ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p; - if (!(ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED)) + if (!(ext_object_p->u.clz.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED)) { - ecma_object_t *arraybuffer_p = ecma_get_object_from_value (ext_object_p->u.cls.u3.arraybuffer); + ecma_object_t *arraybuffer_p = ecma_get_object_from_value (ext_object_p->u.clz.typedarray.arraybuffer); ecma_extended_object_t *arraybuffer_object_p = (ecma_extended_object_t *) arraybuffer_p; - uint32_t buffer_length = arraybuffer_object_p->u.cls.u3.length; + uint32_t buffer_length = arraybuffer_object_p->u.clz.arraybuffer.length; uint8_t shift = ecma_typedarray_get_element_size_shift (typedarray_p); return buffer_length >> shift; @@ -1589,7 +1589,7 @@ ecma_typedarray_get_offset (ecma_object_t *typedarray_p) /**< the pointer to the ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p; - if (!(ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED)) + if (!(ext_object_p->u.clz.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED)) { return 0; } @@ -1766,13 +1766,13 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY; - ext_object_p->u.cls.u1.typedarray_type = (uint8_t) typedarray_id; - ext_object_p->u.cls.u2.typedarray_flags = 0; - ext_object_p->u.cls.u3.arraybuffer = ecma_make_object_value (arraybuffer_p); + ext_object_p->u.clz.typedarray.type = (uint8_t) typedarray_id; + ext_object_p->u.clz.typedarray.flags = 0; + ext_object_p->u.clz.typedarray.arraybuffer = ecma_make_object_value (arraybuffer_p); if (needs_ext_typedarray_obj) { - ext_object_p->u.cls.u2.typedarray_flags |= ECMA_TYPEDARRAY_IS_EXTENDED; + ext_object_p->u.clz.typedarray.flags |= ECMA_TYPEDARRAY_IS_EXTENDED; ecma_extended_typedarray_object_t *typedarray_info_p = (ecma_extended_typedarray_object_t *) object_p; typedarray_info_p->array_length = new_byte_length >> element_size_shift;