Split opcode and instruction entities and perform related renamings: opcode_t is now vm_instr_t, opcode position is instruction position, etc.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-07-21 19:14:06 +03:00
committed by Evgeny Gavrin
parent 1990762cf0
commit 502f4c4623
43 changed files with 1096 additions and 1085 deletions
+36 -36
View File
@@ -20,16 +20,16 @@
* 'Jump down if true' opcode handler.
*
* Note:
* current opcode's position changes by adding specified offset
* current instruction's position changes by adding specified offset
* if argument evaluates to true.
*/
ecma_completion_value_t
opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */
opfunc_is_true_jmp_down (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t cond_var_idx = opdata.data.is_true_jmp_down.value;
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_down.opcode_1,
opdata.data.is_true_jmp_down.opcode_2);
const idx_t cond_var_idx = instr.data.is_true_jmp_down.value;
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_down.oc_idx_1,
instr.data.is_true_jmp_down.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -41,7 +41,7 @@ opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */
if (ecma_is_completion_value_normal_true (to_bool_completion))
{
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES);
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset);
}
else
{
@@ -57,12 +57,12 @@ opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */
/* Likewise to opfunc_is_true_jmp_down, but jumps up. */
ecma_completion_value_t
opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */
opfunc_is_true_jmp_up (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t cond_var_idx = opdata.data.is_true_jmp_up.value;
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_up.opcode_1,
opdata.data.is_true_jmp_up.opcode_2);
const idx_t cond_var_idx = instr.data.is_true_jmp_up.value;
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_up.oc_idx_1,
instr.data.is_true_jmp_up.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -74,7 +74,7 @@ opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */
if (ecma_is_completion_value_normal_true (to_bool_completion))
{
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset);
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset);
}
else
{
@@ -92,16 +92,16 @@ opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */
* 'Jump down if false' opcode handler.
*
* Note:
* current opcode's position changes by adding specified offset
* current instruction's position changes by adding specified offset
* if argument evaluates to false.
*/
ecma_completion_value_t
opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */
opfunc_is_false_jmp_down (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t cond_var_idx = opdata.data.is_false_jmp_down.value;
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_down.opcode_1,
opdata.data.is_false_jmp_down.opcode_2);
const idx_t cond_var_idx = instr.data.is_false_jmp_down.value;
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_down.oc_idx_1,
instr.data.is_false_jmp_down.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -113,7 +113,7 @@ opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */
if (!ecma_is_completion_value_normal_true (to_bool_completion))
{
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES);
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset);
}
else
{
@@ -129,12 +129,12 @@ opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */
/* Likewise to opfunc_is_false_jmp_down, but jumps up. */
ecma_completion_value_t
opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */
opfunc_is_false_jmp_up (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t cond_var_idx = opdata.data.is_false_jmp_up.value;
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_up.opcode_1,
opdata.data.is_false_jmp_up.opcode_2);
const idx_t cond_var_idx = instr.data.is_false_jmp_up.value;
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_up.oc_idx_1,
instr.data.is_false_jmp_up.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -146,7 +146,7 @@ opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */
if (!ecma_is_completion_value_normal_true (to_bool_completion))
{
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset);
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset);
}
else
{
@@ -164,18 +164,18 @@ opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */
* 'Jump down' opcode handler.
*
* Note:
* the opcode changes adds specified value to current opcode position
* the opcode changes adds specified value to current instruction position
*/
ecma_completion_value_t
opfunc_jmp_down (opcode_t opdata, /**< operation data */
opfunc_jmp_down (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1,
opdata.data.jmp_down.opcode_2);
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1,
instr.data.jmp_down.oc_idx_2);
JERRY_ASSERT (((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES));
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset);
return ecma_make_empty_completion_value ();
}
@@ -184,17 +184,17 @@ opfunc_jmp_down (opcode_t opdata, /**< operation data */
* 'Jump up' opcode handler.
*
* Note:
* the opcode changes substracts specified value from current opcode position
* the opcode changes substracts specified value from current instruction position
*/
ecma_completion_value_t
opfunc_jmp_up (opcode_t opdata, /**< operation data */
opfunc_jmp_up (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_up.opcode_1,
opdata.data.jmp_up.opcode_2);
const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_up.oc_idx_1,
instr.data.jmp_up.oc_idx_2);
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset);
frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset);
frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset);
return ecma_make_empty_completion_value ();
}
@@ -206,12 +206,12 @@ opfunc_jmp_up (opcode_t opdata, /**< operation data */
* the opcode returns break-continue completion value with jump target
*/
ecma_completion_value_t
opfunc_jmp_break_continue (opcode_t opdata, /**< operation data */
opfunc_jmp_break_continue (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
opcode_counter_t target = frame_ctx_p->pos;
target = (opcode_counter_t) (target + calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1,
opdata.data.jmp_down.opcode_2));
vm_instr_counter_t target = frame_ctx_p->pos;
target = (vm_instr_counter_t) (target + vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1,
instr.data.jmp_down.oc_idx_2));
return ecma_make_jump_completion_value (target);
} /* opfunc_jmp_break_continue */
+26 -26
View File
@@ -103,12 +103,12 @@ do_number_arithmetic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_addition (opcode_t opdata, /**< operation data */
opfunc_addition (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.addition.dst;
const idx_t left_var_idx = instr.data.addition.var_left;
const idx_t right_var_idx = instr.data.addition.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -169,12 +169,12 @@ opfunc_addition (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_substraction (opcode_t opdata, /**< operation data */
opfunc_substraction (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.substraction.dst;
const idx_t left_var_idx = instr.data.substraction.var_left;
const idx_t right_var_idx = instr.data.substraction.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -204,12 +204,12 @@ opfunc_substraction (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_multiplication (opcode_t opdata, /**< operation data */
opfunc_multiplication (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.multiplication.dst;
const idx_t left_var_idx = instr.data.multiplication.var_left;
const idx_t right_var_idx = instr.data.multiplication.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -239,12 +239,12 @@ opfunc_multiplication (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_division (opcode_t opdata, /**< operation data */
opfunc_division (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.division.dst;
const idx_t left_var_idx = instr.data.division.var_left;
const idx_t right_var_idx = instr.data.division.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -274,12 +274,12 @@ opfunc_division (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_remainder (opcode_t opdata, /**< operation data */
opfunc_remainder (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t left_var_idx = instr.data.remainder.var_left;
const idx_t right_var_idx = instr.data.remainder.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -309,11 +309,11 @@ opfunc_remainder (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_unary_plus (opcode_t opdata, /**< operation data */
opfunc_unary_plus (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.remainder.dst;
const idx_t var_idx = opdata.data.remainder.var_left;
const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t var_idx = instr.data.remainder.var_left;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -346,11 +346,11 @@ opfunc_unary_plus (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_unary_minus (opcode_t opdata, /**< operation data */
opfunc_unary_minus (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.remainder.dst;
const idx_t var_idx = opdata.data.remainder.var_left;
const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t var_idx = instr.data.remainder.var_left;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
+27 -27
View File
@@ -119,12 +119,12 @@ do_number_bitwise_logic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context *
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_and (opcode_t opdata, /**< operation data */
opfunc_b_and (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_and.dst;
const idx_t left_var_idx = instr.data.b_and.var_left;
const idx_t right_var_idx = instr.data.b_and.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -154,12 +154,12 @@ opfunc_b_and (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_or (opcode_t opdata, /**< operation data */
opfunc_b_or (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_or.dst;
const idx_t left_var_idx = instr.data.b_or.var_left;
const idx_t right_var_idx = instr.data.b_or.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -189,12 +189,12 @@ opfunc_b_or (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_xor (opcode_t opdata, /**< operation data */
opfunc_b_xor (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_xor.dst;
const idx_t left_var_idx = instr.data.b_xor.var_left;
const idx_t right_var_idx = instr.data.b_xor.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -224,12 +224,12 @@ opfunc_b_xor (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_left (opcode_t opdata, /**< operation data */
opfunc_b_shift_left (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_shift_left.dst;
const idx_t left_var_idx = instr.data.b_shift_left.var_left;
const idx_t right_var_idx = instr.data.b_shift_left.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -259,12 +259,12 @@ opfunc_b_shift_left (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_right (opcode_t opdata, /**< operation data */
opfunc_b_shift_right (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_shift_right.dst;
const idx_t left_var_idx = instr.data.b_shift_right.var_left;
const idx_t right_var_idx = instr.data.b_shift_right.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -294,12 +294,12 @@ opfunc_b_shift_right (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_shift_uright (opcode_t opdata, /**< operation data */
opfunc_b_shift_uright (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.b_shift_uright.dst;
const idx_t left_var_idx = instr.data.b_shift_uright.var_left;
const idx_t right_var_idx = instr.data.b_shift_uright.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -329,11 +329,11 @@ opfunc_b_shift_uright (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_b_not (opcode_t opdata, /**< operation data */
opfunc_b_not (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.b_not.dst;
const idx_t right_var_idx = opdata.data.b_not.var_right;
const idx_t dst_var_idx = instr.data.b_not.dst;
const idx_t right_var_idx = instr.data.b_not.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_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_t opdata, /**< operation data */
opfunc_equal_value (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.equal_value.dst;
const idx_t left_var_idx = instr.data.equal_value.var_left;
const idx_t right_var_idx = instr.data.equal_value.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -64,12 +64,12 @@ opfunc_equal_value (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_not_equal_value (opcode_t opdata, /**< operation data */
opfunc_not_equal_value (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.not_equal_value.dst;
const idx_t left_var_idx = instr.data.not_equal_value.var_left;
const idx_t right_var_idx = instr.data.not_equal_value.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -105,12 +105,12 @@ opfunc_not_equal_value (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_equal_value_type (opcode_t opdata, /**< operation data */
opfunc_equal_value_type (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.equal_value_type.dst;
const idx_t left_var_idx = instr.data.equal_value_type.var_left;
const idx_t right_var_idx = instr.data.equal_value_type.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -140,12 +140,12 @@ opfunc_equal_value_type (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_not_equal_value_type (opcode_t opdata, /**< operation data */
opfunc_not_equal_value_type (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.not_equal_value_type.dst;
const idx_t left_var_idx = instr.data.not_equal_value_type.var_left;
const idx_t right_var_idx = instr.data.not_equal_value_type.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
+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_t opdata, /**< operation data */
opfunc_less_than (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.less_than.dst;
const idx_t left_var_idx = instr.data.less_than.var_left;
const idx_t right_var_idx = instr.data.less_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -73,12 +73,12 @@ opfunc_less_than (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_greater_than (opcode_t opdata, /**< operation data */
opfunc_greater_than (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.greater_than.dst;
const idx_t left_var_idx = instr.data.greater_than.var_left;
const idx_t right_var_idx = instr.data.greater_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -121,12 +121,12 @@ opfunc_greater_than (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */
opfunc_less_or_equal_than (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.less_or_equal_than.dst;
const idx_t left_var_idx = instr.data.less_or_equal_than.var_left;
const idx_t right_var_idx = instr.data.less_or_equal_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -176,12 +176,12 @@ opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */
opfunc_greater_or_equal_than (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
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;
const idx_t dst_var_idx = instr.data.greater_or_equal_than.dst;
const idx_t left_var_idx = instr.data.greater_or_equal_than.var_left;
const idx_t right_var_idx = instr.data.greater_or_equal_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -231,12 +231,12 @@ opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_instanceof (opcode_t opdata __attr_unused___, /**< operation data */
opfunc_instanceof (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
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;
const idx_t dst_idx = instr.data.instanceof.dst;
const idx_t left_var_idx = instr.data.instanceof.var_left;
const idx_t right_var_idx = instr.data.instanceof.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -277,12 +277,12 @@ opfunc_instanceof (opcode_t opdata __attr_unused___, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_in (opcode_t opdata __attr_unused___, /**< operation data */
opfunc_in (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
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;
const idx_t dst_idx = instr.data.in.dst;
const idx_t left_var_idx = instr.data.in.var_left;
const idx_t right_var_idx = instr.data.in.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
+2 -1
View File
@@ -18,6 +18,7 @@
#include "ecma-alloc.h"
#include "ecma-array-object.h"
#include "ecma-builtins.h"
#include "ecma-comparison.h"
#include "ecma-conversion.h"
#include "ecma-exceptions.h"
@@ -35,7 +36,7 @@
bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, idx_t var_idx);
ecma_completion_value_t get_variable_value (vm_frame_ctx_t *, idx_t, bool);
ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, opcode_counter_t, idx_t, ecma_value_t);
ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, vm_instr_counter_t, idx_t, ecma_value_t);
ecma_completion_value_t fill_varg_list (vm_frame_ctx_t *frame_ctx_p,
ecma_length_t args_number,
ecma_value_t args_values[],
@@ -27,13 +27,13 @@
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_try_block (opcode_t opdata, /**< operation data */
opfunc_try_block (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t block_end_oc_idx_1 = opdata.data.try_block.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.try_block.oc_idx_2;
const opcode_counter_t try_end_oc = (opcode_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos);
const idx_t block_end_oc_idx_1 = instr.data.try_block.oc_idx_1;
const idx_t block_end_oc_idx_2 = instr.data.try_block.oc_idx_2;
const vm_instr_counter_t try_end_oc = (vm_instr_counter_t) (
vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos);
frame_ctx_p->pos++;
@@ -43,23 +43,23 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|| (ecma_is_completion_value_empty (try_completion) && frame_ctx_p->pos == try_end_oc));
frame_ctx_p->pos = try_end_oc;
opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
if (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH)
if (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH)
{
const opcode_counter_t catch_end_oc = (opcode_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos);
const vm_instr_counter_t catch_end_oc = (vm_instr_counter_t) (
vm_read_instr_counter_from_meta (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++;
if (ecma_is_completion_value_throw (try_completion))
{
next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER);
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER);
lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid (next_opcode.data.meta.data_1,
frame_ctx_p->opcodes_p,
lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
frame_ctx_p->pos++;
@@ -98,13 +98,13 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
frame_ctx_p->pos = catch_end_oc;
}
next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
if (next_opcode.data.meta.type == OPCODE_META_TYPE_FINALLY)
if (next_instr.data.meta.type == OPCODE_META_TYPE_FINALLY)
{
const opcode_counter_t finally_end_oc = (opcode_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos);
const vm_instr_counter_t finally_end_oc = (vm_instr_counter_t) (
vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++;
vm_run_scope_t run_scope_finally = { frame_ctx_p->pos, finally_end_oc };
@@ -121,9 +121,9 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
}
}
next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos++);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos++);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
return try_completion;
} /* opfunc_try_block */
+13 -13
View File
@@ -182,15 +182,15 @@ vm_helper_for_in_enumerate_properties_names (ecma_object_t *obj_p) /**< starting
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_for_in (opcode_t opdata, /**< operation data */
opfunc_for_in (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *int_data_p) /**< interpreter context */
{
const idx_t expr_idx = opdata.data.for_in.expr;
const idx_t block_end_oc_idx_1 = opdata.data.for_in.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.for_in.oc_idx_2;
const opcode_counter_t for_in_end_oc = (opcode_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1,
block_end_oc_idx_2) + int_data_p->pos);
const idx_t expr_idx = instr.data.for_in.expr;
const idx_t block_end_oc_idx_1 = instr.data.for_in.oc_idx_1;
const idx_t block_end_oc_idx_2 = instr.data.for_in.oc_idx_2;
const vm_instr_counter_t for_in_end_oc = (vm_instr_counter_t) (
vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1,
block_end_oc_idx_2) + int_data_p->pos);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -203,9 +203,9 @@ opfunc_for_in (opcode_t opdata, /**< operation data */
int_data_p->pos++;
opcode_t meta_opcode = vm_get_opcode (int_data_p->opcodes_p, for_in_end_oc);
JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_FOR_IN);
vm_instr_t meta_instr = vm_get_instr (int_data_p->instrs_p, for_in_end_oc);
JERRY_ASSERT (meta_instr.op_idx == VM_OP_META);
JERRY_ASSERT (meta_instr.data.meta.type == OPCODE_META_TYPE_END_FOR_IN);
/* 3. */
if (!ecma_is_value_undefined (expr_value)
@@ -225,8 +225,8 @@ opfunc_for_in (opcode_t opdata, /**< operation data */
{
ecma_collection_iterator_init (&names_iterator, names_p);
const opcode_counter_t for_in_body_begin_oc = int_data_p->pos;
const opcode_counter_t for_in_body_end_oc = for_in_end_oc;
const vm_instr_counter_t for_in_body_begin_oc = int_data_p->pos;
const vm_instr_counter_t for_in_body_end_oc = for_in_end_oc;
while (ecma_collection_iterator_next (&names_iterator))
{
@@ -270,7 +270,7 @@ opfunc_for_in (opcode_t opdata, /**< operation data */
ECMA_FINALIZE (obj_expr_value);
}
int_data_p->pos = (opcode_counter_t) (for_in_end_oc + 1u);
int_data_p->pos = (vm_instr_counter_t) (for_in_end_oc + 1u);
ECMA_FINALIZE (expr_value);
+3 -3
View File
@@ -91,7 +91,7 @@ get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
else
{
ecma_string_t var_name_string;
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, frame_ctx_p->pos);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
@@ -125,7 +125,7 @@ get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
*/
ecma_completion_value_t
set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
opcode_counter_t lit_oc, /**< opcode counter for literal */
vm_instr_counter_t lit_oc, /**< instruction counter for literal */
idx_t var_idx, /**< variable identifier */
ecma_value_t value) /**< value to set */
{
@@ -158,7 +158,7 @@ set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
else
{
ecma_string_t var_name_string;
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, lit_oc);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, lit_oc);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
+5 -5
View File
@@ -28,13 +28,13 @@
* 'Native call' opcode handler.
*/
ecma_completion_value_t
opfunc_native_call (opcode_t opdata, /**< operation data */
opfunc_native_call (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.native_call.lhs;
const idx_t native_call_id_idx = opdata.data.native_call.name;
const idx_t args_number = opdata.data.native_call.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t dst_var_idx = instr.data.native_call.lhs;
const idx_t native_call_id_idx = instr.data.native_call.name;
const idx_t args_number = instr.data.native_call.arg_list;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
JERRY_ASSERT (native_call_id_idx < OPCODE_NATIVE_CALL__COUNT);
+9 -9
View File
@@ -44,11 +44,11 @@ fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
if (ecma_is_completion_value_empty (evaluate_arg_completion))
{
opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG);
const idx_t varg_var_idx = next_opcode.data.meta.data_1;
const idx_t varg_var_idx = next_instr.data.meta.data_1;
ecma_completion_value_t get_arg_completion = get_variable_value (frame_ctx_p, varg_var_idx, false);
@@ -91,12 +91,12 @@ fill_params_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
param_index < params_number;
param_index++)
{
opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG);
const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_opcode.data.meta.data_1,
frame_ctx_p->opcodes_p,
const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
params_names[param_index] = ecma_new_ecma_string_from_lit_cp (param_name_lit_idx);
+146 -146
View File
@@ -59,12 +59,12 @@
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_assignment (opcode_t opdata, /**< operation data */
opfunc_assignment (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.assignment.var_left;
const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) opdata.data.assignment.type_value_right;
const idx_t src_val_descr = opdata.data.assignment.value_right;
const idx_t dst_var_idx = instr.data.assignment.var_left;
const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) instr.data.assignment.type_value_right;
const idx_t src_val_descr = instr.data.assignment.value_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -77,7 +77,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
}
else if (type_value_right == OPCODE_ARG_TYPE_STRING)
{
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos);
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
ret_value = set_variable_value (frame_ctx_p,
@@ -106,7 +106,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
{
ecma_number_t *num_p = frame_ctx_p->tmp_num_p;
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos);
literal_t lit = lit_get_literal_by_cp (lit_cp);
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
@@ -121,7 +121,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
{
ecma_number_t *num_p = frame_ctx_p->tmp_num_p;
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos);
literal_t lit = lit_get_literal_by_cp (lit_cp);
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
@@ -147,7 +147,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
{
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr,
frame_ctx_p->opcodes_p,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
@@ -230,11 +230,11 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_pre_incr (opcode_t opdata, /**< operation data */
opfunc_pre_incr (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.pre_incr.dst;
const idx_t incr_var_idx = opdata.data.pre_incr.var_right;
const idx_t dst_var_idx = instr.data.pre_incr.dst;
const idx_t incr_var_idx = instr.data.pre_incr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -277,11 +277,11 @@ opfunc_pre_incr (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_pre_decr (opcode_t opdata, /**< operation data */
opfunc_pre_decr (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.pre_decr.dst;
const idx_t decr_var_idx = opdata.data.pre_decr.var_right;
const idx_t dst_var_idx = instr.data.pre_decr.dst;
const idx_t decr_var_idx = instr.data.pre_decr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -324,11 +324,11 @@ opfunc_pre_decr (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_post_incr (opcode_t opdata, /**< operation data */
opfunc_post_incr (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.post_incr.dst;
const idx_t incr_var_idx = opdata.data.post_incr.var_right;
const idx_t dst_var_idx = instr.data.post_incr.dst;
const idx_t incr_var_idx = instr.data.post_incr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -372,11 +372,11 @@ opfunc_post_incr (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_post_decr (opcode_t opdata, /**< operation data */
opfunc_post_decr (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.post_decr.dst;
const idx_t decr_var_idx = opdata.data.post_decr.var_right;
const idx_t dst_var_idx = instr.data.post_decr.dst;
const idx_t decr_var_idx = instr.data.post_decr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -417,7 +417,7 @@ opfunc_post_decr (opcode_t opdata, /**< operation data */
* The opcode is meta-opcode that is not supposed to be executed.
*/
ecma_completion_value_t
opfunc_reg_var_decl (opcode_t opdata __attr_unused___, /**< operation data */
opfunc_reg_var_decl (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
JERRY_UNREACHABLE ();
@@ -433,11 +433,11 @@ opfunc_reg_var_decl (opcode_t opdata __attr_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_t opdata, /**< operation data */
opfunc_var_decl (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (opdata.data.var_decl.variable_name,
frame_ctx_p->opcodes_p,
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (instr.data.var_decl.variable_name,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
@@ -485,11 +485,11 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
bool do_instantiate_arguments_object = true;
const bool is_configurable_bindings = frame_ctx_p->is_eval_code;
const opcode_counter_t function_code_end_oc = (opcode_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos);
const vm_instr_counter_t function_code_end_oc = (vm_instr_counter_t) (
vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->opcodes_p, frame_ctx_p->pos++);
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p, frame_ctx_p->pos++);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
{
@@ -508,7 +508,7 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
ecma_completion_value_t ret_value = ecma_op_function_declaration (frame_ctx_p->lex_env_p,
function_name_string_p,
frame_ctx_p->opcodes_p,
frame_ctx_p->instrs_p,
frame_ctx_p->pos,
args_names,
args_number,
@@ -529,14 +529,14 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_func_decl_n (opcode_t opdata, /**< operation data */
opfunc_func_decl_n (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_decl_n.arg_list;
const idx_t function_name_idx = instr.data.func_decl_n.name_lit_idx;
const ecma_length_t params_number = instr.data.func_decl_n.arg_list;
lit_cpointer_t function_name_lit_cp = serializer_get_literal_cp_by_uid (function_name_idx,
frame_ctx_p->opcodes_p,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
frame_ctx_p->pos++;
@@ -571,21 +571,21 @@ opfunc_func_decl_n (opcode_t opdata, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_func_expr_n (opcode_t opdata, /**< operation data */
opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
frame_ctx_p->pos++;
const idx_t dst_var_idx = opdata.data.func_expr_n.lhs;
const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_expr_n.arg_list;
const idx_t dst_var_idx = instr.data.func_expr_n.lhs;
const idx_t function_name_lit_idx = instr.data.func_expr_n.name_lit_idx;
const ecma_length_t params_number = instr.data.func_expr_n.arg_list;
const bool is_named_func_expr = (function_name_lit_idx != INVALID_VALUE);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
opcode_counter_t function_code_end_oc;
vm_instr_counter_t function_code_end_oc;
MEM_DEFINE_LOCAL_ARRAY (params_names, params_number, ecma_string_t*);
@@ -594,11 +594,11 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
bool is_strict = frame_ctx_p->is_strict;
bool do_instantiate_arguments_object = true;
function_code_end_oc = (opcode_counter_t) (read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END,
frame_ctx_p) + frame_ctx_p->pos);
function_code_end_oc = (vm_instr_counter_t) (vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END,
frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->opcodes_p,
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p,
frame_ctx_p->pos++);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
@@ -621,7 +621,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
scope_p = ecma_create_decl_lex_env (frame_ctx_p->lex_env_p);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (function_name_lit_idx,
frame_ctx_p->opcodes_p,
frame_ctx_p->instrs_p,
lit_oc);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
@@ -639,7 +639,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
scope_p,
is_strict,
do_instantiate_arguments_object,
frame_ctx_p->opcodes_p,
frame_ctx_p->instrs_p,
frame_ctx_p->pos);
ret_value = set_variable_value (frame_ctx_p, lit_oc,
@@ -682,8 +682,8 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
*/
static ecma_value_t
vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< interpreter context */
opcode_counter_t var_idx_lit_oc, /**< opcode counter, corresponding to
* instruction with function_var_idx */
vm_instr_counter_t var_idx_lit_oc, /**< instruction counter of instruction
with var_idx */
idx_t var_idx, /**< idx, used to retrieve the called function object */
opcode_call_flags_t *out_flags_p) /**< out: call flags */
{
@@ -694,7 +694,7 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int
opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY;
idx_t this_arg_var_idx = INVALID_VALUE;
opcode_t next_opcode = vm_get_opcode (int_data_p->opcodes_p, int_data_p->pos);
vm_instr_t next_opcode = vm_get_instr (int_data_p->instrs_p, int_data_p->pos);
if (next_opcode.op_idx == VM_OP_META
&& next_opcode.data.meta.type == OPCODE_META_TYPE_CALL_SITE_INFO)
{
@@ -753,7 +753,7 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int
/* 6.b.i */
ecma_string_t var_name_string;
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, int_data_p->opcodes_p, var_idx_lit_oc);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, int_data_p->instrs_p, var_idx_lit_oc);
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (int_data_p->lex_env_p,
@@ -792,13 +792,13 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_call_n (opcode_t opdata, /**< operation data */
opfunc_call_n (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t lhs_var_idx = opdata.data.call_n.lhs;
const idx_t function_var_idx = opdata.data.call_n.function_var_idx;
const idx_t args_number_idx = opdata.data.call_n.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t lhs_var_idx = instr.data.call_n.lhs;
const idx_t function_var_idx = instr.data.call_n.function_var_idx;
const idx_t args_number_idx = instr.data.call_n.arg_list;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -895,13 +895,13 @@ opfunc_call_n (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_construct_n (opcode_t opdata, /**< operation data */
opfunc_construct_n (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t lhs_var_idx = opdata.data.construct_n.lhs;
const idx_t constructor_name_lit_idx = opdata.data.construct_n.name_lit_idx;
const idx_t args_number = opdata.data.construct_n.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t lhs_var_idx = instr.data.construct_n.lhs;
const idx_t constructor_name_lit_idx = instr.data.construct_n.name_lit_idx;
const idx_t args_number = instr.data.construct_n.arg_list;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (constructor_value,
@@ -972,12 +972,12 @@ opfunc_construct_n (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_array_decl (opcode_t opdata, /**< operation data */
opfunc_array_decl (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t lhs_var_idx = opdata.data.array_decl.lhs;
const idx_t args_number = opdata.data.array_decl.list;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t lhs_var_idx = instr.data.array_decl.lhs;
const idx_t args_number = instr.data.array_decl.list;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
frame_ctx_p->pos++;
@@ -1035,12 +1035,12 @@ opfunc_array_decl (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_obj_decl (opcode_t opdata, /**< operation data */
opfunc_obj_decl (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t lhs_var_idx = opdata.data.obj_decl.lhs;
const idx_t args_number = opdata.data.obj_decl.list;
const opcode_counter_t obj_lit_oc = frame_ctx_p->pos;
const idx_t lhs_var_idx = instr.data.obj_decl.lhs;
const idx_t args_number = instr.data.obj_decl.list;
const vm_instr_counter_t obj_lit_oc = frame_ctx_p->pos;
frame_ctx_p->pos++;
@@ -1056,7 +1056,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
if (ecma_is_completion_value_empty (evaluate_prop_completion))
{
opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
vm_instr_t next_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type;
@@ -1191,7 +1191,7 @@ opfunc_obj_decl (opcode_t 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_t opdata __attr_unused___, /**< operation data */
opfunc_ret (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
return ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
@@ -1207,12 +1207,12 @@ opfunc_ret (opcode_t opdata __attr_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_t opdata __attr_unused___, /**< operation data */
opfunc_retval (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (expr_val, get_variable_value (frame_ctx_p, opdata.data.retval.ret_value, false), ret_value);
ECMA_TRY_CATCH (expr_val, get_variable_value (frame_ctx_p, instr.data.retval.ret_value, false), ret_value);
ret_value = ecma_make_return_completion_value (ecma_copy_value (expr_val, true));
@@ -1231,12 +1231,12 @@ opfunc_retval (opcode_t opdata __attr_unused___, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_prop_getter (opcode_t opdata __attr_unused___, /**< operation data */
opfunc_prop_getter (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
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;
const idx_t lhs_var_idx = instr.data.prop_getter.lhs;
const idx_t base_var_idx = instr.data.prop_getter.obj;
const idx_t prop_name_var_idx = instr.data.prop_getter.prop;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1284,12 +1284,12 @@ opfunc_prop_getter (opcode_t opdata __attr_unused___, /**< operation data */
* returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */
opfunc_prop_setter (vm_instr_t instr __attr_unused___, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
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;
const idx_t base_var_idx = instr.data.prop_setter.obj;
const idx_t prop_name_var_idx = instr.data.prop_setter.prop;
const idx_t rhs_var_idx = instr.data.prop_setter.rhs;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1336,11 +1336,11 @@ opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_logical_not (opcode_t opdata, /**< operation data */
opfunc_logical_not (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.logical_not.dst;
const idx_t right_var_idx = opdata.data.logical_not.var_right;
const idx_t dst_var_idx = instr.data.logical_not.dst;
const idx_t right_var_idx = instr.data.logical_not.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1374,11 +1374,11 @@ opfunc_logical_not (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_this_binding (opcode_t opdata, /**< operation data */
opfunc_this_binding (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.this_binding.lhs;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t dst_var_idx = instr.data.this_binding.lhs;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
frame_ctx_p->pos++;
@@ -1400,14 +1400,14 @@ opfunc_this_binding (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_with (opcode_t opdata, /**< operation data */
opfunc_with (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t expr_var_idx = opdata.data.with.expr;
const idx_t block_end_oc_idx_1 = opdata.data.with.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.with.oc_idx_2;
const opcode_counter_t with_end_oc = (opcode_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos);
const idx_t expr_var_idx = instr.data.with.expr;
const idx_t block_end_oc_idx_1 = instr.data.with.oc_idx_1;
const idx_t block_end_oc_idx_2 = instr.data.with.oc_idx_2;
const vm_instr_counter_t with_end_oc = (vm_instr_counter_t) (
vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1431,7 +1431,7 @@ opfunc_with (opcode_t opdata, /**< operation data */
frame_ctx_p->lex_env_p = new_env_p;
#ifndef JERRY_NDEBUG
opcode_t meta_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, with_end_oc);
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, with_end_oc);
JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META);
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH);
#endif /* !JERRY_NDEBUG */
@@ -1474,10 +1474,10 @@ opfunc_with (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_throw_value (opcode_t opdata, /**< operation data */
opfunc_throw_value (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t var_idx = opdata.data.throw_value.var;
const idx_t var_idx = instr.data.throw_value.var;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1520,7 +1520,7 @@ evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context *
}
else
{
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, frame_ctx_p->pos);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
@@ -1553,11 +1553,11 @@ evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context *
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_typeof (opcode_t opdata, /**< operation data */
opfunc_typeof (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.typeof.lhs;
const idx_t obj_var_idx = opdata.data.typeof.obj;
const idx_t dst_var_idx = instr.data.typeof.lhs;
const idx_t obj_var_idx = instr.data.typeof.obj;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1625,18 +1625,18 @@ opfunc_typeof (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_delete_var (opcode_t opdata, /**< operation data */
opfunc_delete_var (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.delete_var.lhs;
const idx_t name_lit_idx = opdata.data.delete_var.name;
const opcode_counter_t lit_oc = frame_ctx_p->pos;
const idx_t dst_var_idx = instr.data.delete_var.lhs;
const idx_t name_lit_idx = instr.data.delete_var.name;
const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
frame_ctx_p->pos++;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (name_lit_idx, frame_ctx_p->opcodes_p, lit_oc);
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (name_lit_idx, frame_ctx_p->instrs_p, lit_oc);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
@@ -1692,12 +1692,12 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_delete_prop (opcode_t opdata, /**< operation data */
opfunc_delete_prop (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.delete_prop.lhs;
const idx_t base_var_idx = opdata.data.delete_prop.base;
const idx_t name_var_idx = opdata.data.delete_prop.name;
const idx_t dst_var_idx = instr.data.delete_prop.lhs;
const idx_t base_var_idx = instr.data.delete_prop.base;
const idx_t name_var_idx = instr.data.delete_prop.name;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
@@ -1763,10 +1763,10 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */
* @return implementation-defined meta completion value
*/
ecma_completion_value_t
opfunc_meta (opcode_t opdata, /**< operation data */
opfunc_meta (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{
const opcode_meta_type type = (opcode_meta_type) opdata.data.meta.type;
const opcode_meta_type type = (opcode_meta_type) instr.data.meta.type;
switch (type)
{
@@ -1797,73 +1797,73 @@ opfunc_meta (opcode_t opdata, /**< operation data */
} /* opfunc_meta */
/**
* Calculate opcode counter from 'meta' opcode's data arguments.
* Calculate instruction counter from 'meta' instruction's data arguments.
*
* @return opcode counter
* @return instruction counter
*/
opcode_counter_t
calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */
const idx_t oc_idx_2) /**< second idx */
vm_instr_counter_t
vm_calc_instr_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */
const idx_t oc_idx_2) /**< second idx */
{
opcode_counter_t counter;
vm_instr_counter_t counter;
counter = oc_idx_1;
counter = (opcode_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE));
counter = (opcode_counter_t) (counter | oc_idx_2);
counter = (vm_instr_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE));
counter = (vm_instr_counter_t) (counter | oc_idx_2);
return counter;
} /* calc_meta_opcode_counter_from_meta_data */
} /* vm_calc_instr_counter_from_idx_idx */
/**
* Read opcode counter from current opcode,
* that should be 'meta' opcode of type 'opcode counter'.
* Read instruction counter from current instruction,
* that should be 'meta' instruction of specified type.
*/
opcode_counter_t
read_meta_opcode_counter (opcode_meta_type expected_type, /**< expected type of meta opcode */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
vm_instr_counter_t
vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected type of meta instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
opcode_t meta_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos);
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (meta_opcode.data.meta.type == expected_type);
const idx_t data_1 = meta_opcode.data.meta.data_1;
const idx_t data_2 = meta_opcode.data.meta.data_2;
return calc_opcode_counter_from_idx_idx (data_1, data_2);
} /* read_meta_opcode_counter */
return vm_calc_instr_counter_from_idx_idx (data_1, data_2);
} /* vm_read_instr_counter_from_meta */
#define VM_OP_0(opcode_name, opcode_name_uppercase) \
opcode_t getop_##opcode_name (void) \
vm_instr_t getop_##opcode_name (void) \
{ \
opcode_t opdata; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \
return opdata; \
vm_instr_t instr; \
instr.op_idx = VM_OP_##opcode_name_uppercase; \
return instr; \
}
#define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \
opcode_t getop_##opcode_name (idx_t arg1_v) \
vm_instr_t getop_##opcode_name (idx_t arg1_v) \
{ \
opcode_t opdata; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \
return opdata; \
vm_instr_t instr; \
instr.op_idx = VM_OP_##opcode_name_uppercase; \
instr.data.opcode_name.arg1 = arg1_v; \
return instr; \
}
#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \
opcode_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \
vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \
{ \
opcode_t opdata; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \
opdata.data.opcode_name.arg2 = arg2_v; \
return opdata; \
vm_instr_t instr; \
instr.op_idx = VM_OP_##opcode_name_uppercase; \
instr.data.opcode_name.arg1 = arg1_v; \
instr.data.opcode_name.arg2 = arg2_v; \
return instr; \
}
#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \
opcode_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \
vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \
{ \
opcode_t opdata; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \
opdata.data.opcode_name.arg2 = arg2_v; \
opdata.data.opcode_name.arg3 = arg3_v; \
return opdata; \
vm_instr_t instr; \
instr.op_idx = VM_OP_##opcode_name_uppercase; \
instr.data.opcode_name.arg1 = arg1_v; \
instr.data.opcode_name.arg2 = arg2_v; \
instr.data.opcode_name.arg3 = arg3_v; \
return instr; \
}
#include "vm-opcodes.inc.h"
+32 -25
View File
@@ -35,8 +35,15 @@
#define OP_3(action, name, field1, field2, field3) \
__##action (name, field1, field2, field3)
typedef uint16_t opcode_counter_t; /** opcode counters */
typedef uint8_t idx_t; /** index values */
/**
* Instruction counter / position
*/
typedef uint16_t vm_instr_counter_t;
/**
* Opcode / argument value in an instruction
*/
typedef uint8_t idx_t;
/**
* Descriptor of assignment's second argument
@@ -139,17 +146,17 @@ typedef enum
} vm_op_arg_type_t;
/**
* Forward declaration of opcode structure
* Forward declaration of instruction structure
*/
struct opcode_t;
struct vm_instr_t;
/**
* Context of interpreter, related to a JS stack frame
*/
typedef struct
{
const opcode_t *opcodes_p; /**< pointer to array containing currently executed bytecode */
opcode_counter_t pos; /**< current opcode to execute */
const vm_instr_t *instrs_p; /**< currently executed byte-code array */
vm_instr_counter_t pos; /**< current position instruction to execute */
ecma_value_t this_binding; /**< this binding for current context */
ecma_object_t *lex_env_p; /**< current lexical environment */
bool is_strict; /**< is current code execution mode strict? */
@@ -178,20 +185,20 @@ typedef struct
* Note:
* Run scope represents boundaries of byte-code block to run.
*
* Jumps within of the current run scope are performed by just changing opcode counter,
* Jumps within of the current run scope are performed by just changing instruction counter,
* and outside of the run scope - by returning corresponding ECMA_COMPLETION_TYPE_BREAK_CONTINUE
* completion value.
*/
typedef struct
{
const opcode_counter_t start_oc; /**< opcode counter of the first instruction of the scope */
const opcode_counter_t end_oc; /**< opcode counter of the last instruction of the scope */
const vm_instr_counter_t start_oc; /**< instruction counter of the first instruction of the scope */
const vm_instr_counter_t end_oc; /**< instruction counter of the last instruction of the scope */
} vm_run_scope_t;
opcode_counter_t calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, const idx_t oc_idx_2);
opcode_counter_t read_meta_opcode_counter (opcode_meta_type expected_type, vm_frame_ctx_t *frame_ctx_p);
vm_instr_counter_t vm_calc_instr_counter_from_idx_idx (const idx_t oc_idx_1, const idx_t oc_idx_2);
vm_instr_counter_t vm_read_instr_counter_from_meta (opcode_meta_type expected_type, vm_frame_ctx_t *int_data);
typedef struct opcode_t
typedef struct vm_instr_t
{
idx_t op_idx;
union
@@ -218,9 +225,9 @@ typedef struct opcode_t
#include "vm-opcodes.inc.h"
} data;
} opcode_t;
} vm_instr_t;
enum __opcode_idx
typedef enum
{
#define VM_OP_0(opcode_name, opcode_name_uppercase) \
VM_OP_ ## opcode_name_uppercase,
@@ -234,29 +241,29 @@ enum __opcode_idx
#include "vm-opcodes.inc.h"
VM_OP__COUNT /**< number of opcodes */
};
} vm_op_t;
#define VM_OP_0(opcode_name, opcode_name_uppercase) \
ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*);
ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*);
#define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \
ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*);
ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*);
#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \
ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*);
ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*);
#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \
ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*);
ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*);
#include "vm-opcodes.inc.h"
typedef ecma_completion_value_t (*opfunc) (opcode_t, vm_frame_ctx_t *);
typedef ecma_completion_value_t (*opfunc) (vm_instr_t, vm_frame_ctx_t *);
#define VM_OP_0(opcode_name, opcode_name_uppercase) \
opcode_t getop_##opcode_name (void);
vm_instr_t getop_##opcode_name (void);
#define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \
opcode_t getop_##opcode_name (idx_t);
vm_instr_t getop_##opcode_name (idx_t);
#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \
opcode_t getop_##opcode_name (idx_t, idx_t);
vm_instr_t getop_##opcode_name (idx_t, idx_t);
#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \
opcode_t getop_##opcode_name (idx_t, idx_t, idx_t);
vm_instr_t getop_##opcode_name (idx_t, idx_t, idx_t);
#include "vm-opcodes.inc.h"
@@ -264,6 +271,6 @@ typedef ecma_completion_value_t (*opfunc) (opcode_t, vm_frame_ctx_t *);
typedef struct
{
uint8_t uids[4];
} raw_opcode;
} raw_instr;
#endif /* OPCODES_H */
+17 -17
View File
@@ -94,9 +94,9 @@ tmp_id_to_str (idx_t id)
}
static const char *
var_to_str (opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint8_t current_arg)
var_to_str (vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, uint8_t current_arg)
{
raw_opcode raw = *(raw_opcode*) &opcode;
raw_instr raw = *(raw_instr*) &instr;
if (raw.uids[current_arg] == LITERAL_TO_REWRITE)
{
if (lit_ids == NULL)
@@ -117,7 +117,7 @@ var_to_str (opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint
}
static void
pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint8_t start_arg)
pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, uint8_t start_arg)
{
uint8_t current_arg = start_arg;
JERRY_ASSERT (current_arg <= 3);
@@ -136,14 +136,14 @@ pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode
case 'd':
{
JERRY_ASSERT (current_arg <= 3);
raw_opcode raw = *(raw_opcode*) &opcode;
raw_instr raw = *(raw_instr*) &instr;
printf ("%d", raw.uids[current_arg]);
break;
}
case 's':
{
JERRY_ASSERT (current_arg <= 3);
printf ("%s", var_to_str (opcode, lit_ids, oc, current_arg));
printf ("%s", var_to_str (instr, lit_ids, oc, current_arg));
break;
}
default:
@@ -160,22 +160,22 @@ pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode
#define PP_OP(op_name, format) \
case op_name: pp_printf (format, opm.op, opm.lit_id, oc, 1); break;
#define VAR(i) var_to_str (opm.op, opm.lit_id, oc, i)
#define OC(i, j) __extension__({ raw_opcode* raw = (raw_opcode *) &opm.op; \
calc_opcode_counter_from_idx_idx (raw->uids[i], raw->uids[j]); })
#define OC(i, j) __extension__({ raw_instr* raw = (raw_instr *) &opm.op; \
vm_calc_instr_counter_from_idx_idx (raw->uids[i], raw->uids[j]); })
static int vargs_num = 0;
static int seen_vargs = 0;
static void
dump_asm (opcode_counter_t oc, opcode_t opcode)
dump_asm (vm_instr_counter_t oc, vm_instr_t instr)
{
uint8_t i = 0;
uint8_t opcode_id = opcode.op_idx;
uint8_t opcode_id = instr.op_idx;
printf ("%3d: %20s ", oc, opcode_names[opcode_id]);
for (i = 1; i < opcode_sizes[opcode_id]; i++)
{
printf ("%4d ", ((raw_opcode *) &opcode)->uids[i]);
printf ("%4d ", ((raw_instr *) &instr)->uids[i]);
}
for (; i < 4; i++)
@@ -185,8 +185,8 @@ dump_asm (opcode_counter_t oc, opcode_t opcode)
}
void
pp_op_meta (const opcode_t *opcodes_p,
opcode_counter_t oc,
pp_op_meta (const vm_instr_t *instrs_p,
vm_instr_counter_t oc,
op_meta opm,
bool rewrite)
{
@@ -397,11 +397,11 @@ pp_op_meta (const opcode_t *opcodes_p,
if (seen_vargs == vargs_num)
{
bool found = false;
opcode_counter_t start = oc;
vm_instr_counter_t start = oc;
while ((int16_t) start >= 0 && !found)
{
start--;
switch (serializer_get_opcode (opcodes_p, start).op_idx)
switch (serializer_get_instr (instrs_p, start).op_idx)
{
case VM_OP_CALL_N:
case VM_OP_NATIVE_CALL:
@@ -416,7 +416,7 @@ pp_op_meta (const opcode_t *opcodes_p,
}
}
}
opcode_t start_op = serializer_get_opcode (opcodes_p, start);
vm_instr_t start_op = serializer_get_instr (instrs_p, start);
switch (start_op.op_idx)
{
case VM_OP_CALL_N:
@@ -476,9 +476,9 @@ pp_op_meta (const opcode_t *opcodes_p,
JERRY_UNREACHABLE ();
}
}
for (opcode_counter_t counter = start; counter <= oc; counter++)
for (vm_instr_counter_t counter = start; counter <= oc; counter++)
{
opcode_t meta_op = serializer_get_opcode (opcodes_p, counter);
vm_instr_t meta_op = serializer_get_instr (instrs_p, counter);
switch (meta_op.op_idx)
{
+1 -2
View File
@@ -21,8 +21,7 @@
#include "vm.h"
#include "scopes-tree.h"
void pp_opcode (opcode_counter_t, opcode_t, bool);
void pp_op_meta (const opcode_t*, opcode_counter_t, op_meta, bool);
void pp_op_meta (const vm_instr_t*, vm_instr_counter_t, op_meta, bool);
#endif // JERRY_ENABLE_PRETTY_PRINTER
#endif // PRETTY_PRINTER
+14 -14
View File
@@ -264,36 +264,36 @@ VM_OP_2 (unary_plus, UNARY_PLUS,
var, VM_OP_ARG_TYPE_VARIABLE)
VM_OP_2 (jmp_up, JMP_UP,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_2 (jmp_down, JMP_DOWN,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_2 (jmp_break_continue, JMP_BREAK_CONTINUE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (is_true_jmp_up, IS_TRUE_JMP_UP,
value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (is_true_jmp_down, IS_TRUE_JMP_DOWN,
value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (is_false_jmp_up, IS_FALSE_JMP_UP,
value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_3 (is_false_jmp_down, IS_FALSE_JMP_DOWN,
value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST)
oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_1 (var_decl, VAR_DECL,
variable_name, VM_OP_ARG_TYPE_STRING)
+78 -78
View File
@@ -44,9 +44,9 @@ static const opfunc __opfuncs[VM_OP__COUNT] =
#include "vm-opcodes.inc.h"
};
JERRY_STATIC_ASSERT (sizeof (opcode_t) <= 4);
JERRY_STATIC_ASSERT (sizeof (vm_instr_t) <= 4);
const opcode_t *__program = NULL;
const vm_instr_t *__program = NULL;
#ifdef MEM_STATS
static const char *__op_names[VM_OP__COUNT] =
@@ -120,8 +120,8 @@ interp_mem_get_stats (mem_heap_stats_t *out_heap_stats_p,
}
static void
interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p,
opcode_counter_t block_position)
interp_mem_stats_context_enter (vm_frame_ctx_t *frame_ctx_p,
vm_instr_counter_t block_position)
{
if (likely (!interp_mem_stats_enabled))
{
@@ -136,13 +136,13 @@ interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p,
indent_prefix[indentation] = '|';
indent_prefix[indentation + 1] = '\0';
int_data_p->context_peak_allocated_heap_bytes = 0;
int_data_p->context_peak_waste_heap_bytes = 0;
int_data_p->context_peak_pools_count = 0;
int_data_p->context_peak_allocated_pool_chunks = 0;
frame_ctx_p->context_peak_allocated_heap_bytes = 0;
frame_ctx_p->context_peak_waste_heap_bytes = 0;
frame_ctx_p->context_peak_pools_count = 0;
frame_ctx_p->context_peak_allocated_pool_chunks = 0;
interp_mem_get_stats (&int_data_p->heap_stats_context_enter,
&int_data_p->pools_stats_context_enter,
interp_mem_get_stats (&frame_ctx_p->heap_stats_context_enter,
&frame_ctx_p->pools_stats_context_enter,
false, false);
printf ("\n%s--- Beginning interpretation of a block at position %u ---\n"
@@ -151,15 +151,15 @@ interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p,
"%s Pools: %5u\n"
"%s Allocated pool chunks: %5u\n\n",
indent_prefix, (uint32_t) block_position,
indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes,
indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.pools_count,
indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks);
indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.waste_bytes,
indent_prefix, (uint32_t) frame_ctx_p->pools_stats_context_enter.pools_count,
indent_prefix, (uint32_t) frame_ctx_p->pools_stats_context_enter.allocated_chunks);
}
static void
interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p,
opcode_counter_t block_position)
interp_mem_stats_context_exit (vm_frame_ctx_t *frame_ctx_p,
vm_instr_counter_t block_position)
{
if (likely (!interp_mem_stats_enabled))
{
@@ -181,46 +181,46 @@ interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p,
&pools_stats_context_exit,
false, true);
int_data_p->context_peak_allocated_heap_bytes -= JERRY_MAX (int_data_p->heap_stats_context_enter.allocated_bytes,
frame_ctx_p->context_peak_allocated_heap_bytes -= JERRY_MAX (frame_ctx_p->heap_stats_context_enter.allocated_bytes,
heap_stats_context_exit.allocated_bytes);
int_data_p->context_peak_waste_heap_bytes -= JERRY_MAX (int_data_p->heap_stats_context_enter.waste_bytes,
frame_ctx_p->context_peak_waste_heap_bytes -= JERRY_MAX (frame_ctx_p->heap_stats_context_enter.waste_bytes,
heap_stats_context_exit.waste_bytes);
int_data_p->context_peak_pools_count -= JERRY_MAX (int_data_p->pools_stats_context_enter.pools_count,
frame_ctx_p->context_peak_pools_count -= JERRY_MAX (frame_ctx_p->pools_stats_context_enter.pools_count,
pools_stats_context_exit.pools_count);
int_data_p->context_peak_allocated_pool_chunks -= JERRY_MAX (int_data_p->pools_stats_context_enter.allocated_chunks,
frame_ctx_p->context_peak_allocated_pool_chunks -= JERRY_MAX (frame_ctx_p->pools_stats_context_enter.allocated_chunks,
pools_stats_context_exit.allocated_chunks);
printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
(uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes,
(uint32_t) frame_ctx_p->heap_stats_context_enter.allocated_bytes,
(uint32_t) heap_stats_context_exit.allocated_bytes,
(uint32_t) (heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes),
(uint32_t) int_data_p->context_peak_allocated_heap_bytes,
(uint32_t) (heap_stats_context_exit.allocated_bytes - frame_ctx_p->heap_stats_context_enter.allocated_bytes),
(uint32_t) frame_ctx_p->context_peak_allocated_heap_bytes,
(uint32_t) heap_stats_context_exit.global_peak_allocated_bytes);
printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
(uint32_t) int_data_p->heap_stats_context_enter.waste_bytes,
(uint32_t) frame_ctx_p->heap_stats_context_enter.waste_bytes,
(uint32_t) heap_stats_context_exit.waste_bytes,
(uint32_t) (heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes),
(uint32_t) int_data_p->context_peak_waste_heap_bytes,
(uint32_t) (heap_stats_context_exit.waste_bytes - frame_ctx_p->heap_stats_context_enter.waste_bytes),
(uint32_t) frame_ctx_p->context_peak_waste_heap_bytes,
(uint32_t) heap_stats_context_exit.global_peak_waste_bytes);
printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
(uint32_t) int_data_p->pools_stats_context_enter.pools_count,
(uint32_t) frame_ctx_p->pools_stats_context_enter.pools_count,
(uint32_t) pools_stats_context_exit.pools_count,
(uint32_t) (pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count),
(uint32_t) int_data_p->context_peak_pools_count,
(uint32_t) (pools_stats_context_exit.pools_count - frame_ctx_p->pools_stats_context_enter.pools_count),
(uint32_t) frame_ctx_p->context_peak_pools_count,
(uint32_t) pools_stats_context_exit.global_peak_pools_count);
printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
(uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks,
(uint32_t) frame_ctx_p->pools_stats_context_enter.allocated_chunks,
(uint32_t) pools_stats_context_exit.allocated_chunks,
(uint32_t) (pools_stats_context_exit.allocated_chunks -
int_data_p->pools_stats_context_enter.allocated_chunks),
(uint32_t) int_data_p->context_peak_allocated_pool_chunks,
frame_ctx_p->pools_stats_context_enter.allocated_chunks),
(uint32_t) frame_ctx_p->context_peak_allocated_pool_chunks,
(uint32_t) pools_stats_context_exit.global_peak_allocated_chunks);
printf ("\n%s--- End of interpretation of a block at position %u ---\n\n",
@@ -228,8 +228,8 @@ interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p,
}
static void
interp_mem_stats_opcode_enter (const opcode_t *opcodes_p,
opcode_counter_t opcode_position,
interp_mem_stats_opcode_enter (const vm_instr_t *instrs_p,
vm_instr_counter_t instr_position,
mem_heap_stats_t *out_heap_stats_p,
mem_pools_stats_t *out_pools_stats_p)
{
@@ -250,17 +250,17 @@ interp_mem_stats_opcode_enter (const opcode_t *opcodes_p,
out_pools_stats_p,
true, false);
opcode_t opcode = vm_get_opcode (opcodes_p, opcode_position);
vm_instr_t instr = vm_get_instr (instrs_p, instr_position);
printf ("%s-- Opcode: %s (position %u) --\n",
indent_prefix, __op_names[opcode.op_idx], (uint32_t) opcode_position);
indent_prefix, __op_names[instr.op_idx], (uint32_t) instr_position);
interp_mem_stats_print_indentation += INTERP_MEM_PRINT_INDENTATION_STEP;
}
static void
interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p,
opcode_counter_t opcode_position,
interp_mem_stats_opcode_exit (vm_frame_ctx_t *frame_ctx_p,
vm_instr_counter_t instr_position,
mem_heap_stats_t *heap_stats_before_p,
mem_pools_stats_t *pools_stats_before_p)
{
@@ -286,16 +286,16 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p,
&pools_stats_after,
false, true);
int_data_p->context_peak_allocated_heap_bytes = JERRY_MAX (int_data_p->context_peak_allocated_heap_bytes,
frame_ctx_p->context_peak_allocated_heap_bytes = JERRY_MAX (frame_ctx_p->context_peak_allocated_heap_bytes,
heap_stats_after.allocated_bytes);
int_data_p->context_peak_waste_heap_bytes = JERRY_MAX (int_data_p->context_peak_waste_heap_bytes,
frame_ctx_p->context_peak_waste_heap_bytes = JERRY_MAX (frame_ctx_p->context_peak_waste_heap_bytes,
heap_stats_after.waste_bytes);
int_data_p->context_peak_pools_count = JERRY_MAX (int_data_p->context_peak_pools_count,
frame_ctx_p->context_peak_pools_count = JERRY_MAX (frame_ctx_p->context_peak_pools_count,
pools_stats_after.pools_count);
int_data_p->context_peak_allocated_pool_chunks = JERRY_MAX (int_data_p->context_peak_allocated_pool_chunks,
frame_ctx_p->context_peak_allocated_pool_chunks = JERRY_MAX (frame_ctx_p->context_peak_allocated_pool_chunks,
pools_stats_after.allocated_chunks);
opcode_t opcode = vm_get_opcode (int_data_p->opcodes_p, opcode_position);
vm_instr_t instr = vm_get_instr (frame_ctx_p->instrs_p, instr_position);
printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
@@ -343,7 +343,7 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p,
}
printf ("%s-- End of execution of opcode %s (position %u) --\n\n",
indent_prefix, __op_names[opcode.op_idx], opcode_position);
indent_prefix, __op_names[instr.op_idx], instr_position);
}
#endif /* MEM_STATS */
@@ -351,8 +351,8 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p,
* Initialize interpreter.
*/
void
vm_init (const opcode_t *program_p, /**< pointer to byte-code program */
bool dump_mem_stats) /** dump per-opcode memory usage change statistics */
vm_init (const vm_instr_t *program_p, /**< pointer to byte-code program */
bool dump_mem_stats) /** dump per-instruction memory usage change statistics */
{
#ifdef MEM_STATS
interp_mem_stats_enabled = dump_mem_stats;
@@ -392,7 +392,7 @@ vm_run_global (void)
#endif /* MEM_STATS */
bool is_strict = false;
opcode_counter_t start_pos = 0;
vm_instr_counter_t start_pos = 0;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program,
start_pos++);
@@ -448,7 +448,7 @@ vm_run_global (void)
* Otherwise - the completion value is discarded and normal empty completion value is returned.
*/
ecma_completion_value_t
vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
vm_loop (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
vm_run_scope_t *run_scope_p) /**< current run scope,
* or NULL - if there is no active run scope */
{
@@ -467,29 +467,29 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
do
{
JERRY_ASSERT (run_scope_p == NULL
|| (run_scope_p->start_oc <= int_data_p->pos
&& int_data_p->pos <= run_scope_p->end_oc));
|| (run_scope_p->start_oc <= frame_ctx_p->pos
&& frame_ctx_p->pos <= run_scope_p->end_oc));
const opcode_t *curr = &int_data_p->opcodes_p[int_data_p->pos];
const vm_instr_t *curr = &frame_ctx_p->instrs_p[frame_ctx_p->pos];
#ifdef MEM_STATS
const opcode_counter_t opcode_pos = int_data_p->pos;
const vm_instr_counter_t instr_pos = frame_ctx_p->pos;
interp_mem_stats_opcode_enter (int_data_p->opcodes_p,
opcode_pos,
interp_mem_stats_opcode_enter (frame_ctx_p->instrs_p,
instr_pos,
&heap_stats_before,
&pools_stats_before);
#endif /* MEM_STATS */
completion = __opfuncs[curr->op_idx] (*curr, int_data_p);
completion = __opfuncs[curr->op_idx] (*curr, frame_ctx_p);
#ifdef CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE
ecma_gc_run ();
#endif /* CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE */
#ifdef MEM_STATS
interp_mem_stats_opcode_exit (int_data_p,
opcode_pos,
interp_mem_stats_opcode_exit (frame_ctx_p,
instr_pos,
&heap_stats_before,
&pools_stats_before);
#endif /* MEM_STATS */
@@ -501,7 +501,7 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
if (ecma_is_completion_value_jump (completion))
{
opcode_counter_t target = ecma_get_jump_target_from_completion_value (completion);
vm_instr_counter_t target = ecma_get_jump_target_from_completion_value (completion);
/*
* TODO:
@@ -512,7 +512,7 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
|| (target >= run_scope_p->start_oc /* or target is within the current run scope */
&& target <= run_scope_p->end_oc))
{
int_data_p->pos = target;
frame_ctx_p->pos = target;
continue;
}
@@ -528,11 +528,11 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
} /* vm_loop */
/**
* Run the code, starting from specified opcode
* Run the code, starting from specified instruction position
*/
ecma_completion_value_t
vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */
opcode_counter_t start_pos, /**< identifier of starting opcode */
vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */
vm_instr_counter_t start_pos, /**< position of starting instruction */
ecma_value_t this_binding_value, /**< value of 'ThisBinding' */
ecma_object_t *lex_env_p, /**< lexical environment to use */
bool is_strict, /**< is the code is strict mode code (ECMA-262 v5, 10.1.1) */
@@ -540,7 +540,7 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */
{
ecma_completion_value_t completion;
const opcode_t *curr = &opcodes_p[start_pos];
const vm_instr_t *curr = &instrs_p[start_pos];
JERRY_ASSERT (curr->op_idx == VM_OP_REG_VAR_DECL);
const idx_t min_reg_num = curr->data.reg_var_decl.min;
@@ -552,8 +552,8 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */
MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_t);
vm_frame_ctx_t frame_ctx;
frame_ctx.opcodes_p = opcodes_p;
frame_ctx.pos = (opcode_counter_t) (start_pos + 1);
frame_ctx.instrs_p = instrs_p;
frame_ctx.pos = (vm_instr_counter_t) (start_pos + 1);
frame_ctx.this_binding = this_binding_value;
frame_ctx.lex_env_p = lex_env_p;
frame_ctx.is_strict = is_strict;
@@ -592,28 +592,28 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */
} /* vm_run_from_pos */
/**
* Get specified opcode from the program.
* Get specified instruction from the program.
*/
opcode_t
vm_get_opcode (const opcode_t *opcodes_p, /**< byte-code array */
opcode_counter_t counter) /**< opcode counter */
vm_instr_t
vm_get_instr (const vm_instr_t *instrs_p, /**< byte-code array */
vm_instr_counter_t counter) /**< instruction counter */
{
return opcodes_p[ counter ];
} /* vm_get_opcode */
return instrs_p[ counter ];
} /* vm_get_instr */
/**
* Get scope code flags from opcode specified by opcode counter
* Get scope code flags from instruction at specified position
*
* @return mask of scope code flags
*/
opcode_scope_code_flags_t
vm_get_scope_flags (const opcode_t *opcodes_p, /**< byte-code array */
opcode_counter_t counter) /**< opcode counter */
vm_get_scope_flags (const vm_instr_t *instrs_p, /**< byte-code array */
vm_instr_counter_t counter) /**< instruction counter */
{
opcode_t flags_opcode = vm_get_opcode (opcodes_p, counter);
JERRY_ASSERT (flags_opcode.op_idx == VM_OP_META
&& flags_opcode.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS);
return (opcode_scope_code_flags_t) flags_opcode.data.meta.data_1;
vm_instr_t flags_instr = vm_get_instr (instrs_p, counter);
JERRY_ASSERT (flags_instr.op_idx == VM_OP_META
&& flags_instr.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS);
return (opcode_scope_code_flags_t) flags_instr.data.meta.data_1;
} /* vm_get_scope_flags */
/**
+5 -5
View File
@@ -20,19 +20,19 @@
#include "jrt.h"
#include "opcodes.h"
extern void vm_init (const opcode_t* program_p, bool dump_mem_stats);
extern void vm_init (const vm_instr_t* program_p, bool dump_mem_stats);
extern void vm_finalize (void);
extern jerry_completion_code_t vm_run_global (void);
extern ecma_completion_value_t vm_loop (vm_frame_ctx_t *frame_ctx_p, vm_run_scope_t *run_scope_p);
extern ecma_completion_value_t vm_run_from_pos (const opcode_t *opcodes_p,
opcode_counter_t start_pos,
extern ecma_completion_value_t vm_run_from_pos (const vm_instr_t *instrs_p,
vm_instr_counter_t start_pos,
ecma_value_t this_binding_value,
ecma_object_t *lex_env_p,
bool is_strict,
bool is_eval_code);
extern opcode_t vm_get_opcode (const opcode_t*, opcode_counter_t counter);
extern opcode_scope_code_flags_t vm_get_scope_flags (const opcode_t*, opcode_counter_t counter);
extern vm_instr_t vm_get_instr (const vm_instr_t*, vm_instr_counter_t counter);
extern opcode_scope_code_flags_t vm_get_scope_flags (const vm_instr_t*, vm_instr_counter_t counter);
extern bool vm_is_strict_mode (void);
extern bool vm_is_direct_eval_form_call (void);