Skip to content

Commit b9f96a6

Browse files
authored
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
1 parent 94760b1 commit b9f96a6

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

jerry-core/parser/js/common.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ typedef enum
7474
/* Initialize this variable after the byte code is freed. */
7575
#define LEXER_FLAG_LATE_INIT 0x80
7676

77+
/**
78+
* Type of property length.
79+
*/
80+
#ifdef JERRY_CPOINTER_32_BIT
81+
typedef uint32_t prop_length_t;
82+
#else /* !JERRY_CPOINTER_32_BIT */
83+
typedef uint16_t prop_length_t;
84+
#endif /* JERRY_CPOINTER_32_BIT */
85+
7786
/**
7887
* Literal data.
7988
*/
@@ -93,7 +102,7 @@ typedef struct
93102
union
94103
#endif /* PARSER_DUMP_BYTE_CODE */
95104
{
96-
uint16_t length; /**< length of ident / string literal */
105+
prop_length_t length; /**< length of ident / string literal */
97106
uint16_t index; /**< real index during post processing */
98107
} prop;
99108

jerry-core/parser/js/js-lexer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
544544
{
545545
/* Fill literal data. */
546546
context_p->token.lit_location.char_p = ident_start_p;
547-
context_p->token.lit_location.length = (uint16_t) length;
547+
context_p->token.lit_location.length = (prop_length_t) length;
548548
}
549549

550550
context_p->source_p = source_p;
@@ -815,7 +815,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
815815

816816
/* Fill literal data. */
817817
context_p->token.lit_location.char_p = string_start_p;
818-
context_p->token.lit_location.length = (uint16_t) length;
818+
context_p->token.lit_location.length = (prop_length_t) length;
819819
context_p->token.lit_location.type = LEXER_STRING_LITERAL;
820820
context_p->token.lit_location.has_escape = has_escape;
821821

@@ -966,7 +966,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
966966
parser_raise_error (context_p, PARSER_ERR_NUMBER_TOO_LONG);
967967
}
968968

969-
context_p->token.lit_location.length = (uint16_t) length;
969+
context_p->token.lit_location.length = (prop_length_t) length;
970970
PARSER_PLUS_EQUAL_LC (context_p->column, length);
971971
context_p->source_p = source_p;
972972
} /* lexer_parse_number */
@@ -1374,7 +1374,7 @@ lexer_process_char_literal (parser_context_t *context_p, /**< context */
13741374
}
13751375

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

@@ -1718,7 +1718,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
17181718
lexer_literal_t *literal_p;
17191719
ecma_number_t num;
17201720
uint32_t literal_index = 0;
1721-
uint16_t length = context_p->token.lit_location.length;
1721+
prop_length_t length = context_p->token.lit_location.length;
17221722

17231723
if (context_p->token.extra_value != LEXER_NUMBER_OCTAL)
17241724
{
@@ -2007,7 +2007,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
20072007
}
20082008

20092009
literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
2010-
literal_p->prop.length = (uint16_t) length;
2010+
literal_p->prop.length = (prop_length_t) length;
20112011
literal_p->type = LEXER_UNUSED_LITERAL;
20122012
literal_p->status_flags = 0;
20132013

jerry-core/parser/js/js-lexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ typedef enum
233233
typedef struct
234234
{
235235
const uint8_t *char_p; /**< start of identifier or string token */
236-
uint16_t length; /**< length or index of a literal */
236+
prop_length_t length; /**< length or index of a literal */
237237
uint8_t type; /**< type of the current literal */
238238
uint8_t has_escape; /**< has escape sequences */
239239
} lexer_lit_location_t;

jerry-core/parser/js/js-parser-limits.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@
3232
#define PARSER_MAXIMUM_IDENT_LENGTH 255
3333
#endif /* !PARSER_MAXIMUM_IDENT_LENGTH */
3434

35+
/* Maximum string limit.
36+
* Limit: 2147483647 / 65535. */
37+
#ifdef JERRY_CPOINTER_32_BIT
38+
#define PARSER_MAXIMUM_STRING_LIMIT 2147483647
39+
#else /* !JERRY_CPOINTER_32_BIT */
40+
#define PARSER_MAXIMUM_STRING_LIMIT 65535
41+
#endif /* JERRY_CPOINTER_32_BIT */
42+
3543
/* Maximum string length.
36-
* Limit: 65535. */
44+
* Limit: PARSER_MAXIMUM_STRING_LIMIT. */
3745
#ifndef PARSER_MAXIMUM_STRING_LENGTH
38-
#define PARSER_MAXIMUM_STRING_LENGTH 65535
46+
#define PARSER_MAXIMUM_STRING_LENGTH PARSER_MAXIMUM_STRING_LIMIT
3947
#endif /* !PARSER_MAXIMUM_STRING_LENGTH */
4048

4149
/* Maximum number of literals.
@@ -65,9 +73,9 @@
6573

6674
/* Checks. */
6775

68-
#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535)
76+
#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT)
6977
#error "Maximum string length is not within range."
70-
#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535) */
78+
#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT) */
7179

7280
#if (PARSER_MAXIMUM_IDENT_LENGTH < 1) || (PARSER_MAXIMUM_IDENT_LENGTH > PARSER_MAXIMUM_STRING_LENGTH)
7381
#error "Maximum identifier length is not within range."

jerry-core/parser/js/js-parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ parser_copy_identifiers (parser_context_t *context_p) /**< context */
106106
/* The literal data is updated at every iteration to handle out-of memory. */
107107
parent_p->literal_pool_data = parent_literal_pool.data;
108108

109-
parent_literal_p->prop.length = (uint16_t) length;
109+
parent_literal_p->prop.length = (prop_length_t) length;
110110
parent_literal_p->type = LEXER_IDENT_LITERAL;
111111
parent_literal_p->status_flags = (uint8_t) (literal_p->status_flags & LEXER_FLAG_SOURCE_PTR);
112112
parent_literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE | LEXER_FLAG_UNUSED_IDENT;

0 commit comments

Comments
 (0)