Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion jerry-core/parser/js/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ typedef enum
/* Initialize this variable after the byte code is freed. */
#define LEXER_FLAG_LATE_INIT 0x80

/**
* Type of property length.
*/
#ifdef JERRY_CPOINTER_32_BIT
typedef uint32_t prop_length_t;
#else /* !JERRY_CPOINTER_32_BIT */
typedef uint16_t prop_length_t;
#endif /* JERRY_CPOINTER_32_BIT */

/**
* Literal data.
*/
Expand All @@ -93,7 +102,7 @@ typedef struct
union
#endif /* PARSER_DUMP_BYTE_CODE */
{
uint16_t length; /**< length of ident / string literal */
prop_length_t length; /**< length of ident / string literal */
uint16_t index; /**< real index during post processing */
} prop;

Expand Down
12 changes: 6 additions & 6 deletions jerry-core/parser/js/js-lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
{
/* Fill literal data. */
context_p->token.lit_location.char_p = ident_start_p;
context_p->token.lit_location.length = (uint16_t) length;
context_p->token.lit_location.length = (prop_length_t) length;
}

context_p->source_p = source_p;
Expand Down Expand Up @@ -815,7 +815,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */

/* Fill literal data. */
context_p->token.lit_location.char_p = string_start_p;
context_p->token.lit_location.length = (uint16_t) length;
context_p->token.lit_location.length = (prop_length_t) length;
context_p->token.lit_location.type = LEXER_STRING_LITERAL;
context_p->token.lit_location.has_escape = has_escape;

Expand Down Expand Up @@ -966,7 +966,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_NUMBER_TOO_LONG);
}

context_p->token.lit_location.length = (uint16_t) length;
context_p->token.lit_location.length = (prop_length_t) length;
PARSER_PLUS_EQUAL_LC (context_p->column, length);
context_p->source_p = source_p;
} /* lexer_parse_number */
Expand Down Expand Up @@ -1374,7 +1374,7 @@ lexer_process_char_literal (parser_context_t *context_p, /**< context */
}

literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
literal_p->prop.length = (uint16_t) length;
literal_p->prop.length = (prop_length_t) length;
literal_p->type = literal_type;
literal_p->status_flags = has_escape ? 0 : LEXER_FLAG_SOURCE_PTR;

Expand Down Expand Up @@ -1718,7 +1718,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
lexer_literal_t *literal_p;
ecma_number_t num;
uint32_t literal_index = 0;
uint16_t length = context_p->token.lit_location.length;
prop_length_t length = context_p->token.lit_location.length;

if (context_p->token.extra_value != LEXER_NUMBER_OCTAL)
{
Expand Down Expand Up @@ -2007,7 +2007,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
}

literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
literal_p->prop.length = (uint16_t) length;
literal_p->prop.length = (prop_length_t) length;
literal_p->type = LEXER_UNUSED_LITERAL;
literal_p->status_flags = 0;

Expand Down
2 changes: 1 addition & 1 deletion jerry-core/parser/js/js-lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ typedef enum
typedef struct
{
const uint8_t *char_p; /**< start of identifier or string token */
uint16_t length; /**< length or index of a literal */
prop_length_t length; /**< length or index of a literal */
uint8_t type; /**< type of the current literal */
uint8_t has_escape; /**< has escape sequences */
} lexer_lit_location_t;
Expand Down
16 changes: 12 additions & 4 deletions jerry-core/parser/js/js-parser-limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@
#define PARSER_MAXIMUM_IDENT_LENGTH 255
#endif /* !PARSER_MAXIMUM_IDENT_LENGTH */

/* Maximum string limit.
* Limit: 2147483647 / 65535. */
#ifdef JERRY_CPOINTER_32_BIT
#define PARSER_MAXIMUM_STRING_LIMIT 2147483647
#else /* !JERRY_CPOINTER_32_BIT */
#define PARSER_MAXIMUM_STRING_LIMIT 65535
#endif /* JERRY_CPOINTER_32_BIT */

/* Maximum string length.
* Limit: 65535. */
* Limit: PARSER_MAXIMUM_STRING_LIMIT. */
#ifndef PARSER_MAXIMUM_STRING_LENGTH
#define PARSER_MAXIMUM_STRING_LENGTH 65535
#define PARSER_MAXIMUM_STRING_LENGTH PARSER_MAXIMUM_STRING_LIMIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is the same as the other define, do we need it at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because the maximum is the default configuration, although we allow lower values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

#endif /* !PARSER_MAXIMUM_STRING_LENGTH */

/* Maximum number of literals.
Expand Down Expand Up @@ -65,9 +73,9 @@

/* Checks. */

#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535)
#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT)
#error "Maximum string length is not within range."
#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535) */
#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT) */

#if (PARSER_MAXIMUM_IDENT_LENGTH < 1) || (PARSER_MAXIMUM_IDENT_LENGTH > PARSER_MAXIMUM_STRING_LENGTH)
#error "Maximum identifier length is not within range."
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/parser/js/js-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ parser_copy_identifiers (parser_context_t *context_p) /**< context */
/* The literal data is updated at every iteration to handle out-of memory. */
parent_p->literal_pool_data = parent_literal_pool.data;

parent_literal_p->prop.length = (uint16_t) length;
parent_literal_p->prop.length = (prop_length_t) length;
parent_literal_p->type = LEXER_IDENT_LITERAL;
parent_literal_p->status_flags = (uint8_t) (literal_p->status_flags & LEXER_FLAG_SOURCE_PTR);
parent_literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE | LEXER_FLAG_UNUSED_IDENT;
Expand Down