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:
committed by
Evgeny Gavrin
parent
1990762cf0
commit
502f4c4623
@@ -174,7 +174,7 @@ typedef uint32_t ecma_completion_value_t;
|
||||
* Break / continue jump target
|
||||
*/
|
||||
#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)
|
||||
|
||||
@@ -464,14 +464,14 @@ ecma_get_completion_value_value_field (ecma_completion_value_t 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 */
|
||||
{
|
||||
return (opcode_counter_t) jrt_extract_bit_field (completion_value,
|
||||
ECMA_COMPLETION_VALUE_TARGET_POS,
|
||||
ECMA_COMPLETION_VALUE_TARGET_WIDTH);
|
||||
return (vm_instr_counter_t) jrt_extract_bit_field (completion_value,
|
||||
ECMA_COMPLETION_VALUE_TARGET_POS,
|
||||
ECMA_COMPLETION_VALUE_TARGET_WIDTH);
|
||||
} /* 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___
|
||||
ecma_set_completion_value_target (ecma_completion_value_t completion_value, /**< completion value
|
||||
* 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,
|
||||
target,
|
||||
@@ -645,7 +645,7 @@ ecma_make_meta_completion_value (void)
|
||||
* @return completion value
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -712,9 +712,9 @@ ecma_get_object_from_completion_value (ecma_completion_value_t 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
|
||||
* value */
|
||||
{
|
||||
|
||||
@@ -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_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_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_number_t* __attr_const___
|
||||
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);
|
||||
extern ecma_object_t* __attr_const___
|
||||
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);
|
||||
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);
|
||||
|
||||
@@ -255,13 +255,13 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
|
||||
utf8_string_buffer_pos += sz;
|
||||
}
|
||||
|
||||
const opcode_t* opcodes_p;
|
||||
const vm_instr_t* instrs_p;
|
||||
jsp_status_t parse_status;
|
||||
|
||||
parse_status = parser_parse_new_function ((const jerry_api_char_t **) utf8_string_params_p,
|
||||
utf8_string_params_size,
|
||||
params_count,
|
||||
&opcodes_p);
|
||||
&instrs_p);
|
||||
|
||||
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 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);
|
||||
|
||||
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,
|
||||
is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
opcodes_p,
|
||||
instrs_p,
|
||||
1);
|
||||
|
||||
ecma_deref_object (glob_lex_env_p);
|
||||
|
||||
@@ -86,7 +86,7 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
const opcode_t *opcodes_p;
|
||||
const vm_instr_t *instrs_p;
|
||||
jsp_status_t parse_status;
|
||||
|
||||
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,
|
||||
code_buffer_size,
|
||||
is_strict_call,
|
||||
&opcodes_p);
|
||||
&instrs_p);
|
||||
|
||||
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);
|
||||
|
||||
opcode_counter_t first_opcode_index = 0u;
|
||||
vm_instr_counter_t first_instr_index = 0u;
|
||||
bool is_strict_prologue = false;
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (opcodes_p,
|
||||
first_opcode_index++);
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p,
|
||||
first_instr_index++);
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
completion = vm_run_from_pos (opcodes_p,
|
||||
first_opcode_index,
|
||||
completion = vm_run_from_pos (instrs_p,
|
||||
first_instr_index,
|
||||
this_binding,
|
||||
lex_env_p,
|
||||
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.
|
||||
*
|
||||
* @return packed value
|
||||
@@ -45,9 +45,9 @@ static uint32_t
|
||||
ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
|
||||
bool do_instantiate_args_obj, /**< should an Arguments object be
|
||||
* 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 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 */
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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 */
|
||||
bool* out_is_strict_p, /**< out: is code strict? */
|
||||
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);
|
||||
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 */
|
||||
|
||||
/**
|
||||
@@ -221,8 +221,9 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
|
||||
bool is_strict, /**< 'strict' flag */
|
||||
bool do_instantiate_arguments_object, /**< should an Arguments object be instantiated
|
||||
* for the function object upon call */
|
||||
const opcode_t *opcodes_p, /**< byte-code array */
|
||||
opcode_counter_t first_opcode_index) /**< index of first opcode of function's body */
|
||||
const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
vm_instr_counter_t first_instr_pos) /**< position of first instruction
|
||||
* of function's body */
|
||||
{
|
||||
// 1., 4., 13.
|
||||
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.
|
||||
ecma_property_t *opcodes_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);
|
||||
ecma_property_t *bytecode_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE);
|
||||
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);
|
||||
code_prop_p->u.internal_property.value = ecma_pack_code_internal_property_value (is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
first_opcode_index);
|
||||
first_instr_pos);
|
||||
|
||||
// 14.
|
||||
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) */
|
||||
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_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET);
|
||||
|
||||
@@ -718,10 +719,10 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
// 8.
|
||||
bool is_strict;
|
||||
bool do_instantiate_args_obj;
|
||||
const opcode_t *opcodes_p = MEM_CP_GET_POINTER (const opcode_t, opcodes_prop_p->u.internal_property.value);
|
||||
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value,
|
||||
&is_strict,
|
||||
&do_instantiate_args_obj);
|
||||
const vm_instr_t *instrs_p = MEM_CP_GET_POINTER (const vm_instr_t, bytecode_prop_p->u.internal_property.value);
|
||||
vm_instr_counter_t code_first_instr_pos = ecma_unpack_code_internal_property_value (code_prop_value,
|
||||
&is_strict,
|
||||
&do_instantiate_args_obj);
|
||||
|
||||
ecma_value_t this_binding;
|
||||
// 1.
|
||||
@@ -757,8 +758,8 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
do_instantiate_args_obj),
|
||||
ret_value);
|
||||
|
||||
ecma_completion_value_t completion = vm_run_from_pos (opcodes_p,
|
||||
code_first_opcode_idx,
|
||||
ecma_completion_value_t completion = vm_run_from_pos (instrs_p,
|
||||
code_first_instr_pos,
|
||||
this_binding,
|
||||
local_env_p,
|
||||
is_strict,
|
||||
@@ -1019,8 +1020,9 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *function_name_p, /**< function name */
|
||||
const opcode_t *opcodes_p, /**< byte-code array */
|
||||
opcode_counter_t function_code_opcode_idx, /**< index of first opcode of function code */
|
||||
const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
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_length_t formal_parameter_list_length, /**< length of formal parameters list */
|
||||
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,
|
||||
is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
opcodes_p,
|
||||
function_code_opcode_idx);
|
||||
instrs_p,
|
||||
function_first_instr_pos);
|
||||
|
||||
// c.
|
||||
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,
|
||||
bool is_strict,
|
||||
bool do_instantiate_arguments_object,
|
||||
const opcode_t *opcodes_p,
|
||||
opcode_counter_t first_opcode_idx);
|
||||
const vm_instr_t *instrs_p,
|
||||
vm_instr_counter_t first_opcode_idx);
|
||||
extern ecma_object_t*
|
||||
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
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p,
|
||||
ecma_string_t *function_name_p,
|
||||
const opcode_t *opcodes_p,
|
||||
opcode_counter_t function_code_opcode_idx,
|
||||
const vm_instr_t *instrs_p,
|
||||
vm_instr_counter_t function_code_opcode_idx,
|
||||
ecma_string_t* formal_parameter_list_p[],
|
||||
ecma_length_t formal_parameter_list_length,
|
||||
bool is_strict,
|
||||
|
||||
Reference in New Issue
Block a user