Skip to content

Commit 2ba553a

Browse files
committed
Move Arguments,ArrayBuffer,TypedArray,DataView class members clz.arguments,clz.arraybuffer,clz.typedarray,clz.dataview
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent 00d12c0 commit 2ba553a

11 files changed

+106
-85
lines changed

jerry-core/api/jerryscript.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -5993,7 +5993,7 @@ jerry_arraybuffer_external (uint8_t *buffer_p, /**< the backing store used by th
59935993

59945994
if (buffer_p != NULL)
59955995
{
5996-
arraybuffer_pointer_p->extended_object.u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED;
5996+
arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED;
59975997
arraybuffer_pointer_p->buffer_p = buffer_p;
59985998
}
59995999
}
@@ -6081,7 +6081,7 @@ jerry_shared_arraybuffer_external (uint8_t *buffer_p, /**< the backing store use
60816081

60826082
if (buffer_p != NULL)
60836083
{
6084-
shared_arraybuffer_pointer_p->extended_object.u.cls.u1.array_buffer_flags |= ECMA_ARRAYBUFFER_ALLOCATED;
6084+
shared_arraybuffer_pointer_p->extended_object.u.clz.arraybuffer.flags |= ECMA_ARRAYBUFFER_ALLOCATED;
60856085
shared_arraybuffer_pointer_p->buffer_p = buffer_p;
60866086
}
60876087
}
@@ -6529,7 +6529,7 @@ jerry_dataview_buffer (const jerry_value_t value, /**< DataView to get the array
65296529

65306530
if (byte_length != NULL)
65316531
{
6532-
*byte_length = dataview_p->header.u.cls.u3.length;
6532+
*byte_length = dataview_p->header.u.clz.dataview.length;
65336533
}
65346534

65356535
ecma_object_t *arraybuffer_p = dataview_p->buffer_p;

jerry-core/ecma/base/ecma-gc.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ ecma_gc_mark_arguments_object (ecma_extended_object_t *ext_object_p) /**< argume
208208

209209
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
210210

211-
if (ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
211+
if (ext_object_p->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
212212
{
213213
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
214214
argv_p = (ecma_value_t *) (mapped_arguments_p + 1);
215215

216216
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env));
217217
}
218218

219-
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
219+
uint32_t arguments_number = arguments_p->header.u.clz.arguments.number;
220220

221221
for (uint32_t i = 0; i < arguments_number; i++)
222222
{
@@ -1336,13 +1336,13 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
13361336

13371337
size_t object_size = sizeof (ecma_unmapped_arguments_t);
13381338

1339-
if (ext_object_p->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
1339+
if (ext_object_p->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
13401340
{
13411341
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) ext_object_p;
13421342
object_size = sizeof (ecma_mapped_arguments_t);
13431343

13441344
#if JERRY_SNAPSHOT_EXEC
1345-
if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
1345+
if (!(mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
13461346
#endif /* JERRY_SNAPSHOT_EXEC */
13471347
{
13481348
ecma_compiled_code_t *byte_code_p =
@@ -1354,14 +1354,15 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
13541354

13551355
ecma_value_t *argv_p = (ecma_value_t *) (((uint8_t *) ext_object_p) + object_size);
13561356
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) ext_object_p;
1357-
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
1357+
uint32_t arguments_number = arguments_p->header.u.clz.arguments.number;
13581358

13591359
for (uint32_t i = 0; i < arguments_number; i++)
13601360
{
13611361
ecma_free_value_if_not_object (argv_p[i]);
13621362
}
13631363

1364-
uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number);
1364+
uint32_t saved_argument_count =
1365+
JERRY_MAX (arguments_number, arguments_p->header.u.clz.arguments.formal_params_number);
13651366

