OPCODE define replaced with opcode_t. T_IDX define replaced with idx_t.

This commit is contained in:
e.gavrin
2014-08-23 00:53:41 +04:00
parent 0eece0be5a
commit a99907670b
30 changed files with 368 additions and 362 deletions
+10 -10
View File
@@ -30,15 +30,15 @@ static const opfunc __opfuncs[LAST_OP] =
};
#undef __INIT_OP_FUNC
JERRY_STATIC_ASSERT (sizeof (OPCODE) <= 4);
JERRY_STATIC_ASSERT (sizeof (opcode_t) <= 4);
const OPCODE *__program = NULL;
const opcode_t *__program = NULL;
/**
* Initialize interpreter.
*/
void
init_int (const OPCODE *program_p) /**< pointer to byte-code program */
init_int (const opcode_t *program_p) /**< pointer to byte-code program */
{
JERRY_ASSERT (__program == NULL);
@@ -104,11 +104,11 @@ run_int_from_pos (opcode_counter_t start_pos,
{
ecma_completion_value_t completion;
const OPCODE *curr = &__program[start_pos];
const opcode_t *curr = &__program[start_pos];
JERRY_ASSERT (curr->op_idx == __op__idx_reg_var_decl);
const T_IDX min_reg_num = curr->data.reg_var_decl.min;
const T_IDX max_reg_num = curr->data.reg_var_decl.max;
const idx_t min_reg_num = curr->data.reg_var_decl.min;
const idx_t max_reg_num = curr->data.reg_var_decl.max;
JERRY_ASSERT (max_reg_num >= min_reg_num);
const uint32_t regs_num = (uint32_t) (max_reg_num - min_reg_num + 1);
@@ -133,7 +133,7 @@ run_int_from_pos (opcode_counter_t start_pos,
{
do
{
const OPCODE *curr = &__program[int_data.pos];
const opcode_t *curr = &__program[int_data.pos];
completion = __opfuncs[curr->op_idx] (*curr, &int_data);
JERRY_ASSERT (!ecma_is_completion_value_normal (completion)
@@ -172,7 +172,7 @@ run_int_from_pos (opcode_counter_t start_pos,
* otherwise (buffer size is not enough) - negated minimum required buffer size.
*/
ssize_t
try_get_string_by_idx (T_IDX idx, /**< literal id */
try_get_string_by_idx (idx_t idx, /**< literal id */
ecma_char_t *buffer_p, /**< buffer */
ssize_t buffer_size) /**< buffer size */
{
@@ -205,7 +205,7 @@ try_get_string_by_idx (T_IDX idx, /**< literal id */
* @return value of number literal, corresponding to specified literal id
*/
ecma_number_t
get_number_by_idx (T_IDX idx) /**< literal id */
get_number_by_idx (idx_t idx) /**< literal id */
{
TODO (Actual number literal retrievement);
@@ -218,7 +218,7 @@ get_number_by_idx (T_IDX idx) /**< literal id */
/**
* Get specified opcode from the program.
*/
OPCODE
opcode_t
read_opcode (opcode_counter_t counter) /**< opcode counter */
{
return __program[ counter ];
+4 -4
View File
@@ -20,7 +20,7 @@
#include "globals.h"
#include "opcodes.h"
void init_int (const __opcode* program_p);
void init_int (const opcode_t* program_p);
bool run_int (void);
ecma_completion_value_t run_int_from_pos (opcode_counter_t start_pos,
ecma_value_t this_binding_value,
@@ -28,10 +28,10 @@ ecma_completion_value_t run_int_from_pos (opcode_counter_t start_pos,
bool is_strict,
bool is_eval_code);
ssize_t try_get_string_by_idx (T_IDX idx, ecma_char_t *buffer_p, ssize_t buffer_size);
ecma_number_t get_number_by_idx (T_IDX idx);
ssize_t try_get_string_by_idx (idx_t idx, ecma_char_t *buffer_p, ssize_t buffer_size);
ecma_number_t get_number_by_idx (idx_t idx);
__opcode read_opcode (opcode_counter_t counter);
opcode_t read_opcode (opcode_counter_t counter);
#endif /* INTERPRETER_H */
+9 -9
View File
@@ -24,11 +24,11 @@
* if argument evaluates to true.
*/
ecma_completion_value_t
opfunc_is_true_jmp (OPCODE opdata, /**< operation data */
opfunc_is_true_jmp (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX cond_var_idx = opdata.data.is_true_jmp.value;
const T_IDX dst_opcode_idx = opdata.data.is_true_jmp.opcode;
const idx_t cond_var_idx = opdata.data.is_true_jmp.value;
const idx_t dst_opcode_idx = opdata.data.is_true_jmp.opcode;
ecma_completion_value_t ret_value;
@@ -61,11 +61,11 @@ opfunc_is_true_jmp (OPCODE opdata, /**< operation data */
* if argument evaluates to false.
*/
ecma_completion_value_t
opfunc_is_false_jmp (OPCODE opdata, /**< operation data */
opfunc_is_false_jmp (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX cond_var_idx = opdata.data.is_false_jmp.value;
const T_IDX dst_opcode_idx = opdata.data.is_false_jmp.opcode;
const idx_t cond_var_idx = opdata.data.is_false_jmp.value;
const idx_t dst_opcode_idx = opdata.data.is_false_jmp.opcode;
ecma_completion_value_t ret_value;
@@ -97,7 +97,7 @@ opfunc_is_false_jmp (OPCODE opdata, /**< operation data */
* the opcode changes current opcode position to specified opcode index
*/
ecma_completion_value_t
opfunc_jmp (OPCODE opdata, /**< operation data */
opfunc_jmp (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
int_data->pos = opdata.data.jmp.opcode_idx;
@@ -112,7 +112,7 @@ opfunc_jmp (OPCODE opdata, /**< operation data */
* the opcode changes adds specified value to current opcode position
*/
ecma_completion_value_t
opfunc_jmp_down (OPCODE opdata, /**< operation data */
opfunc_jmp_down (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
JERRY_ASSERT (int_data->pos <= int_data->pos + opdata.data.jmp_up.opcode_count);
@@ -129,7 +129,7 @@ opfunc_jmp_down (OPCODE opdata, /**< operation data */
* the opcode changes substracts specified value from current opcode position
*/
ecma_completion_value_t
opfunc_jmp_up (OPCODE opdata, /**< operation data */
opfunc_jmp_up (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
JERRY_ASSERT (int_data->pos >= opdata.data.jmp_up.opcode_count);
+28 -28
View File
@@ -43,7 +43,7 @@ typedef enum
*/
static ecma_completion_value_t
do_number_bitwise_logic (__int_data *int_data, /**< interpreter context */
T_IDX dst_var_idx, /**< destination variable identifier */
idx_t dst_var_idx, /**< destination variable identifier */
number_bitwise_logic_op op, /**< number bitwise logic operation */
ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /** right value */
@@ -125,12 +125,12 @@ do_number_bitwise_logic (__int_data *int_data, /**< interpreter context */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_and (OPCODE opdata, /**< operation data */
opfunc_b_and (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_and.dst;
const T_IDX left_var_idx = opdata.data.b_and.var_left;
const T_IDX right_var_idx = opdata.data.b_and.var_right;
const idx_t dst_var_idx = opdata.data.b_and.dst;
const idx_t left_var_idx = opdata.data.b_and.var_left;
const idx_t right_var_idx = opdata.data.b_and.var_right;
int_data->pos++;
@@ -160,12 +160,12 @@ opfunc_b_and (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_or (OPCODE opdata, /**< operation data */
opfunc_b_or (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_or.dst;
const T_IDX left_var_idx = opdata.data.b_or.var_left;
const T_IDX right_var_idx = opdata.data.b_or.var_right;
const idx_t dst_var_idx = opdata.data.b_or.dst;
const idx_t left_var_idx = opdata.data.b_or.var_left;
const idx_t right_var_idx = opdata.data.b_or.var_right;
int_data->pos++;
@@ -195,12 +195,12 @@ opfunc_b_or (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_xor (OPCODE opdata, /**< operation data */
opfunc_b_xor (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_xor.dst;
const T_IDX left_var_idx = opdata.data.b_xor.var_left;
const T_IDX right_var_idx = opdata.data.b_xor.var_right;
const idx_t dst_var_idx = opdata.data.b_xor.dst;
const idx_t left_var_idx = opdata.data.b_xor.var_left;
const idx_t right_var_idx = opdata.data.b_xor.var_right;
int_data->pos++;
@@ -230,12 +230,12 @@ opfunc_b_xor (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_left (OPCODE opdata, /**< operation data */
opfunc_b_shift_left (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_shift_left.dst;
const T_IDX left_var_idx = opdata.data.b_shift_left.var_left;
const T_IDX right_var_idx = opdata.data.b_shift_left.var_right;
const idx_t dst_var_idx = opdata.data.b_shift_left.dst;
const idx_t left_var_idx = opdata.data.b_shift_left.var_left;
const idx_t right_var_idx = opdata.data.b_shift_left.var_right;
int_data->pos++;
@@ -265,12 +265,12 @@ opfunc_b_shift_left (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_right (OPCODE opdata, /**< operation data */
opfunc_b_shift_right (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_shift_right.dst;
const T_IDX left_var_idx = opdata.data.b_shift_right.var_left;
const T_IDX right_var_idx = opdata.data.b_shift_right.var_right;
const idx_t dst_var_idx = opdata.data.b_shift_right.dst;
const idx_t left_var_idx = opdata.data.b_shift_right.var_left;
const idx_t right_var_idx = opdata.data.b_shift_right.var_right;
int_data->pos++;
@@ -300,12 +300,12 @@ opfunc_b_shift_right (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_uright (OPCODE opdata, /**< operation data */
opfunc_b_shift_uright (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_shift_uright.dst;
const T_IDX left_var_idx = opdata.data.b_shift_uright.var_left;
const T_IDX right_var_idx = opdata.data.b_shift_uright.var_right;
const idx_t dst_var_idx = opdata.data.b_shift_uright.dst;
const idx_t left_var_idx = opdata.data.b_shift_uright.var_left;
const idx_t right_var_idx = opdata.data.b_shift_uright.var_right;
int_data->pos++;
@@ -335,11 +335,11 @@ opfunc_b_shift_uright (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_not (OPCODE opdata, /**< operation data */
opfunc_b_not (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.b_not.dst;
const T_IDX right_var_idx = opdata.data.b_not.var_right;
const idx_t dst_var_idx = opdata.data.b_not.dst;
const idx_t right_var_idx = opdata.data.b_not.var_right;
int_data->pos++;
+21 -21
View File
@@ -42,7 +42,7 @@ typedef enum
*/
static ecma_completion_value_t
do_number_arithmetic (__int_data *int_data, /**< interpreter context */
T_IDX dst_var_idx, /**< destination variable identifier */
idx_t dst_var_idx, /**< destination variable identifier */
number_arithmetic_op op, /**< number arithmetic operation */
ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /** right value */
@@ -108,12 +108,12 @@ do_number_arithmetic (__int_data *int_data, /**< interpreter context */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_addition (OPCODE opdata, /**< operation data */
opfunc_addition (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.addition.dst;
const T_IDX left_var_idx = opdata.data.addition.var_left;
const T_IDX right_var_idx = opdata.data.addition.var_right;
const idx_t dst_var_idx = opdata.data.addition.dst;
const idx_t left_var_idx = opdata.data.addition.var_left;
const idx_t right_var_idx = opdata.data.addition.var_right;
int_data->pos++;
@@ -155,12 +155,12 @@ opfunc_addition (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_substraction (OPCODE opdata, /**< operation data */
opfunc_substraction (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.substraction.dst;
const T_IDX left_var_idx = opdata.data.substraction.var_left;
const T_IDX right_var_idx = opdata.data.substraction.var_right;
const idx_t dst_var_idx = opdata.data.substraction.dst;
const idx_t left_var_idx = opdata.data.substraction.var_left;
const idx_t right_var_idx = opdata.data.substraction.var_right;
int_data->pos++;
@@ -190,12 +190,12 @@ opfunc_substraction (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_multiplication (OPCODE opdata, /**< operation data */
opfunc_multiplication (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.multiplication.dst;
const T_IDX left_var_idx = opdata.data.multiplication.var_left;
const T_IDX right_var_idx = opdata.data.multiplication.var_right;
const idx_t dst_var_idx = opdata.data.multiplication.dst;
const idx_t left_var_idx = opdata.data.multiplication.var_left;
const idx_t right_var_idx = opdata.data.multiplication.var_right;
int_data->pos++;
@@ -225,12 +225,12 @@ opfunc_multiplication (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_division (OPCODE opdata, /**< operation data */
opfunc_division (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.division.dst;
const T_IDX left_var_idx = opdata.data.division.var_left;
const T_IDX right_var_idx = opdata.data.division.var_right;
const idx_t dst_var_idx = opdata.data.division.dst;
const idx_t left_var_idx = opdata.data.division.var_left;
const idx_t right_var_idx = opdata.data.division.var_right;
int_data->pos++;
@@ -260,12 +260,12 @@ opfunc_division (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_remainder (OPCODE opdata, /**< operation data */
opfunc_remainder (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.remainder.dst;
const T_IDX left_var_idx = opdata.data.remainder.var_left;
const T_IDX right_var_idx = opdata.data.remainder.var_right;
const idx_t dst_var_idx = opdata.data.remainder.dst;
const idx_t left_var_idx = opdata.data.remainder.var_left;
const idx_t right_var_idx = opdata.data.remainder.var_right;
int_data->pos++;
+4 -4
View File
@@ -32,8 +32,8 @@
#include "opcodes.h"
static bool do_strict_eval_arguments_check (ecma_reference_t) __unused;
static ecma_completion_value_t get_variable_value (__int_data *, T_IDX, bool) __unused;
static ecma_completion_value_t set_variable_value (__int_data *, T_IDX, ecma_value_t) __unused;
static ecma_completion_value_t get_variable_value (__int_data *, idx_t, bool) __unused;
static ecma_completion_value_t set_variable_value (__int_data *, idx_t, ecma_value_t) __unused;
/**
* Perform so-called 'strict eval or arguments reference' check
@@ -82,7 +82,7 @@ do_strict_eval_arguments_check (ecma_reference_t ref) /**< ECMA-reference */
*/
static ecma_completion_value_t
get_variable_value (__int_data *int_data, /**< interpreter context */
T_IDX var_idx, /**< variable identifier */
idx_t var_idx, /**< variable identifier */
bool do_eval_or_arguments_check) /** run 'strict eval or arguments reference' check
See also: do_strict_eval_arguments_check */
{
@@ -134,7 +134,7 @@ get_variable_value (__int_data *int_data, /**< interpreter context */
*/
static ecma_completion_value_t
set_variable_value (__int_data *int_data, /**< interpreter context */
T_IDX var_idx, /**< variable identifier */
idx_t var_idx, /**< variable identifier */
ecma_value_t value) /**< value to set */
{
ecma_completion_value_t ret_value;
+16 -16
View File
@@ -25,12 +25,12 @@
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_equal_value (OPCODE opdata, /**< operation data */
opfunc_equal_value (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.equal_value.dst;
const T_IDX left_var_idx = opdata.data.equal_value.var_left;
const T_IDX right_var_idx = opdata.data.equal_value.var_right;
const idx_t dst_var_idx = opdata.data.equal_value.dst;
const idx_t left_var_idx = opdata.data.equal_value.var_left;
const idx_t right_var_idx = opdata.data.equal_value.var_right;
int_data->pos++;
@@ -59,12 +59,12 @@ opfunc_equal_value (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_not_equal_value (OPCODE opdata, /**< operation data */
opfunc_not_equal_value (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.not_equal_value.dst;
const T_IDX left_var_idx = opdata.data.not_equal_value.var_left;
const T_IDX right_var_idx = opdata.data.not_equal_value.var_right;
const idx_t dst_var_idx = opdata.data.not_equal_value.dst;
const idx_t left_var_idx = opdata.data.not_equal_value.var_left;
const idx_t right_var_idx = opdata.data.not_equal_value.var_right;
int_data->pos++;
@@ -94,12 +94,12 @@ opfunc_not_equal_value (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_equal_value_type (OPCODE opdata, /**< operation data */
opfunc_equal_value_type (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.equal_value_type.dst;
const T_IDX left_var_idx = opdata.data.equal_value_type.var_left;
const T_IDX right_var_idx = opdata.data.equal_value_type.var_right;
const idx_t dst_var_idx = opdata.data.equal_value_type.dst;
const idx_t left_var_idx = opdata.data.equal_value_type.var_left;
const idx_t right_var_idx = opdata.data.equal_value_type.var_right;
int_data->pos++;
@@ -128,12 +128,12 @@ opfunc_equal_value_type (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_not_equal_value_type (OPCODE opdata, /**< operation data */
opfunc_not_equal_value_type (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.not_equal_value_type.dst;
const T_IDX left_var_idx = opdata.data.not_equal_value_type.var_left;
const T_IDX right_var_idx = opdata.data.not_equal_value_type.var_right;
const idx_t dst_var_idx = opdata.data.not_equal_value_type.dst;
const idx_t left_var_idx = opdata.data.not_equal_value_type.var_left;
const idx_t right_var_idx = opdata.data.not_equal_value_type.var_right;
int_data->pos++;
+24 -24
View File
@@ -25,12 +25,12 @@
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_less_than (OPCODE opdata, /**< operation data */
opfunc_less_than (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.less_than.dst;
const T_IDX left_var_idx = opdata.data.less_than.var_left;
const T_IDX right_var_idx = opdata.data.less_than.var_right;
const idx_t dst_var_idx = opdata.data.less_than.dst;
const idx_t left_var_idx = opdata.data.less_than.var_left;
const idx_t right_var_idx = opdata.data.less_than.var_right;
int_data->pos++;
@@ -75,12 +75,12 @@ opfunc_less_than (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_greater_than (OPCODE opdata, /**< operation data */
opfunc_greater_than (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.greater_than.dst;
const T_IDX left_var_idx = opdata.data.greater_than.var_left;
const T_IDX right_var_idx = opdata.data.greater_than.var_right;
const idx_t dst_var_idx = opdata.data.greater_than.dst;
const idx_t left_var_idx = opdata.data.greater_than.var_left;
const idx_t right_var_idx = opdata.data.greater_than.var_right;
int_data->pos++;
@@ -125,12 +125,12 @@ opfunc_greater_than (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_less_or_equal_than (OPCODE opdata, /**< operation data */
opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.less_or_equal_than.dst;
const T_IDX left_var_idx = opdata.data.less_or_equal_than.var_left;
const T_IDX right_var_idx = opdata.data.less_or_equal_than.var_right;
const idx_t dst_var_idx = opdata.data.less_or_equal_than.dst;
const idx_t left_var_idx = opdata.data.less_or_equal_than.var_left;
const idx_t right_var_idx = opdata.data.less_or_equal_than.var_right;
int_data->pos++;
@@ -182,12 +182,12 @@ opfunc_less_or_equal_than (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_greater_or_equal_than (OPCODE opdata, /**< operation data */
opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.greater_or_equal_than.dst;
const T_IDX left_var_idx = opdata.data.greater_or_equal_than.var_left;
const T_IDX right_var_idx = opdata.data.greater_or_equal_than.var_right;
const idx_t dst_var_idx = opdata.data.greater_or_equal_than.dst;
const idx_t left_var_idx = opdata.data.greater_or_equal_than.var_left;
const idx_t right_var_idx = opdata.data.greater_or_equal_than.var_right;
int_data->pos++;
@@ -239,12 +239,12 @@ opfunc_greater_or_equal_than (OPCODE opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_instanceof (OPCODE opdata __unused, /**< operation data */
opfunc_instanceof (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
const T_IDX dst_idx = opdata.data.instanceof.dst;
const T_IDX left_var_idx = opdata.data.instanceof.var_left;
const T_IDX right_var_idx = opdata.data.instanceof.var_right;
const idx_t dst_idx = opdata.data.instanceof.dst;
const idx_t left_var_idx = opdata.data.instanceof.var_left;
const idx_t right_var_idx = opdata.data.instanceof.var_right;
ecma_completion_value_t ret_value;
@@ -284,12 +284,12 @@ opfunc_instanceof (OPCODE opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_in (OPCODE opdata __unused, /**< operation data */
opfunc_in (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
const T_IDX dst_idx = opdata.data.in.dst;
const T_IDX left_var_idx = opdata.data.in.var_left;
const T_IDX right_var_idx = opdata.data.in.var_right;
const idx_t dst_idx = opdata.data.in.dst;
const idx_t left_var_idx = opdata.data.in.var_left;
const idx_t right_var_idx = opdata.data.in.var_right;
ecma_completion_value_t ret_value;
+84 -53
View File
@@ -64,7 +64,7 @@ typedef struct
* Initialize string literal copy.
*/
static void
init_string_literal_copy (T_IDX idx, /**< literal identifier */
init_string_literal_copy (idx_t idx, /**< literal identifier */
string_literal_copy *str_lit_descr_p) /**< pointer to string literal copy descriptor */
{
JERRY_ASSERT (str_lit_descr_p != NULL);
@@ -136,7 +136,7 @@ free_string_literal_copy (string_literal_copy *str_lit_descr_p) /**< string lite
static char __unused unimplemented_list_end
#define DEFINE_UNIMPLEMENTED_OP(op) \
ecma_completion_value_t opfunc_ ## op (OPCODE opdata, __int_data *int_data) \
ecma_completion_value_t opfunc_ ## op (opcode_t opdata, __int_data *int_data) \
{ \
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (opdata, int_data); \
}
@@ -148,7 +148,7 @@ OP_UNIMPLEMENTED_LIST (DEFINE_UNIMPLEMENTED_OP);
* 'Nop' opcode handler.
*/
ecma_completion_value_t
opfunc_nop (OPCODE opdata __unused, /**< operation data */
opfunc_nop (opcode_t opdata __unused, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
int_data->pos++;
@@ -157,7 +157,7 @@ opfunc_nop (OPCODE opdata __unused, /**< operation data */
} /* opfunc_nop */
ecma_completion_value_t
opfunc_call_1 (OPCODE opdata __unused, __int_data *int_data)
opfunc_call_1 (opcode_t opdata __unused, __int_data *int_data)
{
ecma_completion_value_t ret_value;
ret_value = ecma_make_empty_completion_value ();
@@ -250,8 +250,8 @@ opfunc_call_1 (OPCODE opdata __unused, __int_data *int_data)
if (!is_native_call)
{
const T_IDX func_name_lit_idx = opdata.data.call_1.name_lit_idx;
const T_IDX lhs_var_idx = opdata.data.call_1.lhs;
const idx_t func_name_lit_idx = opdata.data.call_1.name_lit_idx;
const idx_t lhs_var_idx = opdata.data.call_1.lhs;
ECMA_TRY_CATCH (func_value, get_variable_value (int_data, func_name_lit_idx, false), ret_value);
@@ -298,12 +298,12 @@ opfunc_call_1 (OPCODE opdata __unused, __int_data *int_data)
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_assignment (OPCODE opdata, /**< operation data */
opfunc_assignment (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.assignment.var_left;
const idx_t dst_var_idx = opdata.data.assignment.var_left;
const opcode_arg_type_operand type_value_right = opdata.data.assignment.type_value_right;
const T_IDX src_val_descr = opdata.data.assignment.value_right;
const idx_t src_val_descr = opdata.data.assignment.value_right;
int_data->pos++;
@@ -384,11 +384,11 @@ opfunc_assignment (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_pre_incr (OPCODE opdata, /**< operation data */
opfunc_pre_incr (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.pre_incr.dst;
const T_IDX incr_var_idx = opdata.data.pre_incr.var_right;
const idx_t dst_var_idx = opdata.data.pre_incr.dst;
const idx_t incr_var_idx = opdata.data.pre_incr.var_right;
int_data->pos++;
@@ -434,11 +434,11 @@ opfunc_pre_incr (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_pre_decr (OPCODE opdata, /**< operation data */
opfunc_pre_decr (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.pre_decr.dst;
const T_IDX decr_var_idx = opdata.data.pre_decr.var_right;
const idx_t dst_var_idx = opdata.data.pre_decr.dst;
const idx_t decr_var_idx = opdata.data.pre_decr.var_right;
int_data->pos++;
@@ -484,11 +484,11 @@ opfunc_pre_decr (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_post_incr (OPCODE opdata, /**< operation data */
opfunc_post_incr (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.post_incr.dst;
const T_IDX incr_var_idx = opdata.data.post_incr.var_right;
const idx_t dst_var_idx = opdata.data.post_incr.dst;
const idx_t incr_var_idx = opdata.data.post_incr.var_right;
int_data->pos++;
@@ -532,11 +532,11 @@ opfunc_post_incr (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_post_decr (OPCODE opdata, /**< operation data */
opfunc_post_decr (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.post_decr.dst;
const T_IDX decr_var_idx = opdata.data.post_decr.var_right;
const idx_t dst_var_idx = opdata.data.post_decr.dst;
const idx_t decr_var_idx = opdata.data.post_decr.var_right;
int_data->pos++;
@@ -577,7 +577,7 @@ opfunc_post_decr (OPCODE opdata, /**< operation data */
* The opcode is meta-opcode that is not supposed to be executed.
*/
ecma_completion_value_t
opfunc_reg_var_decl (OPCODE opdata __unused, /**< operation data */
opfunc_reg_var_decl (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
JERRY_UNREACHABLE ();
@@ -593,7 +593,7 @@ opfunc_reg_var_decl (OPCODE opdata __unused, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op.
*/
ecma_completion_value_t
opfunc_var_decl (OPCODE opdata, /**< operation data */
opfunc_var_decl (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_index (opdata.data.var_decl.variable_name);
@@ -633,7 +633,7 @@ opfunc_var_decl (OPCODE opdata, /**< operation data */
*/
static ecma_completion_value_t
function_declaration (__int_data *int_data, /**< interpreter context */
T_IDX function_name_lit_idx, /**< identifier of literal with function name */
idx_t function_name_lit_idx, /**< identifier of literal with function name */
ecma_string_t* args_names[], /**< names of arguments */
ecma_length_t args_number) /**< number of arguments */
{
@@ -643,7 +643,7 @@ function_declaration (__int_data *int_data, /**< interpreter context */
const bool is_configurable_bindings = int_data->is_eval_code;
const opcode_counter_t jmp_down_opcode_idx = (opcode_counter_t) (int_data->pos);
OPCODE jmp_down_opcode = read_opcode (jmp_down_opcode_idx);
opcode_t jmp_down_opcode = read_opcode (jmp_down_opcode_idx);
JERRY_ASSERT (jmp_down_opcode.op_idx == __op__idx_jmp_down);
int_data->pos = (opcode_counter_t) (jmp_down_opcode_idx + jmp_down_opcode.data.jmp_down.opcode_count);
@@ -670,7 +670,7 @@ function_declaration (__int_data *int_data, /**< interpreter context */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_func_decl_0 (OPCODE opdata, /**< operation data */
opfunc_func_decl_0 (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
int_data->pos++;
@@ -688,7 +688,7 @@ opfunc_func_decl_0 (OPCODE opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_func_decl_1 (OPCODE opdata, /**< operation data */
opfunc_func_decl_1 (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
int_data->pos++;
@@ -712,7 +712,7 @@ opfunc_func_decl_1 (OPCODE opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_func_decl_2 (OPCODE opdata, /**< operation data */
opfunc_func_decl_2 (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
int_data->pos++;
@@ -743,11 +743,11 @@ opfunc_func_decl_2 (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_call_0 (OPCODE opdata, /**< operation data */
opfunc_call_0 (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX func_name_lit_idx = opdata.data.call_0.name_lit_idx;
const T_IDX lhs_var_idx = opdata.data.call_0.lhs;
const idx_t func_name_lit_idx = opdata.data.call_0.name_lit_idx;
const idx_t lhs_var_idx = opdata.data.call_0.lhs;
int_data->pos++;
@@ -789,7 +789,7 @@ opfunc_call_0 (OPCODE opdata, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op.
*/
ecma_completion_value_t
opfunc_ret (OPCODE opdata __unused, /**< operation data */
opfunc_ret (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN,
@@ -807,7 +807,7 @@ opfunc_ret (OPCODE opdata __unused, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op.
*/
ecma_completion_value_t
opfunc_retval (OPCODE opdata __unused, /**< operation data */
opfunc_retval (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
ecma_completion_value_t ret_value;
@@ -833,12 +833,12 @@ opfunc_retval (OPCODE opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_prop_getter (OPCODE opdata __unused, /**< operation data */
opfunc_prop_getter (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
const T_IDX lhs_var_idx = opdata.data.prop_getter.lhs;
const T_IDX base_var_idx = opdata.data.prop_getter.obj;
const T_IDX prop_name_var_idx = opdata.data.prop_getter.prop;
const idx_t lhs_var_idx = opdata.data.prop_getter.lhs;
const idx_t base_var_idx = opdata.data.prop_getter.obj;
const idx_t prop_name_var_idx = opdata.data.prop_getter.prop;
int_data->pos++;
@@ -880,12 +880,12 @@ opfunc_prop_getter (OPCODE opdata __unused, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_prop_setter (OPCODE opdata __unused, /**< operation data */
opfunc_prop_setter (opcode_t opdata __unused, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
const T_IDX base_var_idx = opdata.data.prop_setter.obj;
const T_IDX prop_name_var_idx = opdata.data.prop_setter.prop;
const T_IDX rhs_var_idx = opdata.data.prop_setter.rhs;
const idx_t base_var_idx = opdata.data.prop_setter.obj;
const idx_t prop_name_var_idx = opdata.data.prop_setter.prop;
const idx_t rhs_var_idx = opdata.data.prop_setter.rhs;
int_data->pos++;
@@ -929,7 +929,7 @@ opfunc_prop_setter (OPCODE opdata __unused, /**< operation data */
* However, ecma_free_completion_value may be called for it, but it is a no-op.
*/
ecma_completion_value_t
opfunc_exitval (OPCODE opdata, /**< operation data */
opfunc_exitval (opcode_t opdata, /**< operation data */
__int_data *int_data __unused) /**< interpreter context */
{
JERRY_ASSERT (opdata.data.exitval.status_code == 0
@@ -951,11 +951,11 @@ opfunc_exitval (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_logical_not (OPCODE opdata, /**< operation data */
opfunc_logical_not (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.logical_not.dst;
const T_IDX right_var_idx = opdata.data.logical_not.var_right;
const idx_t dst_var_idx = opdata.data.logical_not.dst;
const idx_t right_var_idx = opdata.data.logical_not.var_right;
int_data->pos++;
@@ -989,12 +989,12 @@ opfunc_logical_not (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_logical_or (OPCODE opdata, /**< operation data */
opfunc_logical_or (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.logical_or.dst;
const T_IDX left_var_idx = opdata.data.logical_or.var_left;
const T_IDX right_var_idx = opdata.data.logical_or.var_right;
const idx_t dst_var_idx = opdata.data.logical_or.dst;
const idx_t left_var_idx = opdata.data.logical_or.var_left;
const idx_t right_var_idx = opdata.data.logical_or.var_right;
int_data->pos++;
@@ -1033,12 +1033,12 @@ opfunc_logical_or (OPCODE opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_logical_and (OPCODE opdata, /**< operation data */
opfunc_logical_and (opcode_t opdata, /**< operation data */
__int_data *int_data) /**< interpreter context */
{
const T_IDX dst_var_idx = opdata.data.logical_and.dst;
const T_IDX left_var_idx = opdata.data.logical_and.var_left;
const T_IDX right_var_idx = opdata.data.logical_and.var_right;
const idx_t dst_var_idx = opdata.data.logical_and.dst;
const idx_t left_var_idx = opdata.data.logical_and.var_left;
const idx_t right_var_idx = opdata.data.logical_and.var_right;
int_data->pos++;
@@ -1068,4 +1068,35 @@ opfunc_logical_and (OPCODE opdata, /**< operation data */
return ret_value;
} /* opfunc_logical_and */
#define GETOP_DEF_1(a, name, field1) \
opcode_t getop_##name (idx_t arg1) \
{ \
opcode_t opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
return opdata; \
}
#define GETOP_DEF_2(a, name, field1, field2) \
opcode_t getop_##name (idx_t arg1, idx_t arg2) \
{ \
opcode_t opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
opdata.data.name.field2 = arg2; \
return opdata; \
}
#define GETOP_DEF_3(a, name, field1, field2, field3) \
opcode_t getop_##name (idx_t arg1, idx_t arg2, idx_t arg3) \
{ \
opcode_t opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
opdata.data.name.field2 = arg2; \
opdata.data.name.field3 = arg3; \
return opdata; \
}
OP_ARGS_LIST (GETOP_DEF)
+31 -56
View File
@@ -19,9 +19,6 @@
#include "ecma-globals.h"
#include "globals.h"
#define T_IDX uint8_t /** index values */
#define OPCODE __opcode
#define OP_0(action, name) \
__##action (name, void, void, void)
@@ -34,11 +31,8 @@
#define OP_3(action, name, field1, field2, field3) \
__##action (name, field1, field2, field3)
#define __OP_STRUCT_FIELD(name, arg1, arg2, arg3) __op_##name name;
#define __OP_ENUM_FIELD(name, arg1, arg2, arg3) __op__idx_##name ,
#define __OP_FUNC_DECL(name, arg1, arg2, arg3) ecma_completion_value_t opfunc_##name (__opcode, __int_data*);
typedef uint16_t opcode_counter_t;
typedef uint16_t opcode_counter_t; /** opcode counters */
typedef uint8_t idx_t; /** index values */
/**
* Descriptor of assignment's second argument
@@ -60,8 +54,8 @@ typedef struct
ecma_object_t *lex_env_p; /**< current lexical environment */
bool is_strict; /**< is current code execution mode strict? */
bool is_eval_code; /**< is current code executed with eval */
T_IDX min_reg_num; /**< minimum idx used for register identification */
T_IDX max_reg_num; /**< maximum idx used for register identification */
idx_t min_reg_num; /**< minimum idx used for register identification */
idx_t max_reg_num; /**< maximum idx used for register identification */
ecma_value_t *regs_p; /**< register variables */
} __int_data;
@@ -167,101 +161,82 @@ typedef struct
#define OP_DATA_0(action, name) \
typedef struct \
{ \
T_IDX __do_not_use; \
idx_t __do_not_use; \
} __op_##name;
#define OP_DATA_1(action, name, arg1) \
typedef struct \
{ \
T_IDX arg1; \
idx_t arg1; \
} __op_##name;
#define OP_DATA_2(action, name, arg1, arg2) \
typedef struct \
{ \
T_IDX arg1; \
T_IDX arg2; \
idx_t arg1; \
idx_t arg2; \
} __op_##name;
#define OP_DATA_3(action, name, arg1, arg2, arg3) \
typedef struct \
{ \
T_IDX arg1; \
T_IDX arg2; \
T_IDX arg3; \
idx_t arg1; \
idx_t arg2; \
idx_t arg3; \
} __op_##name;
OP_ARGS_LIST (OP_DATA)
#define __OP_STRUCT_FIELD(name, arg1, arg2, arg3) __op_##name name;
typedef struct
{
T_IDX op_idx;
idx_t op_idx;
union
{
OP_LIST (OP_STRUCT_FIELD)
} data;
} __opcode;
} opcode_t;
#undef __OP_STRUCT_FIELD
#define __OP_ENUM_FIELD(name, arg1, arg2, arg3) __op__idx_##name ,
enum __opcode_idx
{
OP_LIST (OP_ENUM_FIELD)
LAST_OP
};
#undef __OP_ENUM_FIELD
#define __OP_FUNC_DECL(name, arg1, arg2, arg3) ecma_completion_value_t opfunc_##name (opcode_t, __int_data*);
OP_LIST (OP_FUNC_DECL)
#undef __OP_FUNC_DECL
typedef ecma_completion_value_t (*opfunc) (__opcode, __int_data *);
typedef ecma_completion_value_t (*opfunc) (opcode_t, __int_data *);
#define GETOP_DECL_0(a, name) \
__opcode getop_##name (void);
opcode_t getop_##name (void);
#define GETOP_DECL_1(a, name, arg1) \
__opcode getop_##name (T_IDX);
opcode_t getop_##name (idx_t);
#define GETOP_DECL_2(a, name, arg1, arg2) \
__opcode getop_##name (T_IDX, T_IDX);
opcode_t getop_##name (idx_t, idx_t);
#define GETOP_DECL_3(a, name, arg1, arg2, arg3) \
__opcode getop_##name (T_IDX, T_IDX, T_IDX);
opcode_t getop_##name (idx_t, idx_t, idx_t);
#define GETOP_DEF_0(a, name) \
__opcode getop_##name (void) \
opcode_t getop_##name (void) \
{ \
__opcode opdata; \
opcode_t opdata; \
opdata.op_idx = __op__idx_##name; \
return opdata; \
}
#define GETOP_DEF_1(a, name, field1) \
__opcode getop_##name (T_IDX arg1) \
{ \
__opcode opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
return opdata; \
}
#define GETOP_DEF_2(a, name, field1, field2) \
__opcode getop_##name (T_IDX arg1, T_IDX arg2) \
{ \
__opcode opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
opdata.data.name.field2 = arg2; \
return opdata; \
}
#define GETOP_DEF_3(a, name, field1, field2, field3) \
__opcode getop_##name (T_IDX arg1, T_IDX arg2, T_IDX arg3) \
{ \
__opcode opdata; \
opdata.op_idx = __op__idx_##name; \
opdata.data.name.field1 = arg1; \
opdata.data.name.field2 = arg2; \
opdata.data.name.field3 = arg3; \
return opdata; \
}
OP_ARGS_LIST (GETOP_DECL)
#undef GETOP_DECL_0
#undef GETOP_DECL_1
#undef GETOP_DECL_2
#undef GETOP_DECL_3
#endif /* OPCODES_H */
+79 -79
View File
@@ -47,9 +47,9 @@ rewritable_opcode;
#define NESTING_FUNCTION 3
static token tok;
static OPCODE opcode;
static opcode_t opcode;
static opcode_counter_t opcode_counter = 0;
static T_IDX temp_name_stack[MAX_OPCODES], temp_name_stack_head = 0, max_temp_name;
static idx_t temp_name_stack[MAX_OPCODES], temp_name_stack_head = 0, max_temp_name;
static uint8_t nestings[MAX_NESTINGS], nestings_head = 0;
static rewritable_opcode rewritable_opcodes[REWRITABLE_OPCODES_COUNT] =
@@ -58,14 +58,14 @@ static rewritable_opcode rewritable_opcodes[REWRITABLE_OPCODES_COUNT] =
[REWRITABLE_BREAK] = { .size = 0, .head = 0, .oc_stack = NULL }
};
static T_IDX parse_expression (void);
static idx_t parse_expression (void);
static void parse_statement (void);
static T_IDX parse_assignment_expression (void);
static idx_t parse_assignment_expression (void);
static void parse_source_element_list (void);
static T_IDX temp_name, min_temp_name;
static idx_t temp_name, min_temp_name;
static T_IDX
static idx_t
next_temp_name (void)
{
return temp_name++;
@@ -242,7 +242,7 @@ insert_semicolon (void)
#define DUMP_OPCODE_1(GETOP, OP1) \
do { \
JERRY_ASSERT (0+OP1 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1)); \
opcode=getop_##GETOP ((idx_t) (OP1)); \
serializer_dump_opcode (opcode); \
opcode_counter++; \
} while (0)
@@ -251,7 +251,7 @@ insert_semicolon (void)
do { \
JERRY_ASSERT (0+OP1 <= 255); \
JERRY_ASSERT (0+OP2 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1), (T_IDX) (OP2)); \
opcode=getop_##GETOP ((idx_t) (OP1), (idx_t) (OP2)); \
serializer_dump_opcode (opcode); \
opcode_counter++; \
} while (0)
@@ -261,7 +261,7 @@ insert_semicolon (void)
JERRY_ASSERT (0+OP1 <= 255); \
JERRY_ASSERT (0+OP2 <= 255); \
JERRY_ASSERT (0+OP3 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1), (T_IDX) (OP2), (T_IDX) (OP3)); \
opcode=getop_##GETOP ((idx_t) (OP1), (idx_t) (OP2), (idx_t) (OP3)); \
serializer_dump_opcode (opcode); \
opcode_counter++; \
} while (0)
@@ -269,7 +269,7 @@ insert_semicolon (void)
#define REWRITE_OPCODE_1(OC, GETOP, OP1) \
do { \
JERRY_ASSERT (0+OP1 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1)); \
opcode=getop_##GETOP ((idx_t) (OP1)); \
serializer_rewrite_opcode (OC, opcode); \
} while (0)
@@ -277,7 +277,7 @@ insert_semicolon (void)
do { \
JERRY_ASSERT (0+OP1 <= 255); \
JERRY_ASSERT (0+OP2 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1), (T_IDX) (OP2)); \
opcode=getop_##GETOP ((idx_t) (OP1), (idx_t) (OP2)); \
serializer_rewrite_opcode (OC, opcode); \
} while (0)
@@ -286,22 +286,22 @@ insert_semicolon (void)
JERRY_ASSERT (0+OP1 <= 255); \
JERRY_ASSERT (0+OP2 <= 255); \
JERRY_ASSERT (0+OP3 <= 255); \
opcode=getop_##GETOP ((T_IDX) (OP1), (T_IDX) (OP2), (T_IDX) (OP3)); \
opcode=getop_##GETOP ((idx_t) (OP1), (idx_t) (OP2), (idx_t) (OP3)); \
serializer_rewrite_opcode (OC, opcode); \
} while (0)
static T_IDX
static idx_t
integer_zero (void)
{
T_IDX lhs = next_temp_name ();
idx_t lhs = next_temp_name ();
DUMP_OPCODE_3 (assignment, lhs, OPCODE_ARG_TYPE_SMALLINT, 0);
return lhs;
}
static T_IDX
static idx_t
boolean_true (void)
{
T_IDX lhs = next_temp_name ();
idx_t lhs = next_temp_name ();
DUMP_OPCODE_3 (assignment, lhs, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_TRUE);
return lhs;
}
@@ -380,7 +380,7 @@ intrinsic_argument_count (const char *intrinsic)
}
static bool
is_intrinsic (T_IDX obj)
is_intrinsic (idx_t obj)
{
/* Every literal is represented by assignment to tmp.
so if result of parse_primary_expression less then strings count,
@@ -396,7 +396,7 @@ is_intrinsic (T_IDX obj)
}
static void
dump_intrinsic (T_IDX obj, T_IDX args[3])
dump_intrinsic (idx_t obj, idx_t args[3])
{
uint8_t strings_count = lexer_get_strings (NULL);
if (obj < strings_count)
@@ -421,10 +421,10 @@ dump_intrinsic (T_IDX obj, T_IDX args[3])
| StringLiteral
| NumericLiteral
; */
static T_IDX
static idx_t
parse_property_name (void)
{
T_IDX lhs;
idx_t lhs;
switch (tok.type)
{
@@ -450,10 +450,10 @@ parse_property_name (void)
/* property_name_and_value
: property_name LT!* ':' LT!* assignment_expression
; */
static T_IDX
static idx_t
parse_property_name_and_value (void)
{
T_IDX lhs, name, value;
idx_t lhs, name, value;
lhs = next_temp_name ();
name = parse_property_name ();
@@ -470,10 +470,10 @@ parse_property_name_and_value (void)
| get LT!* property_name LT!* '(' LT!* ')' LT!* '{' LT!* function_body LT!* '}'
| set LT!* property_name LT!* '(' identifier ')' LT!* '{' LT!* function_body LT!* '}'
; */
static T_IDX
static idx_t
parse_property_assignment (void)
{
T_IDX lhs, name, arg;
idx_t lhs, name, arg;
current_token_must_be (TOK_NAME);
@@ -524,7 +524,7 @@ parse_property_assignment (void)
}
static void
dump_varg_3 (T_IDX current_param, T_IDX params[3] __unused)
dump_varg_3 (idx_t current_param, idx_t params[3] __unused)
{
if (current_param == 3)
{
@@ -535,7 +535,7 @@ dump_varg_3 (T_IDX current_param, T_IDX params[3] __unused)
}
static void
dump_varg_end (T_IDX current_param, T_IDX params[3] __unused)
dump_varg_end (idx_t current_param, idx_t params[3] __unused)
{
switch (current_param)
{
@@ -578,14 +578,14 @@ argument_list_type;
/** Parse list of identifiers, assigment expressions or properties, splitted by comma.
For each ALT dumps appropriate bytecode. Uses OBJ during dump if neccesary.
Returns temp var if expression has lhs, or 0 otherwise. */
static T_IDX
parse_argument_list (argument_list_type alt, T_IDX obj)
static idx_t
parse_argument_list (argument_list_type alt, idx_t obj)
{
token_type open_tt, close_tt;
T_IDX first_opcode_args_count;
T_IDX lhs = 0;
T_IDX args[3 + 1/* +1 for stack protector */];
T_IDX current_arg = 0;
idx_t first_opcode_args_count;
idx_t lhs = 0;
idx_t args[3 + 1/* +1 for stack protector */];
idx_t current_arg = 0;
switch (alt)
{
@@ -891,7 +891,7 @@ parse_argument_list (argument_list_type alt, T_IDX obj)
static void
parse_function_declaration (void)
{
T_IDX name;
idx_t name;
opcode_counter_t jmp_oc;
assert_keyword (KW_FUNCTION);
@@ -922,10 +922,10 @@ parse_function_declaration (void)
/* function_expression
: 'function' LT!* Identifier? LT!* '(' formal_parameter_list? LT!* ')' LT!* function_body
; */
static T_IDX
static idx_t
parse_function_expression (void)
{
T_IDX name, lhs;
idx_t name, lhs;
opcode_counter_t jmp_oc;
assert_keyword (KW_FUNCTION);
@@ -965,7 +965,7 @@ parse_function_expression (void)
/* array_literal
: '[' LT!* assignment_expression? (LT!* ',' (LT!* assignment_expression)?)* LT!* ']' LT!*
; */
static T_IDX
static idx_t
parse_array_literal (void)
{
return parse_argument_list (AL_ARRAY_LIT, 0);
@@ -974,16 +974,16 @@ parse_array_literal (void)
/* object_literal
: '{' LT!* property_assignment (LT!* ',' LT!* property_assignment)* LT!* '}'
; */
static T_IDX
static idx_t
parse_object_literal (void)
{
return parse_argument_list (AL_OBJECT_LIT, 0);
}
static T_IDX
static idx_t
parse_literal (void)
{
T_IDX lhs;
idx_t lhs;
switch (tok.type)
{
@@ -1033,10 +1033,10 @@ parse_literal (void)
| '{' LT!* object_literal LT!* '}'
| '(' LT!* expression LT!* ')'
; */
static T_IDX
static idx_t
parse_primary_expression (void)
{
T_IDX lhs;
idx_t lhs;
if (is_keyword (KW_THIS))
{
@@ -1106,17 +1106,17 @@ parse_primary_expression (void)
property_reference_suffix
: '.' LT!* Identifier
; */
static T_IDX
static idx_t
parse_member_expression (void)
{
T_IDX lhs, obj, prop;
idx_t lhs, obj, prop;
if (is_keyword (KW_FUNCTION))
{
obj = parse_function_expression ();
}
else if (is_keyword (KW_NEW))
{
T_IDX member;
idx_t member;
NEXT (member, member_expression);
@@ -1174,10 +1174,10 @@ parse_member_expression (void)
arguments
: '(' LT!* assignment_expression LT!* (',' LT!* assignment_expression * LT!*)* ')'
; */
static T_IDX
static idx_t
parse_call_expression (void)
{
T_IDX lhs, obj, prop;
idx_t lhs, obj, prop;
obj = parse_member_expression ();
@@ -1238,7 +1238,7 @@ parse_call_expression (void)
: call_expression
| new_expression
; */
static T_IDX
static idx_t
parse_left_hand_side_expression (void)
{
return parse_call_expression ();
@@ -1247,10 +1247,10 @@ parse_left_hand_side_expression (void)
/* postfix_expression
: left_hand_side_expression ('++' | '--')?
; */
static T_IDX
static idx_t
parse_postfix_expression (void)
{
T_IDX expr = parse_left_hand_side_expression (), lhs;
idx_t expr = parse_left_hand_side_expression (), lhs;
tok = lexer_next_token ();
if (tok.type == TOK_DOUBLE_PLUS)
@@ -1275,10 +1275,10 @@ parse_postfix_expression (void)
: postfix_expression
| ('delete' | 'void' | 'typeof' | '++' | '--' | '+' | '-' | '~' | '!') unary_expression
; */
static T_IDX
static idx_t
parse_unary_expression (void)
{
T_IDX expr, lhs;
idx_t expr, lhs;
switch (tok.type)
{
@@ -1362,10 +1362,10 @@ parse_unary_expression (void)
/* multiplicative_expression
: unary_expression (LT!* ('*' | '/' | '%') LT!* unary_expression)*
; */
static T_IDX
static idx_t
parse_multiplicative_expression (void)
{
T_IDX lhs, expr1, expr2;
idx_t lhs, expr1, expr2;
expr1 = parse_unary_expression ();
@@ -1391,10 +1391,10 @@ parse_multiplicative_expression (void)
/* additive_expression
: multiplicative_expression (LT!* ('+' | '-') LT!* multiplicative_expression)*
; */
static T_IDX
static idx_t
parse_additive_expression (void)
{
T_IDX lhs, expr1, expr2;
idx_t lhs, expr1, expr2;
expr1 = parse_multiplicative_expression ();
@@ -1419,10 +1419,10 @@ parse_additive_expression (void)
/* shift_expression
: additive_expression (LT!* ('<<' | '>>' | '>>>') LT!* additive_expression)*
; */
static T_IDX
static idx_t
parse_shift_expression (void)
{
T_IDX lhs, expr1, expr2;
idx_t lhs, expr1, expr2;
expr1 = parse_additive_expression ();
@@ -1448,10 +1448,10 @@ parse_shift_expression (void)
/* relational_expression
: shift_expression (LT!* ('<' | '>' | '<=' | '>=' | 'instanceof' | 'in') LT!* shift_expression)*
; */
static T_IDX
static idx_t
parse_relational_expression (void)
{
T_IDX lhs, expr1, expr2;
idx_t lhs, expr1, expr2;
expr1 = parse_shift_expression ();
@@ -1492,10 +1492,10 @@ parse_relational_expression (void)
/* equality_expression
: relational_expression (LT!* ('==' | '!=' | '===' | '!==') LT!* relational_expression)*
; */
static T_IDX
static idx_t
parse_equality_expression (void)
{
T_IDX lhs, expr1, expr2;
idx_t lhs, expr1, expr2;
expr1 = parse_relational_expression ();
@@ -1520,8 +1520,8 @@ parse_equality_expression (void)
}
#define PARSE_OF(FUNC, EXPR, TOK_TYPE, GETOP) \
static T_IDX parse_##FUNC (void) { \
T_IDX lhs, expr1, expr2; \
static idx_t parse_##FUNC (void) { \
idx_t lhs, expr1, expr2; \
expr1 = parse_##EXPR (); \
skip_newlines (); \
while (true) \
@@ -1563,15 +1563,15 @@ PARSE_OF (logical_or_expression, logical_and_expression, DOUBLE_OR, logical_or)
/* conditional_expression
: logical_or_expression (LT!* '?' LT!* assignment_expression LT!* ':' LT!* assignment_expression)?
; */
static T_IDX
static idx_t
parse_conditional_expression (bool *was_conditional)
{
T_IDX expr = parse_logical_or_expression ();
idx_t expr = parse_logical_or_expression ();
skip_newlines ();
if (tok.type == TOK_QUERY)
{
T_IDX lhs, res = next_temp_name ();
idx_t lhs, res = next_temp_name ();
opcode_counter_t jmp_oc;
DUMP_OPCODE_2 (is_true_jmp, expr, opcode_counter + 2);
@@ -1604,10 +1604,10 @@ parse_conditional_expression (bool *was_conditional)
: conditional_expression
| left_hand_side_expression LT!* assignment_operator LT!* assignment_expression
; */
static T_IDX
static idx_t
parse_assignment_expression (void)
{
T_IDX lhs, rhs;
idx_t lhs, rhs;
bool was_conditional = false;
lhs = parse_conditional_expression (&was_conditional);
@@ -1704,10 +1704,10 @@ parse_assignment_expression (void)
: assignment_expression (LT!* ',' LT!* assignment_expression)*
;
*/
static T_IDX
static idx_t
parse_expression (void)
{
T_IDX expr = parse_assignment_expression ();
idx_t expr = parse_assignment_expression ();
while (true)
{
@@ -1733,7 +1733,7 @@ parse_expression (void)
static void
parse_variable_declaration (void)
{
T_IDX name, expr;
idx_t name, expr;
current_token_must_be (TOK_NAME);
name = tok.data.uid;
@@ -1800,7 +1800,7 @@ parse_variable_declaration_list (bool *several_decls)
static void
parse_for_or_for_in_statement (void)
{
T_IDX stop;
idx_t stop;
opcode_counter_t cond_oc, body_oc, step_oc, end_oc;
assert_keyword (KW_FOR);
@@ -1932,10 +1932,10 @@ for_in:
JERRY_UNIMPLEMENTED ();
}
static T_IDX
static idx_t
parse_expression_inside_parens (void)
{
T_IDX expr;
idx_t expr;
token_after_newlines_must_be (TOK_OPEN_PAREN);
NEXT (expr, expression);
token_after_newlines_must_be (TOK_CLOSE_PAREN);
@@ -1971,7 +1971,7 @@ parse_statement_list (void)
static void
parse_if_statement (void)
{
T_IDX cond;
idx_t cond;
opcode_counter_t cond_oc;
assert_keyword (KW_IF);
@@ -2002,7 +2002,7 @@ parse_if_statement (void)
static void
parse_do_while_statement (void)
{
T_IDX cond;
idx_t cond;
opcode_counter_t loop_oc;
assert_keyword (KW_DO);
@@ -2028,7 +2028,7 @@ parse_do_while_statement (void)
static void
parse_while_statement (void)
{
T_IDX cond;
idx_t cond;
opcode_counter_t cond_oc, jmp_oc;
assert_keyword (KW_WHILE);
@@ -2056,7 +2056,7 @@ parse_while_statement (void)
static void
parse_with_statement (void)
{
T_IDX expr;
idx_t expr;
assert_keyword (KW_WITH);
expr = parse_expression_inside_parens ();
@@ -2233,7 +2233,7 @@ parse_statement (void)
}
if (is_keyword (KW_RETURN))
{
T_IDX expr;
idx_t expr;
tok = lexer_next_token ();
if (tok.type != TOK_SEMICOLON)
{
+1 -1
View File
@@ -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
+25 -25
View File
@@ -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);
}
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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);
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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);
+4 -4
View File
@@ -32,14 +32,14 @@
#define MAX_STRINGS 100
#define MAX_NUMS 25
static const OPCODE *
static const opcode_t *
parser_run (const char *script_source, size_t script_source_size, bool is_show_opcodes)
{
const char *strings[MAX_STRINGS];
ecma_number_t nums[MAX_NUMS];
uint8_t strings_num, nums_count;
uint16_t offset;
const OPCODE *opcodes;
const opcode_t *opcodes;
lexer_init (script_source, script_source_size, is_show_opcodes);
@@ -59,7 +59,7 @@ parser_run (const char *script_source, size_t script_source_size, bool is_show_o
opcodes = deserialize_bytecode ();
optimizer_run_passes ((OPCODE *) opcodes);
optimizer_run_passes ((opcode_t *) opcodes);
#ifdef __TARGET_HOST_x64
serializer_print_opcodes ();
@@ -72,7 +72,7 @@ static bool
jerry_run (const char *script_source, size_t script_source_size,
bool is_parse_only, bool is_show_opcodes, bool is_show_mem_stats)
{
const OPCODE *opcodes;
const opcode_t *opcodes;
mem_init ();
+1 -1
View File
@@ -27,7 +27,7 @@ static uint8_t opcode_sizes[] = {
};
static bool
opcodes_equal (const OPCODE *opcodes1, OPCODE *opcodes2, uint16_t size)
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)
{
uint16_t i;
for (i = 0; i < size; i++)
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
+1 -1
View File
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
/* 0: */ getop_reg_var_decl( 255, 255),
/* 1: */ getop_var_decl( 0),
/* 2: */ getop_var_decl( 1),
+1 -1
View File
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
+1 -1
View File
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
+4 -4
View File
@@ -30,7 +30,7 @@ int
main( int __unused argc,
char __unused **argv)
{
OPCODE test_program[] = {
opcode_t test_program[] = {
[0] = getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1),
[1] = getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0),
[2] = getop_is_false_jmp (0, 10),
@@ -56,10 +56,10 @@ main( int __unused argc,
for (int i = 0; i < 11; i++)
serializer_dump_opcode (test_program[i]);
OPCODE * opcodes = (OPCODE *) deserialize_bytecode ();
opcode_t * opcodes = (opcode_t *) deserialize_bytecode ();
optimizer_move_opcodes (opcodes + 9, opcodes + 2, 1);
if (!opcodes_equal (opcodes, (OPCODE[]) {
if (!opcodes_equal (opcodes, (opcode_t[]) {
[0] = getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1),
[1] = getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0),
[2] = getop_assignment (0, OPCODE_ARG_TYPE_SMALLINT, 253),
@@ -75,7 +75,7 @@ main( int __unused argc,
return 1;
optimizer_adjust_jumps (opcodes + 3, opcodes + 10, 1);
if (!opcodes_equal (opcodes, (OPCODE[]) {
if (!opcodes_equal (opcodes, (opcode_t[]) {
[0] = getop_assignment( 0, OPCODE_ARG_TYPE_STRING, 1),
[1] = getop_assignment( 1, OPCODE_ARG_TYPE_VARIABLE, 0),
[2] = getop_assignment (0, OPCODE_ARG_TYPE_SMALLINT, 253),
+2 -2
View File
@@ -37,7 +37,7 @@ main( int __unused argc,
ecma_number_t nums[MAX_NUMS];
uint8_t strings_num, nums_count;
uint16_t offset;
const OPCODE *opcodes;
const opcode_t *opcodes;
const char *source = "for (var i = 0; i < 10; i++) {\n"
" var j = 10;\n"
"}\n"
@@ -62,7 +62,7 @@ main( int __unused argc,
opcodes = deserialize_bytecode ();
serializer_print_opcodes ();
if (!opcodes_equal (opcodes, (OPCODE[]) {
if (!opcodes_equal (opcodes, (opcode_t[]) {
[0] = getop_reg_var_decl (2, 5), // var tmp2 .. tmp5;
[1] = getop_var_decl (0), // var i;
[2] = getop_var_decl (1), // var j;
+3 -3
View File
@@ -31,7 +31,7 @@ main( int __unused argc,
char __unused **argv)
{
// Honestly, after RETVAL there must be RET
OPCODE test_program[] = {
opcode_t test_program[] = {
[0] = getop_reg_var_decl (5, 5), // tmp6
[1] = getop_assignment (0, OPCODE_ARG_TYPE_STRING, 1), // a = "b"
[2] = getop_var_decl (1), // var b
@@ -54,10 +54,10 @@ main( int __unused argc,
for (int i = 0; i < 9; i++)
serializer_dump_opcode (test_program[i]);
OPCODE * opcodes = (OPCODE *) deserialize_bytecode ();
opcode_t * opcodes = (opcode_t *) deserialize_bytecode ();
optimizer_reorder_scope (1, 8);
if (!opcodes_equal (opcodes, (OPCODE[]) {
if (!opcodes_equal (opcodes, (opcode_t[]) {
[0] = getop_reg_var_decl (5, 5), // tmp6
[1] = getop_assignment (5, OPCODE_ARG_TYPE_STRING, 3), // "use strict"
[2] = getop_func_decl_0 (2), // function c()
+1 -1
View File
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
+1 -1
View File
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
@@ -26,7 +26,7 @@ int
main( int __unused argc,
char __unused **argv)
{
const OPCODE test_program[] = {
const opcode_t test_program[] = {
/* 0: */ getop_reg_var_decl( 255, 255),
/* 1: */ getop_var_decl( 0),
/* 2: */ getop_is_true_jmp( 0, 4),