mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix receiving of byte-code instructions from serializer.
Related issue: #203 JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
parent
d1055f98e5
commit
ab2abfa8b3
@ -43,6 +43,7 @@ typedef struct __attribute__ ((aligned (MEM_ALIGNMENT)))
|
||||
mem_cpointer_t lit_id_hash_cp; /**< pointer to literal identifiers hash table
|
||||
* See also: lit_id_hash_table_init */
|
||||
mem_cpointer_t next_opcodes_cp; /**< pointer to next byte-code memory region */
|
||||
opcode_counter_t instructions_number; /**< number of instructions in the byte-code array */
|
||||
} opcodes_header_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
@ -33,16 +33,27 @@ serializer_get_op_meta (opcode_counter_t oc)
|
||||
return scopes_tree_op_meta (current_scope, oc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get byte-code instruction from current scope, or specified byte-code array
|
||||
*
|
||||
* @return byte-code instruction
|
||||
*/
|
||||
opcode_t
|
||||
serializer_get_opcode (opcode_counter_t oc)
|
||||
serializer_get_opcode (const opcode_t *opcodes_p, /**< pointer to byte-code array (or NULL,
|
||||
* if instruction should be taken from
|
||||
* instruction list of current scope) */
|
||||
opcode_counter_t oc) /**< opcode counter of the intruction */
|
||||
{
|
||||
if (bytecode_data.opcodes == NULL)
|
||||
if (opcodes_p == NULL)
|
||||
{
|
||||
return serializer_get_op_meta (oc).op;
|
||||
}
|
||||
JERRY_ASSERT (oc < bytecode_data.opcodes_count);
|
||||
return bytecode_data.opcodes[oc];
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (oc < GET_BYTECODE_HEADER (opcodes_p)->instructions_number);
|
||||
return opcodes_p[oc];
|
||||
}
|
||||
} /* serializer_get_opcode */
|
||||
|
||||
/**
|
||||
* Convert literal id (operand value of instruction) to compressed pointer to literal
|
||||
@ -85,7 +96,7 @@ serializer_merge_scopes_into_bytecode (void)
|
||||
|
||||
const size_t buckets_count = scopes_tree_count_literals_in_blocks (current_scope);
|
||||
const size_t blocks_count = (size_t) bytecode_data.opcodes_count / BLOCK_SIZE + 1;
|
||||
const size_t opcodes_count = scopes_tree_count_opcodes (current_scope);
|
||||
const opcode_counter_t opcodes_count = scopes_tree_count_opcodes (current_scope);
|
||||
|
||||
const size_t opcodes_array_size = JERRY_ALIGNUP (sizeof (opcodes_header_t) + opcodes_count * sizeof (opcode_t),
|
||||
MEM_ALIGNMENT);
|
||||
@ -104,6 +115,7 @@ serializer_merge_scopes_into_bytecode (void)
|
||||
|
||||
opcodes_header_t *header_p = (opcodes_header_t*) buffer_p;
|
||||
MEM_CP_SET_POINTER (header_p->next_opcodes_cp, bytecode_data.opcodes);
|
||||
header_p->instructions_number = opcodes_count;
|
||||
bytecode_data.opcodes = opcodes_p;
|
||||
|
||||
if (print_opcodes)
|
||||
@ -125,7 +137,7 @@ serializer_dump_op_meta (op_meta op)
|
||||
#ifdef JERRY_ENABLE_PRETTY_PRINTER
|
||||
if (print_opcodes)
|
||||
{
|
||||
pp_op_meta ((opcode_counter_t) (scopes_tree_opcodes_num (current_scope) - 1), op, false);
|
||||
pp_op_meta (NULL, (opcode_counter_t) (scopes_tree_opcodes_num (current_scope) - 1), op, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -156,7 +168,7 @@ serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op)
|
||||
#ifdef JERRY_ENABLE_PRETTY_PRINTER
|
||||
if (print_opcodes)
|
||||
{
|
||||
pp_op_meta (loc, op, true);
|
||||
pp_op_meta (NULL, loc, op, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -176,7 +188,7 @@ serializer_print_opcodes (const opcode_t *opcodes_p,
|
||||
opm.lit_id[i] = NOT_A_LITERAL;
|
||||
}
|
||||
|
||||
pp_op_meta (loc, opm, false);
|
||||
pp_op_meta (opcodes_p, loc, opm, false);
|
||||
}
|
||||
#else
|
||||
(void) opcodes_p;
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
void serializer_init ();
|
||||
void serializer_set_show_opcodes (bool show_opcodes);
|
||||
op_meta serializer_get_op_meta (opcode_counter_t);
|
||||
opcode_t serializer_get_opcode (opcode_counter_t);
|
||||
opcode_t serializer_get_opcode (const opcode_t*, opcode_counter_t);
|
||||
lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t, const opcode_t*, opcode_counter_t);
|
||||
void serializer_set_strings_buffer (const ecma_char_t *);
|
||||
void serializer_set_scope (scopes_tree);
|
||||
|
||||
@ -179,7 +179,10 @@ dump_asm (opcode_counter_t oc, opcode_t opcode)
|
||||
}
|
||||
|
||||
void
|
||||
pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
|
||||
pp_op_meta (const opcode_t *opcodes_p,
|
||||
opcode_counter_t oc,
|
||||
op_meta opm,
|
||||
bool rewrite)
|
||||
{
|
||||
dump_asm (oc, opm.op);
|
||||
printf (" // ");
|
||||
@ -393,7 +396,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
|
||||
while ((int16_t) start >= 0 && !found)
|
||||
{
|
||||
start--;
|
||||
switch (serializer_get_opcode (start).op_idx)
|
||||
switch (serializer_get_opcode (opcodes_p, start).op_idx)
|
||||
{
|
||||
case NAME_TO_ID (call_n):
|
||||
case NAME_TO_ID (native_call):
|
||||
@ -408,7 +411,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
|
||||
}
|
||||
}
|
||||
}
|
||||
opcode_t start_op = serializer_get_opcode (start);
|
||||
opcode_t start_op = serializer_get_opcode (opcodes_p, start);
|
||||
switch (start_op.op_idx)
|
||||
{
|
||||
case NAME_TO_ID (call_n):
|
||||
@ -470,7 +473,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
|
||||
}
|
||||
for (opcode_counter_t counter = start; counter <= oc; counter++)
|
||||
{
|
||||
opcode_t meta_op = serializer_get_opcode (counter);
|
||||
opcode_t meta_op = serializer_get_opcode (opcodes_p, counter);
|
||||
|
||||
switch (meta_op.op_idx)
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "scopes-tree.h"
|
||||
|
||||
void pp_opcode (opcode_counter_t, opcode_t, bool);
|
||||
void pp_op_meta (opcode_counter_t, op_meta, bool);
|
||||
void pp_op_meta (const opcode_t*, opcode_counter_t, op_meta, bool);
|
||||
#endif // JERRY_ENABLE_PRETTY_PRINTER
|
||||
|
||||
#endif // PRETTY_PRINTER
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user