diff --git a/src/libcoreint/opcodes-support.c b/src/libcoreint/opcodes-support.c deleted file mode 100644 index 4e50f3149..000000000 --- a/src/libcoreint/opcodes-support.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "opcodes-support.h" - -#define GETOP_DEF_0(a, name) \ - __opcode getop_##name (void) \ - { \ - __opcode opdata; \ - opdata.op_idx = __op__idx_##name; \ - return opdata; \ - } - -#define GETOP_DEF_1(a, name, field1) \ - __opcode getop_##name (T_IDX arg1) \ - { \ - __opcode opdata; \ - opdata.op_idx = __op__idx_##name; \ - opdata.data.name.field1 = arg1; \ - return opdata; \ - } - -#define GETOP_DEF_2(a, name, field1, field2) \ - __opcode getop_##name (T_IDX arg1, T_IDX arg2) \ - { \ - __opcode opdata; \ - opdata.op_idx = __op__idx_##name; \ - opdata.data.name.field1 = arg1; \ - opdata.data.name.field2 = arg2; \ - return opdata; \ - } - -#define GETOP_DEF_3(a, name, field1, field2, field3) \ - __opcode getop_##name (T_IDX arg1, T_IDX arg2, T_IDX arg3) \ - { \ - __opcode opdata; \ - opdata.op_idx = __op__idx_##name; \ - opdata.data.name.field1 = arg1; \ - opdata.data.name.field2 = arg2; \ - opdata.data.name.field3 = arg3; \ - return opdata; \ - } - -OP_ARGS_LIST (GETOP_DEF) diff --git a/src/libcoreint/opcodes-support.h b/src/libcoreint/opcodes-support.h deleted file mode 100644 index 563e2fa59..000000000 --- a/src/libcoreint/opcodes-support.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OPCODES_SUPPORT_H -#define OPCODES_SUPPORT_H - -#include "opcodes.h" - -#define GETOP_DECL_0(a, name) \ - __opcode getop_##name (void); - -#define GETOP_DECL_1(a, name, arg1) \ - __opcode getop_##name (T_IDX); - -#define GETOP_DECL_2(a, name, arg1, arg2) \ - __opcode getop_##name (T_IDX, T_IDX); - -#define GETOP_DECL_3(a, name, arg1, arg2, arg3) \ - __opcode getop_##name (T_IDX, T_IDX, T_IDX); - - -OP_ARGS_LIST (GETOP_DECL) - -#endif /* OPCODES_SUPPORT_H */ - diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 00830871a..9cb16e833 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -1067,3 +1067,5 @@ opfunc_logical_and (OPCODE opdata, /**< operation data */ return ret_value; } /* opfunc_logical_and */ + +OP_ARGS_LIST (GETOP_DEF) diff --git a/src/libcoreint/opcodes.h b/src/libcoreint/opcodes.h index 160101032..82dca5542 100644 --- a/src/libcoreint/opcodes.h +++ b/src/libcoreint/opcodes.h @@ -40,6 +40,19 @@ typedef uint16_t opcode_counter_t; +/** + * Descriptor of assignment's second argument + * that specifies type of third argument. + */ +typedef enum +{ + OPCODE_ARG_TYPE_SIMPLE, /**< ecma_simple_value_t */ + OPCODE_ARG_TYPE_SMALLINT, /**< small integer: from -128 to 127 */ + OPCODE_ARG_TYPE_NUMBER, /**< index of number literal */ + OPCODE_ARG_TYPE_STRING, /**< index of string literal */ + OPCODE_ARG_TYPE_VARIABLE /**< index of variable name */ +} opcode_arg_type_operand; + typedef struct { opcode_counter_t pos; /**< current opcode to execute */ @@ -52,101 +65,101 @@ typedef struct ecma_value_t *regs_p; /**< register variables */ } __int_data; -#define OP_CALLS_AND_ARGS(p, a) \ - p##_2 (a, call_0, lhs, name_lit_idx) \ - p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \ - p##_3 (a, call_n, lhs, name_lit_idx, arg1_lit_idx) \ - p##_3 (a, native_call, lhs, name, arg_list) \ - p##_3 (a, construct_decl, lhs, name_lit_idx, arg_list) \ - p##_1 (a, func_decl_0, name_lit_idx) \ - p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \ - p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ - p##_3 (a, func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ - p##_3 (a, varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx) \ - p##_1 (a, exitval, status_code) \ - p##_1 (a, retval, ret_value) \ - p##_0 (a, ret) +#define OP_CALLS_AND_ARGS(p, a) \ + p##_2 (a, call_0, lhs, name_lit_idx) \ + p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \ + p##_3 (a, call_n, lhs, name_lit_idx, arg1_lit_idx) \ + p##_3 (a, native_call, lhs, name, arg_list) \ + p##_3 (a, construct_decl, lhs, name_lit_idx, arg_list) \ + p##_1 (a, func_decl_0, name_lit_idx) \ + p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \ + p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ + p##_3 (a, func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ + p##_3 (a, varg_list, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx) \ + p##_1 (a, exitval, status_code) \ + p##_1 (a, retval, ret_value) \ + p##_0 (a, ret) -#define OP_INITS(p, a) \ - p##_2 (a, array_decl, lhs, list) \ - p##_3 (a, prop, lhs, name, value) \ - p##_3 (a, prop_getter, lhs, obj, prop) \ - p##_3 (a, prop_setter, obj, prop, rhs) \ - p##_2 (a, prop_get_decl, lhs, prop) \ - p##_3 (a, prop_set_decl, lhs, prop, arg) \ - p##_2 (a, obj_decl, lhs, list) \ - p##_1 (a, this, lhs) \ - p##_2 (a, delete, lhs, obj) \ - p##_2 (a, typeof, lhs, obj) \ - p##_1 (a, with, expr) \ - p##_0 (a, end_with) +#define OP_INITS(p, a) \ + p##_2 (a, array_decl, lhs, list) \ + p##_3 (a, prop, lhs, name, value) \ + p##_3 (a, prop_getter, lhs, obj, prop) \ + p##_3 (a, prop_setter, obj, prop, rhs) \ + p##_2 (a, prop_get_decl, lhs, prop) \ + p##_3 (a, prop_set_decl, lhs, prop, arg) \ + p##_2 (a, obj_decl, lhs, list) \ + p##_1 (a, this, lhs) \ + p##_2 (a, delete, lhs, obj) \ + p##_2 (a, typeof, lhs, obj) \ + p##_1 (a, with, expr) \ + p##_0 (a, end_with) -#define OP_ASSIGNMENTS(p, a) \ - p##_3 (a, assignment, var_left, type_value_right, value_right) +#define OP_ASSIGNMENTS(p, a) \ + p##_3 (a, assignment, var_left, type_value_right, value_right) -#define OP_B_SHIFTS(p, a) \ - p##_3 (a, b_shift_left, dst, var_left, var_right) \ - p##_3 (a, b_shift_right, dst, var_left, var_right) \ - p##_3 (a, b_shift_uright, dst, var_left, var_right) +#define OP_B_SHIFTS(p, a) \ + p##_3 (a, b_shift_left, dst, var_left, var_right) \ + p##_3 (a, b_shift_right, dst, var_left, var_right) \ + p##_3 (a, b_shift_uright, dst, var_left, var_right) -#define OP_B_BITWISE(p, a) \ - p##_3 (a, b_and, dst, var_left, var_right) \ - p##_3 (a, b_or, dst, var_left, var_right) \ - p##_3 (a, b_xor, dst, var_left, var_right) \ - p##_2 (a, b_not, dst, var_right) +#define OP_B_BITWISE(p, a) \ + p##_3 (a, b_and, dst, var_left, var_right) \ + p##_3 (a, b_or, dst, var_left, var_right) \ + p##_3 (a, b_xor, dst, var_left, var_right) \ + p##_2 (a, b_not, dst, var_right) -#define OP_B_LOGICAL(p, a) \ - p##_3 (a, logical_and, dst, var_left, var_right) \ - p##_3 (a, logical_or, dst, var_left, var_right) \ - p##_2 (a, logical_not, dst, var_right) +#define OP_B_LOGICAL(p, a) \ + p##_3 (a, logical_and, dst, var_left, var_right) \ + p##_3 (a, logical_or, dst, var_left, var_right) \ + p##_2 (a, logical_not, dst, var_right) -#define OP_EQUALITY(p, a) \ - p##_3 (a, equal_value, dst, var_left, var_right) \ - p##_3 (a, not_equal_value, dst, var_left, var_right) \ - p##_3 (a, equal_value_type, dst, var_left, var_right) \ - p##_3 (a, not_equal_value_type, dst, var_left, var_right) +#define OP_EQUALITY(p, a) \ + p##_3 (a, equal_value, dst, var_left, var_right) \ + p##_3 (a, not_equal_value, dst, var_left, var_right) \ + p##_3 (a, equal_value_type, dst, var_left, var_right) \ + p##_3 (a, not_equal_value_type, dst, var_left, var_right) -#define OP_RELATIONAL(p, a) \ - p##_3 (a, less_than, dst, var_left, var_right) \ - p##_3 (a, greater_than, dst, var_left, var_right) \ - p##_3 (a, less_or_equal_than, dst, var_left, var_right) \ - p##_3 (a, greater_or_equal_than, dst, var_left, var_right) \ - p##_3 (a, instanceof, dst, var_left, var_right) \ - p##_3 (a, in, dst, var_left, var_right) +#define OP_RELATIONAL(p, a) \ + p##_3 (a, less_than, dst, var_left, var_right) \ + p##_3 (a, greater_than, dst, var_left, var_right) \ + p##_3 (a, less_or_equal_than, dst, var_left, var_right) \ + p##_3 (a, greater_or_equal_than, dst, var_left, var_right) \ + p##_3 (a, instanceof, dst, var_left, var_right) \ + p##_3 (a, in, dst, var_left, var_right) -#define OP_ARITHMETIC(p, a) \ - p##_2 (a, post_incr, dst, var_right) \ - p##_2 (a, post_decr, dst, var_right) \ - p##_2 (a, pre_incr, dst, var_right) \ - p##_2 (a, pre_decr, dst, var_right) \ - p##_3 (a, addition, dst, var_left, var_right) \ - p##_3 (a, substraction, dst, var_left, var_right) \ - p##_3 (a, division, dst, var_left, var_right) \ - p##_3 (a, multiplication, dst, var_left, var_right) \ - p##_3 (a, remainder, dst, var_left, var_right) +#define OP_ARITHMETIC(p, a) \ + p##_2 (a, post_incr, dst, var_right) \ + p##_2 (a, post_decr, dst, var_right) \ + p##_2 (a, pre_incr, dst, var_right) \ + p##_2 (a, pre_decr, dst, var_right) \ + p##_3 (a, addition, dst, var_left, var_right) \ + p##_3 (a, substraction, dst, var_left, var_right) \ + p##_3 (a, division, dst, var_left, var_right) \ + p##_3 (a, multiplication, dst, var_left, var_right) \ + p##_3 (a, remainder, dst, var_left, var_right) -#define OP_JUMPS(p, a) \ - p##_1 (a, jmp, opcode_idx) \ - p##_1 (a, jmp_up, opcode_count) \ - p##_1 (a, jmp_down, opcode_count) \ - p##_0 (a, nop) \ - p##_2 (a, is_true_jmp, value, opcode) \ - p##_2 (a, is_false_jmp, value, opcode) +#define OP_JUMPS(p, a) \ + p##_1 (a, jmp, opcode_idx) \ + p##_1 (a, jmp_up, opcode_count) \ + p##_1 (a, jmp_down, opcode_count) \ + p##_0 (a, nop) \ + p##_2 (a, is_true_jmp, value, opcode) \ + p##_2 (a, is_false_jmp, value, opcode) -#define OP_LIST_FULL(p, a) \ - OP_CALLS_AND_ARGS (p, a) \ - OP_INITS (p, a) \ - OP_ASSIGNMENTS (p, a) \ - OP_B_LOGICAL (p, a) \ - OP_B_BITWISE (p, a) \ - OP_B_SHIFTS (p, a) \ - OP_EQUALITY (p, a) \ - OP_RELATIONAL (p, a) \ - OP_ARITHMETIC (p, a) \ - OP_JUMPS (p, a) \ - p##_1 (a, var_decl, variable_name) \ - p##_2 (a, reg_var_decl, min, max) \ - p##_3 (a, meta, type, data_1, data_2) +#define OP_LIST_FULL(p, a) \ + OP_CALLS_AND_ARGS (p, a) \ + OP_INITS (p, a) \ + OP_ASSIGNMENTS (p, a) \ + OP_B_LOGICAL (p, a) \ + OP_B_BITWISE (p, a) \ + OP_B_SHIFTS (p, a) \ + OP_EQUALITY (p, a) \ + OP_RELATIONAL (p, a) \ + OP_ARITHMETIC (p, a) \ + OP_JUMPS (p, a) \ + p##_1 (a, var_decl, variable_name) \ + p##_2 (a, reg_var_decl, min, max) \ + p##_3 (a, meta, type, data_1, data_2) #define OP_LIST(a) OP_LIST_FULL (OP, a) #define OP_ARGS_LIST(a) OP_LIST_FULL (a, void) @@ -197,20 +210,58 @@ enum __opcode_idx OP_LIST (OP_FUNC_DECL) - typedef ecma_completion_value_t (*opfunc) (__opcode, __int_data *); -/** - * Descriptor of assignment's second argument - * that specifies type of third argument. - */ -typedef enum -{ - OPCODE_ARG_TYPE_SIMPLE, /**< ecma_simple_value_t */ - OPCODE_ARG_TYPE_SMALLINT, /**< small integer: from -128 to 127 */ - OPCODE_ARG_TYPE_NUMBER, /**< index of number literal */ - OPCODE_ARG_TYPE_STRING, /**< index of string literal */ - OPCODE_ARG_TYPE_VARIABLE /**< index of variable name */ -} opcode_arg_type_operand; +#define GETOP_DECL_0(a, name) \ + __opcode getop_##name (void); + +#define GETOP_DECL_1(a, name, arg1) \ + __opcode getop_##name (T_IDX); + +#define GETOP_DECL_2(a, name, arg1, arg2) \ + __opcode getop_##name (T_IDX, T_IDX); + +#define GETOP_DECL_3(a, name, arg1, arg2, arg3) \ + __opcode getop_##name (T_IDX, T_IDX, T_IDX); + +#define GETOP_DEF_0(a, name) \ + __opcode getop_##name (void) \ + { \ + __opcode opdata; \ + opdata.op_idx = __op__idx_##name; \ + return opdata; \ + } + +#define GETOP_DEF_1(a, name, field1) \ + __opcode getop_##name (T_IDX arg1) \ + { \ + __opcode opdata; \ + opdata.op_idx = __op__idx_##name; \ + opdata.data.name.field1 = arg1; \ + return opdata; \ + } + +#define GETOP_DEF_2(a, name, field1, field2) \ + __opcode getop_##name (T_IDX arg1, T_IDX arg2) \ + { \ + __opcode opdata; \ + opdata.op_idx = __op__idx_##name; \ + opdata.data.name.field1 = arg1; \ + opdata.data.name.field2 = arg2; \ + return opdata; \ + } + +#define GETOP_DEF_3(a, name, field1, field2, field3) \ + __opcode getop_##name (T_IDX arg1, T_IDX arg2, T_IDX arg3) \ + { \ + __opcode opdata; \ + opdata.op_idx = __op__idx_##name; \ + opdata.data.name.field1 = arg1; \ + opdata.data.name.field2 = arg2; \ + opdata.data.name.field3 = arg3; \ + return opdata; \ + } + +OP_ARGS_LIST (GETOP_DECL) #endif /* OPCODES_H */ diff --git a/src/libjsparser/parser.c b/src/libjsparser/parser.c index 0088f276f..06766b0cf 100644 --- a/src/libjsparser/parser.c +++ b/src/libjsparser/parser.c @@ -17,7 +17,7 @@ #include "jerry-libc.h" #include "lexer.h" #include "parser.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" #include "interpreter.h" diff --git a/tests/unit/test_addition_opcode_number_operands.c b/tests/unit/test_addition_opcode_number_operands.c index fc3187ec3..e40494530 100644 --- a/tests/unit/test_addition_opcode_number_operands.c +++ b/tests/unit/test_addition_opcode_number_operands.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_assignment_opcode.c b/tests/unit/test_assignment_opcode.c index 622997683..f7030774e 100644 --- a/tests/unit/test_assignment_opcode.c +++ b/tests/unit/test_assignment_opcode.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_division_opcode.c b/tests/unit/test_division_opcode.c index e9fbf01ca..e8237b11a 100644 --- a/tests/unit/test_division_opcode.c +++ b/tests/unit/test_division_opcode.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_multiplication_opcode.c b/tests/unit/test_multiplication_opcode.c index 1af4a14a8..0052f60df 100644 --- a/tests/unit/test_multiplication_opcode.c +++ b/tests/unit/test_multiplication_opcode.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_optimizer_adjust_jumps.c b/tests/unit/test_optimizer_adjust_jumps.c index e087651c8..50670d79f 100644 --- a/tests/unit/test_optimizer_adjust_jumps.c +++ b/tests/unit/test_optimizer_adjust_jumps.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" #include "optimizer-passes.h" #include "jerry-libc.h" diff --git a/tests/unit/test_optimizer_for_loops.c b/tests/unit/test_optimizer_for_loops.c index 2c0bdd570..845e3d376 100644 --- a/tests/unit/test_optimizer_for_loops.c +++ b/tests/unit/test_optimizer_for_loops.c @@ -22,7 +22,7 @@ #include "lexer.h" #include "parser.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #define MAX_STRINGS 100 #define MAX_NUMS 25 diff --git a/tests/unit/test_optimizer_reorder_scope.c b/tests/unit/test_optimizer_reorder_scope.c index a9298004b..748dbbd8a 100644 --- a/tests/unit/test_optimizer_reorder_scope.c +++ b/tests/unit/test_optimizer_reorder_scope.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" #include "optimizer-passes.h" #include "jerry-libc.h" diff --git a/tests/unit/test_remainder_opcode.c b/tests/unit/test_remainder_opcode.c index 05a7f4b14..f7f4fa2e7 100644 --- a/tests/unit/test_remainder_opcode.c +++ b/tests/unit/test_remainder_opcode.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_substraction_opcode.c b/tests/unit/test_substraction_opcode.c index 699b9c0e9..61b8d28a1 100644 --- a/tests/unit/test_substraction_opcode.c +++ b/tests/unit/test_substraction_opcode.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /** diff --git a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c index 4f06e0a7e..1ca720f99 100644 --- a/tests/unit/test_var_decl_opcode_in_decl_lex_env.c +++ b/tests/unit/test_var_decl_opcode_in_decl_lex_env.c @@ -16,7 +16,7 @@ #include "globals.h" #include "interpreter.h" #include "mem-allocator.h" -#include "opcodes-support.h" +#include "opcodes.h" #include "serializer.h" /**