@@ -66,9 +66,9 @@ static ecma_length_t ecma_magic_string_max_length;
66
66
#endif /* !JERRY_NDEBUG */
67
67
68
68
static void
69
- ecma_init_ecma_string_from_lit_index (ecma_string_t *string_p,
70
- literal_index_t lit_index,
71
- bool is_stack_var);
69
+ ecma_init_ecma_string_from_lit_cp (ecma_string_t *string_p,
70
+ lit_cpointer_t lit_index,
71
+ bool is_stack_var);
72
72
static void
73
73
ecma_init_ecma_string_from_magic_string_id (ecma_string_t *string_p,
74
74
ecma_magic_string_id_t magic_string_id,
@@ -370,42 +370,42 @@ ecma_get_magic_string_ex_count (void)
370
370
* Initialize ecma-string descriptor with string described by index in literal table
371
371
*/
372
372
static void
373
- ecma_init_ecma_string_from_lit_index (ecma_string_t *string_p, /* *< descriptor to initialize */
374
- literal_index_t lit_index , /* *< index in the literal table */
375
- bool is_stack_var) /* *< flag indicating whether the string descriptor
373
+ ecma_init_ecma_string_from_lit_cp (ecma_string_t *string_p, /* *< descriptor to initialize */
374
+ lit_cpointer_t lit_cp , /* *< compressed pointer to literal */
375
+ bool is_stack_var) /* *< flag indicating whether the string descriptor
376
376
is placed on stack (true) or in the heap (false) */
377
377
{
378
378
#ifndef JERRY_NDEBUG
379
379
JERRY_ASSERT (is_stack_var == (!mem_is_heap_pointer (string_p)));
380
380
#endif /* !JERRY_NDEBUG */
381
381
382
- const literal lit = serializer_get_literal_by_id (lit_index );
383
- if (lit. type == LIT_MAGIC_STR )
382
+ literal_t lit = lit_get_literal_by_cp (lit_cp );
383
+ if (lit-> get_type () == LIT_MAGIC_STR_T )
384
384
{
385
385
ecma_init_ecma_string_from_magic_string_id (string_p,
386
- lit. data . magic_str_id ,
386
+ lit_magic_record_get_magic_str_id ( lit) ,
387
387
is_stack_var);
388
388
389
389
return ;
390
390
}
391
- else if (lit. type == LIT_MAGIC_STR_EX )
391
+ else if (lit-> get_type () == LIT_MAGIC_STR_EX_T )
392
392
{
393
393
ecma_init_ecma_string_from_magic_string_ex_id (string_p,
394
- lit. data . magic_str_ex_id ,
394
+ lit_magic_record_ex_get_magic_str_id ( lit) ,
395
395
is_stack_var);
396
-
397
396
return ;
398
397
}
399
- JERRY_ASSERT (lit.type == LIT_STR);
398
+
399
+ JERRY_ASSERT (lit->get_type () == LIT_STR_T);
400
400
401
401
string_p->refs = 1 ;
402
402
string_p->is_stack_var = (is_stack_var != 0 );
403
403
string_p->container = ECMA_STRING_CONTAINER_LIT_TABLE;
404
- string_p->hash = lit. data . lp . hash ;
404
+ string_p->hash = lit_charset_literal_get_hash ( lit) ;
405
405
406
406
string_p->u .common_field = 0 ;
407
- string_p->u .lit_index = lit_index ;
408
- } /* ecma_init_ecma_string_from_lit_index */
407
+ string_p->u .lit_cp = lit_cp ;
408
+ } /* ecma_init_ecma_string_from_lit_cp */
409
409
410
410
/* *
411
411
* Initialize ecma-string descriptor with specified magic string
@@ -591,27 +591,27 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
591
591
* with string described by index in literal table
592
592
*/
593
593
void
594
- ecma_new_ecma_string_on_stack_from_lit_index (ecma_string_t *string_p, /* *< pointer to the ecma-string
594
+ ecma_new_ecma_string_on_stack_from_lit_cp (ecma_string_t *string_p, /* *< pointer to the ecma-string
595
595
descriptor to initialize */
596
- literal_index_t lit_index ) /* *< index in the literal table */
596
+ lit_cpointer_t lit_cp ) /* *< compressed pointer to literal */
597
597
{
598
- ecma_init_ecma_string_from_lit_index (string_p, lit_index , true );
599
- } /* ecma_new_ecma_string_on_stack_from_lit_index */
598
+ ecma_init_ecma_string_from_lit_cp (string_p, lit_cp , true );
599
+ } /* ecma_new_ecma_string_on_stack_from_lit_cp */
600
600
601
601
/* *
602
602
* Allocate new ecma-string and fill it with reference to string literal
603
603
*
604
604
* @return pointer to ecma-string descriptor
605
605
*/
606
606
ecma_string_t *
607
- ecma_new_ecma_string_from_lit_index ( literal_index_t lit_index ) /* *< index in the literal table */
607
+ ecma_new_ecma_string_from_lit_cp ( lit_cpointer_t lit_cp ) /* *< index in the literal table */
608
608
{
609
609
ecma_string_t * string_desc_p = ecma_alloc_string ();
610
610
611
- ecma_init_ecma_string_from_lit_index (string_desc_p, lit_index , false );
611
+ ecma_init_ecma_string_from_lit_cp (string_desc_p, lit_cp , false );
612
612
613
613
return string_desc_p;
614
- } /* ecma_new_ecma_string_from_lit_index */
614
+ } /* ecma_new_ecma_string_from_lit_cp */
615
615
616
616
/* *
617
617
* Initialize ecma-string descriptor placed on stack with specified magic string
@@ -1037,13 +1037,9 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
1037
1037
}
1038
1038
case ECMA_STRING_CONTAINER_LIT_TABLE:
1039
1039
{
1040
- const literal lit = serializer_get_literal_by_id (string_desc_p->u .lit_index );
1041
- JERRY_ASSERT (lit.type == LIT_STR);
1042
- const ecma_char_t *str_p = literal_to_zt (lit);
1043
- JERRY_ASSERT (str_p != NULL );
1044
-
1045
- ecma_copy_zt_string_to_buffer (str_p, buffer_p, required_buffer_size);
1046
-
1040
+ literal_t lit = lit_get_literal_by_cp (string_desc_p->u .lit_cp );
1041
+ JERRY_ASSERT (lit->get_type () == LIT_STR_T);
1042
+ lit_literal_to_charset (lit, buffer_p, (size_t ) required_buffer_size);
1047
1043
break ;
1048
1044
}
1049
1045
case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
@@ -1141,7 +1137,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
1141
1137
{
1142
1138
if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
1143
1139
{
1144
- JERRY_ASSERT (string1_p->u .lit_index != string2_p->u .lit_index );
1140
+ JERRY_ASSERT (string1_p->u .lit_cp . packed_value != string2_p->u .lit_cp . packed_value );
1145
1141
1146
1142
return false ;
1147
1143
}
@@ -1214,7 +1210,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
1214
1210
}
1215
1211
case ECMA_STRING_CONTAINER_LIT_TABLE:
1216
1212
{
1217
- JERRY_ASSERT (string1_p->u .lit_index != string2_p->u .lit_index );
1213
+ JERRY_ASSERT (string1_p->u .lit_cp . packed_value != string2_p->u .lit_cp . packed_value );
1218
1214
1219
1215
return false ;
1220
1216
}
@@ -1346,74 +1342,56 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1346
1342
ecma_char_t zt_string1_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER + 1 ];
1347
1343
ecma_char_t zt_string2_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER + 1 ];
1348
1344
1349
- if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
1350
- {
1351
- const literal lit = serializer_get_literal_by_id (string1_p->u .lit_index );
1352
- JERRY_ASSERT (lit.type == LIT_STR);
1353
- zt_string1_p = literal_to_zt (lit);
1354
- }
1355
- else
1356
- {
1357
- ssize_t req_size = ecma_string_to_zt_string (string1_p,
1358
- zt_string1_buffer,
1359
- sizeof (zt_string1_buffer));
1345
+ ssize_t req_size = ecma_string_to_zt_string (string1_p,
1346
+ zt_string1_buffer,
1347
+ sizeof (zt_string1_buffer));
1360
1348
1361
- if (req_size < 0 )
1349
+ if (req_size < 0 )
1350
+ {
1351
+ ecma_char_t *heap_buffer_p = (ecma_char_t *) mem_heap_alloc_block ((size_t ) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
1352
+ if (heap_buffer_p == NULL )
1362
1353
{
1363
- ecma_char_t *heap_buffer_p = (ecma_char_t *) mem_heap_alloc_block ((size_t ) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
1364
- if (heap_buffer_p == NULL )
1365
- {
1366
- jerry_fatal (ERR_OUT_OF_MEMORY);
1367
- }
1354
+ jerry_fatal (ERR_OUT_OF_MEMORY);
1355
+ }
1368
1356
1369
- ssize_t bytes_copied = ecma_string_to_zt_string (string1_p,
1370
- heap_buffer_p,
1371
- -req_size);
1357
+ ssize_t bytes_copied = ecma_string_to_zt_string (string1_p,
1358
+ heap_buffer_p,
1359
+ -req_size);
1372
1360
1373
- JERRY_ASSERT (bytes_copied > 0 );
1361
+ JERRY_ASSERT (bytes_copied > 0 );
1374
1362
1375
- zt_string1_p = heap_buffer_p;
1376
- is_zt_string1_on_heap = true ;
1377
- }
1378
- else
1379
- {
1380
- zt_string1_p = zt_string1_buffer;
1381
- }
1382
- }
1383
-
1384
- if (string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
1385
- {
1386
- const literal lit = serializer_get_literal_by_id (string2_p->u .lit_index );
1387
- JERRY_ASSERT (lit.type == LIT_STR);
1388
- zt_string2_p = literal_to_zt (lit);
1363
+ zt_string1_p = heap_buffer_p;
1364
+ is_zt_string1_on_heap = true ;
1389
1365
}
1390
1366
else
1391
1367
{
1392
- ssize_t req_size = ecma_string_to_zt_string (string2_p,
1393
- zt_string2_buffer,
1394
- sizeof (zt_string2_buffer));
1368
+ zt_string1_p = zt_string1_buffer;
1369
+ }
1395
1370
1396
- if (req_size < 0 )
1371
+ req_size = ecma_string_to_zt_string (string2_p,
1372
+ zt_string2_buffer,
1373
+ sizeof (zt_string2_buffer));
1374
+
1375
+ if (req_size < 0 )
1376
+ {
1377
+ ecma_char_t *heap_buffer_p = (ecma_char_t *) mem_heap_alloc_block ((size_t ) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
1378
+ if (heap_buffer_p == NULL )
1397
1379
{
1398
- ecma_char_t *heap_buffer_p = (ecma_char_t *) mem_heap_alloc_block ((size_t ) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
1399
- if (heap_buffer_p == NULL )
1400
- {
1401
- jerry_fatal (ERR_OUT_OF_MEMORY);
1402
- }
1380
+ jerry_fatal (ERR_OUT_OF_MEMORY);
1381
+ }
1403
1382
1404
- ssize_t bytes_copied = ecma_string_to_zt_string (string2_p,
1405
- heap_buffer_p,
1406
- -req_size);
1383
+ ssize_t bytes_copied = ecma_string_to_zt_string (string2_p,
1384
+ heap_buffer_p,
1385
+ -req_size);
1407
1386
1408
- JERRY_ASSERT (bytes_copied > 0 );
1387
+ JERRY_ASSERT (bytes_copied > 0 );
1409
1388
1410
- zt_string2_p = heap_buffer_p;
1411
- is_zt_string2_on_heap = true ;
1412
- }
1413
- else
1414
- {
1415
- zt_string2_p = zt_string2_buffer;
1416
- }
1389
+ zt_string2_p = heap_buffer_p;
1390
+ is_zt_string2_on_heap = true ;
1391
+ }
1392
+ else
1393
+ {
1394
+ zt_string2_p = zt_string2_buffer;
1417
1395
}
1418
1396
1419
1397
bool is_first_less_than_second = ecma_compare_zt_strings_relational (zt_string1_p,
@@ -1445,9 +1423,9 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
1445
1423
1446
1424
if (container == ECMA_STRING_CONTAINER_LIT_TABLE)
1447
1425
{
1448
- const literal lit = serializer_get_literal_by_id (string_p->u .lit_index );
1449
-
1450
- return lit. data . lp . length ;
1426
+ literal_t lit = lit_get_literal_by_cp (string_p->u .lit_cp );
1427
+ JERRY_ASSERT (lit-> get_type () == LIT_STR_T);
1428
+ return lit_charset_record_get_length ( lit) ;
1451
1429
}
1452
1430
else if (container == ECMA_STRING_CONTAINER_MAGIC_STRING)
1453
1431
{
0 commit comments