Added literal list loading feature to the snapshot tool. (#2422)
It is needed to load literals and register them as magic strings to be able to generate static snapshots. Also modified the list format saving feature to save all of the literals not only the identifiers. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1633,9 +1633,15 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
|
||||
{
|
||||
ecma_string_t *literal_p = ecma_get_string_from_value (*iterator_p);
|
||||
|
||||
/* We don't save a literal which isn't a valid identifier or it's a magic string. */
|
||||
/* NOTE:
|
||||
* We don't save a literal (in C format) which isn't a valid
|
||||
* identifier or it's a magic string.
|
||||
* TODO:
|
||||
* Save all of the literals in C format as well.
|
||||
*/
|
||||
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
|
||||
&& ecma_string_is_valid_identifier (literal_p))
|
||||
&& (!is_c_format
|
||||
|| (is_c_format && ecma_string_is_valid_identifier (literal_p))))
|
||||
{
|
||||
literal_count++;
|
||||
}
|
||||
@@ -1666,8 +1672,15 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
|
||||
{
|
||||
ecma_string_t *literal_p = ecma_get_string_from_value (*iterator_p);
|
||||
|
||||
/* NOTE:
|
||||
* We don't save a literal (in C format) which isn't a valid
|
||||
* identifier or it's a magic string.
|
||||
* TODO:
|
||||
* Save all of the literals in C format as well.
|
||||
*/
|
||||
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
|
||||
&& ecma_string_is_valid_identifier (literal_p))
|
||||
&& (!is_c_format
|
||||
|| (is_c_format && ecma_string_is_valid_identifier (literal_p))))
|
||||
{
|
||||
literal_array[literal_idx++] = literal_p;
|
||||
}
|
||||
|
||||
@@ -151,9 +151,7 @@ lit_magic_strings_ex_set (const lit_utf8_byte_t **ex_str_items, /**< character a
|
||||
id < JERRY_CONTEXT (lit_magic_string_ex_count);
|
||||
id = (lit_magic_string_ex_id_t) (id + 1))
|
||||
{
|
||||
lit_utf8_size_t string_size = lit_zt_utf8_string_size (lit_get_magic_string_ex_utf8 (id));
|
||||
JERRY_ASSERT (JERRY_CONTEXT (lit_magic_string_ex_sizes)[id] == string_size);
|
||||
JERRY_ASSERT (JERRY_CONTEXT (lit_magic_string_ex_sizes)[id] <= LIT_MAGIC_STRING_LENGTH_LIMIT);
|
||||
lit_utf8_size_t string_size = JERRY_CONTEXT (lit_magic_string_ex_sizes)[id];
|
||||
|
||||
/**
|
||||
* Check whether the strings are sorted by size and lexicographically,
|
||||
@@ -163,6 +161,8 @@ lit_magic_strings_ex_set (const lit_utf8_byte_t **ex_str_items, /**< character a
|
||||
{
|
||||
const lit_magic_string_ex_id_t prev_id = id - 1;
|
||||
const lit_utf8_size_t prev_string_size = lit_get_magic_string_ex_size (prev_id);
|
||||
JERRY_ASSERT (lit_is_valid_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
string_size));
|
||||
JERRY_ASSERT (prev_string_size <= string_size);
|
||||
|
||||
if (prev_string_size == string_size)
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
|
||||
#include "lit-globals.h"
|
||||
|
||||
/**
|
||||
* Limit for magic string length
|
||||
*/
|
||||
#define LIT_MAGIC_STRING_LENGTH_LIMIT 32
|
||||
|
||||
/**
|
||||
* Identifiers of ECMA and implementation-defined magic string constants
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user