Remove the usage of ecma_length_t (#4009)

Now the following conventions are applied:
 - passing the number of arguments for a function call is always uint32_t
 - string size/length/position related operation should use lit_utf8_size_t
 - Extended objects internal fields must be uint32_t

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-07-20 16:36:27 +02:00
committed by GitHub
parent 321215fdbb
commit 39cb67397d
110 changed files with 417 additions and 415 deletions
+6 -6
View File
@@ -1200,7 +1200,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
case LIT_MAGIC_STRING_ARRAY_BUFFER_UL:
{
ecma_length_t arraybuffer_length = ext_object_p->u.class_prop.u.length;
uint32_t arraybuffer_length = ext_object_p->u.class_prop.u.length;
if (ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY (ext_object_p))
{
@@ -1340,14 +1340,14 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
{
JERRY_ASSERT (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_ARGUMENTS);
ecma_length_t formal_params_number = ext_object_p->u.pseudo_array.u1.length;
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
uint32_t formal_params_number = ext_object_p->u.pseudo_array.u1.length;
ecma_value_t *arg_literal_p = (ecma_value_t *) (ext_object_p + 1);
for (ecma_length_t i = 0; i < formal_params_number; i++)
for (uint32_t i = 0; i < formal_params_number; i++)
{
if (arg_Literal_p[i] != ECMA_VALUE_EMPTY)
if (arg_literal_p[i] != ECMA_VALUE_EMPTY)
{
ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[i]);
ecma_string_t *name_p = ecma_get_string_from_value (arg_literal_p[i]);
ecma_deref_ecma_string (name_p);
}
}
+4 -4
View File
@@ -288,7 +288,7 @@ typedef ecma_value_t (*ecma_vm_exec_stop_callback_t) (void *user_p);
typedef ecma_value_t (*ecma_external_handler_t) (const ecma_value_t function_obj,
const ecma_value_t this_val,
const ecma_value_t args_p[],
const ecma_length_t args_count);
const uint32_t args_count);
/**
* Native free callback of an object.
@@ -1851,8 +1851,8 @@ typedef struct
typedef struct
{
ecma_extended_object_t extended_object; /**< extended object part */
ecma_length_t byte_offset; /**< the byteoffset of the above arraybuffer */
ecma_length_t array_length; /**< the array length */
uint32_t byte_offset; /**< the byteoffset of the above arraybuffer */
uint32_t array_length; /**< the array length */
} ecma_extended_typedarray_object_t;
/**
@@ -1867,7 +1867,7 @@ typedef struct
* - This address must be used during indexed read/write operation. */
ecma_typedarray_type_t id; /**< [[TypedArrayName]] internal slot */
uint32_t length; /**< [[ByteLength]] internal slot */
ecma_length_t offset; /**< [[ByteOffset]] internal slot. */
uint32_t offset; /**< [[ByteOffset]] internal slot. */
uint8_t shift; /**< the element size shift in the typedArray */
uint8_t element_size; /**< element size based on [[TypedArrayName]] in Table 49 */
} ecma_typedarray_info_t;
+28 -28
View File
@@ -372,7 +372,7 @@ ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string
{
JERRY_ASSERT (string_p != NULL || string_size == 0);
ecma_length_t converted_string_length = 0;
lit_utf8_size_t converted_string_length = 0;
lit_utf8_size_t converted_string_size = 0;
lit_utf8_size_t pos = 0;
@@ -1057,8 +1057,8 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string
*/
lit_utf8_size_t
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
ecma_length_t start_pos, /**< position of the first character */
ecma_length_t end_pos, /**< position of the last character */
lit_utf8_size_t start_pos, /**< position of the first character */
lit_utf8_size_t end_pos, /**< position of the last character */
lit_utf8_byte_t *buffer_p, /**< destination buffer pointer
* (can be NULL if buffer_size == 0) */
lit_utf8_size_t buffer_size) /**< size of buffer */
@@ -1066,7 +1066,7 @@ ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p, /**< ec
JERRY_ASSERT (string_desc_p != NULL);
JERRY_ASSERT (buffer_p != NULL || buffer_size == 0);
ecma_length_t string_length = ecma_string_get_length (string_desc_p);
lit_utf8_size_t string_length = ecma_string_get_length (string_desc_p);
lit_utf8_size_t size = 0;
if (start_pos >= string_length || start_pos >= end_pos)
@@ -1136,8 +1136,8 @@ ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p, /**< ec
*/
lit_utf8_size_t
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
ecma_length_t start_pos, /**< position of the first character */
ecma_length_t end_pos, /**< position of the last character */
lit_utf8_size_t start_pos, /**< position of the first character */
lit_utf8_size_t end_pos, /**< position of the last character */
lit_utf8_byte_t *buffer_p, /**< destination buffer pointer
* (can be NULL if buffer_size == 0) */
lit_utf8_size_t buffer_size) /**< size of buffer */
@@ -1148,7 +1148,7 @@ ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p, /**< ecm
lit_utf8_size_t size = 0;
ecma_length_t utf8_str_length = ecma_string_get_utf8_length (string_desc_p);
lit_utf8_size_t utf8_str_length = ecma_string_get_utf8_length (string_desc_p);
if (start_pos >= utf8_str_length || start_pos >= end_pos)
{
@@ -1161,7 +1161,7 @@ ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p, /**< ecm
}
ECMA_STRING_TO_UTF8_STRING (string_desc_p, cesu8_str_p, cesu8_str_size);
ecma_length_t cesu8_str_length = ecma_string_get_length (string_desc_p);
lit_utf8_size_t cesu8_str_length = ecma_string_get_length (string_desc_p);
if (cesu8_str_length == cesu8_str_size)
{
@@ -1280,12 +1280,12 @@ ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, /**< ecma-string
*
* @return size in bytes
*/
static inline ecma_length_t JERRY_ATTR_ALWAYS_INLINE
static inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
ecma_string_get_uint32_size (const uint32_t uint32_number) /**< number in the string-descriptor */
{
uint32_t prev_number = 1;
uint32_t next_number = 100;
ecma_length_t size = 1;
lit_utf8_size_t size = 1;
const uint32_t max_size = 9;
@@ -1330,7 +1330,7 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
* uint32 string descriptor */
uint8_t *flags_p) /**< [in,out] any combination of ecma_string_flag_t bits */
{
ecma_length_t length;
lit_utf8_size_t length;
lit_utf8_size_t size;
const lit_utf8_byte_t *result_p;
@@ -1896,7 +1896,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
*
* @return number of characters in the string
*/
static ecma_length_t
static lit_utf8_size_t
ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
{
if (ECMA_IS_DIRECT_STRING (string_p))
@@ -1945,10 +1945,10 @@ ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
*
* @return number of characters in the string
*/
ecma_length_t
lit_utf8_size_t
ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
{
ecma_length_t length = ecma_string_get_ascii_size (string_p);
lit_utf8_size_t length = ecma_string_get_ascii_size (string_p);
if (length != ECMA_STRING_NO_ASCII_SIZE)
{
@@ -1967,12 +1967,12 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
{
return (ecma_length_t) (((ecma_utf8_string_t *) string_p)->length);
return (lit_utf8_size_t) (((ecma_utf8_string_t *) string_p)->length);
}
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING)
{
return (ecma_length_t) (((ecma_long_utf8_string_t *) string_p)->length);
return (lit_utf8_size_t) (((ecma_long_utf8_string_t *) string_p)->length);
}
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
@@ -1987,10 +1987,10 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
*
* @return number of characters in the UTF-8 encoded string
*/
ecma_length_t
lit_utf8_size_t
ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
{
ecma_length_t length = ecma_string_get_ascii_size (string_p);
lit_utf8_size_t length = ecma_string_get_ascii_size (string_p);
if (length != ECMA_STRING_NO_ASCII_SIZE)
{
@@ -2013,7 +2013,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
if (utf8_string_p->size == utf8_string_p->length)
{
return (ecma_length_t) (utf8_string_p->length);
return (lit_utf8_size_t) (utf8_string_p->length);
}
return lit_get_utf8_length_of_cesu8_string (ECMA_UTF8_STRING_GET_BUFFER (string_p), utf8_string_p->size);
@@ -2025,7 +2025,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
if (long_utf8_string_p->size == long_utf8_string_p->length)
{
return (ecma_length_t) (long_utf8_string_p->length);
return (lit_utf8_size_t) (long_utf8_string_p->length);
}
return lit_get_utf8_length_of_cesu8_string (ECMA_LONG_UTF8_STRING_GET_BUFFER (string_p),
@@ -2048,7 +2048,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
lit_utf8_size_t
ecma_string_get_size (const ecma_string_t *string_p) /**< ecma-string */
{
ecma_length_t length = ecma_string_get_ascii_size (string_p);
lit_utf8_size_t length = ecma_string_get_ascii_size (string_p);
if (length != ECMA_STRING_NO_ASCII_SIZE)
{
@@ -2086,7 +2086,7 @@ ecma_string_get_size (const ecma_string_t *string_p) /**< ecma-string */
lit_utf8_size_t
ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
{
ecma_length_t length = ecma_string_get_ascii_size (string_p);
lit_utf8_size_t length = ecma_string_get_ascii_size (string_p);
if (length != ECMA_STRING_NO_ASCII_SIZE)
{
@@ -2142,7 +2142,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
*/
static ecma_char_t JERRY_ATTR_NOINLINE
ecma_external_string_get_char_at_pos (lit_utf8_size_t id, /**< id of the external magic string */
ecma_length_t index) /**< index of character */
lit_utf8_size_t index) /**< index of character */
{
id -= LIT_MAGIC_STRING__COUNT;
const lit_utf8_byte_t *data_p = lit_get_magic_string_ex_utf8 (id);
@@ -2164,7 +2164,7 @@ ecma_external_string_get_char_at_pos (lit_utf8_size_t id, /**< id of the externa
*/
ecma_char_t
ecma_string_get_char_at_pos (const ecma_string_t *string_p, /**< ecma-string */
ecma_length_t index) /**< index of character */
lit_utf8_size_t index) /**< index of character */
{
JERRY_ASSERT (index < ecma_string_get_length (string_p));
@@ -2297,10 +2297,10 @@ ecma_string_hash (const ecma_string_t *string_p) /**< ecma-string to calculate h
*/
ecma_string_t *
ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma string */
ecma_length_t start_pos, /**< start position, should be less or equal than string length */
ecma_length_t end_pos) /**< end position, should be less or equal than string length */
lit_utf8_size_t start_pos, /**< start position, should be less or equal than string length */
lit_utf8_size_t end_pos) /**< end position, should be less or equal than string length */
{
const ecma_length_t string_length = ecma_string_get_length (string_p);
const lit_utf8_size_t string_length = ecma_string_get_length (string_p);
JERRY_ASSERT (start_pos <= string_length);
JERRY_ASSERT (end_pos <= string_length);
@@ -2767,7 +2767,7 @@ ecma_op_advance_string_index (ecma_string_t *str_p, /**< input string */
return next_index;
}
ecma_length_t str_len = ecma_string_get_length (str_p);
lit_utf8_size_t str_len = ecma_string_get_length (str_p);
if (next_index >= str_len)
{
+1 -1
View File
@@ -1489,7 +1489,7 @@ ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *b
*
* @return number of formal parameters
*/
ecma_length_t
uint32_t
ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
{
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED))
+9 -9
View File
@@ -336,14 +336,14 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
lit_utf8_size_t buffer_size);
lit_utf8_size_t
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
ecma_length_t start_pos,
ecma_length_t end_pos,
lit_utf8_size_t start_pos,
lit_utf8_size_t end_pos,
lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
lit_utf8_size_t
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
ecma_length_t start_pos,
ecma_length_t end_pos,
lit_utf8_size_t start_pos,
lit_utf8_size_t end_pos,
lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
@@ -367,16 +367,16 @@ bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpoint
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
ecma_length_t ecma_string_get_length (const ecma_string_t *string_p);
ecma_length_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_size (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p);
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, ecma_length_t index);
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, lit_utf8_size_t index);
lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p);
lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, ecma_length_t start_pos, ecma_length_t end_pos);
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p,
lit_utf8_size_t *utf8_str_size);
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
@@ -502,7 +502,7 @@ void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_ESNEXT)
ecma_length_t ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_p);
uint32_t ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_p);
ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p);
ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p);
#endif /* ENABLED (JERRY_ESNEXT) */
+2 -2
View File
@@ -453,7 +453,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
}
lit_mem_to_snapshot_id_map_entry_t *map_p;
ecma_length_t total_count = lit_pool_p->item_count;
uint32_t total_count = lit_pool_p->item_count;
map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
@@ -475,7 +475,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
map_p->literal_id = lit_buffer_p[i];
map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET;
ecma_length_t length;
lit_utf8_size_t length;
if (ecma_is_value_float_number (lit_buffer_p[i]))
{