@@ -33,16 +33,27 @@ serializer_get_op_meta (opcode_counter_t oc)
3333  return  scopes_tree_op_meta  (current_scope, oc);
3434}
3535
36+ /* *
37+  * Get byte-code instruction from current scope, or specified byte-code array 
38+  * 
39+  * @return byte-code instruction 
40+  */  
3641opcode_t 
37- serializer_get_opcode  (opcode_counter_t  oc)
42+ serializer_get_opcode  (const  opcode_t * opcodes_p, /* *< pointer to byte-code array (or NULL),
43+                                                    *   if instruction should be taken from 
44+                                                    *   instruction list of current scope */  
45+                        opcode_counter_t  oc) /* *< opcode counter of the intruction */ 
3846{
39-   if  (bytecode_data. opcodes  == NULL )
47+   if  (opcodes_p  == NULL )
4048  {
4149    return  serializer_get_op_meta  (oc).op ;
4250  }
43-   JERRY_ASSERT  (oc < bytecode_data.opcodes_count );
44-   return  bytecode_data.opcodes [oc];
45- }
51+   else 
52+   {
53+     JERRY_ASSERT  (oc < GET_BYTECODE_HEADER  (opcodes_p)->instructions_number );
54+     return  opcodes_p[oc];
55+   }
56+ } /*  serializer_get_opcode */ 
4657
4758/* *
4859 * Convert literal id (operand value of instruction) to compressed pointer to literal 
@@ -85,7 +96,7 @@ serializer_merge_scopes_into_bytecode (void)
8596
8697  const  size_t  buckets_count = scopes_tree_count_literals_in_blocks  (current_scope);
8798  const  size_t  blocks_count = (size_t ) bytecode_data.opcodes_count  / BLOCK_SIZE + 1 ;
88-   const  size_t  opcodes_count = scopes_tree_count_opcodes  (current_scope);
99+   const  opcode_counter_t  opcodes_count = scopes_tree_count_opcodes  (current_scope);
89100
90101  const  size_t  opcodes_array_size = JERRY_ALIGNUP  (sizeof  (opcodes_header_t ) + opcodes_count * sizeof  (opcode_t ),
91102                                                   MEM_ALIGNMENT);
@@ -104,6 +115,7 @@ serializer_merge_scopes_into_bytecode (void)
104115
105116  opcodes_header_t  *header_p = (opcodes_header_t *) buffer_p;
106117  MEM_CP_SET_POINTER  (header_p->next_opcodes_cp , bytecode_data.opcodes );
118+   header_p->instructions_number  = opcodes_count;
107119  bytecode_data.opcodes  = opcodes_p;
108120
109121  if  (print_opcodes)
@@ -125,7 +137,7 @@ serializer_dump_op_meta (op_meta op)
125137#ifdef  JERRY_ENABLE_PRETTY_PRINTER
126138  if  (print_opcodes)
127139  {
128-     pp_op_meta  ((opcode_counter_t ) (scopes_tree_opcodes_num  (current_scope) - 1 ), op, false );
140+     pp_op_meta  (NULL ,  (opcode_counter_t ) (scopes_tree_opcodes_num  (current_scope) - 1 ), op, false );
129141  }
130142#endif 
131143}
@@ -156,7 +168,7 @@ serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op)
156168#ifdef  JERRY_ENABLE_PRETTY_PRINTER
157169  if  (print_opcodes)
158170  {
159-     pp_op_meta  (loc, op, true );
171+     pp_op_meta  (NULL ,  loc, op, true );
160172  }
161173#endif 
162174}
@@ -176,7 +188,7 @@ serializer_print_opcodes (const opcode_t *opcodes_p,
176188      opm.lit_id [i] = NOT_A_LITERAL;
177189    }
178190
179-     pp_op_meta  (loc, opm, false );
191+     pp_op_meta  (opcodes_p,  loc, opm, false );
180192  }
181193#else 
182194  (void ) opcodes_p;
0 commit comments