Implement direct strings. (#2196)

Direct strings are a new type of direct ecma-values (no memory allocation
is needed for encoding them) in JerryScript. Currently magic strings,
external magic strings and uint values are encoded as direct strings.

The constant pool of JerryScript byte-code is changed to hold ecma-values
rather than cpointers to support direct strings.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-02-23 00:21:46 +01:00
committed by yichoi
parent fbf5c32747
commit 51e3c4455a
37 changed files with 1493 additions and 1148 deletions
+6 -5
View File
@@ -104,23 +104,24 @@ main (void)
for (uint32_t j = 0; j < test_sub_iters; j++)
{
jmem_cpointer_t lit1;
jmem_cpointer_t lit2;
ecma_value_t lit1;
ecma_value_t lit2;
if (ptrs[j])
{
lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
TEST_ASSERT (ecma_is_value_string (lit1));
TEST_ASSERT (ecma_is_value_string (lit2));
TEST_ASSERT (lit1 == lit2);
}
else
{
lit1 = ecma_find_or_create_literal_number (numbers[j]);
lit2 = ecma_find_or_create_literal_number (numbers[j]);
TEST_ASSERT (ecma_is_value_number (lit1));
TEST_ASSERT (ecma_is_value_number (lit2));
TEST_ASSERT (lit1 == lit2);
}
TEST_ASSERT (lit1);
TEST_ASSERT (lit2);
TEST_ASSERT (lit1 == lit2);
}
/* Check empty string exists. */
+10 -10
View File
@@ -127,18 +127,18 @@ main (void)
/* Check the snapshot data. Unused bytes should be filled with zeroes */
const uint8_t expected_data[] =
{
0x4A, 0x52, 0x52, 0x59, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x4A, 0x52, 0x52, 0x59, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x28, 0x00,
0xB7, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x01, 0x00, 0x21, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x47, 0x00,
0x1C, 0x00, 0x00, 0x00, 0x14, 0x00, 0x73, 0x74,
0x72, 0x69, 0x6E, 0x67, 0x20, 0x66, 0x72, 0x6F,
0x6D, 0x20, 0x73, 0x6E, 0x61, 0x70, 0x73, 0x68,
0x6F, 0x74, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
0x28, 0x00, 0xB7, 0x46, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x01, 0x00, 0x41, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00,
0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x14, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67,
0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x73, 0x6E,
0x61, 0x70, 0x73, 0x68, 0x6F, 0x74
};
TEST_ASSERT (sizeof (expected_data) == global_mode_snapshot_size);
TEST_ASSERT (0 == memcmp (expected_data, global_mode_snapshot_buffer, sizeof (expected_data)));