Support large string constants in 32 bit cpointer mode. (#2233)

After this patch, all sunspider tests run when cpointer 32 is enabled.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-03-05 11:41:52 +01:00
committed by GitHub
parent 94760b1213
commit b9f96a64d9
5 changed files with 30 additions and 13 deletions
+10 -1
View File
@@ -74,6 +74,15 @@ typedef enum
/* Initialize this variable after the byte code is freed. */ /* Initialize this variable after the byte code is freed. */
#define LEXER_FLAG_LATE_INIT 0x80 #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. * Literal data.
*/ */
@@ -93,7 +102,7 @@ typedef struct
union union
#endif /* PARSER_DUMP_BYTE_CODE */ #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 */ uint16_t index; /**< real index during post processing */
} prop; } prop;
+6 -6
View File
@@ -544,7 +544,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
{ {
/* Fill literal data. */ /* Fill literal data. */
context_p->token.lit_location.char_p = ident_start_p; 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; context_p->source_p = source_p;
@@ -815,7 +815,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
/* Fill literal data. */ /* Fill literal data. */
context_p->token.lit_location.char_p = string_start_p; 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.type = LEXER_STRING_LITERAL;
context_p->token.lit_location.has_escape = has_escape; context_p->token.lit_location.has_escape = has_escape;
@@ -966,7 +966,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
parser_raise_error (context_p, PARSER_ERR_NUMBER_TOO_LONG); 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); PARSER_PLUS_EQUAL_LC (context_p->column, length);
context_p->source_p = source_p; context_p->source_p = source_p;
} /* lexer_parse_number */ } /* lexer_parse_number */
@@ -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 = (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->type = literal_type;
literal_p->status_flags = has_escape ? 0 : LEXER_FLAG_SOURCE_PTR; literal_p->status_flags = has_escape ? 0 : LEXER_FLAG_SOURCE_PTR;
@@ -1718,7 +1718,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
lexer_literal_t *literal_p; lexer_literal_t *literal_p;
ecma_number_t num; ecma_number_t num;
uint32_t literal_index = 0; 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) if (context_p->token.extra_value != LEXER_NUMBER_OCTAL)
{ {
@@ -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 = (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->type = LEXER_UNUSED_LITERAL;
literal_p->status_flags = 0; literal_p->status_flags = 0;
+1 -1
View File
@@ -233,7 +233,7 @@ typedef enum
typedef struct typedef struct
{ {
const uint8_t *char_p; /**< start of identifier or string token */ 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 type; /**< type of the current literal */
uint8_t has_escape; /**< has escape sequences */ uint8_t has_escape; /**< has escape sequences */
} lexer_lit_location_t; } lexer_lit_location_t;
+12 -4
View File
@@ -32,10 +32,18 @@
#define PARSER_MAXIMUM_IDENT_LENGTH 255 #define PARSER_MAXIMUM_IDENT_LENGTH 255
#endif /* !PARSER_MAXIMUM_IDENT_LENGTH */ #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. /* Maximum string length.
* Limit: 65535. */ * Limit: PARSER_MAXIMUM_STRING_LIMIT. */
#ifndef PARSER_MAXIMUM_STRING_LENGTH #ifndef PARSER_MAXIMUM_STRING_LENGTH
#define PARSER_MAXIMUM_STRING_LENGTH 65535 #define PARSER_MAXIMUM_STRING_LENGTH PARSER_MAXIMUM_STRING_LIMIT
#endif /* !PARSER_MAXIMUM_STRING_LENGTH */ #endif /* !PARSER_MAXIMUM_STRING_LENGTH */
/* Maximum number of literals. /* Maximum number of literals.
@@ -65,9 +73,9 @@
/* Checks. */ /* 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." #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) #if (PARSER_MAXIMUM_IDENT_LENGTH < 1) || (PARSER_MAXIMUM_IDENT_LENGTH > PARSER_MAXIMUM_STRING_LENGTH)
#error "Maximum identifier length is not within range." #error "Maximum identifier length is not within range."
+1 -1
View File
@@ -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. */ /* The literal data is updated at every iteration to handle out-of memory. */
parent_p->literal_pool_data = parent_literal_pool.data; 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->type = LEXER_IDENT_LITERAL;
parent_literal_p->status_flags = (uint8_t) (literal_p->status_flags & LEXER_FLAG_SOURCE_PTR); 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; parent_literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE | LEXER_FLAG_UNUSED_IDENT;