Update of several 'vm' component interfaces naming.
init_int -> vm_init; run_int -> vm_run_global; run_int_loop -> vm_loop; run_int_from_pos -> vm_run_from_pos; read_opcode -> vm_get_opcode. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -579,11 +579,12 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
is_strict),
|
||||
ret_value);
|
||||
|
||||
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
|
||||
this_binding,
|
||||
local_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
ecma_completion_value_t completion = vm_run_from_pos (code_first_opcode_idx,
|
||||
this_binding,
|
||||
local_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
|
||||
if (ecma_is_completion_value_return (completion))
|
||||
{
|
||||
ret_value = ecma_make_normal_completion_value (ecma_get_completion_value_value (completion));
|
||||
|
||||
@@ -1225,7 +1225,7 @@ jerry_parse (const char* source_p, /**< script source */
|
||||
|
||||
bool is_show_mem_stats_per_opcode = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0);
|
||||
|
||||
init_int (opcodes, is_show_mem_stats_per_opcode);
|
||||
vm_init (opcodes, is_show_mem_stats_per_opcode);
|
||||
|
||||
return true;
|
||||
} /* jerry_parse */
|
||||
@@ -1240,7 +1240,7 @@ jerry_run (void)
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
return run_int ();
|
||||
return vm_run_global ();
|
||||
} /* jerry_run */
|
||||
/**
|
||||
* Simple jerry runner
|
||||
|
||||
@@ -37,12 +37,12 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
ecma_completion_value_t try_completion = run_int_loop (int_data);
|
||||
ecma_completion_value_t try_completion = vm_loop (int_data);
|
||||
JERRY_ASSERT ((!ecma_is_completion_value_empty (try_completion) && int_data->pos <= try_end_oc)
|
||||
|| (ecma_is_completion_value_empty (try_completion) && int_data->pos == try_end_oc));
|
||||
int_data->pos = try_end_oc;
|
||||
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
@@ -58,7 +58,7 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
|
||||
if (ecma_is_completion_value_throw (try_completion))
|
||||
{
|
||||
next_opcode = read_opcode (int_data->pos);
|
||||
next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER);
|
||||
|
||||
@@ -87,7 +87,7 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
int_data->lex_env_p = catch_env_p;
|
||||
|
||||
ecma_free_completion_value (try_completion);
|
||||
try_completion = run_int_loop (int_data);
|
||||
try_completion = vm_loop (int_data);
|
||||
|
||||
int_data->lex_env_p = old_env_p;
|
||||
|
||||
@@ -100,7 +100,7 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
int_data->pos = catch_end_oc;
|
||||
}
|
||||
|
||||
next_opcode = read_opcode (int_data->pos);
|
||||
next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
@@ -114,7 +114,7 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
read_meta_opcode_counter (OPCODE_META_TYPE_FINALLY, int_data) + int_data->pos);
|
||||
int_data->pos++;
|
||||
|
||||
ecma_completion_value_t finally_completion = run_int_loop (int_data);
|
||||
ecma_completion_value_t finally_completion = vm_loop (int_data);
|
||||
JERRY_ASSERT ((!ecma_is_completion_value_empty (finally_completion) && int_data->pos <= finally_end_oc)
|
||||
|| (ecma_is_completion_value_empty (finally_completion) && int_data->pos == finally_end_oc));
|
||||
int_data->pos = finally_end_oc;
|
||||
@@ -126,7 +126,7 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
}
|
||||
}
|
||||
|
||||
next_opcode = read_opcode (int_data->pos++);
|
||||
next_opcode = vm_get_opcode (int_data->pos++);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
||||
arg_index < args_number;
|
||||
arg_index++)
|
||||
{
|
||||
ecma_completion_value_t evaluate_arg_completion = run_int_loop (int_data);
|
||||
ecma_completion_value_t evaluate_arg_completion = vm_loop (int_data);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluate_arg_completion))
|
||||
{
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||
|
||||
@@ -92,7 +92,7 @@ fill_params_list (int_data_t *int_data, /**< interpreter context */
|
||||
param_index < params_number;
|
||||
param_index++)
|
||||
{
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ function_declaration (int_data_t *int_data, /**< interpreter context */
|
||||
read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, int_data) + int_data->pos);
|
||||
int_data->pos++;
|
||||
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
if (next_opcode.op_idx == __op__idx_meta
|
||||
&& next_opcode.data.meta.type == OPCODE_META_TYPE_STRICT_CODE)
|
||||
{
|
||||
@@ -548,7 +548,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
||||
int_data) + int_data->pos);
|
||||
int_data->pos++;
|
||||
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
if (next_opcode.op_idx == __op__idx_meta
|
||||
&& next_opcode.data.meta.type == OPCODE_META_TYPE_STRICT_CODE)
|
||||
{
|
||||
@@ -638,7 +638,7 @@ opfunc_call_n (opcode_t opdata, /**< operation data */
|
||||
idx_t this_arg_var_idx = INVALID_VALUE;
|
||||
idx_t args_number;
|
||||
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
if (next_opcode.op_idx == __op__idx_meta
|
||||
&& next_opcode.data.meta.type == OPCODE_META_TYPE_THIS_ARG)
|
||||
{
|
||||
@@ -896,13 +896,13 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
|
||||
prop_index < args_number;
|
||||
prop_index++)
|
||||
{
|
||||
ecma_completion_value_t evaluate_prop_completion = run_int_loop (int_data);
|
||||
ecma_completion_value_t evaluate_prop_completion = vm_loop (int_data);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluate_prop_completion))
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (evaluate_prop_completion));
|
||||
|
||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||
opcode_t next_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
|
||||
const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type;
|
||||
@@ -1305,13 +1305,13 @@ opfunc_with (opcode_t opdata, /**< operation data */
|
||||
true);
|
||||
int_data->lex_env_p = new_env_p;
|
||||
|
||||
ecma_completion_value_t evaluation_completion = run_int_loop (int_data);
|
||||
ecma_completion_value_t evaluation_completion = vm_loop (int_data);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluation_completion))
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (evaluation_completion));
|
||||
|
||||
opcode_t meta_opcode = read_opcode (int_data->pos);
|
||||
opcode_t meta_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (meta_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH);
|
||||
|
||||
@@ -1695,7 +1695,7 @@ opcode_counter_t
|
||||
read_meta_opcode_counter (opcode_meta_type expected_type, /**< expected type of meta opcode */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
opcode_t meta_opcode = read_opcode (int_data->pos);
|
||||
opcode_t meta_opcode = vm_get_opcode (int_data->pos);
|
||||
JERRY_ASSERT (meta_opcode.data.meta.type == expected_type);
|
||||
|
||||
const idx_t data_1 = meta_opcode.data.meta.data_1;
|
||||
|
||||
+40
-24
@@ -235,7 +235,7 @@ interp_mem_stats_opcode_enter (opcode_counter_t opcode_position,
|
||||
out_pools_stats_p,
|
||||
true, false);
|
||||
|
||||
opcode_t opcode = read_opcode (opcode_position);
|
||||
opcode_t opcode = vm_get_opcode (opcode_position);
|
||||
|
||||
printf ("%s-- Opcode: %s (position %u) --\n",
|
||||
indent_prefix, __op_names[opcode.op_idx], (uint32_t) opcode_position);
|
||||
@@ -280,7 +280,7 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
|
||||
int_data_p->context_peak_allocated_pool_chunks = JERRY_MAX (int_data_p->context_peak_allocated_pool_chunks,
|
||||
pools_stats_after.allocated_chunks);
|
||||
|
||||
opcode_t opcode = read_opcode (opcode_position);
|
||||
opcode_t opcode = vm_get_opcode (opcode_position);
|
||||
|
||||
printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
|
||||
indent_prefix,
|
||||
@@ -336,8 +336,8 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
|
||||
* Initialize interpreter.
|
||||
*/
|
||||
void
|
||||
init_int (const opcode_t *program_p, /**< pointer to byte-code program */
|
||||
bool dump_mem_stats) /** dump per-opcode memory usage change statistics */
|
||||
vm_init (const opcode_t *program_p, /**< pointer to byte-code program */
|
||||
bool dump_mem_stats) /** dump per-opcode memory usage change statistics */
|
||||
{
|
||||
#ifdef MEM_STATS
|
||||
interp_mem_stats_enabled = dump_mem_stats;
|
||||
@@ -348,10 +348,13 @@ init_int (const opcode_t *program_p, /**< pointer to byte-code program */
|
||||
JERRY_ASSERT (__program == NULL);
|
||||
|
||||
__program = program_p;
|
||||
} /* init_int */
|
||||
} /* vm_init */
|
||||
|
||||
/**
|
||||
* Run global code
|
||||
*/
|
||||
jerry_completion_code_t
|
||||
run_int (void)
|
||||
vm_run_global (void)
|
||||
{
|
||||
JERRY_ASSERT (__program != NULL);
|
||||
JERRY_ASSERT (vm_top_context_p == NULL);
|
||||
@@ -363,7 +366,7 @@ run_int (void)
|
||||
bool is_strict = false;
|
||||
opcode_counter_t start_pos = 0;
|
||||
|
||||
opcode_t first_opcode = read_opcode (start_pos);
|
||||
opcode_t first_opcode = vm_get_opcode (start_pos);
|
||||
if (first_opcode.op_idx == __op__idx_meta
|
||||
&& first_opcode.data.meta.type == OPCODE_META_TYPE_STRICT_CODE)
|
||||
{
|
||||
@@ -374,11 +377,11 @@ run_int (void)
|
||||
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
|
||||
ecma_object_t *lex_env_p = ecma_get_global_environment ();
|
||||
|
||||
ecma_completion_value_t completion = run_int_from_pos (start_pos,
|
||||
ecma_make_object_value (glob_obj_p),
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
ecma_completion_value_t completion = vm_run_from_pos (start_pos,
|
||||
ecma_make_object_value (glob_obj_p),
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
|
||||
jerry_completion_code_t ret_code;
|
||||
|
||||
@@ -408,10 +411,20 @@ run_int (void)
|
||||
JERRY_ASSERT (vm_top_context_p == NULL);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
} /* vm_run_global */
|
||||
|
||||
/**
|
||||
* Run interpreter loop using specified context
|
||||
*
|
||||
* Note:
|
||||
* The interpreter loop stops upon receiving completion value that is normal completion value.
|
||||
*
|
||||
* @return If the received completion value is not meta completion value (ECMA_COMPLETION_TYPE_META), then
|
||||
* the completion value is returned as is;
|
||||
* Otherwise - the completion value is discarded and normal empty completion value is returned.
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
run_int_loop (int_data_t *int_data)
|
||||
vm_loop (int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
@@ -470,14 +483,17 @@ run_int_loop (int_data_t *int_data)
|
||||
|
||||
return completion;
|
||||
}
|
||||
}
|
||||
} /* vm_loop */
|
||||
|
||||
/**
|
||||
* Run the code, starting from specified opcode
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
run_int_from_pos (opcode_counter_t start_pos,
|
||||
ecma_value_t this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code)
|
||||
vm_run_from_pos (opcode_counter_t start_pos, /**< identifier of starting opcode */
|
||||
ecma_value_t this_binding_value, /**< value of 'ThisBinding' */
|
||||
ecma_object_t *lex_env_p, /**< lexical environment to use */
|
||||
bool is_strict, /**< is the code is strict mode code (ECMA-262 v5, 10.1.1) */
|
||||
bool is_eval_code) /**< is the code is eval code (ECMA-262 v5, 10.1) */
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
@@ -510,7 +526,7 @@ run_int_from_pos (opcode_counter_t start_pos,
|
||||
interp_mem_stats_context_enter (&int_data, start_pos);
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
completion = run_int_loop (&int_data);
|
||||
completion = vm_loop (&int_data);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (completion)
|
||||
|| ecma_is_completion_value_throw (completion)
|
||||
@@ -530,16 +546,16 @@ run_int_from_pos (opcode_counter_t start_pos,
|
||||
MEM_FINALIZE_LOCAL_ARRAY (regs);
|
||||
|
||||
return completion;
|
||||
}
|
||||
} /* vm_run_from_pos */
|
||||
|
||||
/**
|
||||
* Get specified opcode from the program.
|
||||
*/
|
||||
opcode_t
|
||||
read_opcode (opcode_counter_t counter) /**< opcode counter */
|
||||
vm_get_opcode (opcode_counter_t counter) /**< opcode counter */
|
||||
{
|
||||
return __program[ counter ];
|
||||
} /* read_opcode */
|
||||
} /* vm_get_opcode */
|
||||
|
||||
/**
|
||||
* Get this binding of current execution context
|
||||
|
||||
+9
-9
@@ -20,16 +20,16 @@
|
||||
#include "jrt.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
void init_int (const opcode_t* program_p, bool dump_mem_stats);
|
||||
jerry_completion_code_t run_int (void);
|
||||
ecma_completion_value_t run_int_loop (int_data_t *int_data);
|
||||
ecma_completion_value_t run_int_from_pos (opcode_counter_t start_pos,
|
||||
ecma_value_t this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code);
|
||||
extern void vm_init (const opcode_t* program_p, bool dump_mem_stats);
|
||||
extern jerry_completion_code_t vm_run_global (void);
|
||||
extern ecma_completion_value_t vm_loop (int_data_t *int_data);
|
||||
extern ecma_completion_value_t vm_run_from_pos (opcode_counter_t start_pos,
|
||||
ecma_value_t this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code);
|
||||
|
||||
opcode_t read_opcode (opcode_counter_t counter);
|
||||
extern opcode_t vm_get_opcode (opcode_counter_t counter);
|
||||
|
||||
extern ecma_value_t vm_get_this_binding (void);
|
||||
extern ecma_object_t* vm_get_lex_env (void);
|
||||
|
||||
Reference in New Issue
Block a user