Parser optimizations.
- parser is now non-recursive (i.e. parse function is not called recursively in any case);
- byte-code is now more compact:
- constants are now not immediately dumped upon occurence, but later - where necessary;
- assignments are combined with unary / binary operations;
- binary operations are encoded more compactly in many cases;
- byte-code arrays are now allocated separately for each scope (so, GC of the scopes now becomes possible);
- byte-code is dumped directly into corresponding byte-code arrays:
- linked lists of op_meta are not now used for main code of a scope.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
committed by
Ruben Ayrapetyan
parent
b1de93abd6
commit
50d124bfc3
@@ -84,11 +84,12 @@ lit_id_hash_table_free (lit_id_hash_table *table_p) /**< table's header */
|
||||
} /* lit_id_hash_table_free */
|
||||
|
||||
/**
|
||||
* Register pair in the hash table
|
||||
* Register literal in the hash table
|
||||
*
|
||||
* @return corresponding idx
|
||||
*/
|
||||
void
|
||||
vm_idx_t
|
||||
lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
|
||||
vm_idx_t uid, /**< value of byte-code instruction's argument */
|
||||
vm_instr_counter_t oc, /**< instruction counter of the instruction */
|
||||
lit_cpointer_t lit_cp) /**< literal identifier */
|
||||
{
|
||||
@@ -101,8 +102,31 @@ lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
|
||||
table_p->buckets[block_id] = table_p->raw_buckets + table_p->current_bucket_pos;
|
||||
}
|
||||
|
||||
table_p->buckets[block_id][uid] = lit_cp;
|
||||
table_p->current_bucket_pos++;
|
||||
lit_cpointer_t *raw_bucket_iter_p = table_p->raw_buckets + table_p->current_bucket_pos;
|
||||
|
||||
JERRY_ASSERT (raw_bucket_iter_p >= table_p->buckets[block_id]);
|
||||
ssize_t bucket_size = (raw_bucket_iter_p - table_p->buckets[block_id]);
|
||||
|
||||
int32_t index;
|
||||
for (index = 0; index < bucket_size; index++)
|
||||
{
|
||||
if (table_p->buckets[block_id][index].packed_value == lit_cp.packed_value)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == bucket_size)
|
||||
{
|
||||
JERRY_ASSERT ((uint8_t *) (table_p->raw_buckets + table_p->current_bucket_pos) < (uint8_t *) (table_p->buckets));
|
||||
|
||||
table_p->buckets[block_id][index] = lit_cp;
|
||||
table_p->current_bucket_pos++;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (index <= VM_IDX_LITERAL_LAST);
|
||||
|
||||
return (vm_idx_t) index;
|
||||
} /* lit_id_hash_table_insert */
|
||||
|
||||
/**
|
||||
@@ -194,17 +218,8 @@ lit_id_hash_table_dump_for_snapshot (uint8_t *buffer_p, /**< buffer to dump to *
|
||||
{
|
||||
lit_cpointer_t lit_cp = table_p->buckets[block_index][block_idx_pair_index];
|
||||
|
||||
uint32_t lit_index;
|
||||
for (lit_index = 0; lit_index < literals_num; lit_index++)
|
||||
{
|
||||
if (lit_map_p[lit_index].literal_id.packed_value == lit_cp.packed_value)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
JERRY_ASSERT (lit_index < literals_num);
|
||||
uint32_t offset = bc_find_lit_offset (lit_cp, lit_map_p, literals_num);
|
||||
|
||||
uint32_t offset = lit_map_p[lit_index].literal_offset;
|
||||
if (!jrt_write_to_buffer_by_offset (buffer_p, buffer_size, in_out_buffer_offset_p, offset))
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user