13661367
return object_size + (saved_argument_count * sizeof (ecma_value_t));
13671368
} /* ecma_free_arguments_object */
@@ -1781,7 +1782,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
17811782
#if JERRY_BUILTIN_TYPEDARRAY
17821783
case ECMA_OBJECT_CLASS_TYPEDARRAY:
17831784
{
1784-
if (ext_object_p->u.cls.u2.typedarray_flags & ECMA_TYPEDARRAY_IS_EXTENDED)
1785+
if (ext_object_p->u.clz.typedarray.flags & ECMA_TYPEDARRAY_IS_EXTENDED)
17851786
{
17861787
ext_object_size = sizeof (ecma_extended_typedarray_object_t);
17871788
}
@@ -1858,7 +1859,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
18581859
{
18591860
if (!(ECMA_ARRAYBUFFER_GET_FLAGS (ext_object_p) & ECMA_ARRAYBUFFER_HAS_POINTER))
18601861
{
1861-
ext_object_size += ext_object_p->u.cls.u3.length;
1862+
ext_object_size += ext_object_p->u.clz.arraybuffer.length;
18621863
break;
18631864
}
18641865

jerry-core/ecma/base/ecma-globals.h

+34-14
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,6 @@ typedef struct
10251025
*/
10261026
union
10271027
{
1028-
uint8_t arguments_flags; /**< arguments object flags */
10291028
uint8_t error_type; /**< jerry_error_t type of native error objects */
10301029
#if JERRY_BUILTIN_DATE
10311030
uint8_t date_flags; /**< flags for date objects */
@@ -1039,17 +1038,12 @@ typedef struct
10391038
#if JERRY_BUILTIN_CONTAINER
10401039
uint8_t container_flags; /**< container object flags */
10411040
#endif /* JERRY_BUILTIN_CONTAINER */
1042-
#if JERRY_BUILTIN_TYPEDARRAY
1043-
uint8_t array_buffer_flags; /**< ArrayBuffer flags */
1044-
uint8_t typedarray_type; /**< type of typed array */
1045-
#endif /* JERRY_BUILTIN_TYPEDARRAY */
10461041
} u1;
10471042
/**
10481043
* Description of 16 bit extra fields. These extra fields depend on the type.
10491044
*/
10501045
union
10511046
{
1052-
uint16_t formal_params_number; /**< for arguments: formal parameters number */
10531047
#if JERRY_MODULE_SYSTEM
10541048
uint16_t module_flags; /**< Module flags */
10551049
#endif /* JERRY_MODULE_SYSTEM */
@@ -1058,9 +1052,6 @@ typedef struct
10581052
#if JERRY_BUILTIN_CONTAINER
10591053
uint16_t container_id; /**< magic string id of a container */
10601054
#endif /* JERRY_BUILTIN_CONTAINER */
1061-
#if JERRY_BUILTIN_TYPEDARRAY
1062-
uint16_t typedarray_flags; /**< typed array object flags */
1063-
#endif /* JERRY_BUILTIN_TYPEDARRAY */
10641055
} u2;
10651056
/**
10661057
* Description of 32 bit / value. These extra fields depend on the type.
@@ -1069,23 +1060,52 @@ typedef struct
10691060
{
10701061
ecma_value_t value; /**< value of the object (e.g. boolean, number, string, etc.) */
10711062
ecma_value_t target; /**< [[ProxyTarget]] or [[WeakRefTarget]] internal property */
1072-
#if JERRY_BUILTIN_TYPEDARRAY
1073-
ecma_value_t arraybuffer; /**< for typedarray: ArrayBuffer reference */
1074-
#endif /* JERRY_BUILTIN_TYPEDARRAY */
10751063
ecma_value_t head; /**< points to the async generator task queue head item */
10761064
ecma_value_t iterated_value; /**< for %Iterator%: [[IteratedObject]] property */
10771065
ecma_value_t promise; /**< PromiseCapability[[Promise]] internal slot */
10781066
ecma_value_t sync_iterator; /**< IteratorRecord [[Iterator]] internal slot for AsyncFromSyncIterator */
10791067
ecma_value_t spread_value; /**< for spread object: spreaded element */
10801068
int32_t tza; /**< TimeZone adjustment for date objects */
1081-
uint32_t length; /**< length related property (e.g. length of ArrayBuffer) */
1082-
uint32_t arguments_number; /**< for arguments: arguments number */
10831069
#if JERRY_MODULE_SYSTEM
10841070
uint32_t dfs_ancestor_index; /**< module dfs ancestor index (ES2020 15.2.1.16) */
10851071
#endif /* JERRY_MODULE_SYSTEM */
10861072
} u3;
10871073
} cls;
10881074

