diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index 9a5f642ba0..12a27e7471 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -751,7 +751,8 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + bytecode_data_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); } else if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_FUNCTION) { diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c index 640edb52d4..deac9ea8b9 100644 --- a/jerry-core/api/jerryscript.c +++ b/jerry-core/api/jerryscript.c @@ -453,8 +453,8 @@ jerry_parse_common (void *source_p, /**< script source */ ecma_object_t *object_p = ecma_create_object (NULL, 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.cls.type = ECMA_OBJECT_CLASS_SCRIPT; - ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, bytecode_data_p); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_SCRIPT; + ECMA_SET_INTERNAL_VALUE_POINTER (ecma_object_cls_general (ext_object_p)->value, bytecode_data_p); return ecma_make_object_value (object_p); } /* jerry_parse_common */ @@ -541,7 +541,8 @@ jerry_run (const jerry_value_t script) /**< script or module to run */ ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; const ecma_compiled_code_t *bytecode_data_p; - bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + bytecode_data_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); JERRY_ASSERT (CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags) == CBC_FUNCTION_SCRIPT); @@ -638,7 +639,7 @@ jerry_module_evaluate (const jerry_value_t module) /**< root module */ return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_NOT_MODULE)); } - if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_LINKED) + if (module_p->header.u.cls.module.state != JERRY_MODULE_STATE_LINKED) { return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE)); } @@ -670,7 +671,7 @@ jerry_module_state (const jerry_value_t module) /**< module object */ return JERRY_MODULE_STATE_INVALID; } - return (jerry_module_state_t) module_p->header.u.cls.u1.module_state; + return (jerry_module_state_t) module_p->header.u.cls.module.state; #else /* !JERRY_MODULE_SYSTEM */ JERRY_UNUSED (module); @@ -818,8 +819,8 @@ jerry_module_namespace (const jerry_value_t module) /**< module */ return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_NOT_MODULE)); } - if (module_p->header.u.cls.u1.module_state < JERRY_MODULE_STATE_LINKED - || module_p->header.u.cls.u1.module_state > JERRY_MODULE_STATE_EVALUATED) + if (module_p->header.u.cls.module.state < JERRY_MODULE_STATE_LINKED + || module_p->header.u.cls.module.state > JERRY_MODULE_STATE_EVALUATED) { return jerry_throw_sz (JERRY_ERROR_RANGE, ecma_get_error_msg (ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE)); } @@ -952,7 +953,7 @@ jerry_native_module (jerry_native_module_evaluate_cb_t callback, /**< evaluation ecma_module_t *module_p = ecma_module_create (); - module_p->header.u.cls.u2.module_flags |= ECMA_MODULE_IS_NATIVE; + module_p->header.u.cls.module.flags |= ECMA_MODULE_IS_NATIVE; module_p->scope_p = scope_p; module_p->local_exports_p = local_exports_p; module_p->u.callback = callback; @@ -993,7 +994,7 @@ jerry_native_module_get (const jerry_value_t native_module, /**< a native module return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_NOT_MODULE)); } - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name)) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name)) { return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_WRONG_ARGS_MSG)); } @@ -1038,7 +1039,7 @@ jerry_native_module_set (jerry_value_t native_module, /**< a native module objec return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_NOT_MODULE)); } - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name) || ecma_is_value_exception (value)) { return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_WRONG_ARGS_MSG)); @@ -1534,8 +1535,8 @@ jerry_object_type (const jerry_value_t value) /**< input value to check */ case ECMA_OBJECT_TYPE_CLASS: case ECMA_OBJECT_TYPE_BUILT_IN_CLASS: { - JERRY_ASSERT (ext_obj_p->u.cls.type < ECMA_OBJECT_CLASS__MAX); - return jerry_class_object_type[ext_obj_p->u.cls.type]; + JERRY_ASSERT (ext_obj_p->u.cls.head.type < ECMA_OBJECT_CLASS__MAX); + return jerry_class_object_type[ext_obj_p->u.cls.head.type]; } case ECMA_OBJECT_TYPE_ARRAY: case ECMA_OBJECT_TYPE_BUILT_IN_ARRAY: @@ -1644,7 +1645,7 @@ jerry_iterator_type (const jerry_value_t value) /**< input value to check */ if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS) { - switch (ext_obj_p->u.cls.type) + switch (ext_obj_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_ARRAY_ITERATOR: { @@ -3610,7 +3611,7 @@ jerry_object_set_internal (jerry_value_t object, /**< object value */ internal_object_p = ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); { ecma_extended_object_t *container_p = (ecma_extended_object_t *) internal_object_p; - container_p->u.cls.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT; + container_p->u.cls.head.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT; } value_p->value = ecma_make_object_value (internal_object_p); @@ -4141,7 +4142,7 @@ jerry_object_is_valid_foreach (ecma_object_t *object_p) /**< object to test */ if (object_type == ECMA_OBJECT_TYPE_CLASS) { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { /* An object's internal property object should not be iterable by foreach. */ case ECMA_OBJECT_CLASS_INTERNAL_OBJECT: @@ -5647,16 +5648,17 @@ jerry_source_info (const jerry_value_t value) /**< jerry api value */ ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; const ecma_compiled_code_t *bytecode_p = NULL; - if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT) + if (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_SCRIPT) { - bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + bytecode_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); } #if JERRY_MODULE_SYSTEM - else if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE) + else if (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_MODULE) { ecma_module_t *module_p = (ecma_module_t *) object_p; - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE)) { bytecode_p = module_p->u.compiled_code_p; } @@ -5987,7 +5989,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.cls.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; arraybuffer_pointer_p->buffer_p = buffer_p; } } @@ -6075,7 +6077,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.cls.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; shared_arraybuffer_pointer_p->buffer_p = buffer_p; } } @@ -6523,7 +6525,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.cls.dataview.length; } ecma_object_t *arraybuffer_p = dataview_p->buffer_p; @@ -7024,7 +7026,7 @@ jerry_container_type (const jerry_value_t value) /**< the container object */ if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_CONTAINER)) { - switch (((ecma_extended_object_t *) obj_p)->u.cls.u2.container_id) + switch (((ecma_extended_object_t *) obj_p)->u.cls.container.id) { case LIT_MAGIC_STRING_MAP_UL: { @@ -7095,10 +7097,10 @@ jerry_container_to_array (const jerry_value_t value, /**< the container or itera *is_key_value_p = false; - if (ext_obj_p->u.cls.type == ECMA_OBJECT_CLASS_MAP_ITERATOR - || ext_obj_p->u.cls.type == ECMA_OBJECT_CLASS_SET_ITERATOR) + if (ext_obj_p->u.cls.head.type == ECMA_OBJECT_CLASS_MAP_ITERATOR + || ext_obj_p->u.cls.head.type == ECMA_OBJECT_CLASS_SET_ITERATOR) { - ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_obj_p->u.cls.iterator.value; if (ecma_is_value_empty (iterated_value)) { @@ -7107,27 +7109,29 @@ jerry_container_to_array (const jerry_value_t value, /**< the container or itera ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) (ecma_get_object_from_value (iterated_value)); - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); - index = ext_obj_p->u.cls.u2.iterator_index; + index = ext_obj_p->u.cls.iterator.index; - entry_size = ecma_op_container_entry_size (map_object_p->u.cls.u2.container_id); + entry_size = ecma_op_container_entry_size (map_object_p->u.cls.container.id); start_p = ECMA_CONTAINER_START (container_p); - iterator_kind = ext_obj_p->u.cls.u1.iterator_kind; + iterator_kind = ext_obj_p->u.cls.iterator.kind; } else if (jerry_container_type (value) != JERRY_CONTAINER_TYPE_INVALID) { - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ext_obj_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ext_obj_p->u.cls.container.value); entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); - entry_size = ecma_op_container_entry_size (ext_obj_p->u.cls.u2.container_id); + entry_size = ecma_op_container_entry_size (ext_obj_p->u.cls.container.id); index = 0; iterator_kind = ECMA_ITERATOR_KEYS; start_p = ECMA_CONTAINER_START (container_p); - if (ext_obj_p->u.cls.u2.container_id == LIT_MAGIC_STRING_MAP_UL - || ext_obj_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL) + if (ext_obj_p->u.cls.container.id == LIT_MAGIC_STRING_MAP_UL + || ext_obj_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKMAP_UL) { iterator_kind = ECMA_ITERATOR_ENTRIES; } @@ -7192,7 +7196,7 @@ jerry_container_op (jerry_container_op_t operation, /**< container operation */ { return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT)); } - uint16_t type = ((ecma_extended_object_t *) obj_p)->u.cls.u2.container_id; + uint16_t type = ((ecma_extended_object_t *) obj_p)->u.cls.container.id; ecma_extended_object_t *container_object_p = ecma_op_container_get_object (container, type); if (container_object_p == NULL) diff --git a/jerry-core/ecma/base/ecma-alloc.c b/jerry-core/ecma/base/ecma-alloc.c index 970b05ee80..b5528260bb 100644 --- a/jerry-core/ecma/base/ecma-alloc.c +++ b/jerry-core/ecma/base/ecma-alloc.c @@ -29,6 +29,8 @@ JERRY_STATIC_ASSERT (((sizeof (ecma_property_value_t) - 1) & sizeof (ecma_proper JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <= sizeof (uint64_t), size_of_ecma_extended_object_part_must_be_less_than_or_equal_to_8_bytes); +JERRY_STATIC_ASSERT (sizeof (ecma_object_cls_t) == 8, size_of_ecma_object_cls_t_should_be_8_bytes); + /** \addtogroup ecma ECMA * @{ * diff --git a/jerry-core/ecma/base/ecma-gc.c b/jerry-core/ecma/base/ecma-gc.c index b42e5a6776..2f7dd404e8 100644 --- a/jerry-core/ecma/base/ecma-gc.c +++ b/jerry-core/ecma/base/ecma-gc.c @@ -204,7 +204,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.cls.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); @@ -212,7 +212,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.cls.arguments.number; for (uint32_t i = 0; i < arguments_number; i++) { @@ -368,8 +368,8 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */ ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) reference_object_p; - if (map_object_p->u.cls.type != ECMA_OBJECT_CLASS_CONTAINER - || map_object_p->u.cls.u2.container_id != LIT_MAGIC_STRING_WEAKMAP_UL + if (map_object_p->u.cls.head.type != ECMA_OBJECT_CLASS_CONTAINER + || map_object_p->u.cls.container.id != LIT_MAGIC_STRING_WEAKMAP_UL || !ecma_gc_is_object_visited (reference_object_p)) { continue; @@ -513,7 +513,7 @@ static void ecma_gc_mark_promise_object (ecma_extended_object_t *ext_object_p) /**< extended object */ { /* Mark promise result. */ - ecma_value_t result = ext_object_p->u.cls.u3.value; + ecma_value_t result = ext_object_p->u.cls.promise.value; if (ecma_is_value_object (result)) { @@ -559,7 +559,8 @@ ecma_gc_mark_map_object (ecma_object_t *object_p) /**< object */ JERRY_ASSERT (object_p != NULL); 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); @@ -593,7 +594,8 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */ JERRY_ASSERT (object_p != NULL); 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); @@ -624,7 +626,8 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */ JERRY_ASSERT (object_p != NULL); 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); @@ -653,9 +656,9 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */ { vm_executable_object_t *executable_object_p = (vm_executable_object_t *) object_p; - if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_ASYNC_GENERATOR_CALLED) + if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_ASYNC_GENERATOR_CALLED) { - ecma_value_t task = executable_object_p->extended_object.u.cls.u3.head; + ecma_value_t task = executable_object_p->extended_object.u.cls.generator.head; while (!ECMA_IS_INTERNAL_VALUE_NULL (task)) { @@ -678,8 +681,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */ ecma_gc_set_object_visited (executable_object_p->shared.function_object_p); if (!ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p) - && !(executable_object_p->extended_object.u.cls.u2.executable_obj_flags - & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)) + && !(executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)) { /* All objects referenced by running executable objects are strong roots, * and a finished executable object cannot refer to other values. */ @@ -891,7 +893,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_ARGUMENTS: { @@ -902,7 +904,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ case ECMA_OBJECT_CLASS_SCRIPT: { const ecma_compiled_code_t *compiled_code_p; - compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + compiled_code_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)); ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value); @@ -920,7 +923,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ case ECMA_OBJECT_CLASS_MODULE_NAMESPACE: { JERRY_ASSERT (proto_cp == JMEM_CP_NULL); - ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ext_object_p->u.cls.u3.value)); + ecma_gc_set_object_visited ( + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ecma_object_cls_general (ext_object_p)->value)); ecma_gc_mark_properties (object_p, true); return; } @@ -940,8 +944,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ ecma_gc_set_object_visited (((ecma_module_t *) ext_object_p)->namespace_object_p); } - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) - && module_p->u.compiled_code_p != NULL) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE) && module_p->u.compiled_code_p != NULL) { const ecma_compiled_code_t *compiled_code_p = module_p->u.compiled_code_p; @@ -974,22 +977,22 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ #if JERRY_BUILTIN_CONTAINER case ECMA_OBJECT_CLASS_CONTAINER: { - if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_MAP_UL) + if (ext_object_p->u.cls.container.id == LIT_MAGIC_STRING_MAP_UL) { ecma_gc_mark_map_object (object_p); break; } - if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL) + if (ext_object_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKMAP_UL) { ecma_gc_mark_weakmap_object (object_p); break; } - if (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_SET_UL) + if (ext_object_p->u.cls.container.id == LIT_MAGIC_STRING_SET_UL) { ecma_gc_mark_set_object (object_p); break; } - JERRY_ASSERT (ext_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKSET_UL); + JERRY_ASSERT (ext_object_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKSET_UL); break; } #endif /* JERRY_BUILTIN_CONTAINER */ @@ -1008,9 +1011,10 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ { ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) object_p; - if (ecma_is_value_object (capability_p->header.u.cls.u3.promise)) + if (ecma_is_value_object (capability_p->header.u.cls.promise_capabality.promise)) { - ecma_gc_set_object_visited (ecma_get_object_from_value (capability_p->header.u.cls.u3.promise)); + ecma_gc_set_object_visited ( + ecma_get_object_from_value (capability_p->header.u.cls.promise_capabality.promise)); } if (ecma_is_value_object (capability_p->resolve)) { @@ -1026,7 +1030,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ { ecma_async_from_sync_iterator_object_t *iter_p = (ecma_async_from_sync_iterator_object_t *) ext_object_p; - ecma_gc_set_object_visited (ecma_get_object_from_value (iter_p->header.u.cls.u3.sync_iterator)); + ecma_gc_set_object_visited (ecma_get_object_from_value (iter_p->header.u.cls.sync_iterator.value)); if (!ecma_is_value_undefined (iter_p->sync_next_method)) { @@ -1039,7 +1043,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ case ECMA_OBJECT_CLASS_SET_ITERATOR: case ECMA_OBJECT_CLASS_MAP_ITERATOR: { - ecma_value_t iterated_value = ext_object_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_object_p->u.cls.iterator.value; if (!ecma_is_value_empty (iterated_value)) { ecma_gc_set_object_visited (ecma_get_object_from_value (iterated_value)); @@ -1058,7 +1062,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */ default: { /* The ECMA_OBJECT_CLASS__MAX type represents an uninitialized class. */ - JERRY_ASSERT (ext_object_p->u.cls.type <= ECMA_OBJECT_CLASS__MAX); + JERRY_ASSERT (ext_object_p->u.cls.head.type <= ECMA_OBJECT_CLASS__MAX); break; } } @@ -1330,13 +1334,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.cls.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.cls.arguments.flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)) #endif /* JERRY_SNAPSHOT_EXEC */ { ecma_compiled_code_t *byte_code_p = @@ -1348,14 +1352,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.cls.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.cls.arguments.formal_params_number); return object_size + (saved_argument_count * sizeof (ecma_value_t)); } /* ecma_free_arguments_object */ @@ -1417,13 +1422,13 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */ size = JERRY_ALIGNUP (sizeof (vm_executable_object_t) + size, sizeof (uintptr_t)); ecma_bytecode_deref ((ecma_compiled_code_t *) bytecode_header_p); - uint16_t executable_obj_flags = executable_object_p->extended_object.u.cls.u2.executable_obj_flags; + uint16_t executable_obj_flags = executable_object_p->extended_object.u.cls.generator.obj_flags; JERRY_ASSERT (!(executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING)); if (executable_obj_flags & ECMA_ASYNC_GENERATOR_CALLED) { - ecma_value_t task = executable_object_p->extended_object.u.cls.u3.head; + ecma_value_t task = executable_object_p->extended_object.u.cls.generator.head; while (!ECMA_IS_INTERNAL_VALUE_NULL (task)) { @@ -1624,7 +1629,7 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */ if (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_WEAKREF)) { ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; - ext_obj_p->u.cls.u3.target = ECMA_VALUE_UNDEFINED; + ext_obj_p->u.cls.weakref.target = ECMA_VALUE_UNDEFINED; continue; } ecma_op_container_remove_weak_entry (obj_p, ecma_make_object_value (object_p)); @@ -1755,7 +1760,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_STRING: case ECMA_OBJECT_CLASS_NUMBER: @@ -1764,7 +1769,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ case ECMA_OBJECT_CLASS_BIGINT: #endif /* JERRY_BUILTIN_BIGINT */ { - ecma_free_value (ext_object_p->u.cls.u3.value); + ecma_free_value (ecma_object_cls_general (ext_object_p)->value); break; } case ECMA_OBJECT_CLASS_ARGUMENTS: @@ -1775,7 +1780,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.cls.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED) { ext_object_size = sizeof (ecma_extended_typedarray_object_t); } @@ -1794,7 +1799,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ case ECMA_OBJECT_CLASS_SCRIPT: { ecma_compiled_code_t *compiled_code_p; - compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + compiled_code_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); ecma_bytecode_deref (compiled_code_p); break; @@ -1811,7 +1817,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ case ECMA_OBJECT_CLASS_REGEXP: { ecma_compiled_code_t *bytecode_p = - ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); ecma_bytecode_deref (bytecode_p); @@ -1820,7 +1826,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ #endif /* JERRY_BUILTIN_REGEXP */ case ECMA_OBJECT_CLASS_STRING_ITERATOR: { - ecma_value_t iterated_value = ext_object_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_object_p->u.cls.iterator.value; if (!ecma_is_value_empty (iterated_value)) { @@ -1852,7 +1858,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.cls.arraybuffer.length; break; } @@ -1868,7 +1874,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ #if JERRY_BUILTIN_WEAKREF case ECMA_OBJECT_CLASS_WEAKREF: { - ecma_value_t target = ext_object_p->u.cls.u3.target; + ecma_value_t target = ext_object_p->u.cls.weakref.target; if (!ecma_is_value_undefined (target)) { @@ -1882,7 +1888,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ { 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.cls.u3.value); + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_op_container_free_entries (object_p); ecma_collection_destroy (container_p); break; @@ -1903,7 +1909,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ } case ECMA_OBJECT_CLASS_PROMISE: { - ecma_free_value_if_not_object (ext_object_p->u.cls.u3.value); + ecma_free_value_if_not_object (ext_object_p->u.cls.promise.value); /* Reactions only contains objects. */ ecma_collection_destroy (((ecma_promise_object_t *) object_p)->reactions); @@ -1932,7 +1938,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ default: { /* The ECMA_OBJECT_CLASS__MAX type represents an uninitialized class. */ - JERRY_ASSERT (ext_object_p->u.cls.type <= ECMA_OBJECT_CLASS__MAX); + JERRY_ASSERT (ext_object_p->u.cls.head.type <= ECMA_OBJECT_CLASS__MAX); break; } } diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 526f269be3..22d8677f0b 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -969,6 +969,231 @@ typedef enum */ #define ECMA_BUILT_IN_BITSET_SHIFT 5 +/** + * Description of the following general class object: + * ECMA_OBJECT_CLASS_BOOLEAN(boolean) + * ECMA_OBJECT_CLASS_NUMBER(number) + * ECMA_OBJECT_CLASS_STRING(string) + * ECMA_OBJECT_CLASS_BIGINT(bigint) + * ECMA_OBJECT_CLASS_SYMBOL(symbol) + * ECMA_OBJECT_CLASS_SCRIPT(Compiled ECMAScript byte code) + * ECMA_OBJECT_CLASS_REGEXP(RegExp Object) + * ECMA_OBJECT_CLASS_MODULE_NAMESPACE(Module Namespace) + * Can only be accessed with ecma_object_cls_general + */ +typedef struct +{ + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; + uint16_t padding1; + ecma_value_t value; /**< value of the general object */ +} ecma_object_cls_general_t; + +/** + * Description of objects with class. + * + * Note: + * class is a reserved word in c++, so cls is used instead + * all struct for object should begin with `uint8_t cls_type;` + */ +typedef union +{ + /** + * Description of the class type in head struct for shared access + */ + struct + { + uint8_t type; /**< class type of the object */ + uint8_t padding0; + uint16_t padding1; + uint32_t padding2; + } head; + /** + * Fields for general class type, do not access directly, + * use ecma_object_cls_general to access to ensure the cls_type is valid + */ + ecma_object_cls_general_t __general; + /** + * Fields can only used by ecma_extended_object_t + * That is ECMA_OBJECT_CLASS_WEAKREF(WeakRef) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; + uint16_t padding1; + ecma_value_t target; /**< [[WeakRefTarget]] internal property */ + } weakref; + /** + * Fields can only used by ecma_promise_t. + * That is ECMA_OBJECT_CLASS_PROMISE(Promise) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< Promise object flags */ + uint16_t padding1; + ecma_value_t value; /**< value of the Promise object */ + } promise; + /** + * Fields can only used by ecma_promise_capabality_t. + * That is ECMA_OBJECT_CLASS_PROMISE_CAPABILITY(Promise capability) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; /**< Promise object flags */ + uint16_t padding1; + ecma_value_t promise; /**< PromiseCapability[[Promise]] internal slot */ + } promise_capabality; + /** + * Fields can only used by ecma_regexp_string_iterator_t. + * That is ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR(RegExp string iterator object) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< flags for RegExp string iterator */ + uint16_t padding0; + uint32_t padding1; + } regexp_string_iterator; + /** + * Fields can only used by vm_executable_object_t. + * That is ECMA_OBJECT_CLASS_GENERATOR(Generator object) or + * ECMA_OBJECT_CLASS_GENERATOR(Async generator object) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; + uint16_t obj_flags; /**< executable object flags */ + ecma_value_t head; /**< points to the async generator task queue head item */ + } generator; + /** + * Fields can only used by ecma_async_from_sync_iterator_object_t. + * That is ECMA_OBJECT_CLASS_ASYNC_FROM_SYNC_ITERATOR(AsyncFromSyncIterator) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; + uint16_t padding1; + ecma_value_t value; /**< IteratorRecord [[Iterator]] internal slot for AsyncFromSyncIterator */ + } sync_iterator; + /** + * Fields can only used by %Iterator% object, those objects class type is: + * ECMA_OBJECT_CLASS_ARRAY_ITERATOR + * ECMA_OBJECT_CLASS_SET_ITERATOR + * ECMA_OBJECT_CLASS_MAP_ITERATOR + * ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR + * ECMA_OBJECT_CLASS_STRING_ITERATOR + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t kind; /**< type of iterator */ + uint16_t index; /**< for %Iterator%: [[%Iterator%NextIndex]] property */ + ecma_value_t value; /**< for %Iterator%: [[IteratedObject]] property */ + } iterator; +#if JERRY_BUILTIN_CONTAINER + /** + * Fields can only used by container(Map/Set) object + * That is ECMA_OBJECT_CLASS_CONTAINER(Container (Map, WeakMap, Set, WeakSet)) + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< container object flags */ + uint16_t id; /**< magic string id of a container */ + ecma_value_t value; /**< internal value pointer */ + } container; +#endif /* JERRY_BUILTIN_CONTAINER */ + /** + * Fields can only used by Error object + * That is ECMA_OBJECT_CLASS_ERROR + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t type; /**< jerry_error_t type of native error objects */ + uint16_t padding0; + uint32_t padding1; + } error; +#if JERRY_BUILTIN_DATE + /** + * Fields can only used by Date object + * That is ECMA_OBJECT_CLASS_DATE + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< flags for date objects */ + uint16_t padding0; + int32_t tza; /**< TimeZone adjustment for date objects */ + } date; +#endif /* JERRY_BUILTIN_DATE */ +#if JERRY_MODULE_SYSTEM + /** + * Fields can only used by ES2020 module + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t state; /**< Module state */ + uint16_t flags; /**< Module flags */ + uint32_t dfs_ancestor_index; /**< module dfs ancestor index (ES2020 15.2.1.16) */ + } module; +#endif /* JERRY_MODULE_SYSTEM */ + /** + * Fields can only used by Arguments Exotic Object + * That is ECMA_OBJECT_CLASS_ARGUMENTS + */ + 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_DATAVIEW + /** + * Fields can only used by DataView Object + * That is ECMA_OBJECT_CLASS_DATAVIEW + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t padding0; + uint16_t padding1; + uint32_t length; /**< length of DataView */ + } dataview; +#endif /* JERRY_BUILTIN_DATAVIEW */ +#if JERRY_BUILTIN_TYPEDARRAY + /** + * Fields can only used by ArrayBuffer Object + * That is ECMA_OBJECT_CLASS_ARRAY_BUFFER or ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER + */ + struct + { + uint8_t cls_type; /**< class type of the object */ + uint8_t flags; /**< ArrayBuffer flags */ + uint16_t padding0; + uint32_t length; /**< length of ArrayBuffer */ + } arraybuffer; + /** + * Fields can only used by TypedArray Object + * That is ECMA_OBJECT_CLASS_TYPEDARRAY + */ + 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 */ +} ecma_object_cls_t; + /** * Description of extended ECMA-object. * @@ -985,80 +1210,7 @@ typedef struct { ecma_built_in_props_t built_in; /**< built-in object part */ - /** - * Description of objects with class. - * - * Note: - * class is a reserved word in c++, so cls is used instead - */ - struct - { - uint8_t type; /**< class type of the object */ - /** - * Description of 8 bit extra fields. These extra fields depend on the type. - */ - 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 */ -#endif /* JERRY_BUILTIN_DATE */ -#if JERRY_MODULE_SYSTEM - uint8_t module_state; /**< Module state */ -#endif /* JERRY_MODULE_SYSTEM */ - uint8_t iterator_kind; /**< type of iterator */ - uint8_t regexp_string_iterator_flags; /**< flags for RegExp string iterator */ - uint8_t promise_flags; /**< Promise object flags */ -#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 */ - uint16_t iterator_index; /**< for %Iterator%: [[%Iterator%NextIndex]] property */ - uint16_t executable_obj_flags; /**< executable object flags */ -#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. - */ - union - { - 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; + ecma_object_cls_t cls; /**< objects with class. */ /** * Description of function objects. @@ -1898,8 +2050,8 @@ typedef enum /** * Checks whether the executable object is waiting for resuming. */ -#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \ - (!((executable_object_p)->extended_object.u.cls.u2.executable_obj_flags \ +#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \ + (!((executable_object_p)->extended_object.u.cls.generator.obj_flags \ & (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_EXECUTABLE_OBJECT_RUNNING))) /** @@ -1916,7 +2068,7 @@ typedef enum * Resume execution of the byte code. */ #define ECMA_EXECUTABLE_OBJECT_RESUME_EXEC(executable_object_p) \ - ((executable_object_p)->extended_object.u.cls.u2.executable_obj_flags &= ECMA_EXECUTABLE_OBJECT_RESUME_EXEC_MASK) + ((executable_object_p)->extended_object.u.cls.generator.obj_flags &= ECMA_EXECUTABLE_OBJECT_RESUME_EXEC_MASK) /** * Enqueued task of an AsyncGenerator. diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c index e7780db159..bc7bd57719 100644 --- a/jerry-core/ecma/base/ecma-helpers.c +++ b/jerry-core/ecma/base/ecma-helpers.c @@ -73,6 +73,33 @@ JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_ARRAY == ((int) ECMA_OBJECT && ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0, ecma_object_type_built_in_array_has_unexpected_value); +/** + * Get the general class property of extended ECMA-object + * + * @return pointer to the object's general class property + */ +extern inline ecma_object_cls_general_t *JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE +ecma_object_cls_general (ecma_extended_object_t *obj) /**< pointer to extended ECMA-object */ +{ + ecma_object_cls_general_t *cls = &(obj->u.cls.__general); +#ifndef JERRY_NDEBUG + bool is_general_class = cls->cls_type == ECMA_OBJECT_CLASS_BOOLEAN || cls->cls_type == ECMA_OBJECT_CLASS_NUMBER + || cls->cls_type == ECMA_OBJECT_CLASS_STRING || cls->cls_type == ECMA_OBJECT_CLASS_BIGINT + || cls->cls_type == ECMA_OBJECT_CLASS_SYMBOL; +#if JERRY_PARSER + is_general_class |= cls->cls_type == ECMA_OBJECT_CLASS_SCRIPT; +#endif /* JERRY_PARSER */ +#if JERRY_BUILTIN_REGEXP + is_general_class |= cls->cls_type == ECMA_OBJECT_CLASS_REGEXP; +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_MODULE_SYSTEM + is_general_class |= cls->cls_type == ECMA_OBJECT_CLASS_MODULE_NAMESPACE; +#endif /* JERRY_MODULE_SYSTEM */ + JERRY_ASSERT (is_general_class); +#endif /* !JERRY_NDEBUG */ + return cls; +} /* ecma_object_cls_general */ + /** * Create an object with specified prototype object * (or NULL prototype if there is not prototype for the object) @@ -266,7 +293,7 @@ ecma_object_class_is (ecma_object_t *object_p, /**< object */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - if (ext_object_p->u.cls.type == (uint8_t) class_id) + if (ext_object_p->u.cls.head.type == (uint8_t) class_id) { return true; } @@ -1616,18 +1643,19 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT) + if (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_SCRIPT) { - bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value); + bytecode_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); break; } #if JERRY_MODULE_SYSTEM - if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE) + if (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_MODULE) { ecma_module_t *module_p = (ecma_module_t *) object_p; - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE)) { bytecode_p = module_p->u.compiled_code_p; break; diff --git a/jerry-core/ecma/base/ecma-helpers.h b/jerry-core/ecma/base/ecma-helpers.h index 9e37bf5108..e039f22d69 100644 --- a/jerry-core/ecma/base/ecma-helpers.h +++ b/jerry-core/ecma/base/ecma-helpers.h @@ -407,6 +407,7 @@ ecma_value_t *ecma_compact_collection_end (ecma_value_t *compact_collection_p); void ecma_compact_collection_destroy (ecma_value_t *compact_collection_p); /* ecma-helpers.c */ +ecma_object_cls_general_t *ecma_object_cls_general (ecma_extended_object_t *obj); ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type); ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p); ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p); diff --git a/jerry-core/ecma/base/ecma-module.c b/jerry-core/ecma/base/ecma-module.c index 21fc52fd70..72de00a42f 100644 --- a/jerry-core/ecma/base/ecma-module.c +++ b/jerry-core/ecma/base/ecma-module.c @@ -68,9 +68,9 @@ ecma_module_create (void) ecma_object_t *obj_p = ecma_create_object (NULL, sizeof (ecma_module_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_MODULE; - ext_object_p->u.cls.u1.module_state = JERRY_MODULE_STATE_UNLINKED; - ext_object_p->u.cls.u2.module_flags = 0; + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_MODULE; + ext_object_p->u.cls.module.state = JERRY_MODULE_STATE_UNLINKED; + ext_object_p->u.cls.module.flags = 0; ecma_module_t *module_p = (ecma_module_t *) obj_p; @@ -103,7 +103,7 @@ ecma_module_cleanup_context (void) static void ecma_module_set_error_state (ecma_module_t *module_p) /**< module */ { - module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR; + module_p->header.u.cls.module.state = JERRY_MODULE_STATE_ERROR; if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL && !jcontext_has_pending_abort ()) { @@ -391,13 +391,13 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */ ecma_module_t *current_module_p = current_set_p->module_p; ecma_string_t *current_export_name_p = current_set_p->name_p; - if (current_module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_ERROR) + if (current_module_p->header.u.cls.module.state == JERRY_MODULE_STATE_ERROR) { resolve_result_p->result_type = ECMA_MODULE_RESOLVE_ERROR; goto exit; } - if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE) + if (current_module_p->header.u.cls.module.flags & ECMA_MODULE_HAS_NAMESPACE) { ecma_property_t *property_p = ecma_find_named_property (current_module_p->namespace_object_p, current_export_name_p); @@ -538,24 +538,24 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */ ecma_value_t ecma_module_evaluate (ecma_module_t *module_p) /**< module */ { - if (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_ERROR) + if (module_p->header.u.cls.module.state == JERRY_MODULE_STATE_ERROR) { return ecma_raise_range_error (ECMA_ERR_MODULE_IS_IN_ERROR_STATE); } - if (module_p->header.u.cls.u1.module_state >= JERRY_MODULE_STATE_EVALUATING) + if (module_p->header.u.cls.module.state >= JERRY_MODULE_STATE_EVALUATING) { return ECMA_VALUE_EMPTY; } - JERRY_ASSERT (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKED); + JERRY_ASSERT (module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKED); JERRY_ASSERT (module_p->scope_p != NULL); - module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_EVALUATING; + module_p->header.u.cls.module.state = JERRY_MODULE_STATE_EVALUATING; ecma_value_t ret_value; - if (module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) + if (module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE) { ret_value = ECMA_VALUE_UNDEFINED; @@ -577,7 +577,7 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */ if (JERRY_LIKELY (!ECMA_IS_VALUE_ERROR (ret_value))) { - module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_EVALUATED; + module_p->header.u.cls.module.state = JERRY_MODULE_STATE_EVALUATED; if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL) { @@ -593,7 +593,7 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */ ecma_module_set_error_state (module_p); } - if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)) + if (!(module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE)) { ecma_bytecode_deref (module_p->u.compiled_code_p); } @@ -715,9 +715,9 @@ ecma_module_heap_sort_shift_down (ecma_value_t *buffer_p, /**< array of items */ static ecma_value_t ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */ { - JERRY_ASSERT (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING); + JERRY_ASSERT (module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING); JERRY_ASSERT (module_p->namespace_object_p != NULL); - JERRY_ASSERT (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE)); + JERRY_ASSERT (!(module_p->header.u.cls.module.flags & ECMA_MODULE_HAS_NAMESPACE)); ecma_module_resolve_set_t *resolve_set_p; resolve_set_p = ecma_module_resolve_set_create (module_p, ecma_get_magic_string (LIT_MAGIC_STRING_ASTERIX_CHAR)); @@ -733,7 +733,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */ { ecma_module_t *current_module_p = current_set_p->module_p; - if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE) + if (current_module_p->header.u.cls.module.flags & ECMA_MODULE_HAS_NAMESPACE) { JERRY_ASSERT (!allow_default); @@ -898,7 +898,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */ buffer_p += 2; } - module_p->header.u.cls.u2.module_flags |= ECMA_MODULE_HAS_NAMESPACE; + module_p->header.u.cls.module.flags |= ECMA_MODULE_HAS_NAMESPACE; ecma_module_release_module_names (module_p->local_exports_p); module_p->local_exports_p = NULL; @@ -1081,12 +1081,12 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ jerry_module_resolve_cb_t callback, /**< resolve module callback */ void *user_p) /**< pointer passed to the resolve callback */ { - if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_UNLINKED) + if (module_p->header.u.cls.module.state != JERRY_MODULE_STATE_UNLINKED) { return ecma_raise_type_error (ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE); } - module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_LINKING; + module_p->header.u.cls.module.state = JERRY_MODULE_STATE_LINKING; uint32_t dfs_index = 0; ecma_module_stack_item_t *last_p; @@ -1099,7 +1099,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ last_p->node_p = module_p->imports_p; last_p->dfs_index = dfs_index; - module_p->header.u.cls.u3.dfs_ancestor_index = dfs_index; + module_p->header.u.cls.module.dfs_ancestor_index = dfs_index; ecma_value_t module_val = ecma_make_object_value (&module_p->header.object); ecma_module_stack_item_t *current_p = last_p; @@ -1144,7 +1144,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ resolved_module_p = ecma_module_get_from_object (node_p->u.path_or_module); } - if (resolved_module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_ERROR) + if (resolved_module_p->header.u.cls.module.state == JERRY_MODULE_STATE_ERROR) { ecma_raise_type_error (ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE); goto error; @@ -1163,10 +1163,10 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ { module_p = ecma_module_get_from_object (node_p->u.path_or_module); - if (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_UNLINKED) + if (module_p->header.u.cls.module.state == JERRY_MODULE_STATE_UNLINKED) { current_p->node_p = node_p->next_p; - module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_LINKING; + module_p->header.u.cls.module.state = JERRY_MODULE_STATE_LINKING; ecma_module_stack_item_t *item_p; item_p = (ecma_module_stack_item_t *) jmem_heap_alloc_block (sizeof (ecma_module_stack_item_t)); @@ -1179,7 +1179,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ item_p->node_p = module_p->imports_p; item_p->dfs_index = dfs_index; - module_p->header.u.cls.u3.dfs_ancestor_index = dfs_index; + module_p->header.u.cls.module.dfs_ancestor_index = dfs_index; last_p = item_p; current_p = item_p; @@ -1187,13 +1187,13 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ goto restart; } - if (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING) + if (module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING) { - uint32_t dfs_ancestor_index = module_p->header.u.cls.u3.dfs_ancestor_index; + uint32_t dfs_ancestor_index = module_p->header.u.cls.module.dfs_ancestor_index; - if (dfs_ancestor_index < current_module_p->header.u.cls.u3.dfs_ancestor_index) + if (dfs_ancestor_index < current_module_p->header.u.cls.module.dfs_ancestor_index) { - current_module_p->header.u.cls.u3.dfs_ancestor_index = dfs_ancestor_index; + current_module_p->header.u.cls.module.dfs_ancestor_index = dfs_ancestor_index; } } @@ -1202,7 +1202,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ if (current_module_p->scope_p == NULL) { - JERRY_ASSERT (!(current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)); + JERRY_ASSERT (!(current_module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE)); /* Initialize scope for handling circular references. */ ecma_value_t result = vm_init_module_scope (current_module_p); @@ -1224,23 +1224,23 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE; ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) namespace_object_p; - ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_MODULE_NAMESPACE; - ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, module_p); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_MODULE_NAMESPACE; + ECMA_SET_INTERNAL_VALUE_POINTER (ecma_object_cls_general (ext_object_p)->value, module_p); current_module_p->namespace_object_p = namespace_object_p; ecma_deref_object (namespace_object_p); } - if (current_module_p->header.u.cls.u3.dfs_ancestor_index != current_p->dfs_index) + if (current_module_p->header.u.cls.module.dfs_ancestor_index != current_p->dfs_index) { current_p = current_p->parent_p; JERRY_ASSERT (current_p != NULL); - uint32_t dfs_ancestor_index = current_module_p->header.u.cls.u3.dfs_ancestor_index; + uint32_t dfs_ancestor_index = current_module_p->header.u.cls.module.dfs_ancestor_index; - if (dfs_ancestor_index < current_p->module_p->header.u.cls.u3.dfs_ancestor_index) + if (dfs_ancestor_index < current_p->module_p->header.u.cls.module.dfs_ancestor_index) { - current_p->module_p->header.u.cls.u3.dfs_ancestor_index = dfs_ancestor_index; + current_p->module_p->header.u.cls.module.dfs_ancestor_index = dfs_ancestor_index; } continue; } @@ -1252,7 +1252,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ do { - JERRY_ASSERT (iterator_p->module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING); + JERRY_ASSERT (iterator_p->module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING); if (ECMA_IS_VALUE_ERROR (ecma_module_create_namespace_object (iterator_p->module_p))) { @@ -1267,7 +1267,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ do { - JERRY_ASSERT (iterator_p->module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING); + JERRY_ASSERT (iterator_p->module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING); if (ECMA_IS_VALUE_ERROR (ecma_module_connect_imports (iterator_p->module_p))) { @@ -1282,8 +1282,8 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ { ecma_module_stack_item_t *prev_p = last_p->prev_p; - JERRY_ASSERT (last_p->module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING); - last_p->module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_LINKED; + JERRY_ASSERT (last_p->module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING); + last_p->module_p->header.u.cls.module.state = JERRY_MODULE_STATE_LINKED; if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL) { @@ -1311,10 +1311,10 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ { ecma_module_stack_item_t *prev_p = last_p->prev_p; - if (last_p->module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_ERROR) + if (last_p->module_p->header.u.cls.module.state != JERRY_MODULE_STATE_ERROR) { - JERRY_ASSERT (last_p->module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_LINKING); - last_p->module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_UNLINKED; + JERRY_ASSERT (last_p->module_p->header.u.cls.module.state == JERRY_MODULE_STATE_LINKING); + last_p->module_p->header.u.cls.module.state = JERRY_MODULE_STATE_UNLINKED; } jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t)); @@ -1371,7 +1371,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */ goto error_module_instantiate; } - if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_EVALUATED) + if (module_p->header.u.cls.module.state != JERRY_MODULE_STATE_EVALUATED) { ecma_deref_object (&module_p->header.object); goto error_module_instantiate; @@ -1405,7 +1405,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */ void ecma_module_release_module (ecma_module_t *module_p) /**< module */ { - jerry_module_state_t state = (jerry_module_state_t) module_p->header.u.cls.u1.module_state; + jerry_module_state_t state = (jerry_module_state_t) module_p->header.u.cls.module.state; JERRY_ASSERT (state != JERRY_MODULE_STATE_INVALID); @@ -1416,7 +1416,7 @@ ecma_module_release_module (ecma_module_t *module_p) /**< module */ ecma_module_release_module_names (module_p->local_exports_p); - if (module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) + if (module_p->header.u.cls.module.flags & ECMA_MODULE_IS_NATIVE) { return; } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c index c295f7a0e6..7eef0e4a1a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c @@ -80,7 +80,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } - ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_obj_p->u.cls.iterator.value; /* 4 - 5 */ if (ecma_is_value_empty (iterated_value)) @@ -114,7 +114,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t } } - ecma_length_t index = ext_obj_p->u.cls.u2.iterator_index; + ecma_length_t index = ext_obj_p->u.cls.iterator.index; if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT)) { @@ -137,17 +137,17 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t else { /* 11. */ - ext_obj_p->u.cls.u2.iterator_index++; + ext_obj_p->u.cls.iterator.index++; } if (index >= length) { - ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY; + ext_obj_p->u.cls.iterator.value = ECMA_VALUE_EMPTY; return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE); } /* 7. */ - uint8_t iterator_kind = ext_obj_p->u.cls.u1.iterator_kind; + uint8_t iterator_kind = ext_obj_p->u.cls.iterator.kind; if (iterator_kind == ECMA_ITERATOR_KEYS) { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c index 43308c86a6..715cba4874 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c @@ -147,7 +147,7 @@ ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_itera { /* 5. */ ecma_value_t next_result = - ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value); + ecma_op_iterator_next (iter_p->header.u.cls.sync_iterator.value, iter_p->sync_next_method, value); /* 6. */ if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p))) @@ -180,7 +180,7 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato lit_magic_string_id_t method_id) /**< method id */ { /* 5. */ - ecma_value_t sync_iterator = iter_p->header.u.cls.u3.sync_iterator; + ecma_value_t sync_iterator = iter_p->header.u.cls.sync_iterator.value; ecma_value_t method = ecma_op_get_method_by_magic_id (sync_iterator, method_id); /* 6. */ @@ -234,7 +234,7 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato } /* 7.c. */ - return ecma_copy_value (capability_p->header.u.cls.u3.promise); + return ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); } /* 8. */ @@ -276,7 +276,7 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato ecma_free_value (reject); /* 10.b. */ - return ecma_copy_value (capability_p->header.u.cls.u3.promise); + return ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); } ecma_value_t result = ecma_op_async_from_sync_iterator_prototype_continuation (call_result, capability_obj_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c index 474bd87740..685013cb76 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c @@ -123,7 +123,7 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine return promise; } - if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) + if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) { ecma_value_t promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE)); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c index 4e6ad9bffd..788de39ee6 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c @@ -76,9 +76,9 @@ ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.cls.u3.value)); + JERRY_ASSERT (ecma_is_value_bigint (ecma_object_cls_general (ext_object_p)->value)); - return ecma_copy_value (ext_object_p->u.cls.u3.value); + return ecma_copy_value (ecma_object_cls_general (ext_object_p)->value); } } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c index 0d71a0677c..08d911dadf 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c @@ -83,9 +83,9 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - JERRY_ASSERT (ecma_is_value_boolean (ext_object_p->u.cls.u3.value)); + JERRY_ASSERT (ecma_is_value_boolean (ecma_object_cls_general (ext_object_p)->value)); - return ext_object_p->u.cls.u3.value; + return ecma_object_cls_general (ext_object_p)->value; } } 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 1342ac52c8..f2c7afc7d3 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c @@ -120,7 +120,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.cls.arraybuffer.length); } default: { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c index 5ad4f2d81c..4f358848d9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c @@ -401,9 +401,9 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil { ecma_number_t local_tza; - if (date_object_p->header.u.cls.u1.date_flags & ECMA_DATE_TZA_SET) + if (date_object_p->header.u.cls.date.flags & ECMA_DATE_TZA_SET) { - local_tza = date_object_p->header.u.cls.u3.tza; + local_tza = date_object_p->header.u.cls.date.tza; JERRY_ASSERT (local_tza == ecma_date_local_time_zone_adjustment (date_value)); } else @@ -457,7 +457,7 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil if (ecma_number_is_nan (converted_number[0])) { *date_value_p = converted_number[0]; - date_object_p->header.u.cls.u1.date_flags &= (uint8_t) ~ECMA_DATE_TZA_SET; + date_object_p->header.u.cls.date.flags &= (uint8_t) ~ECMA_DATE_TZA_SET; return ecma_make_number_value (converted_number[0]); } @@ -586,7 +586,7 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil *date_value_p = full_date; - date_object_p->header.u.cls.u1.date_flags &= (uint8_t) ~ECMA_DATE_TZA_SET; + date_object_p->header.u.cls.date.flags &= (uint8_t) ~ECMA_DATE_TZA_SET; return ecma_make_number_value (full_date); } /* ecma_builtin_date_prototype_dispatch_set */ @@ -644,7 +644,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b } *date_value_p = ecma_date_time_clip (time_num); - date_object_p->header.u.cls.u1.date_flags &= (uint8_t) ~ECMA_DATE_TZA_SET; + date_object_p->header.u.cls.date.flags &= (uint8_t) ~ECMA_DATE_TZA_SET; return ecma_make_number_value (*date_value_p); } @@ -657,17 +657,17 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b { ecma_number_t local_tza; - if (date_object_p->header.u.cls.u1.date_flags & ECMA_DATE_TZA_SET) + if (date_object_p->header.u.cls.date.flags & ECMA_DATE_TZA_SET) { - local_tza = date_object_p->header.u.cls.u3.tza; + local_tza = date_object_p->header.u.cls.date.tza; JERRY_ASSERT (local_tza == ecma_date_local_time_zone_adjustment (date_value)); } else { local_tza = ecma_date_local_time_zone_adjustment (date_value); JERRY_ASSERT (local_tza <= INT32_MAX && local_tza >= INT32_MIN); - date_object_p->header.u.cls.u3.tza = (int32_t) local_tza; - date_object_p->header.u.cls.u1.date_flags |= ECMA_DATE_TZA_SET; + date_object_p->header.u.cls.date.tza = (int32_t) local_tza; + date_object_p->header.u.cls.date.flags |= ECMA_DATE_TZA_SET; } date_value += local_tza; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c index 201634d93a..a45b86d777 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c @@ -720,9 +720,9 @@ ecma_builtin_date_create (ecma_number_t tv) ecma_deref_object (prototype_obj_p); ecma_date_object_t *date_object_p = (ecma_date_object_t *) obj_p; - date_object_p->header.u.cls.type = ECMA_OBJECT_CLASS_DATE; - date_object_p->header.u.cls.u1.date_flags = ECMA_DATE_TZA_NONE; - date_object_p->header.u.cls.u3.tza = 0; + date_object_p->header.u.cls.head.type = ECMA_OBJECT_CLASS_DATE; + date_object_p->header.u.cls.date.flags = ECMA_DATE_TZA_NONE; + date_object_p->header.u.cls.date.tza = 0; date_object_p->date_value = tv; return ecma_make_object_value (obj_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c index 09881d92d6..d27461e780 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c @@ -89,9 +89,9 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob while (true) { - if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) + if (generator_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) { - if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING) + if (generator_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING) { return ecma_raise_type_error (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION); } @@ -101,10 +101,10 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob bool done = false; - generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_RUNNING; + generator_object_p->extended_object.u.cls.generator.obj_flags |= ECMA_EXECUTABLE_OBJECT_RUNNING; ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, next_method, arg, &done); ecma_free_value (arg); - generator_object_p->extended_object.u.cls.u2.executable_obj_flags &= (uint8_t) ~ECMA_EXECUTABLE_OBJECT_RUNNING; + generator_object_p->extended_object.u.cls.generator.obj_flags &= (uint8_t) ~ECMA_EXECUTABLE_OBJECT_RUNNING; if (ECMA_IS_VALUE_ERROR (result)) { @@ -156,7 +156,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob } bool done; - done = (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED); + done = (generator_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED); if (!done) { @@ -179,7 +179,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob } ecma_deref_object (ecma_get_object_from_value (iterator)); - generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD; + generator_object_p->extended_object.u.cls.generator.obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD; generator_object_p->iterator = iterator; if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED) @@ -232,12 +232,12 @@ ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, / return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT); } - if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING) + if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING) { return ecma_raise_type_error (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION); } - if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) + if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) { if (builtin_routine_id != ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW) { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c index 11a6871b60..0483f30755 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c @@ -1311,7 +1311,7 @@ ecma_builtin_json_serialize_property (ecma_json_stringify_context_t *context_p, if (ecma_get_object_base_type (obj_p) == ECMA_OBJECT_BASE_TYPE_CLASS) { - switch (((ecma_extended_object_t *) obj_p)->u.cls.type) + switch (((ecma_extended_object_t *) obj_p)->u.cls.head.type) { /* 5.a */ case ECMA_OBJECT_CLASS_NUMBER: @@ -1346,7 +1346,7 @@ ecma_builtin_json_serialize_property (ecma_json_stringify_context_t *context_p, case ECMA_OBJECT_CLASS_BOOLEAN: { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - value = ext_object_p->u.cls.u3.value; + value = ecma_object_cls_general (ext_object_p)->value; ecma_deref_object (obj_p); break; } @@ -1355,7 +1355,7 @@ ecma_builtin_json_serialize_property (ecma_json_stringify_context_t *context_p, case ECMA_OBJECT_CLASS_BIGINT: { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - value = ecma_copy_value (ext_object_p->u.cls.u3.value); + value = ecma_copy_value (ecma_object_cls_general (ext_object_p)->value); ecma_deref_object (obj_p); break; } @@ -1616,7 +1616,7 @@ ecma_builtin_json_stringify (ecma_value_t arg1, /**< value */ if (ecma_get_object_base_type (value_obj_p) == ECMA_OBJECT_BASE_TYPE_CLASS) { - uint8_t class_type = ((ecma_extended_object_t *) value_obj_p)->u.cls.type; + uint8_t class_type = ((ecma_extended_object_t *) value_obj_p)->u.cls.head.type; if (class_type == ECMA_OBJECT_CLASS_NUMBER || class_type == ECMA_OBJECT_CLASS_STRING) { @@ -1667,7 +1667,7 @@ ecma_builtin_json_stringify (ecma_value_t arg1, /**< value */ if (ecma_get_object_base_type (obj_p) == ECMA_OBJECT_BASE_TYPE_CLASS) { - uint8_t class_type = ((ecma_extended_object_t *) obj_p)->u.cls.type; + uint8_t class_type = ((ecma_extended_object_t *) obj_p)->u.cls.head.type; /* 5.a */ if (class_type == ECMA_OBJECT_CLASS_NUMBER) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c index 1d212f5f7c..e5a3c8fe08 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c @@ -332,9 +332,9 @@ ecma_builtin_number_prototype_object_value_of (ecma_value_t this_arg) /**< this { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - JERRY_ASSERT (ecma_is_value_number (ext_object_p->u.cls.u3.value)); + JERRY_ASSERT (ecma_is_value_number (ecma_object_cls_general (ext_object_p)->value)); - return ext_object_p->u.cls.u3.value; + return ecma_object_cls_general (ext_object_p)->value; } } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c index d9d252641c..1ade29d5e2 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c @@ -117,7 +117,7 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for if (ecma_is_value_false (next)) { /* ii. */ - ret_value = ecma_copy_value (capability_p->header.u.cls.u3.promise); + ret_value = ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); goto done; } @@ -247,7 +247,7 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */ } /* iv. */ - ret_value = ecma_copy_value (capability_p->header.u.cls.u3.promise); + ret_value = ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); goto done; } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c index 94c0384dd8..f08d883b28 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c @@ -64,7 +64,8 @@ static ecma_value_t ecma_builtin_regexp_prototype_flags_helper (ecma_extended_object_t *re_obj_p, /**< this object */ uint16_t builtin_routine_id) /**< id of the flag */ { - re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value); + re_compiled_code_t *bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (re_obj_p)->value); uint16_t flags = bc_p->header.status_flags; @@ -201,7 +202,8 @@ ecma_op_escape_regexp_pattern (ecma_string_t *pattern_str_p) /**< RegExp pattern static ecma_value_t ecma_builtin_regexp_prototype_get_source (ecma_extended_object_t *re_obj_p) /**< this argument */ { - re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value); + re_compiled_code_t *bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (re_obj_p)->value); return ecma_op_escape_regexp_pattern (ecma_get_string_from_value (bc_p->source)); } /* ecma_builtin_regexp_prototype_get_source */ @@ -225,7 +227,8 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */ { ecma_object_t *this_obj_p = ecma_get_object_from_value (this_arg); ecma_extended_object_t *re_obj_p = (ecma_extended_object_t *) this_obj_p; - re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value); + re_compiled_code_t *old_bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (re_obj_p)->value); ecma_value_t ret_value; @@ -237,7 +240,8 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */ } ecma_extended_object_t *pattern_obj_p = (ecma_extended_object_t *) ecma_get_object_from_value (pattern_arg); - re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, pattern_obj_p->u.cls.u3.value); + re_compiled_code_t *bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (pattern_obj_p)->value); ret_value = ecma_op_create_regexp_from_bytecode (this_obj_p, bc_p); } @@ -518,8 +522,8 @@ ecma_builtin_regexp_prototype_match_all (ecma_object_t *regexp_obj_p, /**< this result_obj = ecma_create_object (proto_p, sizeof (ecma_regexp_string_iterator_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) result_obj; - ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR; - ext_obj_p->u.cls.u1.regexp_string_iterator_flags = (uint8_t) (parsed_flag & (RE_FLAG_GLOBAL | RE_FLAG_UNICODE)); + ext_obj_p->u.cls.head.type = ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR; + ext_obj_p->u.cls.regexp_string_iterator.flags = (uint8_t) (parsed_flag & (RE_FLAG_GLOBAL | RE_FLAG_UNICODE)); ecma_regexp_string_iterator_t *regexp_string_iterator_obj = (ecma_regexp_string_iterator_t *) result_obj; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c index 5a1d554dfa..0cf3b2f1ad 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c @@ -102,7 +102,7 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val ecma_value_t result = ECMA_VALUE_ERROR; /* 11. */ - if (regexp_string_iterator_obj->header.u.cls.u1.regexp_string_iterator_flags & RE_FLAG_GLOBAL) + if (regexp_string_iterator_obj->header.u.cls.regexp_string_iterator.flags & RE_FLAG_GLOBAL) { ecma_value_t matched_str_value = ecma_op_object_get_by_index (match_result_array_p, 0); @@ -141,7 +141,7 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val goto free_variables; } - uint8_t flags = regexp_string_iterator_obj->header.u.cls.u1.regexp_string_iterator_flags; + uint8_t flags = regexp_string_iterator_obj->header.u.cls.regexp_string_iterator.flags; ecma_length_t next_index = ecma_op_advance_string_index (matcher_str_p, this_index, (flags & RE_FLAG_UNICODE) != 0); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c index 0b3cfe58d0..5c1e07ed05 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c @@ -102,7 +102,7 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**< if (ecma_object_is_regexp_object (pattern_value)) { ecma_extended_object_t *pattern_obj_p = (ecma_extended_object_t *) ecma_get_object_from_value (pattern_value); - bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, pattern_obj_p->u.cls.u3.value); + bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (pattern_obj_p)->value); create_regexp_from_bc = ecma_is_value_undefined (flags_value); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c index 5f2158cf99..f85a500a00 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c @@ -78,7 +78,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } - ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_obj_p->u.cls.iterator.value; /* 4 - 5 */ if (ecma_is_value_empty (iterated_value)) @@ -91,7 +91,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< ecma_string_t *string_p = ecma_get_string_from_value (iterated_value); /* 6. */ - lit_utf8_size_t position = ext_obj_p->u.cls.u2.iterator_index; + lit_utf8_size_t position = ext_obj_p->u.cls.iterator.index; if (JERRY_UNLIKELY (position == ECMA_ITERATOR_INDEX_LIMIT)) { @@ -111,7 +111,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< if (position >= len) { ecma_deref_ecma_string (string_p); - ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY; + ext_obj_p->u.cls.iterator.value = ECMA_VALUE_EMPTY; return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE); } @@ -148,11 +148,11 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< /* 13. */ if (position + result_size < ECMA_ITERATOR_INDEX_LIMIT) { - ext_obj_p->u.cls.u2.iterator_index = (uint16_t) (position + result_size); + ext_obj_p->u.cls.iterator.index = (uint16_t) (position + result_size); } else { - ext_obj_p->u.cls.u2.iterator_index = ECMA_ITERATOR_INDEX_LIMIT; + ext_obj_p->u.cls.iterator.index = ECMA_ITERATOR_INDEX_LIMIT; ecma_string_t *prop_name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_ITERATOR_NEXT_INDEX); ecma_value_t put_result = diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index 8616fbf5a5..bb3323a287 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -136,9 +136,9 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - JERRY_ASSERT (ecma_is_value_string (ext_object_p->u.cls.u3.value)); + JERRY_ASSERT (ecma_is_value_string (ecma_object_cls_general (ext_object_p)->value)); - return ecma_copy_value (ext_object_p->u.cls.u3.value); + return ecma_copy_value (ecma_object_cls_general (ext_object_p)->value); } } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c index 4b4caf26a5..3149ec215d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c @@ -74,7 +74,7 @@ ecma_builtin_weakref_prototype_object_deref (ecma_value_t this_arg) /**< this ar return ecma_raise_type_error (ECMA_ERR_TARGET_IS_NOT_WEAKREF); } - return ecma_copy_value (this_ext_obj->u.cls.u3.target); + return ecma_copy_value (this_ext_obj->u.cls.weakref.target); } /* ecma_builtin_weakref_prototype_object_deref */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c index bf15aae1c2..eae4a17c6e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c @@ -80,8 +80,8 @@ ecma_builtin_weakref_dispatch_construct (const ecma_value_t *arguments_list_p, / ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_deref_object (proto_p); ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p; - ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_WEAKREF; - ext_obj_p->u.cls.u3.target = arguments_list_p[0]; + ext_obj_p->u.cls.head.type = ECMA_OBJECT_CLASS_WEAKREF; + ext_obj_p->u.cls.weakref.target = arguments_list_p[0]; ecma_op_object_set_weak (ecma_get_object_from_value (arguments_list_p[0]), object_p); return ecma_make_object_value (object_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.c b/jerry-core/ecma/builtin-objects/ecma-builtins.c index c14500717c..510cbd7c26 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.c @@ -425,8 +425,8 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_BUILT_IN_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_STRING; - ext_object_p->u.cls.u3.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_STRING; + ecma_object_cls_general (ext_object_p)->value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); break; } #endif /* JERRY_BUILTIN_STRING */ @@ -437,8 +437,8 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_BUILT_IN_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_NUMBER; - ext_object_p->u.cls.u3.value = ecma_make_integer_value (0); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_NUMBER; + ecma_object_cls_general (ext_object_p)->value = ecma_make_integer_value (0); break; } #endif /* JERRY_BUILTIN_NUMBER */ @@ -449,8 +449,8 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_BUILT_IN_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BOOLEAN; - ext_object_p->u.cls.u3.value = ECMA_VALUE_FALSE; + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_BOOLEAN; + ecma_object_cls_general (ext_object_p)->value = ECMA_VALUE_FALSE; break; } #endif /* JERRY_BUILTIN_BOOLEAN */ 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 4b57d9f4f2..b22f56ca65 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 @@ -2107,7 +2107,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.cls.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..253c880b85 100644 --- a/jerry-core/ecma/operations/ecma-arguments-object.c +++ b/jerry-core/ecma/operations/ecma-arguments-object.c @@ -75,10 +75,10 @@ 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.cls.head.type = ECMA_OBJECT_CLASS_ARGUMENTS; + arguments_p->header.u.cls.arguments.flags = ECMA_ARGUMENTS_OBJECT_NO_FLAGS; + arguments_p->header.u.cls.arguments.formal_params_number = formal_params_number; + arguments_p->header.u.cls.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.cls.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.cls.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.cls.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.cls.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.cls.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.cls.arguments.number; + uint8_t flags = arguments_p->header.u.cls.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.cls.arguments.flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED)); - arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED; + arguments_p->header.u.cls.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.cls.arguments.flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED)); + JERRY_ASSERT (arguments_p->header.u.cls.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED); - arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED; + arguments_p->header.u.cls.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.cls.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.cls.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.cls.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.cls.arguments.number; + uint8_t flags = arguments_p->header.u.cls.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.cls.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED); + JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.cls.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.cls.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 1491e31ec5..7ee3d29868 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -67,9 +67,9 @@ ecma_arraybuffer_create_object (uint8_t type, /**< type of the arraybuffer */ ECMA_OBJECT_TYPE_CLASS); 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.cls.head.type = type; + ext_object_p->u.cls.arraybuffer.flags = ECMA_ARRAYBUFFER_ALLOCATED; + ext_object_p->u.cls.arraybuffer.length = length; memset ((uint8_t *) (ext_object_p + 1), 0, length); return object_p; @@ -101,9 +101,9 @@ ecma_arraybuffer_create_object_with_buffer (uint8_t type, /**< type of the array ecma_create_object (ecma_builtin_get (prototype_id), sizeof (ecma_arraybuffer_pointer_t), ECMA_OBJECT_TYPE_CLASS); 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.cls.head.type = type; + arraybuffer_pointer_p->extended_object.u.cls.arraybuffer.flags = ECMA_ARRAYBUFFER_HAS_POINTER; + arraybuffer_pointer_p->extended_object.u.cls.arraybuffer.length = length; arraybuffer_pointer_p->buffer_p = NULL; arraybuffer_pointer_p->arraybuffer_user_p = NULL; @@ -142,11 +142,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.cls.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.cls.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; @@ -156,7 +156,7 @@ ecma_arraybuffer_allocate_buffer (ecma_object_t *arraybuffer_p) /**< ArrayBuffer jerry_arraybuffer_type_t type = JERRY_ARRAYBUFFER_TYPE_ARRAYBUFFER; #if JERRY_BUILTIN_SHAREDARRAYBUFFER - if (extended_object_p->u.cls.type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER) + if (extended_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER) { type = JERRY_ARRAYBUFFER_TYPE_SHARED_ARRAYBUFFER; } @@ -178,7 +178,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.cls.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED; memset (buffer_p, 0, arraybuffer_length); return ECMA_VALUE_UNDEFINED; @@ -215,7 +215,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.cls.arraybuffer.length; if (free_callback == NULL) { @@ -226,7 +226,7 @@ ecma_arraybuffer_release_buffer (ecma_object_t *arraybuffer_p) /**< ArrayBuffer jerry_arraybuffer_type_t type = JERRY_ARRAYBUFFER_TYPE_ARRAYBUFFER; #if JERRY_BUILTIN_SHAREDARRAYBUFFER - if (arraybuffer_pointer_p->extended_object.u.cls.type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER) + if (arraybuffer_pointer_p->extended_object.u.cls.head.type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER) { type = JERRY_ARRAYBUFFER_TYPE_SHARED_ARRAYBUFFER; } @@ -332,7 +332,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.cls.arraybuffer.length; } /* ecma_arraybuffer_get_length */ /** @@ -389,14 +389,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.cls.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.cls.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 822e13f050..235d4a9bef 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.h +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.h @@ -32,7 +32,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.cls.arraybuffer.flags) /** * Check whether the backing store is allocated for an array buffer. diff --git a/jerry-core/ecma/operations/ecma-async-generator-object.c b/jerry-core/ecma/operations/ecma-async-generator-object.c index f73e4e1823..8aa00bce64 100644 --- a/jerry-core/ecma/operations/ecma-async-generator-object.c +++ b/jerry-core/ecma/operations/ecma-async-generator-object.c @@ -59,20 +59,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.cls.u3.head; + ecma_value_t head = async_generator_object_p->extended_object.u.cls.generator.head; if (ECMA_IS_INTERNAL_VALUE_NULL (head)) { - ECMA_SET_INTERNAL_VALUE_POINTER (async_generator_object_p->extended_object.u.cls.u3.head, task_p); + ECMA_SET_INTERNAL_VALUE_POINTER (async_generator_object_p->extended_object.u.cls.generator.head, task_p); - if (async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_ASYNC_GENERATOR_CALLED) + if (async_generator_object_p->extended_object.u.cls.generator.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.cls.u2.executable_obj_flags |= ECMA_ASYNC_GENERATOR_CALLED; + async_generator_object_p->extended_object.u.cls.generator.obj_flags |= ECMA_ASYNC_GENERATOR_CALLED; ecma_async_generator_run (async_generator_object_p); return result; } @@ -180,15 +180,14 @@ 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.cls.type == ECMA_OBJECT_CLASS_ASYNC_GENERATOR); - JERRY_ASSERT (!ECMA_IS_INTERNAL_VALUE_NULL (async_generator_object_p->extended_object.u.cls.u3.head)); + JERRY_ASSERT (async_generator_object_p->extended_object.u.cls.head.type == ECMA_OBJECT_CLASS_ASYNC_GENERATOR); + JERRY_ASSERT (!ECMA_IS_INTERNAL_VALUE_NULL (async_generator_object_p->extended_object.u.cls.generator.head)); - ecma_value_t head = async_generator_object_p->extended_object.u.cls.u3.head; + ecma_value_t head = async_generator_object_p->extended_object.u.cls.generator.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.cls.u2.executable_obj_flags - & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) + if (async_generator_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) { switch (task_p->operation_type) { @@ -245,7 +244,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.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK; + async_generator_object_p->extended_object.u.cls.generator.obj_flags &= ECMA_AWAIT_CLEAR_MASK; async_generator_object_p->iterator = ECMA_VALUE_UNDEFINED; async_generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw; @@ -273,9 +272,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.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) + if (async_generator_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) { - JERRY_ASSERT (head == async_generator_object_p->extended_object.u.cls.u3.head); + JERRY_ASSERT (head == async_generator_object_p->extended_object.u.cls.generator.head); ecma_async_generator_finalize (async_generator_object_p, result); result = ECMA_VALUE_UNDEFINED; } @@ -290,7 +289,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.cls.u3.head; + ecma_value_t next = async_generator_object_p->extended_object.u.cls.generator.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)) @@ -308,7 +307,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.cls.u3.head = next; + async_generator_object_p->extended_object.u.cls.generator.head = next; jmem_heap_free_block (task_p, sizeof (ecma_async_generator_task_t)); while (!ECMA_IS_INTERNAL_VALUE_NULL (next)) @@ -329,7 +328,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.cls.u3.head = next; + async_generator_object_p->extended_object.u.cls.generator.head = next; jmem_heap_free_block (task_p, sizeof (ecma_async_generator_task_t)); } } /* ecma_async_generator_finalize */ diff --git a/jerry-core/ecma/operations/ecma-async-generator-object.h b/jerry-core/ecma/operations/ecma-async-generator-object.h index bcd58e0fd9..105f350937 100644 --- a/jerry-core/ecma/operations/ecma-async-generator-object.h +++ b/jerry-core/ecma/operations/ecma-async-generator-object.h @@ -41,18 +41,18 @@ 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.cls.u2.executable_obj_flags >> ECMA_AWAIT_STATE_SHIFT) + ((async_generator_object_p)->extended_object.u.cls.generator.obj_flags >> ECMA_AWAIT_STATE_SHIFT) /** * Set the state of an async yield iterator. */ -#define ECMA_AWAIT_SET_STATE(async_generator_object_p, to) \ - do \ - { \ - 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.cls.u2.executable_obj_flags = extra_info; \ +#define ECMA_AWAIT_SET_STATE(async_generator_object_p, to) \ + do \ + { \ + uint16_t extra_info = (async_generator_object_p)->extended_object.u.cls.generator.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.cls.generator.obj_flags = extra_info; \ } while (false) /** @@ -69,7 +69,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.cls.u2.executable_obj_flags ^= ECMA_AWAIT_CS_HELPER (from, to)) + ((async_generator_object_p)->extended_object.u.cls.generator.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, diff --git a/jerry-core/ecma/operations/ecma-bigint-object.c b/jerry-core/ecma/operations/ecma-bigint-object.c index 6d03cd5171..b3c67f09c6 100644 --- a/jerry-core/ecma/operations/ecma-bigint-object.c +++ b/jerry-core/ecma/operations/ecma-bigint-object.c @@ -52,8 +52,8 @@ ecma_op_create_bigint_object (ecma_value_t arg) /**< argument passed to the toOb ecma_create_object (prototype_obj_p, 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.cls.type = ECMA_OBJECT_CLASS_BIGINT; - ext_object_p->u.cls.u3.value = ecma_copy_value (arg); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_BIGINT; + ecma_object_cls_general (ext_object_p)->value = ecma_copy_value (arg); return ecma_make_object_value (object_p); } /* ecma_op_create_bigint_object */ diff --git a/jerry-core/ecma/operations/ecma-boolean-object.c b/jerry-core/ecma/operations/ecma-boolean-object.c index 956aa4a7e6..1ad0a12710 100644 --- a/jerry-core/ecma/operations/ecma-boolean-object.c +++ b/jerry-core/ecma/operations/ecma-boolean-object.c @@ -71,8 +71,8 @@ ecma_op_create_boolean_object (ecma_value_t arg) /**< argument passed to the Boo ecma_create_object (prototype_obj_p, 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.cls.type = ECMA_OBJECT_CLASS_BOOLEAN; - ext_object_p->u.cls.u3.value = ecma_make_boolean_value (boolean_value); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_BOOLEAN; + ecma_object_cls_general (ext_object_p)->value = ecma_make_boolean_value (boolean_value); if (new_target) { diff --git a/jerry-core/ecma/operations/ecma-container-object.c b/jerry-core/ecma/operations/ecma-container-object.c index 5ce05c228d..55646fab63 100644 --- a/jerry-core/ecma/operations/ecma-container-object.c +++ b/jerry-core/ecma/operations/ecma-container-object.c @@ -309,9 +309,10 @@ ecma_op_container_free_entries (ecma_object_t *object_p) /**< collection object JERRY_ASSERT (object_p != NULL); 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); - switch (map_object_p->u.cls.u2.container_id) + switch (map_object_p->u.cls.container.id) { case LIT_MAGIC_STRING_WEAKSET_UL: { @@ -369,16 +370,16 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_extended_object_t), 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.cls.type = ECMA_OBJECT_CLASS_CONTAINER; - map_obj_p->u.cls.u1.container_flags = ECMA_CONTAINER_FLAGS_EMPTY; - map_obj_p->u.cls.u2.container_id = (uint16_t) lit_id; + map_obj_p->u.cls.head.type = ECMA_OBJECT_CLASS_CONTAINER; + map_obj_p->u.cls.container.flags = ECMA_CONTAINER_FLAGS_EMPTY; + map_obj_p->u.cls.container.id = (uint16_t) lit_id; if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_WEAKSET_UL) { - map_obj_p->u.cls.u1.container_flags |= ECMA_CONTAINER_FLAGS_WEAK; + map_obj_p->u.cls.container.flags |= ECMA_CONTAINER_FLAGS_WEAK; } - ECMA_SET_INTERNAL_VALUE_POINTER (map_obj_p->u.cls.u3.value, container_p); + ECMA_SET_INTERNAL_VALUE_POINTER (map_obj_p->u.cls.container.value, container_p); ecma_value_t set_value = ecma_make_object_value (object_p); ecma_value_t result = set_value; @@ -547,7 +548,7 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */ ecma_object_t *map_object_p = ecma_get_object_from_value (this_arg); if (ecma_object_class_is (map_object_p, ECMA_OBJECT_CLASS_CONTAINER) - && ((ecma_extended_object_t *) map_object_p)->u.cls.u2.container_id == lit_id) + && ((ecma_extended_object_t *) map_object_p)->u.cls.container.id == lit_id) { return (ecma_extended_object_t *) map_object_p; } @@ -572,7 +573,8 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */ 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); return ecma_make_uint32_value (ECMA_CONTAINER_GET_SIZE (container_p)); } /* ecma_op_container_size */ @@ -593,7 +595,8 @@ ecma_op_container_get (ecma_extended_object_t *map_object_p, /**< map object */ return ECMA_VALUE_UNDEFINED; } - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); if (ECMA_CONTAINER_GET_SIZE (container_p) == 0) { @@ -621,9 +624,10 @@ ecma_op_container_has (ecma_extended_object_t *map_object_p, /**< map object */ ecma_value_t key_arg, /**< key argument */ 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); - if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) + if ((map_object_p->u.cls.container.flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) { return ECMA_VALUE_FALSE; } @@ -675,9 +679,10 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */ ecma_value_t value_arg, /**< value argument */ 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); - if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) + if ((map_object_p->u.cls.container.flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) { return ecma_raise_type_error (ECMA_ERR_KEY_MUST_BE_AN_OBJECT); } @@ -688,7 +693,7 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */ { ecma_op_internal_buffer_append (container_p, ecma_op_container_set_noramlize_zero (key_arg), value_arg, lit_id); - if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0) + if ((map_object_p->u.cls.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); @@ -725,7 +730,8 @@ ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object ecma_object_t *func_object_p = ecma_get_object_from_value (predicate); 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); uint8_t entry_size = ecma_op_container_entry_size (lit_id); @@ -782,7 +788,8 @@ ecma_op_container_delete (ecma_extended_object_t *map_object_p, /**< map object ecma_value_t key_arg, /**< key argument */ 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.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id); @@ -811,7 +818,8 @@ ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, /**< map ob return ECMA_VALUE_FALSE; } - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id); @@ -839,12 +847,13 @@ ecma_op_container_find_weak_value (ecma_object_t *object_p, /**< internal contai { ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; - JERRY_ASSERT (map_object_p->u.cls.type == ECMA_OBJECT_CLASS_CONTAINER - && map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL); + JERRY_ASSERT (map_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_CONTAINER + && map_object_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKMAP_UL); - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); - ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id); + ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.container.id); JERRY_ASSERT (entry_p != NULL); @@ -860,17 +869,18 @@ 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; - JERRY_ASSERT (map_object_p->u.cls.type == ECMA_OBJECT_CLASS_CONTAINER - && (map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKSET_UL - || map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL)); + JERRY_ASSERT (map_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_CONTAINER + && (map_object_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKSET_UL + || map_object_p->u.cls.container.id == LIT_MAGIC_STRING_WEAKMAP_UL)); - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.value); - ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id); + ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.container.id); JERRY_ASSERT (entry_p != NULL); - ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.cls.u2.container_id); + ecma_op_internal_buffer_delete (container_p, (ecma_container_pair_t *) entry_p, map_object_p->u.cls.container.id); } /* ecma_op_container_remove_weak_entry */ /** @@ -903,7 +913,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.cls.u2.iterator_index; + uint32_t index = ((ecma_extended_object_t *) iter_obj_p)->u.cls.iterator.index; if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT)) { @@ -945,7 +955,7 @@ ecma_op_iterator_set_index (ecma_object_t *iter_obj_p, /**< iterator object poin } else { - ((ecma_extended_object_t *) iter_obj_p)->u.cls.u2.iterator_index = (uint16_t) index; + ((ecma_extended_object_t *) iter_obj_p)->u.cls.iterator.index = (uint16_t) index; } } /* ecma_op_iterator_set_index */ @@ -979,7 +989,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */ return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } - ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; + ecma_value_t iterated_value = ext_obj_p->u.cls.iterator.value; if (ecma_is_value_empty (iterated_value)) { @@ -987,21 +997,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.cls.u2.container_id; + lit_magic_string_id_t lit_id = map_object_p->u.cls.container.id; - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.container.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.cls.u3.iterated_value = ECMA_VALUE_EMPTY; + ext_obj_p->u.cls.iterator.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.cls.u1.iterator_kind; + uint8_t iterator_kind = ext_obj_p->u.cls.iterator.kind; ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); ecma_value_t ret_value = ECMA_VALUE_UNDEFINED; diff --git a/jerry-core/ecma/operations/ecma-conversion.c b/jerry-core/ecma/operations/ecma-conversion.c index cf0c9fde2e..a35b3d401a 100644 --- a/jerry-core/ecma/operations/ecma-conversion.c +++ b/jerry-core/ecma/operations/ecma-conversion.c @@ -569,8 +569,8 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */ 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.cls.type = class_type; - ext_object_p->u.cls.u3.value = ecma_copy_value_if_not_object (value); + ext_object_p->u.cls.head.type = class_type; + ecma_object_cls_general (ext_object_p)->value = ecma_copy_value_if_not_object (value); return ecma_make_object_value (object_p); } /* ecma_op_to_object */ diff --git a/jerry-core/ecma/operations/ecma-dataview-object.c b/jerry-core/ecma/operations/ecma-dataview-object.c index db2ae0a68b..fdd244467d 100644 --- a/jerry-core/ecma/operations/ecma-dataview-object.c +++ b/jerry-core/ecma/operations/ecma-dataview-object.c @@ -148,8 +148,8 @@ 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.cls.head.type = ECMA_OBJECT_CLASS_DATAVIEW; + dataview_obj_p->header.u.cls.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.cls.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-exceptions.c b/jerry-core/ecma/operations/ecma-exceptions.c index 675aaf92f9..b8d5a80470 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.c +++ b/jerry-core/ecma/operations/ecma-exceptions.c @@ -124,8 +124,8 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */ ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *extended_object_p = (ecma_extended_object_t *) error_object_p; - extended_object_p->u.cls.type = ECMA_OBJECT_CLASS_ERROR; - extended_object_p->u.cls.u1.error_type = (uint8_t) error_type; + extended_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_ERROR; + extended_object_p->u.cls.error.type = (uint8_t) error_type; if (message_string_p != NULL) { @@ -285,7 +285,7 @@ ecma_get_error_type (ecma_object_t *error_object_p) /**< possible error object * return JERRY_ERROR_NONE; } - return (jerry_error_t) ((ecma_extended_object_t *) error_object_p)->u.cls.u1.error_type; + return (jerry_error_t) ((ecma_extended_object_t *) error_object_p)->u.cls.error.type; } /* ecma_get_error_type */ /** diff --git a/jerry-core/ecma/operations/ecma-iterator-object.c b/jerry-core/ecma/operations/ecma-iterator-object.c index 3e8ef7eac9..a32a260234 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.c +++ b/jerry-core/ecma/operations/ecma-iterator-object.c @@ -141,14 +141,14 @@ ecma_op_create_iterator_object (ecma_value_t iterated_value, /**< value from cre ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p; - ext_obj_p->u.cls.type = (uint8_t) iterator_type; + ext_obj_p->u.cls.head.type = (uint8_t) iterator_type; /* 3. */ - ext_obj_p->u.cls.u3.iterated_value = iterated_value; + ext_obj_p->u.cls.iterator.value = iterated_value; /* 4. */ - ext_obj_p->u.cls.u2.iterator_index = 0; + ext_obj_p->u.cls.iterator.index = 0; /* 5. */ - ext_obj_p->u.cls.u1.iterator_kind = (uint8_t) kind; + ext_obj_p->u.cls.iterator.kind = (uint8_t) kind; /* 6. */ return ecma_make_object_value (object_p); @@ -680,8 +680,8 @@ ecma_op_create_async_from_sync_iterator (ecma_value_t sync_iterator, /**< sync i /* 2. */ ext_obj_p->sync_next_method = sync_next_method; - ext_obj_p->header.u.cls.u3.sync_iterator = sync_iterator; - ext_obj_p->header.u.cls.type = ECMA_OBJECT_CLASS_ASYNC_FROM_SYNC_ITERATOR; + ext_obj_p->header.u.cls.sync_iterator.value = sync_iterator; + ext_obj_p->header.u.cls.head.type = ECMA_OBJECT_CLASS_ASYNC_FROM_SYNC_ITERATOR; /* 3. */ *async_next_method_p = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_NEXT); diff --git a/jerry-core/ecma/operations/ecma-jobqueue.c b/jerry-core/ecma/operations/ecma-jobqueue.c index 3cccfa9b58..2d96bad56b 100644 --- a/jerry-core/ecma/operations/ecma-jobqueue.c +++ b/jerry-core/ecma/operations/ecma-jobqueue.c @@ -194,7 +194,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.cls.u3.promise, + capability_p->header.u.cls.promise_capabality.promise, ECMA_VALUE_UNDEFINED, JERRY_CONTEXT (promise_callback_user_p)); } @@ -251,7 +251,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.cls.u3.promise, + capability_p->header.u.cls.promise_capabality.promise, ECMA_VALUE_UNDEFINED, JERRY_CONTEXT (promise_callback_user_p)); } @@ -292,8 +292,7 @@ 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.cls.u2.executable_obj_flags - & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)) + if (!(executable_object_p->extended_object.u.cls.generator.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 +320,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.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK; + executable_object_p->extended_object.u.cls.generator.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.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) + if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) { job_p->argument = ecma_await_continue (executable_object_p, job_p->argument); @@ -337,8 +336,7 @@ 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.cls.u2.executable_obj_flags - & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) + else if (executable_object_p->extended_object.u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) { /* Continue iteration. */ JERRY_ASSERT (job_p->argument == ECMA_VALUE_UNDEFINED); @@ -357,7 +355,7 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_ } /* Clear all status. */ - executable_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK; + executable_object_p->extended_object.u.cls.generator.obj_flags &= ECMA_AWAIT_CLEAR_MASK; } result = opfunc_resume_executable_object (executable_object_p, job_p->argument); @@ -365,7 +363,7 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_ job_p->argument = ECMA_VALUE_UNDEFINED; 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) + if ((executable_object_p->extended_object.u.cls.generator.obj_flags & expected_bits) == expected_bits) { ecma_async_generator_finalize (executable_object_p, result); result = ECMA_VALUE_UNDEFINED; @@ -424,7 +422,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.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_ALREADY_RESOLVED; + promise_p->header.u.cls.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); diff --git a/jerry-core/ecma/operations/ecma-number-object.c b/jerry-core/ecma/operations/ecma-number-object.c index 548f2f736e..e22402b4eb 100644 --- a/jerry-core/ecma/operations/ecma-number-object.c +++ b/jerry-core/ecma/operations/ecma-number-object.c @@ -76,10 +76,10 @@ ecma_op_create_number_object (ecma_value_t arg) /**< argument passed to the Numb ecma_create_object (prototype_obj_p, 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.cls.type = ECMA_OBJECT_CLASS_NUMBER; + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_NUMBER; /* Pass reference (no need to free conv_to_num_completion). */ - ext_object_p->u.cls.u3.value = conv_to_num_completion; + ecma_object_cls_general (ext_object_p)->value = conv_to_num_completion; if (new_target) { diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 41b56adcd8..eb65b87bd6 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -91,7 +91,7 @@ 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; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_STRING: { @@ -99,7 +99,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ { if (options & ECMA_PROPERTY_GET_VALUE) { - ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value; + ecma_value_t prim_value_p = ecma_object_cls_general (ext_object_p)->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); @@ -113,7 +113,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ if (index != ECMA_STRING_NOT_ARRAY_INDEX) { - ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value; + ecma_value_t prim_value_p = ecma_object_cls_general (ext_object_p)->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)) @@ -307,7 +307,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ } case ECMA_OBJECT_TYPE_CLASS: { - if (((ecma_extended_object_t *) object_p)->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS) + if (((ecma_extended_object_t *) object_p)->u.cls.head.type == ECMA_OBJECT_CLASS_ARGUMENTS) { property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p); } @@ -341,14 +341,14 @@ 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.cls.head.type == ECMA_OBJECT_CLASS_ARGUMENTS + && (((ecma_extended_object_t *) object_p)->u.cls.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.cls.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -475,13 +475,13 @@ 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; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_STRING: { if (ecma_string_is_length (property_name_p)) { - ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value; + ecma_value_t prim_value_p = ecma_object_cls_general (ext_object_p)->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); @@ -493,7 +493,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */ if (index != ECMA_STRING_NOT_ARRAY_INDEX) { - ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value; + ecma_value_t prim_value_p = ecma_object_cls_general (ext_object_p)->value; ecma_string_t *prim_value_str_p = ecma_get_string_from_value (prim_value_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.cls.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.cls.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -654,7 +654,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */ } case ECMA_OBJECT_TYPE_CLASS: { - if (((ecma_extended_object_t *) object_p)->u.cls.type == ECMA_OBJECT_CLASS_ARGUMENTS) + if (((ecma_extended_object_t *) object_p)->u.cls.head.type == ECMA_OBJECT_CLASS_ARGUMENTS) { property_p = ecma_op_arguments_object_try_to_lazy_instantiate_property (object_p, property_name_p); } @@ -1283,18 +1283,18 @@ 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; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_ARGUMENTS: { - if (!(ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) + if (!(ext_object_p->u.cls.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.cls.arguments.formal_params_number) { ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p; @@ -1407,7 +1407,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; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_STRING: { @@ -1415,7 +1415,7 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ if (index != ECMA_STRING_NOT_ARRAY_INDEX) { - ecma_value_t prim_value_p = ext_object_p->u.cls.u3.value; + ecma_value_t prim_value_p = ecma_object_cls_general (ext_object_p)->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)) @@ -1559,8 +1559,8 @@ 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) + if (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_ARGUMENTS + && ext_object_p->u.cls.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); @@ -1735,7 +1735,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_ARGUMENTS: { @@ -2145,7 +2145,7 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { case ECMA_OBJECT_CLASS_STRING: { @@ -2809,18 +2809,18 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - switch (ext_object_p->u.cls.type) + switch (ext_object_p->u.cls.head.type) { #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.cls.typedarray.type); } #endif /* JERRY_BUILTIN_TYPEDARRAY */ #if JERRY_BUILTIN_CONTAINER case ECMA_OBJECT_CLASS_CONTAINER: { - return (lit_magic_string_id_t) ext_object_p->u.cls.u2.container_id; + return (lit_magic_string_id_t) ext_object_p->u.cls.container.id; } #endif /* JERRY_BUILTIN_CONTAINER */ default: @@ -2829,10 +2829,10 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ } } - JERRY_ASSERT (ext_object_p->u.cls.type < ECMA_OBJECT_CLASS__MAX); - JERRY_ASSERT (ecma_class_object_magic_string_id[ext_object_p->u.cls.type] != LIT_MAGIC_STRING__EMPTY); + JERRY_ASSERT (ext_object_p->u.cls.head.type < ECMA_OBJECT_CLASS__MAX); + JERRY_ASSERT (ecma_class_object_magic_string_id[ext_object_p->u.cls.head.type] != LIT_MAGIC_STRING__EMPTY); - return (lit_magic_string_id_t) ecma_class_object_magic_string_id[ext_object_p->u.cls.type]; + return (lit_magic_string_id_t) ecma_class_object_magic_string_id[ext_object_p->u.cls.head.type]; } case ECMA_OBJECT_TYPE_FUNCTION: case ECMA_OBJECT_TYPE_NATIVE_FUNCTION: diff --git a/jerry-core/ecma/operations/ecma-promise-object.c b/jerry-core/ecma/operations/ecma-promise-object.c index 092ed773d7..26a8a2ed35 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.c +++ b/jerry-core/ecma/operations/ecma-promise-object.c @@ -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.cls.u3.value); + return ecma_copy_value (ext_object_p->u.cls.promise.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.cls.u3.value == ECMA_VALUE_UNDEFINED); + JERRY_ASSERT (ext_object_p->u.cls.promise.value == ECMA_VALUE_UNDEFINED); - ext_object_p->u.cls.u3.value = result; + ext_object_p->u.cls.promise.value = result; } /* ecma_promise_set_result */ /** @@ -92,7 +92,7 @@ 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.cls.u1.promise_flags; + return ((ecma_extended_object_t *) obj_p)->u.cls.promise.flags; } /* ecma_promise_get_flags */ /** @@ -108,7 +108,7 @@ ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */ 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.cls.u1.promise_flags ^= flags_to_invert; + ((ecma_extended_object_t *) obj_p)->u.cls.promise.flags ^= flags_to_invert; } /* ecma_promise_set_state */ /** @@ -217,7 +217,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.cls.u1.promise_flags |= ECMA_PROMISE_UNHANDLED_REJECT; + ((ecma_extended_object_t *) obj_p)->u.cls.promise.flags |= ECMA_PROMISE_UNHANDLED_REJECT; if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { @@ -333,7 +333,7 @@ ecma_reject_promise_with_checks (ecma_value_t promise, /**< promise */ } /* 5. */ - ((ecma_extended_object_t *) promise_obj_p)->u.cls.u1.promise_flags |= ECMA_PROMISE_ALREADY_RESOLVED; + ((ecma_extended_object_t *) promise_obj_p)->u.cls.promise.flags |= ECMA_PROMISE_ALREADY_RESOLVED; /* 6. */ ecma_reject_promise (promise, reason); @@ -371,7 +371,7 @@ ecma_fulfill_promise_with_checks (ecma_value_t promise, /**< promise */ } /* 5. */ - ((ecma_extended_object_t *) promise_obj_p)->u.cls.u1.promise_flags |= ECMA_PROMISE_ALREADY_RESOLVED; + ((ecma_extended_object_t *) promise_obj_p)->u.cls.promise.flags |= ECMA_PROMISE_ALREADY_RESOLVED; ecma_fulfill_promise (promise, value); return ECMA_VALUE_UNDEFINED; @@ -486,10 +486,10 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_promise_object_t), 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.cls.type = ECMA_OBJECT_CLASS_PROMISE; + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_PROMISE; /* 5 */ - ext_object_p->u.cls.u1.promise_flags = ECMA_PROMISE_IS_PENDING; - ext_object_p->u.cls.u3.value = ECMA_VALUE_UNDEFINED; + ext_object_p->u.cls.promise.flags = ECMA_PROMISE_IS_PENDING; + ext_object_p->u.cls.promise.value = ECMA_VALUE_UNDEFINED; /* 6-8. */ ecma_promise_object_t *promise_object_p = (ecma_promise_object_t *) object_p; @@ -551,11 +551,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.cls.type == ECMA_OBJECT_CLASS_NUMBER); + JERRY_ASSERT (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_NUMBER); - JERRY_ASSERT (ecma_is_value_integer_number (ext_object_p->u.cls.u3.value)); + JERRY_ASSERT (ecma_is_value_integer_number (ext_object_p->u.cls.promise.value)); - uint32_t current = (uint32_t) ecma_get_integer_from_value (ext_object_p->u.cls.u3.value); + uint32_t current = (uint32_t) ecma_get_integer_from_value (ext_object_p->u.cls.promise.value); if (is_inc) { @@ -565,7 +565,7 @@ ecma_promise_remaining_inc_or_dec (ecma_value_t remaining, /**< the remaining co { current--; } - ext_object_p->u.cls.u3.value = ecma_make_uint32_value (current); + ext_object_p->u.cls.promise.value = ecma_make_uint32_value (current); return current; } /* ecma_promise_remaining_inc_or_dec */ @@ -738,8 +738,8 @@ 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.cls.type = ECMA_OBJECT_CLASS_PROMISE_CAPABILITY; - capability_p->header.u.cls.u3.promise = ECMA_VALUE_UNDEFINED; + capability_p->header.u.cls.head.type = ECMA_OBJECT_CLASS_PROMISE_CAPABILITY; + capability_p->header.u.cls.promise_capabality.promise = ECMA_VALUE_UNDEFINED; capability_p->resolve = ECMA_VALUE_UNDEFINED; capability_p->reject = ECMA_VALUE_UNDEFINED; @@ -791,7 +791,7 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function } /* 10. */ - capability_p->header.u.cls.u3.promise = promise; + capability_p->header.u.cls.promise_capabality.promise = promise; ecma_free_value (promise); @@ -856,7 +856,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.cls.u3.promise); + ecma_value_t promise = ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); ecma_deref_object (capability_obj_p); return promise; @@ -1152,7 +1152,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.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT; + ((ecma_extended_object_t *) promise_obj_p)->u.cls.promise.flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT; if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { @@ -1222,7 +1222,7 @@ ecma_op_if_abrupt_reject_promise (ecma_value_t *value_p, /**< [in - out] complet } ecma_free_value (call_ret); - *value_p = ecma_copy_value (capability_p->header.u.cls.u3.promise); + *value_p = ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); return ECMA_VALUE_EMPTY; } /* ecma_op_if_abrupt_reject_promise */ @@ -1306,7 +1306,7 @@ ecma_promise_perform_then (ecma_value_t promise, /**< the promise which call 'th #if JERRY_PROMISE_CALLBACK if (ecma_promise_get_flags (promise_obj_p) & ECMA_PROMISE_UNHANDLED_REJECT) { - promise_p->header.u.cls.u1.promise_flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT; + promise_p->header.u.cls.promise.flags &= (uint8_t) ~ECMA_PROMISE_UNHANDLED_REJECT; if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { @@ -1322,7 +1322,7 @@ ecma_promise_perform_then (ecma_value_t promise, /**< the promise which call 'th } /* 10. */ - return ecma_copy_value (capability_p->header.u.cls.u3.promise); + return ecma_copy_value (capability_p->header.u.cls.promise_capabality.promise); } /* ecma_promise_perform_then */ /** diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index b84380cc66..e8526f932d 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -159,7 +159,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.cls.type = ECMA_OBJECT_CLASS__MAX; + regexp_obj_p->u.cls.head.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), @@ -179,8 +179,8 @@ ecma_op_regexp_initialize (ecma_object_t *regexp_obj_p, /**< RegExp object */ const re_compiled_code_t *bc_p) /**< bytecode */ { ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) regexp_obj_p; - ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP; - ECMA_SET_INTERNAL_VALUE_POINTER (ext_obj_p->u.cls.u3.value, bc_p); + ext_obj_p->u.cls.head.type = ECMA_OBJECT_CLASS_REGEXP; + ECMA_SET_INTERNAL_VALUE_POINTER (ecma_object_cls_general (ext_obj_p)->value, bc_p); } /* ecma_op_regexp_initialize */ /** @@ -1598,7 +1598,8 @@ 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_POINTER (re_compiled_code_t, ext_object_p->u.cls.u3.value); + re_compiled_code_t *bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (ext_object_p)->value); /* 3. */ lit_utf8_size_t input_size; @@ -2265,7 +2266,8 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**u.cls.u3.value); + const re_compiled_code_t *bc_p = + ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, ecma_object_cls_general (re_obj_p)->value); ecma_bytecode_ref ((ecma_compiled_code_t *) bc_p); JERRY_ASSERT (bc_p != NULL); diff --git a/jerry-core/ecma/operations/ecma-string-object.c b/jerry-core/ecma/operations/ecma-string-object.c index 95b78c9a09..db5825f771 100644 --- a/jerry-core/ecma/operations/ecma-string-object.c +++ b/jerry-core/ecma/operations/ecma-string-object.c @@ -85,8 +85,8 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of ecma_create_object (prototype_obj_p, 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.cls.type = ECMA_OBJECT_CLASS_STRING; - ext_object_p->u.cls.u3.value = prim_value; + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_STRING; + ecma_object_cls_general (ext_object_p)->value = prim_value; if (new_target) { @@ -110,9 +110,9 @@ ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, /**< a String obj if (!(filter & JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES)) { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p; - JERRY_ASSERT (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_STRING); + JERRY_ASSERT (ext_object_p->u.cls.head.type == ECMA_OBJECT_CLASS_STRING); - ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ext_object_p->u.cls.u3.value); + ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ecma_object_cls_general (ext_object_p)->value); lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p); diff --git a/jerry-core/ecma/operations/ecma-symbol-object.c b/jerry-core/ecma/operations/ecma-symbol-object.c index adf8436789..40f7d5f721 100644 --- a/jerry-core/ecma/operations/ecma-symbol-object.c +++ b/jerry-core/ecma/operations/ecma-symbol-object.c @@ -89,8 +89,8 @@ ecma_op_create_symbol_object (const ecma_value_t value) /**< symbol value */ ecma_create_object (prototype_obj_p, 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.cls.type = ECMA_OBJECT_CLASS_SYMBOL; - ext_object_p->u.cls.u3.value = ecma_copy_value (value); + ext_object_p->u.cls.head.type = ECMA_OBJECT_CLASS_SYMBOL; + ecma_object_cls_general (ext_object_p)->value = ecma_copy_value (value); return ecma_make_object_value (object_p); } /* ecma_op_create_symbol_object */ @@ -163,7 +163,7 @@ ecma_symbol_this_value (ecma_value_t this_arg) /**< this argument value */ if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SYMBOL)) { - return ((ecma_extended_object_t *) object_p)->u.cls.u3.value; + return ecma_object_cls_general ((ecma_extended_object_t *) object_p)->value; } } diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index f506ac0470..442cd68b75 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -752,7 +752,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.cls.typedarray.type; } /* ecma_get_typedarray_id */ /** @@ -846,10 +846,10 @@ 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_CLASS); 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.cls.head.type = ECMA_OBJECT_CLASS_TYPEDARRAY; + ext_object_p->u.cls.typedarray.type = (uint8_t) typedarray_id; + ext_object_p->u.cls.typedarray.flags = 0; + ext_object_p->u.cls.typedarray.arraybuffer = ecma_make_object_value (new_arraybuffer_p); ecma_deref_object (new_arraybuffer_p); @@ -1514,7 +1514,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.cls.typedarray.arraybuffer); } /* ecma_typedarray_get_arraybuffer */ /** @@ -1542,11 +1542,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.cls.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.cls.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.cls.arraybuffer.length; uint8_t shift = ecma_typedarray_get_element_size_shift (typedarray_p); return buffer_length >> shift; @@ -1576,7 +1576,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.cls.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED)) { return 0; } @@ -1752,14 +1752,14 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li 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.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.cls.head.type = ECMA_OBJECT_CLASS_TYPEDARRAY; + ext_object_p->u.cls.typedarray.type = (uint8_t) typedarray_id; + ext_object_p->u.cls.typedarray.flags = 0; + ext_object_p->u.cls.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.cls.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; diff --git a/jerry-core/vm/opcodes.c b/jerry-core/vm/opcodes.c index 8555330255..2598f40f28 100644 --- a/jerry-core/vm/opcodes.c +++ b/jerry-core/vm/opcodes.c @@ -613,9 +613,9 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context ecma_deref_object (proto_p); } - executable_object_p->extended_object.u.cls.type = class_type; - executable_object_p->extended_object.u.cls.u2.executable_obj_flags = 0; - ECMA_SET_INTERNAL_VALUE_ANY_POINTER (executable_object_p->extended_object.u.cls.u3.head, NULL); + executable_object_p->extended_object.u.cls.head.type = class_type; + executable_object_p->extended_object.u.cls.generator.obj_flags = 0; + ECMA_SET_INTERNAL_VALUE_ANY_POINTER (executable_object_p->extended_object.u.cls.generator.head, NULL); executable_object_p->iterator = ECMA_VALUE_UNDEFINED; JERRY_ASSERT (!(frame_ctx_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL)); @@ -742,7 +742,7 @@ opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /* JERRY_ASSERT (ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p)); - executable_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_RUNNING; + executable_object_p->extended_object.u.cls.generator.obj_flags |= ECMA_EXECUTABLE_OBJECT_RUNNING; executable_object_p->frame_ctx.prev_context_p = JERRY_CONTEXT (vm_top_context_p); JERRY_CONTEXT (vm_top_context_p) = &executable_object_p->frame_ctx; @@ -763,14 +763,14 @@ opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /* #endif /* JERRY_BUILTIN_REALMS */ JERRY_CONTEXT (current_new_target_p) = old_new_target; - executable_object_p->extended_object.u.cls.u2.executable_obj_flags &= (uint8_t) ~ECMA_EXECUTABLE_OBJECT_RUNNING; + executable_object_p->extended_object.u.cls.generator.obj_flags &= (uint8_t) ~ECMA_EXECUTABLE_OBJECT_RUNNING; if (executable_object_p->frame_ctx.call_operation != VM_EXEC_RETURN) { JERRY_ASSERT (executable_object_p->frame_ctx.call_operation == VM_NO_EXEC_OP); /* All resources are released. */ - executable_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_COMPLETED; + executable_object_p->extended_object.u.cls.generator.obj_flags |= ECMA_EXECUTABLE_OBJECT_COMPLETED; ecma_deref_if_object (executable_object_p->frame_ctx.this_binding); return result; } @@ -814,7 +814,8 @@ opfunc_async_generator_yield (ecma_extended_object_t *async_generator_object_p, ecma_value_t value) /**< value (takes the reference) */ { ecma_async_generator_task_t *task_p; - task_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_async_generator_task_t, async_generator_object_p->u.cls.u3.head); + task_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_async_generator_task_t, async_generator_object_p->u.cls.generator.head); ecma_value_t iter_result = ecma_create_iter_result_object (value, ECMA_VALUE_FALSE); ecma_fulfill_promise (task_p->promise, iter_result); @@ -823,7 +824,7 @@ opfunc_async_generator_yield (ecma_extended_object_t *async_generator_object_p, ecma_free_value (value); ecma_value_t next = task_p->next; - async_generator_object_p->u.cls.u3.head = next; + async_generator_object_p->u.cls.generator.head = next; JERRY_ASSERT (task_p->operation_value == ECMA_VALUE_UNDEFINED); jmem_heap_free_block (task_p, sizeof (ecma_async_generator_task_t)); @@ -864,7 +865,7 @@ opfunc_async_create_and_await (vm_frame_ctx_t *frame_ctx_p, /**< frame context * vm_executable_object_t *executable_object_p; executable_object_p = opfunc_create_executable_object (frame_ctx_p, VM_CREATE_EXECUTABLE_OBJECT_ASYNC); - executable_object_p->extended_object.u.cls.u2.executable_obj_flags |= extra_flags; + executable_object_p->extended_object.u.cls.generator.obj_flags |= extra_flags; ecma_promise_async_then (result, ecma_make_object_value ((ecma_object_t *) executable_object_p)); ecma_deref_object ((ecma_object_t *) executable_object_p); diff --git a/jerry-core/vm/vm-stack.c b/jerry-core/vm/vm-stack.c index c7eaf993dc..699852354a 100644 --- a/jerry-core/vm/vm-stack.c +++ b/jerry-core/vm/vm-stack.c @@ -363,7 +363,7 @@ vm_stack_find_finally (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ { uint16_t extra_flags = (ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD | (ECMA_AWAIT_FOR_CLOSE << ECMA_AWAIT_STATE_SHIFT)); - async_generator_object_p->u.cls.u2.executable_obj_flags |= extra_flags; + async_generator_object_p->u.cls.generator.obj_flags |= extra_flags; stack_top_p = vm_stack_context_abort (frame_ctx_p, stack_top_p); diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index b6e1e88fb8..b5b5ce5eaa 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -2665,7 +2665,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ ecma_extended_object_t *async_generator_object_p = VM_GET_EXECUTABLE_OBJECT (frame_ctx_p); JERRY_ASSERT ( - !(async_generator_object_p->u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)); + !(async_generator_object_p->u.cls.generator.obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)); /* Byte code is executed at the first time. */ left_value = stack_top_p[-1]; @@ -2692,7 +2692,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ goto error; } - async_generator_object_p->u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD; + async_generator_object_p->u.cls.generator.obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD; *VM_GET_EXECUTABLE_ITERATOR (frame_ctx_p) = left_value; frame_ctx_p->call_operation = VM_EXEC_RETURN; @@ -4335,7 +4335,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ goto error; } - executable_object_p->u.cls.u2.executable_obj_flags |= extra_flags; + executable_object_p->u.cls.generator.obj_flags |= extra_flags; return ECMA_VALUE_UNDEFINED; } @@ -4371,7 +4371,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ uint16_t extra_flags = (ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD | (ECMA_AWAIT_FOR_NEXT << ECMA_AWAIT_STATE_SHIFT)); - executable_object_p->u.cls.u2.executable_obj_flags |= extra_flags; + executable_object_p->u.cls.generator.obj_flags |= extra_flags; frame_ctx_p->call_operation = VM_EXEC_RETURN; frame_ctx_p->byte_code_p = byte_code_start_p + branch_offset;