OPCODE define replaced with opcode_t. T_IDX define replaced with idx_t.
This commit is contained in:
1 parent
0eece0be5a
commit
a99907670b
30 files changed
+368
-362
No files matched your search
@@ -32,6 +32,6 @@
|
||||
U32 nums[nums_count];
|
||||
} */
|
||||
extern uint8_t *bytecode_data;
|
||||
OPCODE bytecode_opcodes[MAX_OPCODES];
|
||||
opcode_t bytecode_opcodes[MAX_OPCODES];
|
||||
|
||||
#endif // BYTECODE_LINUX_H
|
||||
@@ -34,9 +34,9 @@
|
||||
var_?_end
|
||||
*/
|
||||
static void
|
||||
optimize_calls (OPCODE *opcodes)
|
||||
optimize_calls (opcode_t *opcodes)
|
||||
{
|
||||
OPCODE *current_opcode;
|
||||
opcode_t *current_opcode;
|
||||
|
||||
for (current_opcode = opcodes;
|
||||
current_opcode->op_idx != NAME_TO_ID (exitval);
|
||||
@@ -45,7 +45,7 @@ optimize_calls (OPCODE *opcodes)
|
||||
if (current_opcode->op_idx == NAME_TO_ID (call_n)
|
||||
&& (current_opcode + 1)->op_idx == NAME_TO_ID (assignment))
|
||||
{
|
||||
OPCODE temp = *current_opcode;
|
||||
opcode_t temp = *current_opcode;
|
||||
*current_opcode = *(current_opcode + 1);
|
||||
*(current_opcode + 1) = temp;
|
||||
}
|
||||
@@ -54,9 +54,9 @@ optimize_calls (OPCODE *opcodes)
|
||||
|
||||
/* Move NUMBER opcodes from FROM to TO and adjust opcodes beetwen FROM and TO. */
|
||||
void
|
||||
optimizer_move_opcodes (OPCODE *from, OPCODE *to, uint16_t number)
|
||||
optimizer_move_opcodes (opcode_t *from, opcode_t *to, uint16_t number)
|
||||
{
|
||||
OPCODE temp[number], *current_opcode;
|
||||
opcode_t temp[number], *current_opcode;
|
||||
uint16_t i;
|
||||
|
||||
if (to == from)
|
||||
@@ -107,16 +107,16 @@ optimizer_move_opcodes (OPCODE *from, OPCODE *to, uint16_t number)
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
opcode_to_counter (OPCODE *opcode)
|
||||
opcode_to_counter (opcode_t *opcode)
|
||||
{
|
||||
JERRY_ASSERT (opcode > (OPCODE *) deserialize_bytecode ());
|
||||
return (uint16_t) (opcode - (OPCODE *) deserialize_bytecode ());
|
||||
JERRY_ASSERT (opcode > (opcode_t *) deserialize_bytecode ());
|
||||
return (uint16_t) (opcode - (opcode_t *) deserialize_bytecode ());
|
||||
}
|
||||
|
||||
void
|
||||
optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value)
|
||||
optimizer_adjust_jumps (opcode_t *first_opcode, opcode_t *last_opcode, int16_t value)
|
||||
{
|
||||
OPCODE *current_opcode;
|
||||
opcode_t *current_opcode;
|
||||
|
||||
JERRY_ASSERT (first_opcode <= last_opcode);
|
||||
|
||||
@@ -151,7 +151,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
if (current_opcode->data.is_true_jmp.opcode >= opcode_to_counter (first_opcode)
|
||||
&& current_opcode->data.is_true_jmp.opcode <= opcode_to_counter (last_opcode) - value)
|
||||
{
|
||||
current_opcode->data.is_true_jmp.opcode = (T_IDX) (current_opcode->data.is_true_jmp.opcode + value);
|
||||
current_opcode->data.is_true_jmp.opcode = (idx_t) (current_opcode->data.is_true_jmp.opcode + value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
*/
|
||||
if (current_opcode->data.is_true_jmp.opcode < opcode_to_counter (last_opcode))
|
||||
{
|
||||
current_opcode->data.is_true_jmp.opcode = (T_IDX) opcode_to_counter (last_opcode);
|
||||
current_opcode->data.is_true_jmp.opcode = (idx_t) opcode_to_counter (last_opcode);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
if (current_opcode->data.is_false_jmp.opcode >= opcode_to_counter (first_opcode)
|
||||
&& current_opcode->data.is_false_jmp.opcode <= opcode_to_counter (last_opcode) - value)
|
||||
{
|
||||
current_opcode->data.is_false_jmp.opcode = (T_IDX) (current_opcode->data.is_false_jmp.opcode + value);
|
||||
current_opcode->data.is_false_jmp.opcode = (idx_t) (current_opcode->data.is_false_jmp.opcode + value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
*/
|
||||
if (current_opcode->data.is_false_jmp.opcode < opcode_to_counter (last_opcode))
|
||||
{
|
||||
current_opcode->data.is_false_jmp.opcode = (T_IDX) opcode_to_counter (last_opcode);
|
||||
current_opcode->data.is_false_jmp.opcode = (idx_t) opcode_to_counter (last_opcode);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
*/
|
||||
if (current_opcode->data.jmp_down.opcode_count >= last_opcode - current_opcode + value)
|
||||
{
|
||||
current_opcode->data.jmp_down.opcode_count = (T_IDX) (current_opcode->data.jmp_down.opcode_count - value);
|
||||
current_opcode->data.jmp_down.opcode_count = (idx_t) (current_opcode->data.jmp_down.opcode_count - value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
if (current_opcode->data.jmp_down.opcode_count >= last_opcode - current_opcode
|
||||
&& current_opcode->data.jmp_down.opcode_count < last_opcode - current_opcode + value)
|
||||
{
|
||||
current_opcode->data.jmp_down.opcode_count = (T_IDX) (last_opcode - current_opcode);
|
||||
current_opcode->data.jmp_down.opcode_count = (idx_t) (last_opcode - current_opcode);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
*/
|
||||
if (current_opcode->data.jmp_up.opcode_count >= current_opcode - first_opcode)
|
||||
{
|
||||
current_opcode->data.jmp_up.opcode_count = (T_IDX) (current_opcode->data.jmp_up.opcode_count + value);
|
||||
current_opcode->data.jmp_up.opcode_count = (idx_t) (current_opcode->data.jmp_up.opcode_count + value);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -332,11 +332,11 @@ optimizer_adjust_jumps (OPCODE *first_opcode, OPCODE *last_opcode, int16_t value
|
||||
void
|
||||
optimizer_reorder_scope (uint16_t scope_start, uint16_t scope_end)
|
||||
{
|
||||
OPCODE *opcodes = (OPCODE *) deserialize_bytecode ();
|
||||
OPCODE *first_opcode = opcodes + scope_start;
|
||||
OPCODE *last_opcode = opcodes + scope_end;
|
||||
OPCODE *current_opcode, *processed_opcode = first_opcode;
|
||||
OPCODE *var_decls_start;
|
||||
opcode_t *opcodes = (opcode_t *) deserialize_bytecode ();
|
||||
opcode_t *first_opcode = opcodes + scope_start;
|
||||
opcode_t *last_opcode = opcodes + scope_end;
|
||||
opcode_t *current_opcode, *processed_opcode = first_opcode;
|
||||
opcode_t *var_decls_start;
|
||||
|
||||
for (current_opcode = processed_opcode; current_opcode != last_opcode; current_opcode++)
|
||||
{
|
||||
@@ -358,7 +358,7 @@ optimizer_reorder_scope (uint16_t scope_start, uint16_t scope_end)
|
||||
|| current_opcode->op_idx == NAME_TO_ID (func_decl_2)
|
||||
|| current_opcode->op_idx == NAME_TO_ID (func_decl_n))
|
||||
{
|
||||
OPCODE *fun_opcode;
|
||||
opcode_t *fun_opcode;
|
||||
int16_t value, jmp_offset = 0;
|
||||
for (fun_opcode = current_opcode + 1; fun_opcode != last_opcode; fun_opcode++)
|
||||
{
|
||||
@@ -399,7 +399,7 @@ optimizer_reorder_scope (uint16_t scope_start, uint16_t scope_end)
|
||||
bool was_decl = false;
|
||||
if (var_decls_start->op_idx == NAME_TO_ID (var_decl) && var_decls_start != current_opcode)
|
||||
{
|
||||
OPCODE *var_decls_iterator;
|
||||
opcode_t *var_decls_iterator;
|
||||
for (var_decls_iterator = var_decls_start;
|
||||
var_decls_iterator != processed_opcode;
|
||||
var_decls_iterator++)
|
||||
@@ -429,7 +429,7 @@ optimizer_reorder_scope (uint16_t scope_start, uint16_t scope_end)
|
||||
}
|
||||
|
||||
void
|
||||
optimizer_run_passes (OPCODE* opcodes)
|
||||
optimizer_run_passes (opcode_t *opcodes)
|
||||
{
|
||||
optimize_calls (opcodes);
|
||||
}
|
||||
@@ -19,9 +19,9 @@
|
||||
#include "globals.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
void optimizer_move_opcodes (OPCODE *, OPCODE *, uint16_t);
|
||||
void optimizer_adjust_jumps (OPCODE *, OPCODE *, int16_t);
|
||||
void optimizer_move_opcodes (opcode_t *, opcode_t *, uint16_t);
|
||||
void optimizer_adjust_jumps (opcode_t *, opcode_t *, int16_t);
|
||||
void optimizer_reorder_scope (uint16_t, uint16_t);
|
||||
void optimizer_run_passes (OPCODE *);
|
||||
void optimizer_run_passes (opcode_t *);
|
||||
|
||||
#endif // OPTIMIZER_PASSES_H
|
||||
@@ -67,7 +67,7 @@ pp_nums (const ecma_number_t nums[], uint8_t size, uint8_t strings_num)
|
||||
}
|
||||
|
||||
static void
|
||||
dump_variable (T_IDX id)
|
||||
dump_variable (idx_t id)
|
||||
{
|
||||
if (id >= deserialize_min_temp ())
|
||||
{
|
||||
@@ -349,7 +349,7 @@ dump_variable (T_IDX id)
|
||||
static char *varg_end;
|
||||
|
||||
void
|
||||
pp_opcode (opcode_counter_t oc, OPCODE opcode, bool is_rewrite)
|
||||
pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite)
|
||||
{
|
||||
uint8_t i = 1;
|
||||
uint8_t opcode_num = opcode.op_idx;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "interpreter.h"
|
||||
|
||||
void pp_opcode (opcode_counter_t, OPCODE, bool);
|
||||
void pp_opcode (opcode_counter_t, opcode_t, bool);
|
||||
void pp_strings (const char **, uint8_t);
|
||||
void pp_nums (const ecma_number_t *, uint8_t, uint8_t);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ serializer_dump_nums (const ecma_number_t nums[], uint8_t size, uint16_t offset,
|
||||
{
|
||||
parser_fatal (ERR_MEMORY);
|
||||
}
|
||||
|
||||
|
||||
__memcpy (data, bytecode_data, offset);
|
||||
mem_heap_free_block (bytecode_data);
|
||||
bytecode_data = data;
|
||||
@@ -114,7 +114,7 @@ serializer_dump_nums (const ecma_number_t nums[], uint8_t size, uint16_t offset,
|
||||
static opcode_counter_t opcode_counter = 0;
|
||||
|
||||
void
|
||||
serializer_dump_opcode (OPCODE opcode)
|
||||
serializer_dump_opcode (opcode_t opcode)
|
||||
{
|
||||
if (print_opcodes)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ serializer_dump_opcode (OPCODE opcode)
|
||||
}
|
||||
|
||||
void
|
||||
serializer_rewrite_opcode (const opcode_counter_t loc, OPCODE opcode)
|
||||
serializer_rewrite_opcode (const opcode_counter_t loc, opcode_t opcode)
|
||||
{
|
||||
JERRY_ASSERT (loc < MAX_OPCODES);
|
||||
bytecode_opcodes[loc] = opcode;
|
||||
|
||||
@@ -26,9 +26,9 @@ uint16_t serializer_dump_strings (const char **, uint8_t);
|
||||
|
||||
void serializer_dump_nums (const ecma_number_t *, uint8_t, uint16_t, uint8_t);
|
||||
|
||||
void serializer_dump_opcode (OPCODE);
|
||||
void serializer_dump_opcode (opcode_t);
|
||||
|
||||
void serializer_rewrite_opcode (const opcode_counter_t, OPCODE);
|
||||
void serializer_rewrite_opcode (const opcode_counter_t, opcode_t);
|
||||
|
||||
void serializer_print_opcodes (void);
|
||||
|
||||
|
||||
Reference in new issue
Block a user