1075+
union
1076+
{
1077+
struct
1078+
{
1079+
uint8_t cls_type; /**< class type of the object */
1080+
uint8_t flags; /**< arguments object flags */
1081+
uint16_t formal_params_number; /**< for arguments: formal parameters number */
1082+
uint32_t number; /**< for arguments: arguments number */
1083+
} arguments;
1084+
#if JERRY_BUILTIN_TYPEDARRAY
1085+
struct
1086+
{
1087+
uint8_t cls_type; /**< class type of the object */
1088+
uint8_t flags; /**< ArrayBuffer flags */
1089+
uint32_t length; /**< length of ArrayBuffer */
1090+
} arraybuffer;
1091+
1092+
struct
1093+
{
1094+
uint8_t cls_type; /**< class type of the object */
1095+
uint8_t type; /**< type of typed array */
1096+
uint16_t flags; /**< typed array object flags */
1097+
ecma_value_t arraybuffer; /**< for typedarray: ArrayBuffer reference */
1098+
} typedarray;
1099+
#endif /* JERRY_BUILTIN_TYPEDARRAY */
1100+
#if JERRY_BUILTIN_DATAVIEW
1101+
struct
1102+
{
1103+
uint8_t cls_type; /**< class type of the object */
1104+
uint32_t length; /**< length of DataView */
1105+
} dataview;
1106+
#endif /* JERRY_BUILTIN_DATAVIEW */
1107+
} clz;
1108+
10891109
/**
10901110
* Description of function objects.
10911111
*/

jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this
124124
{
125125
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
126126
}
127-
return ecma_make_uint32_value (obj_p->header.u.cls.u3.length);
127+
return ecma_make_uint32_value (obj_p->header.u.clz.arraybuffer.length);
128128
}
129129
default:
130130
{

jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id,
20862086
case ECMA_TYPEDARRAY_PROTOTYPE_ROUTINE_TO_STRING_TAG_GETTER:
20872087
{
20882088
ecma_extended_object_t *object_p = (ecma_extended_object_t *) typedarray_p;
2089-
return ecma_make_magic_string_value (ecma_get_typedarray_magic_string_id (object_p->u.cls.u1.typedarray_type));
2089+
return ecma_make_magic_string_value (ecma_get_typedarray_magic_string_id (object_p->u.clz.typedarray.type));
20902090
}
20912091
default:
20922092
{

jerry-core/ecma/operations/ecma-arguments-object.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar
7676
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p;
7777

7878
arguments_p->header.u.cls.type = ECMA_OBJECT_CLASS_ARGUMENTS;
79-
arguments_p->header.u.cls.u1.arguments_flags = ECMA_ARGUMENTS_OBJECT_NO_FLAGS;
80-
arguments_p->header.u.cls.u2.formal_params_number = formal_params_number;
81-
arguments_p->header.u.cls.u3.arguments_number = 0;
79+
arguments_p->header.u.clz.arguments.flags = ECMA_ARGUMENTS_OBJECT_NO_FLAGS;
80+
arguments_p->header.u.clz.arguments.formal_params_number = formal_params_number;
81+
arguments_p->header.u.clz.arguments.number = 0;
8282
arguments_p->callee = ecma_make_object_value (func_obj_p);
8383

8484
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
9393
argv_p[i] = ECMA_VALUE_UNDEFINED;
9494
}
9595

96-
arguments_p->header.u.cls.u3.arguments_number = shared_p->arg_list_len;
96+
arguments_p->header.u.clz.arguments.number = shared_p->arg_list_len;
9797

9898
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
9999
{
100100
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) obj_p;
101101

102102
ECMA_SET_INTERNAL_VALUE_POINTER (mapped_arguments_p->lex_env, lex_env_p);
103-
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_MAPPED;
103+
arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_MAPPED;
104104

105105
#if JERRY_SNAPSHOT_EXEC
106106
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)
107107
{
108-
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE;
108+
arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE;
109109
mapped_arguments_p->u.byte_code_p = (ecma_compiled_code_t *) bytecode_data_p;
110110
}
111111
else
@@ -166,15 +166,15 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
166166
ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p);
167167

