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
+1 -1
View File
@@ -163,7 +163,7 @@
#define CONFIG_VM_STACK_FRAME_INLINED_VALUES_NUMBER (16) #define CONFIG_VM_STACK_FRAME_INLINED_VALUES_NUMBER (16)
/** /**
* Run GC after execution of each opcode * Run GC after execution of each byte-code instruction
*/ */
// #define CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE // #define CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE
+1 -1
View File
@@ -174,7 +174,7 @@ typedef uint32_t ecma_completion_value_t;
* Break / continue jump target * Break / continue jump target
*/ */
#define ECMA_COMPLETION_VALUE_TARGET_POS (0) #define ECMA_COMPLETION_VALUE_TARGET_POS (0)
#define ECMA_COMPLETION_VALUE_TARGET_WIDTH ((uint32_t) sizeof (opcode_counter_t) * JERRY_BITSINBYTE) #define ECMA_COMPLETION_VALUE_TARGET_WIDTH ((uint32_t) sizeof (vm_instr_counter_t) * JERRY_BITSINBYTE)
/** /**
* Type (ecma_completion_type_t) * Type (ecma_completion_type_t)
+9 -9
View File
@@ -464,14 +464,14 @@ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value)
/** /**
* Get target of break / continue completion value * Get target of break / continue completion value
* *
* @return opcode counter * @return instruction counter
*/ */
static opcode_counter_t static vm_instr_counter_t
ecma_get_completion_value_target (ecma_completion_value_t completion_value) /**< completion value */ ecma_get_completion_value_target (ecma_completion_value_t completion_value) /**< completion value */
{ {
return (opcode_counter_t) jrt_extract_bit_field (completion_value, return (vm_instr_counter_t) jrt_extract_bit_field (completion_value,
ECMA_COMPLETION_VALUE_TARGET_POS, ECMA_COMPLETION_VALUE_TARGET_POS,
ECMA_COMPLETION_VALUE_TARGET_WIDTH); ECMA_COMPLETION_VALUE_TARGET_WIDTH);
} /* ecma_get_completion_value_target */ } /* ecma_get_completion_value_target */
/** /**
@@ -514,7 +514,7 @@ ecma_set_completion_value_value_field (ecma_completion_value_t completion_value,
static ecma_completion_value_t __attr_const___ static ecma_completion_value_t __attr_const___
ecma_set_completion_value_target (ecma_completion_value_t completion_value, /**< completion value ecma_set_completion_value_target (ecma_completion_value_t completion_value, /**< completion value
* to set field in */ * to set field in */
opcode_counter_t target) /**< break / continue target */ vm_instr_counter_t target) /**< break / continue target */
{ {
return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value, return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value,
target, target,
@@ -645,7 +645,7 @@ ecma_make_meta_completion_value (void)
* @return completion value * @return completion value
*/ */
ecma_completion_value_t __attr_const___ ecma_completion_value_t __attr_const___
ecma_make_jump_completion_value (opcode_counter_t target) /**< target break / continue */ ecma_make_jump_completion_value (vm_instr_counter_t target) /**< target break / continue */
{ {
ecma_completion_value_t completion_value = 0; ecma_completion_value_t completion_value = 0;
@@ -712,9 +712,9 @@ ecma_get_object_from_completion_value (ecma_completion_value_t completion_value)
/** /**
* Get break / continue target from completion value * Get break / continue target from completion value
* *
* @return opcode counter * @return instruction counter
*/ */
opcode_counter_t vm_instr_counter_t
ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value) /**< completion ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value) /**< completion
* value */ * value */
{ {
+2 -2
View File
@@ -84,7 +84,7 @@ extern ecma_completion_value_t ecma_make_throw_obj_completion_value (ecma_object
extern ecma_completion_value_t ecma_make_empty_completion_value (void); extern ecma_completion_value_t ecma_make_empty_completion_value (void);
extern ecma_completion_value_t ecma_make_return_completion_value (ecma_value_t value); extern ecma_completion_value_t ecma_make_return_completion_value (ecma_value_t value);
extern ecma_completion_value_t ecma_make_meta_completion_value (void); extern ecma_completion_value_t ecma_make_meta_completion_value (void);
extern ecma_completion_value_t ecma_make_jump_completion_value (opcode_counter_t target); extern ecma_completion_value_t ecma_make_jump_completion_value (vm_instr_counter_t target);
extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value); extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value);
extern ecma_number_t* __attr_const___ extern ecma_number_t* __attr_const___
ecma_get_number_from_completion_value (ecma_completion_value_t completion_value); ecma_get_number_from_completion_value (ecma_completion_value_t completion_value);
@@ -92,7 +92,7 @@ extern ecma_string_t* __attr_const___
ecma_get_string_from_completion_value (ecma_completion_value_t completion_value); ecma_get_string_from_completion_value (ecma_completion_value_t completion_value);
extern ecma_object_t* __attr_const___ extern ecma_object_t* __attr_const___
ecma_get_object_from_completion_value (ecma_completion_value_t completion_value); ecma_get_object_from_completion_value (ecma_completion_value_t completion_value);
extern opcode_counter_t extern vm_instr_counter_t
ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value); ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value);
extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value); extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value);
extern void ecma_free_completion_value (ecma_completion_value_t completion_value); extern void ecma_free_completion_value (ecma_completion_value_t completion_value);
@@ -255,13 +255,13 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
utf8_string_buffer_pos += sz; utf8_string_buffer_pos += sz;
} }
const opcode_t* opcodes_p; const vm_instr_t* instrs_p;
jsp_status_t parse_status; jsp_status_t parse_status;
parse_status = parser_parse_new_function ((const jerry_api_char_t **) utf8_string_params_p, parse_status = parser_parse_new_function ((const jerry_api_char_t **) utf8_string_params_p,
utf8_string_params_size, utf8_string_params_size,
params_count, params_count,
&opcodes_p); &instrs_p);
if (parse_status == JSP_STATUS_SYNTAX_ERROR) if (parse_status == JSP_STATUS_SYNTAX_ERROR)
{ {
@@ -277,7 +277,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
bool is_strict = false; bool is_strict = false;
bool do_instantiate_arguments_object = true; bool do_instantiate_arguments_object = true;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (opcodes_p, opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p,
0); 0);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
@@ -302,7 +302,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
glob_lex_env_p, glob_lex_env_p,
is_strict, is_strict,
do_instantiate_arguments_object, do_instantiate_arguments_object,
opcodes_p, instrs_p,
1); 1);
ecma_deref_object (glob_lex_env_p); ecma_deref_object (glob_lex_env_p);
+7 -7
View File
@@ -86,7 +86,7 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters
ecma_completion_value_t completion; ecma_completion_value_t completion;
const opcode_t *opcodes_p; const vm_instr_t *instrs_p;
jsp_status_t parse_status; jsp_status_t parse_status;
bool is_strict_call = (is_direct && is_called_from_strict_mode_code); bool is_strict_call = (is_direct && is_called_from_strict_mode_code);
@@ -94,7 +94,7 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters
parse_status = parser_parse_eval (code_p, parse_status = parser_parse_eval (code_p,
code_buffer_size, code_buffer_size,
is_strict_call, is_strict_call,
&opcodes_p); &instrs_p);
if (parse_status == JSP_STATUS_SYNTAX_ERROR) if (parse_status == JSP_STATUS_SYNTAX_ERROR)
{ {
@@ -108,10 +108,10 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters
{ {
JERRY_ASSERT (parse_status == JSP_STATUS_OK); JERRY_ASSERT (parse_status == JSP_STATUS_OK);
opcode_counter_t first_opcode_index = 0u; vm_instr_counter_t first_instr_index = 0u;
bool is_strict_prologue = false; bool is_strict_prologue = false;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (opcodes_p, opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p,
first_opcode_index++); first_instr_index++);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
{ {
is_strict_prologue = true; is_strict_prologue = true;
@@ -142,8 +142,8 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters
lex_env_p = strict_lex_env_p; lex_env_p = strict_lex_env_p;
} }
completion = vm_run_from_pos (opcodes_p, completion = vm_run_from_pos (instrs_p,
first_opcode_index, first_instr_index,
this_binding, this_binding,
lex_env_p, lex_env_p,
is_strict, is_strict,
@@ -36,7 +36,7 @@
*/ */
/** /**
* Pack 'is_strict', 'do_instantiate_arguments_object' flags and opcode index to value * Pack 'is_strict', 'do_instantiate_arguments_object' flags and instruction position to value
* that can be stored in an [[Code]] internal property. * that can be stored in an [[Code]] internal property.
* *
* @return packed value * @return packed value
@@ -45,9 +45,9 @@ static uint32_t
ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
bool do_instantiate_args_obj, /**< should an Arguments object be bool do_instantiate_args_obj, /**< should an Arguments object be
* instantiated for the code */ * instantiated for the code */
opcode_counter_t opcode_idx) /**< index of first opcode */ vm_instr_counter_t instr_oc) /**< position of first instruction */
{ {
uint32_t value = opcode_idx; uint32_t value = instr_oc;
const uint32_t is_strict_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 1); const uint32_t is_strict_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 1);
const uint32_t do_instantiate_arguments_object_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 2); const uint32_t do_instantiate_arguments_object_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 2);
@@ -68,12 +68,12 @@ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
} /* ecma_pack_code_internal_property_value */ } /* ecma_pack_code_internal_property_value */
/** /**
* Unpack 'is_strict', 'do_instantiate_arguments_object' flags and opcode index from value * Unpack 'is_strict', 'do_instantiate_arguments_object' flags and instruction position from value
* that can be stored in an [[Code]] internal property. * that can be stored in an [[Code]] internal property.
* *
* @return opcode index * @return instruction position
*/ */
static opcode_counter_t static vm_instr_counter_t
ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */ ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */
bool* out_is_strict_p, /**< out: is code strict? */ bool* out_is_strict_p, /**< out: is code strict? */
bool* out_do_instantiate_args_obj_p) /**< should an Arguments object be bool* out_do_instantiate_args_obj_p) /**< should an Arguments object be
@@ -89,7 +89,7 @@ ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */
*out_do_instantiate_args_obj_p = ((value & (1u << do_instantiate_arguments_object_bit_offset)) != 0); *out_do_instantiate_args_obj_p = ((value & (1u << do_instantiate_arguments_object_bit_offset)) != 0);
value &= ~((1u << is_strict_bit_offset) | (1u << do_instantiate_arguments_object_bit_offset)); value &= ~((1u << is_strict_bit_offset) | (1u << do_instantiate_arguments_object_bit_offset));
return (opcode_counter_t) value; return (vm_instr_counter_t) value;
} /* ecma_unpack_code_internal_property_value */ } /* ecma_unpack_code_internal_property_value */
/** /**
@@ -221,8 +221,9 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
bool is_strict, /**< 'strict' flag */ bool is_strict, /**< 'strict' flag */
bool do_instantiate_arguments_object, /**< should an Arguments object be instantiated bool do_instantiate_arguments_object, /**< should an Arguments object be instantiated
* for the function object upon call */ * for the function object upon call */
const opcode_t *opcodes_p, /**< byte-code array */ const vm_instr_t *instrs_p, /**< byte-code array */
opcode_counter_t first_opcode_index) /**< index of first opcode of function's body */ vm_instr_counter_t first_instr_pos) /**< position of first instruction
* of function's body */
{ {
// 1., 4., 13. // 1., 4., 13.
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE); ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
@@ -274,13 +275,13 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
} }
// 12. // 12.
ecma_property_t *opcodes_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); ecma_property_t *bytecode_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE);
MEM_CP_SET_NON_NULL_POINTER (opcodes_prop_p->u.internal_property.value, opcodes_p); MEM_CP_SET_NON_NULL_POINTER (bytecode_prop_p->u.internal_property.value, instrs_p);
ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET); ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET);
code_prop_p->u.internal_property.value = ecma_pack_code_internal_property_value (is_strict, code_prop_p->u.internal_property.value = ecma_pack_code_internal_property_value (is_strict,
do_instantiate_arguments_object, do_instantiate_arguments_object,
first_opcode_index); first_instr_pos);
// 14. // 14.
ecma_number_t* len_p = ecma_alloc_number (); ecma_number_t* len_p = ecma_alloc_number ();
@@ -707,7 +708,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
{ {
/* Entering Function Code (ECMA-262 v5, 10.4.3) */ /* Entering Function Code (ECMA-262 v5, 10.4.3) */
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE); ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_property_t *opcodes_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); ecma_property_t *bytecode_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE);
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p,
ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET); ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET);
@@ -718,10 +719,10 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
// 8. // 8.
bool is_strict; bool is_strict;
bool do_instantiate_args_obj; bool do_instantiate_args_obj;
const opcode_t *opcodes_p = MEM_CP_GET_POINTER (const opcode_t, opcodes_prop_p->u.internal_property.value); const vm_instr_t *instrs_p = MEM_CP_GET_POINTER (const vm_instr_t, bytecode_prop_p->u.internal_property.value);
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, vm_instr_counter_t code_first_instr_pos = ecma_unpack_code_internal_property_value (code_prop_value,
&is_strict, &is_strict,
&do_instantiate_args_obj); &do_instantiate_args_obj);
ecma_value_t this_binding; ecma_value_t this_binding;
// 1. // 1.
@@ -757,8 +758,8 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
do_instantiate_args_obj), do_instantiate_args_obj),
ret_value); ret_value);
ecma_completion_value_t completion = vm_run_from_pos (opcodes_p, ecma_completion_value_t completion = vm_run_from_pos (instrs_p,
code_first_opcode_idx, code_first_instr_pos,
this_binding, this_binding,
local_env_p, local_env_p,
is_strict, is_strict,
@@ -1019,8 +1020,9 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
ecma_completion_value_t ecma_completion_value_t
ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */
ecma_string_t *function_name_p, /**< function name */ ecma_string_t *function_name_p, /**< function name */
const opcode_t *opcodes_p, /**< byte-code array */ const vm_instr_t *instrs_p, /**< byte-code array */
opcode_counter_t function_code_opcode_idx, /**< index of first opcode of function code */ vm_instr_counter_t function_first_instr_pos, /**< position of first instruction
* of function code */
ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */ ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */
ecma_length_t formal_parameter_list_length, /**< length of formal parameters list */ ecma_length_t formal_parameter_list_length, /**< length of formal parameters list */
bool is_strict, /**< flag indicating if function is declared in strict mode code */ bool is_strict, /**< flag indicating if function is declared in strict mode code */
@@ -1036,8 +1038,8 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment
lex_env_p, lex_env_p,
is_strict, is_strict,
do_instantiate_arguments_object, do_instantiate_arguments_object,
opcodes_p, instrs_p,
function_code_opcode_idx); function_first_instr_pos);
// c. // c.
bool func_already_declared = ecma_op_has_binding (lex_env_p, function_name_p); bool func_already_declared = ecma_op_has_binding (lex_env_p, function_name_p);
@@ -35,8 +35,8 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[],
ecma_object_t *scope_p, ecma_object_t *scope_p,
bool is_strict, bool is_strict,
bool do_instantiate_arguments_object, bool do_instantiate_arguments_object,
const opcode_t *opcodes_p, const vm_instr_t *instrs_p,
opcode_counter_t first_opcode_idx); vm_instr_counter_t first_opcode_idx);
extern ecma_object_t* extern ecma_object_t*
ecma_op_create_external_function_object (ecma_external_pointer_t code_p); ecma_op_create_external_function_object (ecma_external_pointer_t code_p);
@@ -58,8 +58,8 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p,
extern ecma_completion_value_t extern ecma_completion_value_t
ecma_op_function_declaration (ecma_object_t *lex_env_p, ecma_op_function_declaration (ecma_object_t *lex_env_p,
ecma_string_t *function_name_p, ecma_string_t *function_name_p,
const opcode_t *opcodes_p, const vm_instr_t *instrs_p,
opcode_counter_t function_code_opcode_idx, vm_instr_counter_t function_code_opcode_idx,
ecma_string_t* formal_parameter_list_p[], ecma_string_t* formal_parameter_list_p[],
ecma_length_t formal_parameter_list_length, ecma_length_t formal_parameter_list_length,
bool is_strict, bool is_strict,
+6 -6
View File
@@ -1329,16 +1329,16 @@ jerry_parse (const jerry_api_char_t* source_p, /**< script source */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
bool is_show_opcodes = ((jerry_flags & JERRY_FLAG_SHOW_OPCODES) != 0); bool is_show_instructions = ((jerry_flags & JERRY_FLAG_SHOW_OPCODES) != 0);
parser_set_show_opcodes (is_show_opcodes); parser_set_show_instrs (is_show_instructions);
const opcode_t *opcodes_p; const vm_instr_t *instrs_p;
jsp_status_t parse_status; jsp_status_t parse_status;
parse_status = parser_parse_script (source_p, parse_status = parser_parse_script (source_p,
source_size, source_size,
&opcodes_p); &instrs_p);
if (parse_status != JSP_STATUS_OK) if (parse_status != JSP_STATUS_OK)
{ {
@@ -1355,9 +1355,9 @@ jerry_parse (const jerry_api_char_t* source_p, /**< script source */
} }
#endif /* MEM_STATS */ #endif /* MEM_STATS */
bool is_show_mem_stats_per_opcode = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0); bool is_show_mem_stats_per_instruction = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0);
vm_init (opcodes_p, is_show_mem_stats_per_opcode); vm_init (instrs_p, is_show_mem_stats_per_instruction);
return true; return true;
} /* jerry_parse */ } /* jerry_parse */
+4 -3
View File
@@ -31,10 +31,11 @@
typedef uint32_t jerry_flag_t; typedef uint32_t jerry_flag_t;
#define JERRY_FLAG_EMPTY (0u) /**< empty flag set */ #define JERRY_FLAG_EMPTY (0u) /**< empty flag set */
#define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump opcodes to stdout after parse */ #define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump byte-code to stdout after parse */
#define JERRY_FLAG_MEM_STATS (1u << 1) /**< dump memory statistics */ #define JERRY_FLAG_MEM_STATS (1u << 1) /**< dump memory statistics */
#define JERRY_FLAG_MEM_STATS_PER_OPCODE (1u << 2) /**< dump per-opcode memory statistics during execution #define JERRY_FLAG_MEM_STATS_PER_OPCODE (1u << 2) /**< dump per-instruction memory statistics during execution
* (in the mode full GC is performed after each opcode handler) */ * (in the mode full GC is performed after execution of each
* opcode handler) */
#define JERRY_FLAG_MEM_STATS_SEPARATE (1u << 3) /**< dump memory statistics and reset peak values after parse */ #define JERRY_FLAG_MEM_STATS_SEPARATE (1u << 3) /**< dump memory statistics and reset peak values after parse */
#define JERRY_FLAG_PARSE_ONLY (1u << 4) /**< parse only, prevents script execution (only for testing) #define JERRY_FLAG_PARSE_ONLY (1u << 4) /**< parse only, prevents script execution (only for testing)
* FIXME: Remove. */ * FIXME: Remove. */
+10 -10
View File
@@ -27,7 +27,7 @@
* *
* Literal id is its index in 'literals' array of bytecode_data_t structure. * Literal id is its index in 'literals' array of bytecode_data_t structure.
* *
* Bytecode, which is kept in the 'opcodes' field, is divided into blocks * Bytecode, which is kept in the 'instrs' field, is divided into blocks
* of 'BLOCK_SIZE' operands. Every block has its own numbering of literals. * of 'BLOCK_SIZE' operands. Every block has its own numbering of literals.
* Literal uid could be in range [0, 127] in every block. * Literal uid could be in range [0, 127] in every block.
* *
@@ -42,27 +42,27 @@ typedef struct __attribute__ ((aligned (MEM_ALIGNMENT)))
{ {
mem_cpointer_t lit_id_hash_cp; /**< pointer to literal identifiers hash table mem_cpointer_t lit_id_hash_cp; /**< pointer to literal identifiers hash table
* See also: lit_id_hash_table_init */ * See also: lit_id_hash_table_init */
mem_cpointer_t next_opcodes_cp; /**< pointer to next byte-code memory region */ mem_cpointer_t next_instrs_cp; /**< pointer to next byte-code memory region */
opcode_counter_t instructions_number; /**< number of instructions in the byte-code array */ vm_instr_counter_t instructions_number; /**< number of instructions in the byte-code array */
} opcodes_header_t; } insts_data_header_t;
typedef struct typedef struct
{ {
const ecma_char_t *strings_buffer; const ecma_char_t *strings_buffer;
const opcode_t *opcodes; const vm_instr_t *instrs_p;
opcode_counter_t opcodes_count; vm_instr_counter_t instrs_count;
} bytecode_data_t; } bytecode_data_t;
/** /**
* Macros to get a pointer to bytecode header by pointer to opcodes start * Macros to get a pointer to bytecode header by pointer to instructions array start
*/ */
#define GET_BYTECODE_HEADER(opcodes) ((opcodes_header_t *) (((uint8_t *) (opcodes)) - sizeof (opcodes_header_t))) #define GET_BYTECODE_HEADER(instrs) ((insts_data_header_t *) (((uint8_t *) (instrs)) - sizeof (insts_data_header_t)))
/** /**
* Macros to get a hash table corresponding to a bytecode region * Macros to get a hash table corresponding to a bytecode region
*/ */
#define GET_HASH_TABLE_FOR_BYTECODE(opcodes) (MEM_CP_GET_POINTER (lit_id_hash_table, \ #define GET_HASH_TABLE_FOR_BYTECODE(instrs) (MEM_CP_GET_POINTER (lit_id_hash_table, \
GET_BYTECODE_HEADER (opcodes)->lit_id_hash_cp)) GET_BYTECODE_HEADER (instrs)->lit_id_hash_cp))
#endif // BYTECODE_DATA_H #endif // BYTECODE_DATA_H
@@ -23,7 +23,7 @@
* @{ * @{
* *
* \addtogroup lit_id_hash_table Literal identifiers hash table * \addtogroup lit_id_hash_table Literal identifiers hash table
* The hash table connects pairs (opcode block, idx_t value) with literal identifiers. * The hash table connects pairs (instruction block, idx_t value) with literal identifiers.
* @{ * @{
*/ */
@@ -36,7 +36,7 @@ lit_id_hash_table *
lit_id_hash_table_init (uint8_t *table_buffer_p, /**< buffer to initialize hash table in */ lit_id_hash_table_init (uint8_t *table_buffer_p, /**< buffer to initialize hash table in */
size_t buffer_size, /**< size of the buffer */ size_t buffer_size, /**< size of the buffer */
size_t buckets_count, /**< number of pairs */ size_t buckets_count, /**< number of pairs */
size_t blocks_count) /**< number of opcode blocks */ size_t blocks_count) /**< number of instruction blocks */
{ {
const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT); const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT);
const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT); const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT);
@@ -62,7 +62,7 @@ lit_id_hash_table_init (uint8_t *table_buffer_p, /**< buffer to initialize hash
*/ */
size_t size_t
lit_id_hash_table_get_size_for_table (size_t buckets_count, /**< number of pairs */ lit_id_hash_table_get_size_for_table (size_t buckets_count, /**< number of pairs */
size_t blocks_count) /**< number of opcode blocks */ size_t blocks_count) /**< number of instructions blocks */
{ {
const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT); const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT);
const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT); const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT);
@@ -88,7 +88,7 @@ lit_id_hash_table_free (lit_id_hash_table *table_p) /**< table's header */
void void
lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */ lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
idx_t uid, /**< value of byte-code instruction's argument */ idx_t uid, /**< value of byte-code instruction's argument */
opcode_counter_t oc, /**< opcode counter of the instruction */ vm_instr_counter_t oc, /**< instruction counter of the instruction */
lit_cpointer_t lit_cp) /**< literal identifier */ lit_cpointer_t lit_cp) /**< literal identifier */
{ {
JERRY_ASSERT (table_p != NULL); JERRY_ASSERT (table_p != NULL);
@@ -112,7 +112,7 @@ lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
lit_cpointer_t lit_cpointer_t
lit_id_hash_table_lookup (lit_id_hash_table *table_p, /**< table's header */ lit_id_hash_table_lookup (lit_id_hash_table *table_p, /**< table's header */
idx_t uid, /**< value of byte-code instruction's argument */ idx_t uid, /**< value of byte-code instruction's argument */
opcode_counter_t oc) /**< opcode counter of the instruction */ vm_instr_counter_t oc) /**< instruction counter of the instruction */
{ {
JERRY_ASSERT (table_p != NULL); JERRY_ASSERT (table_p != NULL);
@@ -31,7 +31,7 @@ typedef struct
lit_id_hash_table *lit_id_hash_table_init (uint8_t*, size_t, size_t, size_t); lit_id_hash_table *lit_id_hash_table_init (uint8_t*, size_t, size_t, size_t);
size_t lit_id_hash_table_get_size_for_table (size_t, size_t); size_t lit_id_hash_table_get_size_for_table (size_t, size_t);
void lit_id_hash_table_free (lit_id_hash_table *); void lit_id_hash_table_free (lit_id_hash_table *);
void lit_id_hash_table_insert (lit_id_hash_table *, idx_t, opcode_counter_t, lit_cpointer_t); void lit_id_hash_table_insert (lit_id_hash_table *, idx_t, vm_instr_counter_t, lit_cpointer_t);
lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, idx_t, opcode_counter_t); lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, idx_t, vm_instr_counter_t);
#endif /* LIT_ID_HASH_TABLE */ #endif /* LIT_ID_HASH_TABLE */
+3 -3
View File
@@ -105,8 +105,8 @@ jsp_label_push (jsp_label_t *out_label_p, /**< out: place where label structure
*/ */
void void
jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, /**< label to remove (should be on top of stack) */ jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, /**< label to remove (should be on top of stack) */
opcode_counter_t break_tgt_oc) /**< target opcode counter vm_instr_counter_t break_tgt_oc) /**< target instruction counter
* for breaks on the label */ * for breaks on the label */
{ {
JERRY_ASSERT (label_p != NULL); JERRY_ASSERT (label_p != NULL);
JERRY_ASSERT (break_tgt_oc != MAX_OPCODES); JERRY_ASSERT (break_tgt_oc != MAX_OPCODES);
@@ -228,7 +228,7 @@ jsp_label_add_jump (jsp_label_t *label_p, /**< label to register jump for */
*/ */
void void
jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, /**< the outermost label to setup target for */ jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, /**< the outermost label to setup target for */
opcode_counter_t tgt_oc) /**< target */ vm_instr_counter_t tgt_oc) /**< target */
{ {
/* There are no labels that could not be targeted with 'break' jumps */ /* There are no labels that could not be targeted with 'break' jumps */
JERRY_ASSERT (tgt_oc != MAX_OPCODES); JERRY_ASSERT (tgt_oc != MAX_OPCODES);
+10 -10
View File
@@ -43,7 +43,7 @@ typedef enum
* Jump instructions with target identified by some specific label, * Jump instructions with target identified by some specific label,
* are linked into singly-linked list. * are linked into singly-linked list.
* *
* Pointer to a next element of the list is represented with opcode counter. * Pointer to a next element of the list is represented with instruction counter.
* stored in instructions linked into the list. * stored in instructions linked into the list.
* *
*/ */
@@ -51,13 +51,13 @@ typedef struct jsp_label_t
{ {
jsp_label_type_flag_t type_mask; /**< label type mask */ jsp_label_type_flag_t type_mask; /**< label type mask */
token id; /**< label name (TOK_NAME), if type is LABEL_NAMED */ token id; /**< label name (TOK_NAME), if type is LABEL_NAMED */
opcode_counter_t continue_tgt_oc; /**< target opcode counter for continues on the label */ vm_instr_counter_t continue_tgt_oc; /**< target instruction counter for continues on the label */
opcode_counter_t breaks_list_oc; /**< opcode counter of first 'break' instruction in the list vm_instr_counter_t breaks_list_oc; /**< instruction counter of first 'break' instruction in the list
* of instructions with the target identified by the label */ * of instructions with the target identified by the label */
opcode_counter_t breaks_number; /**< number of 'break' instructions in the list */ vm_instr_counter_t breaks_number; /**< number of 'break' instructions in the list */
opcode_counter_t continues_list_oc; /**< opcode counter of first 'continue' instruction in the list vm_instr_counter_t continues_list_oc; /**< instruction counter of first 'continue' instruction in the list
* of instructions with the target identified by the label */ * of instructions with the target identified by the label */
opcode_counter_t continues_number; /**< number of 'continue' instructions in the list */ vm_instr_counter_t continues_number; /**< number of 'continue' instructions in the list */
jsp_label_t *next_label_p; /**< next label in current label set stack */ jsp_label_t *next_label_p; /**< next label in current label set stack */
bool is_nested_jumpable_border : 1; /**< flag, indicating that this and outer labels bool is_nested_jumpable_border : 1; /**< flag, indicating that this and outer labels
* are not currently accessible with simple jumps, * are not currently accessible with simple jumps,
@@ -70,12 +70,12 @@ extern void jsp_label_finalize (void);
extern void jsp_label_remove_all_labels (void); extern void jsp_label_remove_all_labels (void);
extern void jsp_label_push (jsp_label_t *out_label_p, jsp_label_type_flag_t type_mask, token id); extern void jsp_label_push (jsp_label_t *out_label_p, jsp_label_type_flag_t type_mask, token id);
extern void jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, opcode_counter_t break_tgt_oc); extern void jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, vm_instr_counter_t break_tgt_oc);
extern jsp_label_t *jsp_label_find (jsp_label_type_flag_t type_mask, token id, bool *out_is_simply_jumpable_p); extern jsp_label_t *jsp_label_find (jsp_label_type_flag_t type_mask, token id, bool *out_is_simply_jumpable_p);
extern void jsp_label_add_jump (jsp_label_t *label_p, bool is_simply_jumpable, bool is_break); extern void jsp_label_add_jump (jsp_label_t *label_p, bool is_simply_jumpable, bool is_break);
extern void jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, opcode_counter_t tgt_oc); extern void jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, vm_instr_counter_t tgt_oc);
extern bool jsp_label_raise_nested_jumpable_border (void); extern bool jsp_label_raise_nested_jumpable_border (void);
extern void jsp_label_remove_nested_jumpable_border (void); extern void jsp_label_remove_nested_jumpable_border (void);
+4 -3
View File
@@ -1826,7 +1826,8 @@ lexer_is_no_escape_sequences_in_token_string (token tok) /**< token of type TOK_
void void
lexer_init (const jerry_api_char_t *source, /**< script source */ lexer_init (const jerry_api_char_t *source, /**< script source */
size_t source_size, /**< script source size in bytes */ size_t source_size, /**< script source size in bytes */
bool show_opcodes) /**< flag indicating if to dump opcodes */ bool is_print_source_code) /**< flag indicating whether to dump
* processed source code */
{ {
empty_token.type = TOK_EMPTY; empty_token.type = TOK_EMPTY;
empty_token.uid = 0; empty_token.uid = 0;
@@ -1848,9 +1849,9 @@ lexer_init (const jerry_api_char_t *source, /**< script source */
lexer_set_strict_mode (false); lexer_set_strict_mode (false);
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
allow_dump_lines = show_opcodes; allow_dump_lines = is_print_source_code;
#else /* JERRY_NDEBUG */ #else /* JERRY_NDEBUG */
(void) show_opcodes; (void) is_print_source_code;
allow_dump_lines = false; allow_dump_lines = false;
#endif /* JERRY_NDEBUG */ #endif /* JERRY_NDEBUG */
} /* lexer_init */ } /* lexer_init */
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -186,12 +186,12 @@ operand dump_prop_setter_or_bitwise_or_res (operand, operand);
void dumper_set_break_target (void); void dumper_set_break_target (void);
void dumper_set_continue_target (void); void dumper_set_continue_target (void);
void dumper_set_next_interation_target (void); void dumper_set_next_interation_target (void);
opcode_counter_t vm_instr_counter_t
dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump,
opcode_counter_t next_jump_for_tg_oc); vm_instr_counter_t next_jump_for_tg_oc);
opcode_counter_t vm_instr_counter_t
rewrite_simple_or_nested_jump_and_get_next (opcode_counter_t jump_oc, rewrite_simple_or_nested_jump_and_get_next (vm_instr_counter_t jump_oc,
opcode_counter_t target_oc); vm_instr_counter_t target_oc);
void dump_continue_iterations_check (operand); void dump_continue_iterations_check (operand);
void start_dumping_case_clauses (void); void start_dumping_case_clauses (void);
@@ -207,12 +207,12 @@ operand dump_delete_res (operand, bool, locus);
void dump_typeof (operand, operand); void dump_typeof (operand, operand);
operand dump_typeof_res (operand); operand dump_typeof_res (operand);
opcode_counter_t dump_with_for_rewrite (operand); vm_instr_counter_t dump_with_for_rewrite (operand);
void rewrite_with (opcode_counter_t); void rewrite_with (vm_instr_counter_t);
void dump_with_end (void); void dump_with_end (void);
opcode_counter_t dump_for_in_for_rewrite (operand); vm_instr_counter_t dump_for_in_for_rewrite (operand);
void rewrite_for_in (opcode_counter_t); void rewrite_for_in (vm_instr_counter_t);
void dump_for_in_end (void); void dump_for_in_end (void);
void dump_try_for_rewrite (void); void dump_try_for_rewrite (void);
@@ -227,8 +227,8 @@ void dump_throw (operand);
bool dumper_variable_declaration_exists (lit_cpointer_t); bool dumper_variable_declaration_exists (lit_cpointer_t);
void dump_variable_declaration (lit_cpointer_t); void dump_variable_declaration (lit_cpointer_t);
opcode_counter_t dump_scope_code_flags_for_rewrite (void); vm_instr_counter_t dump_scope_code_flags_for_rewrite (void);
void rewrite_scope_code_flags (opcode_counter_t scope_code_flags_oc, void rewrite_scope_code_flags (vm_instr_counter_t scope_code_flags_oc,
opcode_scope_code_flags_t scope_flags); opcode_scope_code_flags_t scope_flags);
void dump_reg_var_decl_for_rewrite (void); void dump_reg_var_decl_for_rewrite (void);
+32 -32
View File
@@ -50,7 +50,7 @@ typedef enum
static token tok; static token tok;
static bool inside_eval = false; static bool inside_eval = false;
static bool inside_function = false; static bool inside_function = false;
static bool parser_show_opcodes = false; static bool parser_show_instrs = false;
enum enum
{ {
@@ -1920,7 +1920,7 @@ jsp_parse_for_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost (fi
// Setup ContinueTarget // Setup ContinueTarget
jsp_label_setup_continue_target (outermost_stmt_label_p, jsp_label_setup_continue_target (outermost_stmt_label_p,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
// Increment // Increment
lexer_seek (increment_loc); lexer_seek (increment_loc);
@@ -2027,7 +2027,7 @@ jsp_parse_for_in_statement_iterator (operand *base_p, /**< out: base value of me
* Note: * Note:
* Layout of generate byte-code is the following: * Layout of generate byte-code is the following:
* tmp <- Collection (Expression) * tmp <- Collection (Expression)
* for_in instruction (tmp, opcode counter of for-in end mark) * for_in instruction (tmp, instruction counter of for-in end mark)
* { * {
* Assignment of OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME to * Assignment of OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME to
* Iterator (VariableDeclarationNoIn / LeftHandSideExpression) * Iterator (VariableDeclarationNoIn / LeftHandSideExpression)
@@ -2081,7 +2081,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost
skip_token (); skip_token ();
// Dump for-in instruction // Dump for-in instruction
opcode_counter_t for_in_oc = dump_for_in_for_rewrite (collection); vm_instr_counter_t for_in_oc = dump_for_in_for_rewrite (collection);
// Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME // Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME
lexer_seek (iterator_loc); lexer_seek (iterator_loc);
@@ -2111,7 +2111,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost
// Setup ContinueTarget // Setup ContinueTarget
jsp_label_setup_continue_target (outermost_stmt_label_p, jsp_label_setup_continue_target (outermost_stmt_label_p,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
// Write position of for-in end to for_in instruction // Write position of for-in end to for_in instruction
rewrite_for_in (for_in_oc); rewrite_for_in (for_in_oc);
@@ -2261,7 +2261,7 @@ parse_do_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (f
parse_statement (NULL); parse_statement (NULL);
jsp_label_setup_continue_target (outermost_stmt_label_p, jsp_label_setup_continue_target (outermost_stmt_label_p,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
token_after_newlines_must_be_keyword (KW_WHILE); token_after_newlines_must_be_keyword (KW_WHILE);
const operand cond = parse_expression_inside_parens (); const operand cond = parse_expression_inside_parens ();
@@ -2290,7 +2290,7 @@ parse_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (firs
parse_statement (NULL); parse_statement (NULL);
jsp_label_setup_continue_target (outermost_stmt_label_p, jsp_label_setup_continue_target (outermost_stmt_label_p,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
rewrite_jump_to_end (); rewrite_jump_to_end ();
@@ -2318,7 +2318,7 @@ parse_with_statement (void)
bool is_raised = jsp_label_raise_nested_jumpable_border (); bool is_raised = jsp_label_raise_nested_jumpable_border ();
opcode_counter_t with_begin_oc = dump_with_for_rewrite (expr); vm_instr_counter_t with_begin_oc = dump_with_for_rewrite (expr);
skip_newlines (); skip_newlines ();
parse_statement (NULL); parse_statement (NULL);
rewrite_with (with_begin_oc); rewrite_with (with_begin_oc);
@@ -2442,7 +2442,7 @@ parse_switch_statement (void)
skip_token (); skip_token ();
jsp_label_rewrite_jumps_and_pop (&label, jsp_label_rewrite_jumps_and_pop (&label,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
finish_dumping_case_clauses (); finish_dumping_case_clauses ();
} }
@@ -2595,7 +2595,7 @@ parse_iterational_statement (jsp_label_t *outermost_named_stmt_label_p) /**< out
} }
jsp_label_rewrite_jumps_and_pop (&label, jsp_label_rewrite_jumps_and_pop (&label,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
} /* parse_iterational_statement */ } /* parse_iterational_statement */
/* statement /* statement
@@ -2831,7 +2831,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
parse_statement (outermost_stmt_label_p != NULL ? outermost_stmt_label_p : &label); parse_statement (outermost_stmt_label_p != NULL ? outermost_stmt_label_p : &label);
jsp_label_rewrite_jumps_and_pop (&label, jsp_label_rewrite_jumps_and_pop (&label,
serializer_get_current_opcode_counter ()); serializer_get_current_instr_counter ());
} }
else else
{ {
@@ -2921,7 +2921,7 @@ preparse_scope (bool is_global)
const locus start_loc = tok.loc; const locus start_loc = tok.loc;
const token_type end_tt = is_global ? TOK_EOF : TOK_CLOSE_BRACE; const token_type end_tt = is_global ? TOK_EOF : TOK_CLOSE_BRACE;
opcode_counter_t scope_code_flags_oc = dump_scope_code_flags_for_rewrite (); vm_instr_counter_t scope_code_flags_oc = dump_scope_code_flags_for_rewrite ();
bool is_use_strict = false; bool is_use_strict = false;
bool is_ref_arguments_identifier = false; bool is_ref_arguments_identifier = false;
@@ -3169,10 +3169,10 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
bool in_eval, /**< flag indicating if we are parsing body of eval code */ bool in_eval, /**< flag indicating if we are parsing body of eval code */
bool is_strict, /**< flag, indicating whether current code bool is_strict, /**< flag, indicating whether current code
* inherited strict mode from code of an outer scope */ * inherited strict mode from code of an outer scope */
const opcode_t **out_opcodes_p) /**< out: generated byte-code array const vm_instr_t **out_instrs_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */ * (in case there were no syntax errors) */
{ {
JERRY_ASSERT (out_opcodes_p != NULL); JERRY_ASSERT (out_instrs_p != NULL);
inside_function = in_function; inside_function = in_function;
inside_eval = in_eval; inside_eval = in_eval;
@@ -3186,7 +3186,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
jsp_mm_init (); jsp_mm_init ();
jsp_label_init (); jsp_label_init ();
serializer_set_show_opcodes (parser_show_opcodes); serializer_set_show_instrs (parser_show_instrs);
dumper_init (); dumper_init ();
jsp_early_error_init (); jsp_early_error_init ();
@@ -3205,7 +3205,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
* Operations that could raise an early error can be performed only during execution of the block. * Operations that could raise an early error can be performed only during execution of the block.
*/ */
lexer_init (source_p, source_size, parser_show_opcodes); lexer_init (source_p, source_size, parser_show_instrs);
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes))); lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
skip_newlines (); skip_newlines ();
@@ -3233,7 +3233,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
jsp_early_error_free (); jsp_early_error_free ();
*out_opcodes_p = serializer_merge_scopes_into_bytecode (); *out_instrs_p = serializer_merge_scopes_into_bytecode ();
dumper_free (); dumper_free ();
@@ -3252,7 +3252,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
JERRY_ASSERT (!is_parse_finished); JERRY_ASSERT (!is_parse_finished);
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
*out_opcodes_p = NULL; *out_instrs_p = NULL;
jsp_label_remove_all_labels (); jsp_label_remove_all_labels ();
jsp_mm_free_all (); jsp_mm_free_all ();
@@ -3286,10 +3286,10 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
jsp_status_t jsp_status_t
parser_parse_script (const jerry_api_char_t *source, /**< source script */ parser_parse_script (const jerry_api_char_t *source, /**< source script */
size_t source_size, /**< source script size it bytes */ size_t source_size, /**< source script size it bytes */
const opcode_t **opcodes_p) /**< out: generated byte-code array const vm_instr_t **out_instrs_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */ * (in case there were no syntax errors) */
{ {
return parser_parse_program (source, source_size, false, false, false, opcodes_p); return parser_parse_program (source, source_size, false, false, false, out_instrs_p);
} /* parser_parse_script */ } /* parser_parse_script */
/** /**
@@ -3303,10 +3303,10 @@ parser_parse_eval (const jerry_api_char_t *source, /**< string passed to eval()
size_t source_size, /**< string size in bytes */ size_t source_size, /**< string size in bytes */
bool is_strict, /**< flag, indicating whether eval is called bool is_strict, /**< flag, indicating whether eval is called
* from strict code in direct mode */ * from strict code in direct mode */
const opcode_t **opcodes_p) /**< out: generated byte-code array const vm_instr_t **out_instrs_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */ * (in case there were no syntax errors) */
{ {
return parser_parse_program (source, source_size, false, true, is_strict, opcodes_p); return parser_parse_program (source, source_size, false, true, is_strict, out_instrs_p);
} /* parser_parse_eval */ } /* parser_parse_eval */
/** /**
@@ -3324,8 +3324,8 @@ parser_parse_new_function (const jerry_api_char_t **params, /**< array of argume
* body) call */ * body) call */
const size_t *params_size, /**< sizes of arguments strings */ const size_t *params_size, /**< sizes of arguments strings */
size_t params_count, /**< total number of arguments passed to new Function (...) */ size_t params_count, /**< total number of arguments passed to new Function (...) */
const opcode_t **out_opcodes_p) /**< out: generated byte-code array const vm_instr_t **out_instrs_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */ * (in case there were no syntax errors) */
{ {
// Process arguments // Process arguments
JERRY_ASSERT (params_count > 0); JERRY_ASSERT (params_count > 0);
@@ -3339,14 +3339,14 @@ parser_parse_new_function (const jerry_api_char_t **params, /**< array of argume
true, true,
false, false,
false, false,
out_opcodes_p); out_instrs_p);
} /* parser_parse_new_function */ } /* parser_parse_new_function */
/** /**
* Tell parser to dump bytecode * Tell parser whether to dump bytecode
*/ */
void void
parser_set_show_opcodes (bool show_opcodes) /**< flag indicating if to dump bytecode */ parser_set_show_instrs (bool show_instrs) /**< flag indicating whether to dump bytecode */
{ {
parser_show_opcodes = show_opcodes; parser_show_instrs = show_instrs;
} /* parser_set_show_opcodes */ } /* parser_set_show_instrs */
+4 -4
View File
@@ -28,9 +28,9 @@ typedef enum
JSP_STATUS_REFERENCE_ERROR /**< ReferenceError early error occured */ JSP_STATUS_REFERENCE_ERROR /**< ReferenceError early error occured */
} jsp_status_t; } jsp_status_t;
void parser_set_show_opcodes (bool); void parser_set_show_instrs (bool);
jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t, const opcode_t **); jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t, const vm_instr_t **);
jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool, const opcode_t **); jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool, const vm_instr_t **);
jsp_status_t parser_parse_new_function (const jerry_api_char_t **, const size_t *, size_t, const opcode_t **); jsp_status_t parser_parse_new_function (const jerry_api_char_t **, const size_t *, size_t, const vm_instr_t **);
#endif /* PARSER_H */ #endif /* PARSER_H */
+58 -58
View File
@@ -20,7 +20,7 @@
#define HASH_SIZE 128 #define HASH_SIZE 128
static hash_table lit_id_to_uid = null_hash; static hash_table lit_id_to_uid = null_hash;
static opcode_counter_t global_oc; static vm_instr_counter_t global_oc;
static idx_t next_uid; static idx_t next_uid;
static void static void
@@ -33,7 +33,7 @@ static idx_t
get_uid (op_meta *op, uint8_t i) get_uid (op_meta *op, uint8_t i)
{ {
JERRY_ASSERT (i < 4); JERRY_ASSERT (i < 4);
raw_opcode *raw = (raw_opcode *) &op->op; raw_instr *raw = (raw_instr *) &op->op;
return raw->uids[i + 1]; return raw->uids[i + 1];
} }
@@ -41,57 +41,57 @@ static void
set_uid (op_meta *op, uint8_t i, idx_t uid) set_uid (op_meta *op, uint8_t i, idx_t uid)
{ {
JERRY_ASSERT (i < 4); JERRY_ASSERT (i < 4);
raw_opcode *raw = (raw_opcode *) &op->op; raw_instr *raw = (raw_instr *) &op->op;
raw->uids[i + 1] = uid; raw->uids[i + 1] = uid;
} }
opcode_counter_t vm_instr_counter_t
scopes_tree_opcodes_num (scopes_tree t) scopes_tree_instrs_num (scopes_tree t)
{ {
assert_tree (t); assert_tree (t);
return t->opcodes_num; return t->instrs_num;
} }
void void
scopes_tree_add_op_meta (scopes_tree tree, op_meta op) scopes_tree_add_op_meta (scopes_tree tree, op_meta op)
{ {
assert_tree (tree); assert_tree (tree);
linked_list_set_element (tree->opcodes, tree->opcodes_num++, &op); linked_list_set_element (tree->instrs, tree->instrs_num++, &op);
} }
void void
scopes_tree_set_op_meta (scopes_tree tree, opcode_counter_t oc, op_meta op) scopes_tree_set_op_meta (scopes_tree tree, vm_instr_counter_t oc, op_meta op)
{ {
assert_tree (tree); assert_tree (tree);
JERRY_ASSERT (oc < tree->opcodes_num); JERRY_ASSERT (oc < tree->instrs_num);
linked_list_set_element (tree->opcodes, oc, &op); linked_list_set_element (tree->instrs, oc, &op);
} }
void void
scopes_tree_set_opcodes_num (scopes_tree tree, opcode_counter_t oc) scopes_tree_set_instrs_num (scopes_tree tree, vm_instr_counter_t oc)
{ {
assert_tree (tree); assert_tree (tree);
JERRY_ASSERT (oc < tree->opcodes_num); JERRY_ASSERT (oc < tree->instrs_num);
tree->opcodes_num = oc; tree->instrs_num = oc;
} }
op_meta op_meta
scopes_tree_op_meta (scopes_tree tree, opcode_counter_t oc) scopes_tree_op_meta (scopes_tree tree, vm_instr_counter_t oc)
{ {
assert_tree (tree); assert_tree (tree);
JERRY_ASSERT (oc < tree->opcodes_num); JERRY_ASSERT (oc < tree->instrs_num);
return *(op_meta *) linked_list_element (tree->opcodes, oc); return *(op_meta *) linked_list_element (tree->instrs, oc);
} }
opcode_counter_t vm_instr_counter_t
scopes_tree_count_opcodes (scopes_tree t) scopes_tree_count_instructions (scopes_tree t)
{ {
assert_tree (t); assert_tree (t);
opcode_counter_t res = t->opcodes_num; vm_instr_counter_t res = t->instrs_num;
for (uint8_t i = 0; i < t->t.children_num; i++) for (uint8_t i = 0; i < t->t.children_num; i++)
{ {
res = (opcode_counter_t) ( res = (vm_instr_counter_t) (
res + scopes_tree_count_opcodes ( res + scopes_tree_count_instructions (
*(scopes_tree *) linked_list_element (t->t.children, i))); *(scopes_tree *) linked_list_element (t->t.children, i)));
} }
return res; return res;
@@ -213,18 +213,18 @@ insert_uids_to_lit_id_map (op_meta *om, uint16_t mask)
} }
static op_meta * static op_meta *
extract_op_meta (scopes_tree tree, opcode_counter_t opc_index) extract_op_meta (scopes_tree tree, vm_instr_counter_t instr_pos)
{ {
return (op_meta *) linked_list_element (tree->opcodes, opc_index); return (op_meta *) linked_list_element (tree->instrs, instr_pos);
} }
static opcode_t static vm_instr_t
generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table *lit_ids) generate_instr (scopes_tree tree, vm_instr_counter_t instr_pos, lit_id_hash_table *lit_ids)
{ {
start_new_block_if_necessary (); start_new_block_if_necessary ();
op_meta *om = extract_op_meta (tree, opc_index); op_meta *om = extract_op_meta (tree, instr_pos);
/* Now we should change uids of opcodes. /* Now we should change uids of instructions.
Since different opcodes has different literals/tmps in different places, Since different instructions has different literals/tmps in different places,
we should change only them. we should change only them.
For each case possible literal positions are shown as 0xYYY literal, For each case possible literal positions are shown as 0xYYY literal,
where Y is set to '1' when there is a possible literal in this position, where Y is set to '1' when there is a possible literal in this position,
@@ -363,11 +363,11 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table
} }
static idx_t static idx_t
count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index) count_new_literals_in_instr (scopes_tree tree, vm_instr_counter_t instr_pos)
{ {
start_new_block_if_necessary (); start_new_block_if_necessary ();
idx_t current_uid = next_uid; idx_t current_uid = next_uid;
op_meta *om = extract_op_meta (tree, opc_index); op_meta *om = extract_op_meta (tree, instr_pos);
switch (om->op.op_idx) switch (om->op.op_idx)
{ {
case VM_OP_PROP_GETTER: case VM_OP_PROP_GETTER:
@@ -517,11 +517,11 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree)
global_oc = 0; global_oc = 0;
assert_tree (tree); assert_tree (tree);
opcode_counter_t opc_index; vm_instr_counter_t instr_pos;
bool header = true; bool header = true;
for (opc_index = 0; opc_index < tree->opcodes_num; opc_index++) for (instr_pos = 0; instr_pos < tree->instrs_num; instr_pos++)
{ {
op_meta *om = extract_op_meta (tree, opc_index); op_meta *om = extract_op_meta (tree, instr_pos);
if (om->op.op_idx != VM_OP_VAR_DECL if (om->op.op_idx != VM_OP_VAR_DECL
&& om->op.op_idx != VM_OP_META && !header) && om->op.op_idx != VM_OP_META && !header)
{ {
@@ -531,15 +531,15 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree)
{ {
header = false; header = false;
} }
result += count_new_literals_in_opcode (tree, opc_index); result += count_new_literals_in_instr (tree, instr_pos);
} }
for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++) for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++)
{ {
result += scopes_tree_count_literals_in_blocks (*(scopes_tree *) linked_list_element (tree->t.children, child_id)); result += scopes_tree_count_literals_in_blocks (*(scopes_tree *) linked_list_element (tree->t.children, child_id));
} }
for (; opc_index < tree->opcodes_num; opc_index++) for (; instr_pos < tree->instrs_num; instr_pos++)
{ {
result += count_new_literals_in_opcode (tree, opc_index); result += count_new_literals_in_instr (tree, instr_pos);
} }
return result; return result;
@@ -555,20 +555,20 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree)
Header and var_decls are dumped first, Header and var_decls are dumped first,
then we shall recursively dump function declaration, then we shall recursively dump function declaration,
and finally, other opcodes. and finally, other instructions.
For each opcodes block (size of block is defined in bytecode-data.h) For each instructions block (size of block is defined in bytecode-data.h)
literal indexes 'hash' table is filled. */ literal indexes 'hash' table is filled. */
static void static void
merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids) merge_subscopes (scopes_tree tree, vm_instr_t *data, lit_id_hash_table *lit_ids)
{ {
assert_tree (tree); assert_tree (tree);
JERRY_ASSERT (data); JERRY_ASSERT (data);
opcode_counter_t opc_index; vm_instr_counter_t instr_pos;
bool header = true; bool header = true;
for (opc_index = 0; opc_index < tree->opcodes_num; opc_index++) for (instr_pos = 0; instr_pos < tree->instrs_num; instr_pos++)
{ {
op_meta *om = extract_op_meta (tree, opc_index); op_meta *om = extract_op_meta (tree, instr_pos);
if (om->op.op_idx != VM_OP_VAR_DECL if (om->op.op_idx != VM_OP_VAR_DECL
&& om->op.op_idx != VM_OP_META && !header) && om->op.op_idx != VM_OP_META && !header)
{ {
@@ -578,7 +578,7 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids)
{ {
header = false; header = false;
} }
data[global_oc] = generate_opcode (tree, opc_index, lit_ids); data[global_oc] = generate_instr (tree, instr_pos, lit_ids);
global_oc++; global_oc++;
} }
for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++) for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++)
@@ -586,9 +586,9 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids)
merge_subscopes (*(scopes_tree *) linked_list_element (tree->t.children, child_id), merge_subscopes (*(scopes_tree *) linked_list_element (tree->t.children, child_id),
data, lit_ids); data, lit_ids);
} }
for (; opc_index < tree->opcodes_num; opc_index++) for (; instr_pos < tree->instrs_num; instr_pos++)
{ {
data[global_oc] = generate_opcode (tree, opc_index, lit_ids); data[global_oc] = generate_instr (tree, instr_pos, lit_ids);
global_oc++; global_oc++;
} }
} }
@@ -596,11 +596,11 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids)
/* Postparser. /* Postparser.
Init literal indexes 'hash' table. Init literal indexes 'hash' table.
Reorder function declarations. Reorder function declarations.
Rewrite opcodes' temporary uids with their keys in literal indexes 'hash' table. */ Rewrite instructions' temporary uids with their keys in literal indexes 'hash' table. */
opcode_t * vm_instr_t *
scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code array */ scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code array */
uint8_t *buffer_p, /**< buffer for byte-code array and literal identifiers hash table */ uint8_t *buffer_p, /**< buffer for byte-code array and literal identifiers hash table */
size_t opcodes_array_size, /**< size of space for byte-code array */ size_t instructions_array_size, /**< size of space for byte-code array */
lit_id_hash_table *lit_ids) /**< literal identifiers hash table */ lit_id_hash_table *lit_ids) /**< literal identifiers hash table */
{ {
JERRY_ASSERT (lit_ids); JERRY_ASSERT (lit_ids);
@@ -614,14 +614,14 @@ scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code
global_oc = 0; global_oc = 0;
/* Dump bytecode and fill literal indexes 'hash' table. */ /* Dump bytecode and fill literal indexes 'hash' table. */
JERRY_ASSERT (opcodes_array_size >= JERRY_ASSERT (instructions_array_size >=
sizeof (opcodes_header_t) + (size_t) (scopes_tree_count_opcodes (tree)) * sizeof (opcode_t)); sizeof (insts_data_header_t) + (size_t) (scopes_tree_count_instructions (tree)) * sizeof (vm_instr_t));
opcodes_header_t *opcodes_data = (opcodes_header_t *) buffer_p; insts_data_header_t *opcodes_data = (insts_data_header_t *) buffer_p;
memset (opcodes_data, 0, opcodes_array_size); memset (opcodes_data, 0, instructions_array_size);
opcode_t *opcodes = (opcode_t *)(((uint8_t*) opcodes_data) + sizeof (opcodes_header_t)); vm_instr_t *instrs = (vm_instr_t *)(((uint8_t*) opcodes_data) + sizeof (insts_data_header_t));
merge_subscopes (tree, opcodes, lit_ids); merge_subscopes (tree, instrs, lit_ids);
if (lit_id_to_uid != null_hash) if (lit_id_to_uid != null_hash)
{ {
hash_table_free (lit_id_to_uid); hash_table_free (lit_id_to_uid);
@@ -630,7 +630,7 @@ scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code
MEM_CP_SET_POINTER (opcodes_data->lit_id_hash_cp, lit_ids); MEM_CP_SET_POINTER (opcodes_data->lit_id_hash_cp, lit_ids);
return opcodes; return instrs;
} /* scopes_tree_raw_data */ } /* scopes_tree_raw_data */
void void
@@ -666,9 +666,9 @@ scopes_tree_init (scopes_tree parent)
JERRY_ASSERT (*(scopes_tree *) added == tree); JERRY_ASSERT (*(scopes_tree *) added == tree);
parent->t.children_num++; parent->t.children_num++;
} }
tree->opcodes_num = 0; tree->instrs_num = 0;
tree->strict_mode = 0; tree->strict_mode = 0;
tree->opcodes = linked_list_init (sizeof (op_meta)); tree->instrs = linked_list_init (sizeof (op_meta));
return tree; return tree;
} }
@@ -684,6 +684,6 @@ scopes_tree_free (scopes_tree tree)
} }
linked_list_free (tree->t.children); linked_list_free (tree->t.children);
} }
linked_list_free (tree->opcodes); linked_list_free (tree->instrs);
jsp_mm_free (tree); jsp_mm_free (tree);
} }
+9 -9
View File
@@ -29,7 +29,7 @@
typedef struct typedef struct
{ {
lit_cpointer_t lit_id[3]; lit_cpointer_t lit_id[3];
opcode_t op; vm_instr_t op;
} op_meta; } op_meta;
typedef struct tree_header typedef struct tree_header
@@ -42,8 +42,8 @@ typedef struct tree_header
typedef struct typedef struct
{ {
tree_header t; tree_header t;
linked_list opcodes; linked_list instrs;
opcode_counter_t opcodes_num; vm_instr_counter_t instrs_num;
unsigned strict_mode:1; unsigned strict_mode:1;
} scopes_tree_int; } scopes_tree_int;
@@ -51,14 +51,14 @@ typedef scopes_tree_int * scopes_tree;
scopes_tree scopes_tree_init (scopes_tree); scopes_tree scopes_tree_init (scopes_tree);
void scopes_tree_free (scopes_tree); void scopes_tree_free (scopes_tree);
opcode_counter_t scopes_tree_opcodes_num (scopes_tree); vm_instr_counter_t scopes_tree_instrs_num (scopes_tree);
void scopes_tree_add_op_meta (scopes_tree, op_meta); void scopes_tree_add_op_meta (scopes_tree, op_meta);
void scopes_tree_set_op_meta (scopes_tree, opcode_counter_t, op_meta); void scopes_tree_set_op_meta (scopes_tree, vm_instr_counter_t, op_meta);
void scopes_tree_set_opcodes_num (scopes_tree, opcode_counter_t); void scopes_tree_set_instrs_num (scopes_tree, vm_instr_counter_t);
op_meta scopes_tree_op_meta (scopes_tree, opcode_counter_t); op_meta scopes_tree_op_meta (scopes_tree, vm_instr_counter_t);
size_t scopes_tree_count_literals_in_blocks (scopes_tree); size_t scopes_tree_count_literals_in_blocks (scopes_tree);
opcode_counter_t scopes_tree_count_opcodes (scopes_tree); vm_instr_counter_t scopes_tree_count_instructions (scopes_tree);
opcode_t *scopes_tree_raw_data (scopes_tree, uint8_t *, size_t, lit_id_hash_table *); vm_instr_t *scopes_tree_raw_data (scopes_tree, uint8_t *, size_t, lit_id_hash_table *);
void scopes_tree_set_strict_mode (scopes_tree, bool); void scopes_tree_set_strict_mode (scopes_tree, bool);
bool scopes_tree_strict_mode (scopes_tree); bool scopes_tree_strict_mode (scopes_tree);
+57 -57
View File
@@ -20,14 +20,14 @@
static bytecode_data_t bytecode_data; static bytecode_data_t bytecode_data;
static scopes_tree current_scope; static scopes_tree current_scope;
static bool print_opcodes; static bool print_instrs;
static void static void
serializer_print_opcodes (const opcode_t *opcodes_p, serializer_print_instrs (const vm_instr_t *instrs_p,
size_t opcodes_count); size_t instrs_count);
op_meta op_meta
serializer_get_op_meta (opcode_counter_t oc) serializer_get_op_meta (vm_instr_counter_t oc)
{ {
JERRY_ASSERT (current_scope); JERRY_ASSERT (current_scope);
return scopes_tree_op_meta (current_scope, oc); return scopes_tree_op_meta (current_scope, oc);
@@ -38,22 +38,22 @@ serializer_get_op_meta (opcode_counter_t oc)
* *
* @return byte-code instruction * @return byte-code instruction
*/ */
opcode_t vm_instr_t
serializer_get_opcode (const opcode_t *opcodes_p, /**< pointer to byte-code array (or NULL, serializer_get_instr (const vm_instr_t *instrs_p, /**< pointer to byte-code array (or NULL,
* if instruction should be taken from * if instruction should be taken from
* instruction list of current scope) */ * instruction list of current scope) */
opcode_counter_t oc) /**< opcode counter of the intruction */ vm_instr_counter_t oc) /**< position of the intruction */
{ {
if (opcodes_p == NULL) if (instrs_p == NULL)
{ {
return serializer_get_op_meta (oc).op; return serializer_get_op_meta (oc).op;
} }
else else
{ {
JERRY_ASSERT (oc < GET_BYTECODE_HEADER (opcodes_p)->instructions_number); JERRY_ASSERT (oc < GET_BYTECODE_HEADER (instrs_p)->instructions_number);
return opcodes_p[oc]; return instrs_p[oc];
} }
} /* serializer_get_opcode */ } /* serializer_get_instr */
/** /**
* Convert literal id (operand value of instruction) to compressed pointer to literal * Convert literal id (operand value of instruction) to compressed pointer to literal
@@ -66,10 +66,10 @@ serializer_get_opcode (const opcode_t *opcodes_p, /**< pointer to byte-code arra
*/ */
lit_cpointer_t lit_cpointer_t
serializer_get_literal_cp_by_uid (uint8_t id, /**< literal idx */ serializer_get_literal_cp_by_uid (uint8_t id, /**< literal idx */
const opcode_t *opcodes_p, /**< pointer to bytecode */ const vm_instr_t *instrs_p, /**< pointer to bytecode */
opcode_counter_t oc) /**< position in the bytecode */ vm_instr_counter_t oc) /**< position in the bytecode */
{ {
lit_id_hash_table *lit_id_hash = GET_HASH_TABLE_FOR_BYTECODE (opcodes_p == NULL ? bytecode_data.opcodes : opcodes_p); lit_id_hash_table *lit_id_hash = GET_HASH_TABLE_FOR_BYTECODE (instrs_p == NULL ? bytecode_data.instrs_p : instrs_p);
if (lit_id_hash == null_hash) if (lit_id_hash == null_hash)
{ {
return INVALID_LITERAL; return INVALID_LITERAL;
@@ -89,84 +89,84 @@ serializer_set_scope (scopes_tree new_scope)
current_scope = new_scope; current_scope = new_scope;
} }
const opcode_t * const vm_instr_t *
serializer_merge_scopes_into_bytecode (void) serializer_merge_scopes_into_bytecode (void)
{ {
bytecode_data.opcodes_count = scopes_tree_count_opcodes (current_scope); bytecode_data.instrs_count = scopes_tree_count_instructions (current_scope);
const size_t buckets_count = scopes_tree_count_literals_in_blocks (current_scope); const size_t buckets_count = scopes_tree_count_literals_in_blocks (current_scope);
const size_t blocks_count = (size_t) bytecode_data.opcodes_count / BLOCK_SIZE + 1; const size_t blocks_count = (size_t) bytecode_data.instrs_count / BLOCK_SIZE + 1;
const opcode_counter_t opcodes_count = scopes_tree_count_opcodes (current_scope); const vm_instr_counter_t instrs_count = scopes_tree_count_instructions (current_scope);
const size_t opcodes_array_size = JERRY_ALIGNUP (sizeof (opcodes_header_t) + opcodes_count * sizeof (opcode_t), const size_t bytecode_array_size = JERRY_ALIGNUP (sizeof (insts_data_header_t) + instrs_count * sizeof (vm_instr_t),
MEM_ALIGNMENT); MEM_ALIGNMENT);
const size_t lit_id_hash_table_size = JERRY_ALIGNUP (lit_id_hash_table_get_size_for_table (buckets_count, const size_t lit_id_hash_table_size = JERRY_ALIGNUP (lit_id_hash_table_get_size_for_table (buckets_count,
blocks_count), blocks_count),
MEM_ALIGNMENT); MEM_ALIGNMENT);
uint8_t *buffer_p = (uint8_t*) mem_heap_alloc_block (opcodes_array_size + lit_id_hash_table_size, uint8_t *buffer_p = (uint8_t*) mem_heap_alloc_block (bytecode_array_size + lit_id_hash_table_size,
MEM_HEAP_ALLOC_LONG_TERM); MEM_HEAP_ALLOC_LONG_TERM);
lit_id_hash_table *lit_id_hash = lit_id_hash_table_init (buffer_p + opcodes_array_size, lit_id_hash_table *lit_id_hash = lit_id_hash_table_init (buffer_p + bytecode_array_size,
lit_id_hash_table_size, lit_id_hash_table_size,
buckets_count, blocks_count); buckets_count, blocks_count);
const opcode_t *opcodes_p = scopes_tree_raw_data (current_scope, buffer_p, opcodes_array_size, lit_id_hash); const vm_instr_t *instrs_p = scopes_tree_raw_data (current_scope, buffer_p, bytecode_array_size, lit_id_hash);
opcodes_header_t *header_p = (opcodes_header_t*) buffer_p; insts_data_header_t *header_p = (insts_data_header_t*) buffer_p;
MEM_CP_SET_POINTER (header_p->next_opcodes_cp, bytecode_data.opcodes); MEM_CP_SET_POINTER (header_p->next_instrs_cp, bytecode_data.instrs_p);
header_p->instructions_number = opcodes_count; header_p->instructions_number = instrs_count;
bytecode_data.opcodes = opcodes_p; bytecode_data.instrs_p = instrs_p;
if (print_opcodes) if (print_instrs)
{ {
lit_dump_literals (); lit_dump_literals ();
serializer_print_opcodes (opcodes_p, bytecode_data.opcodes_count); serializer_print_instrs (instrs_p, bytecode_data.instrs_count);
} }
return opcodes_p; return instrs_p;
} }
void void
serializer_dump_op_meta (op_meta op) serializer_dump_op_meta (op_meta op)
{ {
JERRY_ASSERT (scopes_tree_opcodes_num (current_scope) < MAX_OPCODES); JERRY_ASSERT (scopes_tree_instrs_num (current_scope) < MAX_OPCODES);
scopes_tree_add_op_meta (current_scope, op); scopes_tree_add_op_meta (current_scope, op);
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
if (print_opcodes) if (print_instrs)
{ {
pp_op_meta (NULL, (opcode_counter_t) (scopes_tree_opcodes_num (current_scope) - 1), op, false); pp_op_meta (NULL, (vm_instr_counter_t) (scopes_tree_instrs_num (current_scope) - 1), op, false);
} }
#endif #endif
} }
opcode_counter_t vm_instr_counter_t
serializer_get_current_opcode_counter (void) serializer_get_current_instr_counter (void)
{ {
return scopes_tree_opcodes_num (current_scope); return scopes_tree_instrs_num (current_scope);
} }
opcode_counter_t vm_instr_counter_t
serializer_count_opcodes_in_subscopes (void) serializer_count_instrs_in_subscopes (void)
{ {
return (opcode_counter_t) (scopes_tree_count_opcodes (current_scope) - scopes_tree_opcodes_num (current_scope)); return (vm_instr_counter_t) (scopes_tree_count_instructions (current_scope) - scopes_tree_instrs_num (current_scope));
} }
void void
serializer_set_writing_position (opcode_counter_t oc) serializer_set_writing_position (vm_instr_counter_t oc)
{ {
scopes_tree_set_opcodes_num (current_scope, oc); scopes_tree_set_instrs_num (current_scope, oc);
} }
void void
serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op) serializer_rewrite_op_meta (const vm_instr_counter_t loc, op_meta op)
{ {
scopes_tree_set_op_meta (current_scope, loc, op); scopes_tree_set_op_meta (current_scope, loc, op);
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
if (print_opcodes) if (print_instrs)
{ {
pp_op_meta (NULL, loc, op, true); pp_op_meta (NULL, loc, op, true);
} }
@@ -174,25 +174,25 @@ serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op)
} }
static void static void
serializer_print_opcodes (const opcode_t *opcodes_p, serializer_print_instrs (const vm_instr_t *instrs_p,
size_t opcodes_count) size_t instrs_count)
{ {
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
for (opcode_counter_t loc = 0; loc < opcodes_count; loc++) for (vm_instr_counter_t loc = 0; loc < instrs_count; loc++)
{ {
op_meta opm; op_meta opm;
opm.op = opcodes_p[loc]; opm.op = instrs_p[loc];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
opm.lit_id[i] = NOT_A_LITERAL; opm.lit_id[i] = NOT_A_LITERAL;
} }
pp_op_meta (opcodes_p, loc, opm, false); pp_op_meta (instrs_p, loc, opm, false);
} }
#else #else
(void) opcodes_p; (void) instrs_p;
(void) opcodes_count; (void) instrs_count;
#endif #endif
} }
@@ -200,17 +200,17 @@ void
serializer_init () serializer_init ()
{ {
current_scope = NULL; current_scope = NULL;
print_opcodes = false; print_instrs = false;
bytecode_data.strings_buffer = NULL; bytecode_data.strings_buffer = NULL;
bytecode_data.opcodes = NULL; bytecode_data.instrs_p = NULL;
lit_init (); lit_init ();
} }
void serializer_set_show_opcodes (bool show_opcodes) void serializer_set_show_instrs (bool show_instrs)
{ {
print_opcodes = show_opcodes; print_instrs = show_instrs;
} }
void void
@@ -223,10 +223,10 @@ serializer_free (void)
lit_finalize (); lit_finalize ();
while (bytecode_data.opcodes != NULL) while (bytecode_data.instrs_p != NULL)
{ {
opcodes_header_t *header_p = GET_BYTECODE_HEADER (bytecode_data.opcodes); insts_data_header_t *header_p = GET_BYTECODE_HEADER (bytecode_data.instrs_p);
bytecode_data.opcodes = MEM_CP_GET_POINTER (opcode_t, header_p->next_opcodes_cp); bytecode_data.instrs_p = MEM_CP_GET_POINTER (vm_instr_t, header_p->next_instrs_cp);
mem_heap_free_block (header_p); mem_heap_free_block (header_p);
} }
+9 -9
View File
@@ -23,18 +23,18 @@
#include "scopes-tree.h" #include "scopes-tree.h"
void serializer_init (); void serializer_init ();
void serializer_set_show_opcodes (bool show_opcodes); void serializer_set_show_instrs (bool show_instrs);
op_meta serializer_get_op_meta (opcode_counter_t); op_meta serializer_get_op_meta (vm_instr_counter_t);
opcode_t serializer_get_opcode (const opcode_t*, opcode_counter_t); vm_instr_t serializer_get_instr (const vm_instr_t*, vm_instr_counter_t);
lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t, const opcode_t*, opcode_counter_t); lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t, const vm_instr_t*, vm_instr_counter_t);
void serializer_set_strings_buffer (const ecma_char_t *); void serializer_set_strings_buffer (const ecma_char_t *);
void serializer_set_scope (scopes_tree); void serializer_set_scope (scopes_tree);
const opcode_t *serializer_merge_scopes_into_bytecode (void); const vm_instr_t *serializer_merge_scopes_into_bytecode (void);
void serializer_dump_op_meta (op_meta); void serializer_dump_op_meta (op_meta);
opcode_counter_t serializer_get_current_opcode_counter (void); vm_instr_counter_t serializer_get_current_instr_counter (void);
opcode_counter_t serializer_count_opcodes_in_subscopes (void); vm_instr_counter_t serializer_count_instrs_in_subscopes (void);
void serializer_set_writing_position (opcode_counter_t); void serializer_set_writing_position (vm_instr_counter_t);
void serializer_rewrite_op_meta (opcode_counter_t, op_meta); void serializer_rewrite_op_meta (vm_instr_counter_t, op_meta);
void serializer_free (void); void serializer_free (void);
#endif // SERIALIZER_H #endif // SERIALIZER_H
+36 -36
View File
@@ -20,16 +20,16 @@
* 'Jump down if true' opcode handler. * 'Jump down if true' opcode handler.
* *
* Note: * Note:
* current opcode's position changes by adding specified offset * current instruction's position changes by adding specified offset
* if argument evaluates to true. * if argument evaluates to true.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t cond_var_idx = opdata.data.is_true_jmp_down.value; const idx_t cond_var_idx = instr.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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_down.oc_idx_1,
opdata.data.is_true_jmp_down.opcode_2); instr.data.is_true_jmp_down.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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)) if (ecma_is_completion_value_normal_true (to_bool_completion))
{ {
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES); 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 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. */ /* Likewise to opfunc_is_true_jmp_down, but jumps up. */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t cond_var_idx = opdata.data.is_true_jmp_up.value; const idx_t cond_var_idx = instr.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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_up.oc_idx_1,
opdata.data.is_true_jmp_up.opcode_2); instr.data.is_true_jmp_up.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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)) if (ecma_is_completion_value_normal_true (to_bool_completion))
{ {
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); 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 else
{ {
@@ -92,16 +92,16 @@ opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */
* 'Jump down if false' opcode handler. * 'Jump down if false' opcode handler.
* *
* Note: * Note:
* current opcode's position changes by adding specified offset * current instruction's position changes by adding specified offset
* if argument evaluates to false. * if argument evaluates to false.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t cond_var_idx = opdata.data.is_false_jmp_down.value; const idx_t cond_var_idx = instr.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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_down.oc_idx_1,
opdata.data.is_false_jmp_down.opcode_2); instr.data.is_false_jmp_down.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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)) if (!ecma_is_completion_value_normal_true (to_bool_completion))
{ {
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES); 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 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. */ /* Likewise to opfunc_is_false_jmp_down, but jumps up. */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t cond_var_idx = opdata.data.is_false_jmp_up.value; const idx_t cond_var_idx = instr.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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_up.oc_idx_1,
opdata.data.is_false_jmp_up.opcode_2); instr.data.is_false_jmp_up.oc_idx_2);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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)) if (!ecma_is_completion_value_normal_true (to_bool_completion))
{ {
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); 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 else
{ {
@@ -164,18 +164,18 @@ opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */
* 'Jump down' opcode handler. * 'Jump down' opcode handler.
* *
* Note: * 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 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 */ 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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1,
opdata.data.jmp_down.opcode_2); instr.data.jmp_down.oc_idx_2);
JERRY_ASSERT (((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES)); 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 (); return ecma_make_empty_completion_value ();
} }
@@ -184,17 +184,17 @@ opfunc_jmp_down (opcode_t opdata, /**< operation data */
* 'Jump up' opcode handler. * 'Jump up' opcode handler.
* *
* Note: * 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 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 */ 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, const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_up.oc_idx_1,
opdata.data.jmp_up.opcode_2); instr.data.jmp_up.oc_idx_2);
JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); 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 (); 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 * the opcode returns break-continue completion value with jump target
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
opcode_counter_t target = frame_ctx_p->pos; vm_instr_counter_t target = frame_ctx_p->pos;
target = (opcode_counter_t) (target + calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1, target = (vm_instr_counter_t) (target + vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1,
opdata.data.jmp_down.opcode_2)); instr.data.jmp_down.oc_idx_2));
return ecma_make_jump_completion_value (target); return ecma_make_jump_completion_value (target);
} /* opfunc_jmp_break_continue */ } /* 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.addition.dst; const idx_t dst_var_idx = instr.data.addition.dst;
const idx_t left_var_idx = opdata.data.addition.var_left; const idx_t left_var_idx = instr.data.addition.var_left;
const idx_t right_var_idx = opdata.data.addition.var_right; const idx_t right_var_idx = instr.data.addition.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.substraction.dst; const idx_t dst_var_idx = instr.data.substraction.dst;
const idx_t left_var_idx = opdata.data.substraction.var_left; const idx_t left_var_idx = instr.data.substraction.var_left;
const idx_t right_var_idx = opdata.data.substraction.var_right; const idx_t right_var_idx = instr.data.substraction.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.multiplication.dst; const idx_t dst_var_idx = instr.data.multiplication.dst;
const idx_t left_var_idx = opdata.data.multiplication.var_left; const idx_t left_var_idx = instr.data.multiplication.var_left;
const idx_t right_var_idx = opdata.data.multiplication.var_right; const idx_t right_var_idx = instr.data.multiplication.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.division.dst; const idx_t dst_var_idx = instr.data.division.dst;
const idx_t left_var_idx = opdata.data.division.var_left; const idx_t left_var_idx = instr.data.division.var_left;
const idx_t right_var_idx = opdata.data.division.var_right; const idx_t right_var_idx = instr.data.division.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.remainder.dst; const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t left_var_idx = opdata.data.remainder.var_left; const idx_t left_var_idx = instr.data.remainder.var_left;
const idx_t right_var_idx = opdata.data.remainder.var_right; const idx_t right_var_idx = instr.data.remainder.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.remainder.dst; const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t var_idx = opdata.data.remainder.var_left; const idx_t var_idx = instr.data.remainder.var_left;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.remainder.dst; const idx_t dst_var_idx = instr.data.remainder.dst;
const idx_t var_idx = opdata.data.remainder.var_left; const idx_t var_idx = instr.data.remainder.var_left;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_and.dst; const idx_t dst_var_idx = instr.data.b_and.dst;
const idx_t left_var_idx = opdata.data.b_and.var_left; const idx_t left_var_idx = instr.data.b_and.var_left;
const idx_t right_var_idx = opdata.data.b_and.var_right; const idx_t right_var_idx = instr.data.b_and.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_or.dst; const idx_t dst_var_idx = instr.data.b_or.dst;
const idx_t left_var_idx = opdata.data.b_or.var_left; const idx_t left_var_idx = instr.data.b_or.var_left;
const idx_t right_var_idx = opdata.data.b_or.var_right; const idx_t right_var_idx = instr.data.b_or.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_xor.dst; const idx_t dst_var_idx = instr.data.b_xor.dst;
const idx_t left_var_idx = opdata.data.b_xor.var_left; const idx_t left_var_idx = instr.data.b_xor.var_left;
const idx_t right_var_idx = opdata.data.b_xor.var_right; const idx_t right_var_idx = instr.data.b_xor.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_shift_left.dst; const idx_t dst_var_idx = instr.data.b_shift_left.dst;
const idx_t left_var_idx = opdata.data.b_shift_left.var_left; const idx_t left_var_idx = instr.data.b_shift_left.var_left;
const idx_t right_var_idx = opdata.data.b_shift_left.var_right; const idx_t right_var_idx = instr.data.b_shift_left.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_shift_right.dst; const idx_t dst_var_idx = instr.data.b_shift_right.dst;
const idx_t left_var_idx = opdata.data.b_shift_right.var_left; const idx_t left_var_idx = instr.data.b_shift_right.var_left;
const idx_t right_var_idx = opdata.data.b_shift_right.var_right; const idx_t right_var_idx = instr.data.b_shift_right.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_shift_uright.dst; const idx_t dst_var_idx = instr.data.b_shift_uright.dst;
const idx_t left_var_idx = opdata.data.b_shift_uright.var_left; const idx_t left_var_idx = instr.data.b_shift_uright.var_left;
const idx_t right_var_idx = opdata.data.b_shift_uright.var_right; const idx_t right_var_idx = instr.data.b_shift_uright.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.b_not.dst; const idx_t dst_var_idx = instr.data.b_not.dst;
const idx_t right_var_idx = opdata.data.b_not.var_right; const idx_t right_var_idx = instr.data.b_not.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.equal_value.dst; const idx_t dst_var_idx = instr.data.equal_value.dst;
const idx_t left_var_idx = opdata.data.equal_value.var_left; const idx_t left_var_idx = instr.data.equal_value.var_left;
const idx_t right_var_idx = opdata.data.equal_value.var_right; const idx_t right_var_idx = instr.data.equal_value.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.not_equal_value.dst; const idx_t dst_var_idx = instr.data.not_equal_value.dst;
const idx_t left_var_idx = opdata.data.not_equal_value.var_left; const idx_t left_var_idx = instr.data.not_equal_value.var_left;
const idx_t right_var_idx = opdata.data.not_equal_value.var_right; const idx_t right_var_idx = instr.data.not_equal_value.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.equal_value_type.dst; const idx_t dst_var_idx = instr.data.equal_value_type.dst;
const idx_t left_var_idx = opdata.data.equal_value_type.var_left; const idx_t left_var_idx = instr.data.equal_value_type.var_left;
const idx_t right_var_idx = opdata.data.equal_value_type.var_right; const idx_t right_var_idx = instr.data.equal_value_type.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ 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 dst_var_idx = instr.data.not_equal_value_type.dst;
const idx_t left_var_idx = opdata.data.not_equal_value_type.var_left; const idx_t left_var_idx = instr.data.not_equal_value_type.var_left;
const idx_t right_var_idx = opdata.data.not_equal_value_type.var_right; 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 (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.less_than.dst; const idx_t dst_var_idx = instr.data.less_than.dst;
const idx_t left_var_idx = opdata.data.less_than.var_left; const idx_t left_var_idx = instr.data.less_than.var_left;
const idx_t right_var_idx = opdata.data.less_than.var_right; const idx_t right_var_idx = instr.data.less_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.greater_than.dst; const idx_t dst_var_idx = instr.data.greater_than.dst;
const idx_t left_var_idx = opdata.data.greater_than.var_left; const idx_t left_var_idx = instr.data.greater_than.var_left;
const idx_t right_var_idx = opdata.data.greater_than.var_right; const idx_t right_var_idx = instr.data.greater_than.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ 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 dst_var_idx = instr.data.less_or_equal_than.dst;
const idx_t left_var_idx = opdata.data.less_or_equal_than.var_left; const idx_t left_var_idx = instr.data.less_or_equal_than.var_left;
const idx_t right_var_idx = opdata.data.less_or_equal_than.var_right; 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 (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ 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 dst_var_idx = instr.data.greater_or_equal_than.dst;
const idx_t left_var_idx = opdata.data.greater_or_equal_than.var_left; const idx_t left_var_idx = instr.data.greater_or_equal_than.var_left;
const idx_t right_var_idx = opdata.data.greater_or_equal_than.var_right; 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 (); 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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{ {
const idx_t dst_idx = opdata.data.instanceof.dst; const idx_t dst_idx = instr.data.instanceof.dst;
const idx_t left_var_idx = opdata.data.instanceof.var_left; const idx_t left_var_idx = instr.data.instanceof.var_left;
const idx_t right_var_idx = opdata.data.instanceof.var_right; const idx_t right_var_idx = instr.data.instanceof.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{ {
const idx_t dst_idx = opdata.data.in.dst; const idx_t dst_idx = instr.data.in.dst;
const idx_t left_var_idx = opdata.data.in.var_left; const idx_t left_var_idx = instr.data.in.var_left;
const idx_t right_var_idx = opdata.data.in.var_right; const idx_t right_var_idx = instr.data.in.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-builtins.h"
#include "ecma-comparison.h" #include "ecma-comparison.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
@@ -35,7 +36,7 @@
bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, idx_t var_idx); 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 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_completion_value_t fill_varg_list (vm_frame_ctx_t *frame_ctx_p,
ecma_length_t args_number, ecma_length_t args_number,
ecma_value_t args_values[], ecma_value_t args_values[],
@@ -27,13 +27,13 @@
* Returned value must be freed with ecma_free_completion_value * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ 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_1 = instr.data.try_block.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.try_block.oc_idx_2; const idx_t block_end_oc_idx_2 = instr.data.try_block.oc_idx_2;
const opcode_counter_t try_end_oc = (opcode_counter_t) ( const vm_instr_counter_t try_end_oc = (vm_instr_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); 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++; 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)); || (ecma_is_completion_value_empty (try_completion) && frame_ctx_p->pos == try_end_oc));
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); vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); 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) ( const vm_instr_counter_t catch_end_oc = (vm_instr_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos); vm_read_instr_counter_from_meta (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++; frame_ctx_p->pos++;
if (ecma_is_completion_value_throw (try_completion)) if (ecma_is_completion_value_throw (try_completion))
{ {
next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER); 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, 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->opcodes_p, frame_ctx_p->instrs_p,
frame_ctx_p->pos); frame_ctx_p->pos);
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; frame_ctx_p->pos = catch_end_oc;
} }
next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); 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) ( const vm_instr_counter_t finally_end_oc = (vm_instr_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos); vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos);
frame_ctx_p->pos++; frame_ctx_p->pos++;
vm_run_scope_t run_scope_finally = { frame_ctx_p->pos, finally_end_oc }; 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++); next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos++);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY); JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
return try_completion; return try_completion;
} /* opfunc_try_block */ } /* 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *int_data_p) /**< interpreter context */
{ {
const idx_t expr_idx = opdata.data.for_in.expr; const idx_t expr_idx = instr.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_1 = instr.data.for_in.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.for_in.oc_idx_2; const idx_t block_end_oc_idx_2 = instr.data.for_in.oc_idx_2;
const opcode_counter_t for_in_end_oc = (opcode_counter_t) ( const vm_instr_counter_t for_in_end_oc = (vm_instr_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1,
block_end_oc_idx_2) + int_data_p->pos); block_end_oc_idx_2) + int_data_p->pos);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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++; int_data_p->pos++;
opcode_t meta_opcode = vm_get_opcode (int_data_p->opcodes_p, for_in_end_oc); vm_instr_t meta_instr = vm_get_instr (int_data_p->instrs_p, for_in_end_oc);
JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META); JERRY_ASSERT (meta_instr.op_idx == VM_OP_META);
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_FOR_IN); JERRY_ASSERT (meta_instr.data.meta.type == OPCODE_META_TYPE_END_FOR_IN);
/* 3. */ /* 3. */
if (!ecma_is_value_undefined (expr_value) 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); ecma_collection_iterator_init (&names_iterator, names_p);
const opcode_counter_t for_in_body_begin_oc = int_data_p->pos; const vm_instr_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_end_oc = for_in_end_oc;
while (ecma_collection_iterator_next (&names_iterator)) while (ecma_collection_iterator_next (&names_iterator))
{ {
@@ -270,7 +270,7 @@ opfunc_for_in (opcode_t opdata, /**< operation data */
ECMA_FINALIZE (obj_expr_value); 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); 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 else
{ {
ecma_string_t var_name_string; 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); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp); 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 ecma_completion_value_t
set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ 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 */ idx_t var_idx, /**< variable identifier */
ecma_value_t value) /**< value to set */ ecma_value_t value) /**< value to set */
{ {
@@ -158,7 +158,7 @@ set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
else else
{ {
ecma_string_t var_name_string; 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); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp); 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. * 'Native call' opcode handler.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.native_call.lhs; const idx_t dst_var_idx = instr.data.native_call.lhs;
const idx_t native_call_id_idx = opdata.data.native_call.name; const idx_t native_call_id_idx = instr.data.native_call.name;
const idx_t args_number = opdata.data.native_call.arg_list; const idx_t args_number = instr.data.native_call.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos; const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
JERRY_ASSERT (native_call_id_idx < OPCODE_NATIVE_CALL__COUNT); 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)) 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); vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG); 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); 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 < params_number;
param_index++) param_index++)
{ {
opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG); 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, const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1,
frame_ctx_p->opcodes_p, frame_ctx_p->instrs_p,
frame_ctx_p->pos); frame_ctx_p->pos);
params_names[param_index] = ecma_new_ecma_string_from_lit_cp (param_name_lit_idx); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.assignment.var_left; const idx_t dst_var_idx = instr.data.assignment.var_left;
const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) opdata.data.assignment.type_value_right; const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) instr.data.assignment.type_value_right;
const idx_t src_val_descr = opdata.data.assignment.value_right; const idx_t src_val_descr = instr.data.assignment.value_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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) 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); ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
ret_value = set_variable_value (frame_ctx_p, 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; 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); literal_t lit = lit_get_literal_by_cp (lit_cp);
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); 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; 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); literal_t lit = lit_get_literal_by_cp (lit_cp);
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); 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 #ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, 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); frame_ctx_p->pos);
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.pre_incr.dst; const idx_t dst_var_idx = instr.data.pre_incr.dst;
const idx_t incr_var_idx = opdata.data.pre_incr.var_right; const idx_t incr_var_idx = instr.data.pre_incr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.pre_decr.dst; const idx_t dst_var_idx = instr.data.pre_decr.dst;
const idx_t decr_var_idx = opdata.data.pre_decr.var_right; const idx_t decr_var_idx = instr.data.pre_decr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.post_incr.dst; const idx_t dst_var_idx = instr.data.post_incr.dst;
const idx_t incr_var_idx = opdata.data.post_incr.var_right; const idx_t incr_var_idx = instr.data.post_incr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.post_decr.dst; const idx_t dst_var_idx = instr.data.post_decr.dst;
const idx_t decr_var_idx = opdata.data.post_decr.var_right; const idx_t decr_var_idx = instr.data.post_decr.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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. * The opcode is meta-opcode that is not supposed to be executed.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{ {
JERRY_UNREACHABLE (); 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. * However, ecma_free_completion_value may be called for it, but it is a no-op.
*/ */
ecma_completion_value_t 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 */ 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, lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (instr.data.var_decl.variable_name,
frame_ctx_p->opcodes_p, frame_ctx_p->instrs_p,
frame_ctx_p->pos); frame_ctx_p->pos);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); 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; bool do_instantiate_arguments_object = true;
const bool is_configurable_bindings = frame_ctx_p->is_eval_code; const bool is_configurable_bindings = frame_ctx_p->is_eval_code;
const opcode_counter_t function_code_end_oc = (opcode_counter_t) ( const vm_instr_counter_t function_code_end_oc = (vm_instr_counter_t) (
read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos); vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos);
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) 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, ecma_completion_value_t ret_value = ecma_op_function_declaration (frame_ctx_p->lex_env_p,
function_name_string_p, function_name_string_p,
frame_ctx_p->opcodes_p, frame_ctx_p->instrs_p,
frame_ctx_p->pos, frame_ctx_p->pos,
args_names, args_names,
args_number, 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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx; const idx_t function_name_idx = instr.data.func_decl_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_decl_n.arg_list; 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, 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);
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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ 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++; frame_ctx_p->pos++;
const idx_t dst_var_idx = opdata.data.func_expr_n.lhs; const idx_t dst_var_idx = instr.data.func_expr_n.lhs;
const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx; const idx_t function_name_lit_idx = instr.data.func_expr_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_expr_n.arg_list; 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); const bool is_named_func_expr = (function_name_lit_idx != INVALID_VALUE);
ecma_completion_value_t ret_value = ecma_make_empty_completion_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*); 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 is_strict = frame_ctx_p->is_strict;
bool do_instantiate_arguments_object = true; bool do_instantiate_arguments_object = true;
function_code_end_oc = (opcode_counter_t) (read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, 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) + frame_ctx_p->pos);
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++); frame_ctx_p->pos++);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) 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); 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, 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); lit_oc);
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
@@ -639,7 +639,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
scope_p, scope_p,
is_strict, is_strict,
do_instantiate_arguments_object, do_instantiate_arguments_object,
frame_ctx_p->opcodes_p, frame_ctx_p->instrs_p,
frame_ctx_p->pos); frame_ctx_p->pos);
ret_value = set_variable_value (frame_ctx_p, lit_oc, 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 static ecma_value_t
vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< interpreter context */ 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 vm_instr_counter_t var_idx_lit_oc, /**< instruction counter of instruction
* instruction with function_var_idx */ with var_idx */
idx_t var_idx, /**< idx, used to retrieve the called function object */ idx_t var_idx, /**< idx, used to retrieve the called function object */
opcode_call_flags_t *out_flags_p) /**< out: call flags */ 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; opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY;
idx_t this_arg_var_idx = INVALID_VALUE; 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 if (next_opcode.op_idx == VM_OP_META
&& next_opcode.data.meta.type == OPCODE_META_TYPE_CALL_SITE_INFO) && 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 */ /* 6.b.i */
ecma_string_t var_name_string; 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_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, 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. * Returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t lhs_var_idx = opdata.data.call_n.lhs; const idx_t lhs_var_idx = instr.data.call_n.lhs;
const idx_t function_var_idx = opdata.data.call_n.function_var_idx; const idx_t function_var_idx = instr.data.call_n.function_var_idx;
const idx_t args_number_idx = opdata.data.call_n.arg_list; const idx_t args_number_idx = instr.data.call_n.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos; const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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. * Returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t lhs_var_idx = opdata.data.construct_n.lhs; const idx_t lhs_var_idx = instr.data.construct_n.lhs;
const idx_t constructor_name_lit_idx = opdata.data.construct_n.name_lit_idx; const idx_t constructor_name_lit_idx = instr.data.construct_n.name_lit_idx;
const idx_t args_number = opdata.data.construct_n.arg_list; const idx_t args_number = instr.data.construct_n.arg_list;
const opcode_counter_t lit_oc = frame_ctx_p->pos; const vm_instr_counter_t lit_oc = frame_ctx_p->pos;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (constructor_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. * Returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t lhs_var_idx = opdata.data.array_decl.lhs; const idx_t lhs_var_idx = instr.data.array_decl.lhs;
const idx_t args_number = opdata.data.array_decl.list; const idx_t args_number = instr.data.array_decl.list;
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++; 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. * Returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t lhs_var_idx = opdata.data.obj_decl.lhs; const idx_t lhs_var_idx = instr.data.obj_decl.lhs;
const idx_t args_number = opdata.data.obj_decl.list; const idx_t args_number = instr.data.obj_decl.list;
const opcode_counter_t obj_lit_oc = frame_ctx_p->pos; const vm_instr_counter_t obj_lit_oc = frame_ctx_p->pos;
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)) 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); JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type; 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. * However, ecma_free_completion_value may be called for it, but it is a no-op.
*/ */
ecma_completion_value_t 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 */ 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)); 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. * However, ecma_free_completion_value may be called for it, but it is a no-op.
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */
{ {
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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)); 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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ 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 lhs_var_idx = instr.data.prop_getter.lhs;
const idx_t base_var_idx = opdata.data.prop_getter.obj; const idx_t base_var_idx = instr.data.prop_getter.obj;
const idx_t prop_name_var_idx = opdata.data.prop_getter.prop; const idx_t prop_name_var_idx = instr.data.prop_getter.prop;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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. * returned value must be freed with ecma_free_completion_value.
*/ */
ecma_completion_value_t 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 */ 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 base_var_idx = instr.data.prop_setter.obj;
const idx_t prop_name_var_idx = opdata.data.prop_setter.prop; const idx_t prop_name_var_idx = instr.data.prop_setter.prop;
const idx_t rhs_var_idx = opdata.data.prop_setter.rhs; const idx_t rhs_var_idx = instr.data.prop_setter.rhs;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.logical_not.dst; const idx_t dst_var_idx = instr.data.logical_not.dst;
const idx_t right_var_idx = opdata.data.logical_not.var_right; const idx_t right_var_idx = instr.data.logical_not.var_right;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.this_binding.lhs; const idx_t dst_var_idx = instr.data.this_binding.lhs;
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++; 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t expr_var_idx = opdata.data.with.expr; const idx_t expr_var_idx = instr.data.with.expr;
const idx_t block_end_oc_idx_1 = opdata.data.with.oc_idx_1; const idx_t block_end_oc_idx_1 = instr.data.with.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.with.oc_idx_2; const idx_t block_end_oc_idx_2 = instr.data.with.oc_idx_2;
const opcode_counter_t with_end_oc = (opcode_counter_t) ( const vm_instr_counter_t with_end_oc = (vm_instr_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); 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 (); 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; frame_ctx_p->lex_env_p = new_env_p;
#ifndef JERRY_NDEBUG #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.op_idx == VM_OP_META);
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH); JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH);
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
@@ -1474,10 +1474,10 @@ opfunc_with (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ 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 (); 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 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); 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); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.typeof.lhs; const idx_t dst_var_idx = instr.data.typeof.lhs;
const idx_t obj_var_idx = opdata.data.typeof.obj; const idx_t obj_var_idx = instr.data.typeof.obj;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.delete_var.lhs; const idx_t dst_var_idx = instr.data.delete_var.lhs;
const idx_t name_lit_idx = opdata.data.delete_var.name; const idx_t name_lit_idx = instr.data.delete_var.name;
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++; frame_ctx_p->pos++;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); 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 * Returned value must be freed with ecma_free_completion_value
*/ */
ecma_completion_value_t 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 */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{ {
const idx_t dst_var_idx = opdata.data.delete_prop.lhs; const idx_t dst_var_idx = instr.data.delete_prop.lhs;
const idx_t base_var_idx = opdata.data.delete_prop.base; const idx_t base_var_idx = instr.data.delete_prop.base;
const idx_t name_var_idx = opdata.data.delete_prop.name; const idx_t name_var_idx = instr.data.delete_prop.name;
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); 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 * @return implementation-defined meta completion value
*/ */
ecma_completion_value_t 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 */ 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) switch (type)
{ {
@@ -1797,73 +1797,73 @@ opfunc_meta (opcode_t opdata, /**< operation data */
} /* opfunc_meta */ } /* 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 vm_instr_counter_t
calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */ vm_calc_instr_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */
const idx_t oc_idx_2) /**< second idx */ const idx_t oc_idx_2) /**< second idx */
{ {
opcode_counter_t counter; vm_instr_counter_t counter;
counter = oc_idx_1; counter = oc_idx_1;
counter = (opcode_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE)); counter = (vm_instr_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE));
counter = (opcode_counter_t) (counter | oc_idx_2); counter = (vm_instr_counter_t) (counter | oc_idx_2);
return counter; return counter;
} /* calc_meta_opcode_counter_from_meta_data */ } /* vm_calc_instr_counter_from_idx_idx */
/** /**
* Read opcode counter from current opcode, * Read instruction counter from current instruction,
* that should be 'meta' opcode of type 'opcode counter'. * that should be 'meta' instruction of specified type.
*/ */
opcode_counter_t vm_instr_counter_t
read_meta_opcode_counter (opcode_meta_type expected_type, /**< expected type of meta opcode */ 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 */ 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); JERRY_ASSERT (meta_opcode.data.meta.type == expected_type);
const idx_t data_1 = meta_opcode.data.meta.data_1; const idx_t data_1 = meta_opcode.data.meta.data_1;
const idx_t data_2 = meta_opcode.data.meta.data_2; const idx_t data_2 = meta_opcode.data.meta.data_2;
return calc_opcode_counter_from_idx_idx (data_1, data_2); return vm_calc_instr_counter_from_idx_idx (data_1, data_2);
} /* read_meta_opcode_counter */ } /* vm_read_instr_counter_from_meta */
#define VM_OP_0(opcode_name, opcode_name_uppercase) \ #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; \ vm_instr_t instr; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \ instr.op_idx = VM_OP_##opcode_name_uppercase; \
return opdata; \ return instr; \
} }
#define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ #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; \ vm_instr_t instr; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \ instr.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \ instr.data.opcode_name.arg1 = arg1_v; \
return opdata; \ return instr; \
} }
#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ #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; \ vm_instr_t instr; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \ instr.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \ instr.data.opcode_name.arg1 = arg1_v; \
opdata.data.opcode_name.arg2 = arg2_v; \ instr.data.opcode_name.arg2 = arg2_v; \
return opdata; \ return instr; \
} }
#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ #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; \ vm_instr_t instr; \
opdata.op_idx = VM_OP_##opcode_name_uppercase; \ instr.op_idx = VM_OP_##opcode_name_uppercase; \
opdata.data.opcode_name.arg1 = arg1_v; \ instr.data.opcode_name.arg1 = arg1_v; \
opdata.data.opcode_name.arg2 = arg2_v; \ instr.data.opcode_name.arg2 = arg2_v; \
opdata.data.opcode_name.arg3 = arg3_v; \ instr.data.opcode_name.arg3 = arg3_v; \
return opdata; \ return instr; \
} }
#include "vm-opcodes.inc.h" #include "vm-opcodes.inc.h"
+32 -25
View File
@@ -35,8 +35,15 @@
#define OP_3(action, name, field1, field2, field3) \ #define OP_3(action, name, field1, field2, field3) \
__##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 * Descriptor of assignment's second argument
@@ -139,17 +146,17 @@ typedef enum
} vm_op_arg_type_t; } 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 * Context of interpreter, related to a JS stack frame
*/ */
typedef struct typedef struct
{ {
const opcode_t *opcodes_p; /**< pointer to array containing currently executed bytecode */ const vm_instr_t *instrs_p; /**< currently executed byte-code array */
opcode_counter_t pos; /**< current opcode to execute */ vm_instr_counter_t pos; /**< current position instruction to execute */
ecma_value_t this_binding; /**< this binding for current context */ ecma_value_t this_binding; /**< this binding for current context */
ecma_object_t *lex_env_p; /**< current lexical environment */ ecma_object_t *lex_env_p; /**< current lexical environment */
bool is_strict; /**< is current code execution mode strict? */ bool is_strict; /**< is current code execution mode strict? */
@@ -178,20 +185,20 @@ typedef struct
* Note: * Note:
* Run scope represents boundaries of byte-code block to run. * 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 * and outside of the run scope - by returning corresponding ECMA_COMPLETION_TYPE_BREAK_CONTINUE
* completion value. * completion value.
*/ */
typedef struct typedef struct
{ {
const opcode_counter_t start_oc; /**< opcode counter of the first instruction of the scope */ const vm_instr_counter_t start_oc; /**< instruction 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 end_oc; /**< instruction counter of the last instruction of the scope */
} vm_run_scope_t; } 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); vm_instr_counter_t vm_calc_instr_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_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; idx_t op_idx;
union union
@@ -218,9 +225,9 @@ typedef struct opcode_t
#include "vm-opcodes.inc.h" #include "vm-opcodes.inc.h"
} data; } data;
} opcode_t; } vm_instr_t;
enum __opcode_idx typedef enum
{ {
#define VM_OP_0(opcode_name, opcode_name_uppercase) \ #define VM_OP_0(opcode_name, opcode_name_uppercase) \
VM_OP_ ## opcode_name_uppercase, VM_OP_ ## opcode_name_uppercase,
@@ -234,29 +241,29 @@ enum __opcode_idx
#include "vm-opcodes.inc.h" #include "vm-opcodes.inc.h"
VM_OP__COUNT /**< number of opcodes */ VM_OP__COUNT /**< number of opcodes */
}; } vm_op_t;
#define VM_OP_0(opcode_name, opcode_name_uppercase) \ #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) \ #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) \ #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) \ #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" #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) \ #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) \ #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) \ #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) \ #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" #include "vm-opcodes.inc.h"
@@ -264,6 +271,6 @@ typedef ecma_completion_value_t (*opfunc) (opcode_t, vm_frame_ctx_t *);
typedef struct typedef struct
{ {
uint8_t uids[4]; uint8_t uids[4];
} raw_opcode; } raw_instr;
#endif /* OPCODES_H */ #endif /* OPCODES_H */
+17 -17
View File
@@ -94,9 +94,9 @@ tmp_id_to_str (idx_t id)
} }
static const char * 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 (raw.uids[current_arg] == LITERAL_TO_REWRITE)
{ {
if (lit_ids == NULL) 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 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; uint8_t current_arg = start_arg;
JERRY_ASSERT (current_arg <= 3); 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': case 'd':
{ {
JERRY_ASSERT (current_arg <= 3); JERRY_ASSERT (current_arg <= 3);
raw_opcode raw = *(raw_opcode*) &opcode; raw_instr raw = *(raw_instr*) &instr;
printf ("%d", raw.uids[current_arg]); printf ("%d", raw.uids[current_arg]);
break; break;
} }
case 's': case 's':
{ {
JERRY_ASSERT (current_arg <= 3); 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; break;
} }
default: 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) \ #define PP_OP(op_name, format) \
case op_name: pp_printf (format, opm.op, opm.lit_id, oc, 1); break; 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 VAR(i) var_to_str (opm.op, opm.lit_id, oc, i)
#define OC(i, j) __extension__({ raw_opcode* raw = (raw_opcode *) &opm.op; \ #define OC(i, j) __extension__({ raw_instr* raw = (raw_instr *) &opm.op; \
calc_opcode_counter_from_idx_idx (raw->uids[i], raw->uids[j]); }) vm_calc_instr_counter_from_idx_idx (raw->uids[i], raw->uids[j]); })
static int vargs_num = 0; static int vargs_num = 0;
static int seen_vargs = 0; static int seen_vargs = 0;
static void 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 i = 0;
uint8_t opcode_id = opcode.op_idx; uint8_t opcode_id = instr.op_idx;
printf ("%3d: %20s ", oc, opcode_names[opcode_id]); printf ("%3d: %20s ", oc, opcode_names[opcode_id]);
for (i = 1; i < opcode_sizes[opcode_id]; i++) 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++) for (; i < 4; i++)
@@ -185,8 +185,8 @@ dump_asm (opcode_counter_t oc, opcode_t opcode)
} }
void void
pp_op_meta (const opcode_t *opcodes_p, pp_op_meta (const vm_instr_t *instrs_p,
opcode_counter_t oc, vm_instr_counter_t oc,
op_meta opm, op_meta opm,
bool rewrite) bool rewrite)
{ {
@@ -397,11 +397,11 @@ pp_op_meta (const opcode_t *opcodes_p,
if (seen_vargs == vargs_num) if (seen_vargs == vargs_num)
{ {
bool found = false; bool found = false;
opcode_counter_t start = oc; vm_instr_counter_t start = oc;
while ((int16_t) start >= 0 && !found) while ((int16_t) start >= 0 && !found)
{ {
start--; 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_CALL_N:
case VM_OP_NATIVE_CALL: 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) switch (start_op.op_idx)
{ {
case VM_OP_CALL_N: case VM_OP_CALL_N:
@@ -476,9 +476,9 @@ pp_op_meta (const opcode_t *opcodes_p,
JERRY_UNREACHABLE (); 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) switch (meta_op.op_idx)
{ {
+1 -2
View File
@@ -21,8 +21,7 @@
#include "vm.h" #include "vm.h"
#include "scopes-tree.h" #include "scopes-tree.h"
void pp_opcode (opcode_counter_t, opcode_t, bool); void pp_op_meta (const vm_instr_t*, vm_instr_counter_t, op_meta, bool);
void pp_op_meta (const opcode_t*, opcode_counter_t, op_meta, bool);
#endif // JERRY_ENABLE_PRETTY_PRINTER #endif // JERRY_ENABLE_PRETTY_PRINTER
#endif // 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) var, VM_OP_ARG_TYPE_VARIABLE)
VM_OP_2 (jmp_up, JMP_UP, VM_OP_2 (jmp_up, JMP_UP,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_2 (jmp_down, JMP_DOWN, VM_OP_2 (jmp_down, JMP_DOWN,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_2 (jmp_break_continue, JMP_BREAK_CONTINUE, VM_OP_2 (jmp_break_continue, JMP_BREAK_CONTINUE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, 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, VM_OP_3 (is_true_jmp_up, IS_TRUE_JMP_UP,
value, VM_OP_ARG_TYPE_VARIABLE, value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, 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, VM_OP_3 (is_true_jmp_down, IS_TRUE_JMP_DOWN,
value, VM_OP_ARG_TYPE_VARIABLE, value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, 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, VM_OP_3 (is_false_jmp_up, IS_FALSE_JMP_UP,
value, VM_OP_ARG_TYPE_VARIABLE, value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, 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, VM_OP_3 (is_false_jmp_down, IS_FALSE_JMP_DOWN,
value, VM_OP_ARG_TYPE_VARIABLE, value, VM_OP_ARG_TYPE_VARIABLE,
opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST,
opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST)
VM_OP_1 (var_decl, VAR_DECL, VM_OP_1 (var_decl, VAR_DECL,
variable_name, VM_OP_ARG_TYPE_STRING) 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" #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 #ifdef MEM_STATS
static const char *__op_names[VM_OP__COUNT] = 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 static void
interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p, interp_mem_stats_context_enter (vm_frame_ctx_t *frame_ctx_p,
opcode_counter_t block_position) vm_instr_counter_t block_position)
{ {
if (likely (!interp_mem_stats_enabled)) 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] = '|';
indent_prefix[indentation + 1] = '\0'; indent_prefix[indentation + 1] = '\0';
int_data_p->context_peak_allocated_heap_bytes = 0; frame_ctx_p->context_peak_allocated_heap_bytes = 0;
int_data_p->context_peak_waste_heap_bytes = 0; frame_ctx_p->context_peak_waste_heap_bytes = 0;
int_data_p->context_peak_pools_count = 0; frame_ctx_p->context_peak_pools_count = 0;
int_data_p->context_peak_allocated_pool_chunks = 0; frame_ctx_p->context_peak_allocated_pool_chunks = 0;
interp_mem_get_stats (&int_data_p->heap_stats_context_enter, interp_mem_get_stats (&frame_ctx_p->heap_stats_context_enter,
&int_data_p->pools_stats_context_enter, &frame_ctx_p->pools_stats_context_enter,
false, false); false, false);
printf ("\n%s--- Beginning interpretation of a block at position %u ---\n" 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 Pools: %5u\n"
"%s Allocated pool chunks: %5u\n\n", "%s Allocated pool chunks: %5u\n\n",
indent_prefix, (uint32_t) block_position, indent_prefix, (uint32_t) block_position,
indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes, indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes, indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.waste_bytes,
indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.pools_count, indent_prefix, (uint32_t) frame_ctx_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->pools_stats_context_enter.allocated_chunks);
} }
static void static void
interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p, interp_mem_stats_context_exit (vm_frame_ctx_t *frame_ctx_p,
opcode_counter_t block_position) vm_instr_counter_t block_position)
{ {
if (likely (!interp_mem_stats_enabled)) 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, &pools_stats_context_exit,
false, true); 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); 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); 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); 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); pools_stats_context_exit.allocated_chunks);
printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, 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,
(uint32_t) (heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes), (uint32_t) (heap_stats_context_exit.allocated_bytes - frame_ctx_p->heap_stats_context_enter.allocated_bytes),
(uint32_t) int_data_p->context_peak_allocated_heap_bytes, (uint32_t) frame_ctx_p->context_peak_allocated_heap_bytes,
(uint32_t) heap_stats_context_exit.global_peak_allocated_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", printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, 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,
(uint32_t) (heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes), (uint32_t) (heap_stats_context_exit.waste_bytes - frame_ctx_p->heap_stats_context_enter.waste_bytes),
(uint32_t) int_data_p->context_peak_waste_heap_bytes, (uint32_t) frame_ctx_p->context_peak_waste_heap_bytes,
(uint32_t) heap_stats_context_exit.global_peak_waste_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", printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, 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,
(uint32_t) (pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count), (uint32_t) (pools_stats_context_exit.pools_count - frame_ctx_p->pools_stats_context_enter.pools_count),
(uint32_t) int_data_p->context_peak_pools_count, (uint32_t) frame_ctx_p->context_peak_pools_count,
(uint32_t) pools_stats_context_exit.global_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", printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, 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,
(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), frame_ctx_p->pools_stats_context_enter.allocated_chunks),
(uint32_t) int_data_p->context_peak_allocated_pool_chunks, (uint32_t) frame_ctx_p->context_peak_allocated_pool_chunks,
(uint32_t) pools_stats_context_exit.global_peak_allocated_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", 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 static void
interp_mem_stats_opcode_enter (const opcode_t *opcodes_p, interp_mem_stats_opcode_enter (const vm_instr_t *instrs_p,
opcode_counter_t opcode_position, vm_instr_counter_t instr_position,
mem_heap_stats_t *out_heap_stats_p, mem_heap_stats_t *out_heap_stats_p,
mem_pools_stats_t *out_pools_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, out_pools_stats_p,
true, false); 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", 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; interp_mem_stats_print_indentation += INTERP_MEM_PRINT_INDENTATION_STEP;
} }
static void static void
interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p, interp_mem_stats_opcode_exit (vm_frame_ctx_t *frame_ctx_p,
opcode_counter_t opcode_position, vm_instr_counter_t instr_position,
mem_heap_stats_t *heap_stats_before_p, mem_heap_stats_t *heap_stats_before_p,
mem_pools_stats_t *pools_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, &pools_stats_after,
false, true); 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); 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); 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); 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); 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", printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix, 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", 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 */ #endif /* MEM_STATS */
@@ -351,8 +351,8 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p,
* Initialize interpreter. * Initialize interpreter.
*/ */
void void
vm_init (const opcode_t *program_p, /**< pointer to byte-code program */ vm_init (const vm_instr_t *program_p, /**< pointer to byte-code program */
bool dump_mem_stats) /** dump per-opcode memory usage change statistics */ bool dump_mem_stats) /** dump per-instruction memory usage change statistics */
{ {
#ifdef MEM_STATS #ifdef MEM_STATS
interp_mem_stats_enabled = dump_mem_stats; interp_mem_stats_enabled = dump_mem_stats;
@@ -392,7 +392,7 @@ vm_run_global (void)
#endif /* MEM_STATS */ #endif /* MEM_STATS */
bool is_strict = false; 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, opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program,
start_pos++); start_pos++);
@@ -448,7 +448,7 @@ vm_run_global (void)
* Otherwise - the completion value is discarded and normal empty completion value is returned. * Otherwise - the completion value is discarded and normal empty completion value is returned.
*/ */
ecma_completion_value_t 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, vm_run_scope_t *run_scope_p) /**< current run scope,
* or NULL - if there is no active 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 do
{ {
JERRY_ASSERT (run_scope_p == NULL JERRY_ASSERT (run_scope_p == NULL
|| (run_scope_p->start_oc <= int_data_p->pos || (run_scope_p->start_oc <= frame_ctx_p->pos
&& int_data_p->pos <= run_scope_p->end_oc)); && 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 #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, interp_mem_stats_opcode_enter (frame_ctx_p->instrs_p,
opcode_pos, instr_pos,
&heap_stats_before, &heap_stats_before,
&pools_stats_before); &pools_stats_before);
#endif /* MEM_STATS */ #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 #ifdef CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE
ecma_gc_run (); ecma_gc_run ();
#endif /* CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE */ #endif /* CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE */
#ifdef MEM_STATS #ifdef MEM_STATS
interp_mem_stats_opcode_exit (int_data_p, interp_mem_stats_opcode_exit (frame_ctx_p,
opcode_pos, instr_pos,
&heap_stats_before, &heap_stats_before,
&pools_stats_before); &pools_stats_before);
#endif /* MEM_STATS */ #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)) 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: * 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->start_oc /* or target is within the current run scope */
&& target <= run_scope_p->end_oc)) && target <= run_scope_p->end_oc))
{ {
int_data_p->pos = target; frame_ctx_p->pos = target;
continue; continue;
} }
@@ -528,11 +528,11 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */
} /* vm_loop */ } /* vm_loop */
/** /**
* Run the code, starting from specified opcode * Run the code, starting from specified instruction position
*/ */
ecma_completion_value_t ecma_completion_value_t
vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */ vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */
opcode_counter_t start_pos, /**< identifier of starting opcode */ vm_instr_counter_t start_pos, /**< position of starting instruction */
ecma_value_t this_binding_value, /**< value of 'ThisBinding' */ ecma_value_t this_binding_value, /**< value of 'ThisBinding' */
ecma_object_t *lex_env_p, /**< lexical environment to use */ 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) */ 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; 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); JERRY_ASSERT (curr->op_idx == VM_OP_REG_VAR_DECL);
const idx_t min_reg_num = curr->data.reg_var_decl.min; 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); MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_t);
vm_frame_ctx_t frame_ctx; vm_frame_ctx_t frame_ctx;
frame_ctx.opcodes_p = opcodes_p; frame_ctx.instrs_p = instrs_p;
frame_ctx.pos = (opcode_counter_t) (start_pos + 1); frame_ctx.pos = (vm_instr_counter_t) (start_pos + 1);
frame_ctx.this_binding = this_binding_value; frame_ctx.this_binding = this_binding_value;
frame_ctx.lex_env_p = lex_env_p; frame_ctx.lex_env_p = lex_env_p;
frame_ctx.is_strict = is_strict; 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 */ } /* vm_run_from_pos */
/** /**
* Get specified opcode from the program. * Get specified instruction from the program.
*/ */
opcode_t vm_instr_t
vm_get_opcode (const opcode_t *opcodes_p, /**< byte-code array */ vm_get_instr (const vm_instr_t *instrs_p, /**< byte-code array */
opcode_counter_t counter) /**< opcode counter */ vm_instr_counter_t counter) /**< instruction counter */
{ {
return opcodes_p[ counter ]; return instrs_p[ counter ];
} /* vm_get_opcode */ } /* 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 * @return mask of scope code flags
*/ */
opcode_scope_code_flags_t opcode_scope_code_flags_t
vm_get_scope_flags (const opcode_t *opcodes_p, /**< byte-code array */ vm_get_scope_flags (const vm_instr_t *instrs_p, /**< byte-code array */
opcode_counter_t counter) /**< opcode counter */ vm_instr_counter_t counter) /**< instruction counter */
{ {
opcode_t flags_opcode = vm_get_opcode (opcodes_p, counter); vm_instr_t flags_instr = vm_get_instr (instrs_p, counter);
JERRY_ASSERT (flags_opcode.op_idx == VM_OP_META JERRY_ASSERT (flags_instr.op_idx == VM_OP_META
&& flags_opcode.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS); && flags_instr.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS);
return (opcode_scope_code_flags_t) flags_opcode.data.meta.data_1; return (opcode_scope_code_flags_t) flags_instr.data.meta.data_1;
} /* vm_get_scope_flags */ } /* vm_get_scope_flags */
/** /**
+5 -5
View File
@@ -20,19 +20,19 @@
#include "jrt.h" #include "jrt.h"
#include "opcodes.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 void vm_finalize (void);
extern jerry_completion_code_t vm_run_global (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_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, extern ecma_completion_value_t vm_run_from_pos (const vm_instr_t *instrs_p,
opcode_counter_t start_pos, vm_instr_counter_t start_pos,
ecma_value_t this_binding_value, ecma_value_t this_binding_value,
ecma_object_t *lex_env_p, ecma_object_t *lex_env_p,
bool is_strict, bool is_strict,
bool is_eval_code); bool is_eval_code);
extern opcode_t vm_get_opcode (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 opcode_t*, opcode_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_strict_mode (void);
extern bool vm_is_direct_eval_form_call (void); extern bool vm_is_direct_eval_form_call (void);
+11 -11
View File
@@ -21,12 +21,12 @@
#include "test-common.h" #include "test-common.h"
static bool static bool
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size) instrs_equal (const vm_instr_t *instrs1, vm_instr_t *instrs2, uint16_t size)
{ {
uint16_t i; uint16_t i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
if (memcmp (&opcodes1[i], &opcodes2[i], sizeof (opcode_t)) != 0) if (memcmp (&instrs1[i], &instrs2[i], sizeof (vm_instr_t)) != 0)
{ {
return false; return false;
} }
@@ -44,7 +44,7 @@ main (int __attr_unused___ argc,
{ {
TEST_INIT (); TEST_INIT ();
const opcode_t *opcodes_p; const vm_instr_t *instrs_p;
jsp_status_t parse_status; jsp_status_t parse_status;
mem_init (); mem_init ();
@@ -53,12 +53,12 @@ main (int __attr_unused___ argc,
char program1[] = "a=1;var a;"; char program1[] = "a=1;var a;";
serializer_init (); serializer_init ();
parser_set_show_opcodes (true); parser_set_show_instrs (true);
parse_status = parser_parse_script ((jerry_api_char_t *) program1, strlen (program1), &opcodes_p); parse_status = parser_parse_script ((jerry_api_char_t *) program1, strlen (program1), &instrs_p);
JERRY_ASSERT (parse_status == JSP_STATUS_OK && opcodes_p != NULL); JERRY_ASSERT (parse_status == JSP_STATUS_OK && instrs_p != NULL);
opcode_t opcodes[] = vm_instr_t instrs[] =
{ {
getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, // [ ] getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, // [ ]
OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER
@@ -71,7 +71,7 @@ main (int __attr_unused___ argc,
getop_ret () // return; getop_ret () // return;
}; };
JERRY_ASSERT (opcodes_equal (opcodes_p, opcodes, 5)); JERRY_ASSERT (instrs_equal (instrs_p, instrs, 5));
serializer_free (); serializer_free ();
@@ -79,10 +79,10 @@ main (int __attr_unused___ argc,
char program2[] = "var var;"; char program2[] = "var var;";
serializer_init (); serializer_init ();
parser_set_show_opcodes (true); parser_set_show_instrs (true);
parse_status = parser_parse_script ((jerry_api_char_t *) program2, strlen (program2), &opcodes_p); parse_status = parser_parse_script ((jerry_api_char_t *) program2, strlen (program2), &instrs_p);
JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR && opcodes_p == NULL); JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR && instrs_p == NULL);
serializer_free (); serializer_free ();