168168
if (ECMA_IS_VALUE_ERROR (ret_value)
169-
|| !(((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
169+
|| !(((ecma_extended_object_t *) object_p)->u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
170170
{
171171
return ret_value;
172172
}
173173

174174
ecma_mapped_arguments_t *mapped_arguments_p = (ecma_mapped_arguments_t *) object_p;
175175
uint32_t index = ecma_string_get_array_index (property_name_p);
176176

177-
if (index >= mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number)
177+
if (index >= mapped_arguments_p->unmapped.header.u.clz.arguments.formal_params_number)
178178
{
179179
return ret_value;
180180
}
@@ -228,8 +228,8 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object
228228
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
229229
ecma_property_value_t *prop_value_p;
230230
ecma_property_t *prop_p;
231-
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
232-
uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags;
231+
uint32_t arguments_number = arguments_p->header.u.clz.arguments.number;
232+
uint8_t flags = arguments_p->header.u.clz.arguments.flags;
233233

234234
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
235235
{
@@ -327,35 +327,35 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, /**< the ob
327327

328328
if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_LENGTH))
329329
{
330-
JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED));
330+
JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED));
331331

332-
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED;
332+
arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED;
333333
return;
334334
}
335335

336336
if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_CALLEE))
337337
{
338-
JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED));
339-
JERRY_ASSERT (arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED);
338+
JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED));
339+
JERRY_ASSERT (arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED);
340340

341-
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED;
341+
arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED;
342342
return;
343343
}
344344

345345
if (ecma_prop_name_is_symbol (property_name_p))
346346
{
347-
JERRY_ASSERT (!(arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED));
347+
JERRY_ASSERT (!(arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED));
348348
JERRY_ASSERT (ecma_op_compare_string_to_global_symbol (property_name_p, LIT_GLOBAL_SYMBOL_ITERATOR));
349349

350-
arguments_p->header.u.cls.u1.arguments_flags |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED;
350+
arguments_p->header.u.clz.arguments.flags |= ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED;
351351
return;
352352
}
353353

354354
uint32_t index = ecma_string_get_array_index (property_name_p);
355355

356356
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
357357

358-
if (arguments_p->header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
358+
if (arguments_p->header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
359359
{
360360
argv_p = (ecma_value_t *) (((ecma_mapped_arguments_t *) object_p) + 1);
361361
}
@@ -378,8 +378,8 @@ ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< ar
378378

379379
ecma_unmapped_arguments_t *arguments_p = (ecma_unmapped_arguments_t *) obj_p;
380380

381-
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
382-
uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags;
381+
uint32_t arguments_number = arguments_p->header.u.clz.arguments.number;
382+
uint8_t flags = arguments_p->header.u.clz.arguments.flags;
383383

384384
if (!(filter & JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES))
385385
{
@@ -434,13 +434,13 @@ ecma_op_arguments_object_get_formal_parameter (ecma_mapped_arguments_t *mapped_a
434434
* object */
435435
uint32_t index) /**< formal parameter index */
436436
{
437-
JERRY_ASSERT (mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED);
438-
JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.cls.u2.formal_params_number);
437+
JERRY_ASSERT (mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_MAPPED);
438+
JERRY_ASSERT (index < mapped_arguments_p->unmapped.header.u.clz.arguments.formal_params_number);
439439

440440
ecma_compiled_code_t *byte_code_p;
441441

442442
#if JERRY_SNAPSHOT_EXEC
443-
if (mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)
443+
if (mapped_arguments_p->unmapped.header.u.clz.arguments.flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)
444444
{
445445
byte_code_p = mapped_arguments_p->u.byte_code_p;
446446
}

0 commit comments

Comments
 (0)