Update bytecode header structure so that bytecode could be stored independently from hash table and bytecode header.
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
committed by
Ruben Ayrapetyan
parent
6a6fb3fdfa
commit
443673fc5d
@@ -43,7 +43,7 @@ opfunc_try_block (vm_instr_t instr, /**< instruction */
|
||||
|| (ecma_is_completion_value_empty (try_completion) && frame_ctx_p->pos == try_end_oc));
|
||||
frame_ctx_p->pos = try_end_oc;
|
||||
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
|
||||
if (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH)
|
||||
@@ -54,12 +54,12 @@ opfunc_try_block (vm_instr_t instr, /**< instruction */
|
||||
|
||||
if (ecma_is_completion_value_throw (try_completion))
|
||||
{
|
||||
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER);
|
||||
|
||||
lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
frame_ctx_p->pos++;
|
||||
|
||||
@@ -98,7 +98,7 @@ opfunc_try_block (vm_instr_t instr, /**< instruction */
|
||||
frame_ctx_p->pos = catch_end_oc;
|
||||
}
|
||||
|
||||
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
|
||||
if (next_instr.data.meta.type == OPCODE_META_TYPE_FINALLY)
|
||||
@@ -121,7 +121,7 @@ opfunc_try_block (vm_instr_t instr, /**< instruction */
|
||||
}
|
||||
}
|
||||
|
||||
next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos++);
|
||||
next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos++);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ opfunc_for_in (vm_instr_t instr, /**< instruction */
|
||||
|
||||
int_data_p->pos++;
|
||||
|
||||
vm_instr_t meta_instr = vm_get_instr (int_data_p->instrs_p, for_in_end_oc);
|
||||
vm_instr_t meta_instr = vm_get_instr (int_data_p->bytecode_header_p->instrs_p, for_in_end_oc);
|
||||
JERRY_ASSERT (meta_instr.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (meta_instr.data.meta.type == OPCODE_META_TYPE_END_FOR_IN);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "opcodes-ecma-support.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/**
|
||||
@@ -91,7 +92,9 @@ get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
else
|
||||
{
|
||||
ecma_string_t var_name_string;
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
|
||||
|
||||
@@ -158,7 +161,7 @@ set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
else
|
||||
{
|
||||
ecma_string_t var_name_string;
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, lit_oc);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->bytecode_header_p, lit_oc);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ vm_fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
vm_loop (frame_ctx_p, NULL),
|
||||
ret_value);
|
||||
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||
|
||||
@@ -80,12 +80,12 @@ vm_fill_params_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
param_index < params_number;
|
||||
param_index++)
|
||||
{
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||
|
||||
const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
|
||||
|
||||
|
||||
+29
-18
@@ -77,7 +77,9 @@ opfunc_assignment (vm_instr_t instr, /**< instruction */
|
||||
}
|
||||
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->instrs_p, frame_ctx_p->pos);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
|
||||
|
||||
ret_value = set_variable_value (frame_ctx_p,
|
||||
@@ -106,7 +108,9 @@ opfunc_assignment (vm_instr_t instr, /**< instruction */
|
||||
{
|
||||
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->instrs_p, frame_ctx_p->pos);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
literal_t lit = lit_get_literal_by_cp (lit_cp);
|
||||
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
|
||||
|
||||
@@ -121,7 +125,9 @@ opfunc_assignment (vm_instr_t instr, /**< instruction */
|
||||
{
|
||||
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->instrs_p, frame_ctx_p->pos);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
literal_t lit = lit_get_literal_by_cp (lit_cp);
|
||||
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
|
||||
|
||||
@@ -147,7 +153,7 @@ opfunc_assignment (vm_instr_t instr, /**< instruction */
|
||||
{
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
|
||||
|
||||
@@ -438,7 +444,7 @@ opfunc_var_decl (vm_instr_t instr, /**< instruction */
|
||||
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
|
||||
{
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (instr.data.var_decl.variable_name,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
|
||||
@@ -489,7 +495,8 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos);
|
||||
frame_ctx_p->pos++;
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p, frame_ctx_p->pos++);
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->bytecode_header_p->instrs_p,
|
||||
frame_ctx_p->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
@@ -508,7 +515,7 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
|
||||
ecma_completion_value_t ret_value = ecma_op_function_declaration (frame_ctx_p->lex_env_p,
|
||||
function_name_string_p,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos,
|
||||
formal_params_collection_p,
|
||||
is_strict,
|
||||
@@ -535,7 +542,7 @@ opfunc_func_decl_n (vm_instr_t instr, /**< instruction */
|
||||
const ecma_length_t params_number = instr.data.func_decl_n.arg_list;
|
||||
|
||||
lit_cpointer_t function_name_lit_cp = serializer_get_literal_cp_by_uid (function_name_idx,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
|
||||
frame_ctx_p->pos++;
|
||||
@@ -587,7 +594,7 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
|
||||
frame_ctx_p) + frame_ctx_p->pos);
|
||||
frame_ctx_p->pos++;
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p,
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->bytecode_header_p->instrs_p,
|
||||
frame_ctx_p->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
@@ -610,7 +617,7 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
|
||||
scope_p = ecma_create_decl_lex_env (frame_ctx_p->lex_env_p);
|
||||
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (function_name_lit_idx,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
lit_oc);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
|
||||
@@ -627,7 +634,7 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
|
||||
scope_p,
|
||||
is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
frame_ctx_p->instrs_p,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
|
||||
ret_value = set_variable_value (frame_ctx_p, lit_oc,
|
||||
@@ -673,7 +680,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;
|
||||
vm_idx_t this_arg_var_idx = VM_IDX_EMPTY;
|
||||
|
||||
vm_instr_t next_opcode = vm_get_instr (int_data_p->instrs_p, int_data_p->pos);
|
||||
vm_instr_t next_opcode = vm_get_instr (int_data_p->bytecode_header_p->instrs_p, int_data_p->pos);
|
||||
if (next_opcode.op_idx == VM_OP_META
|
||||
&& next_opcode.data.meta.type == OPCODE_META_TYPE_CALL_SITE_INFO)
|
||||
{
|
||||
@@ -732,7 +739,9 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int
|
||||
|
||||
/* 6.b.i */
|
||||
ecma_string_t var_name_string;
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, int_data_p->instrs_p, var_idx_lit_oc);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx,
|
||||
int_data_p->bytecode_header_p,
|
||||
var_idx_lit_oc);
|
||||
ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp);
|
||||
|
||||
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (int_data_p->lex_env_p,
|
||||
@@ -1032,7 +1041,7 @@ opfunc_obj_decl (vm_instr_t instr, /**< instruction */
|
||||
|
||||
if (ecma_is_completion_value_empty (evaluate_prop_completion))
|
||||
{
|
||||
vm_instr_t next_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
vm_instr_t next_opcode = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (next_opcode.op_idx == VM_OP_META);
|
||||
|
||||
const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type;
|
||||
@@ -1407,7 +1416,7 @@ opfunc_with (vm_instr_t instr, /**< instruction */
|
||||
frame_ctx_p->lex_env_p = new_env_p;
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, with_end_oc);
|
||||
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, with_end_oc);
|
||||
JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META);
|
||||
JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -1496,7 +1505,9 @@ evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context *
|
||||
}
|
||||
else
|
||||
{
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
|
||||
ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
|
||||
@@ -1612,7 +1623,7 @@ opfunc_delete_var (vm_instr_t instr, /**< instruction */
|
||||
|
||||
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->instrs_p, lit_oc);
|
||||
lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (name_lit_idx, frame_ctx_p->bytecode_header_p, lit_oc);
|
||||
JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL);
|
||||
|
||||
ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp);
|
||||
@@ -1798,7 +1809,7 @@ vm_instr_counter_t
|
||||
vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected type of meta instruction */
|
||||
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
|
||||
{
|
||||
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||
vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, frame_ctx_p->pos);
|
||||
JERRY_ASSERT (meta_opcode.data.meta.type == expected_type);
|
||||
|
||||
const vm_idx_t data_1 = meta_opcode.data.meta.data_1;
|
||||
|
||||
@@ -183,12 +183,17 @@ typedef enum
|
||||
*/
|
||||
struct vm_instr_t;
|
||||
|
||||
/**
|
||||
* Forward declaration of bytecode data header structure
|
||||
*/
|
||||
struct bytecode_data_header_t;
|
||||
|
||||
/**
|
||||
* Context of interpreter, related to a JS stack frame
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const vm_instr_t *instrs_p; /**< currently executed byte-code array */
|
||||
const bytecode_data_header_t *bytecode_header_p; /**< currently executed byte-code data */
|
||||
vm_instr_counter_t pos; /**< current position instruction to execute */
|
||||
ecma_value_t this_binding; /**< this binding for current context */
|
||||
ecma_object_t *lex_env_p; /**< current lexical environment */
|
||||
|
||||
@@ -181,7 +181,7 @@ dump_asm (vm_instr_counter_t oc, vm_instr_t instr)
|
||||
}
|
||||
|
||||
void
|
||||
pp_op_meta (const vm_instr_t *instrs_p,
|
||||
pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
vm_instr_counter_t oc,
|
||||
op_meta opm,
|
||||
bool rewrite)
|
||||
@@ -379,7 +379,7 @@ pp_op_meta (const vm_instr_t *instrs_p,
|
||||
while ((int16_t) start >= 0 && !found)
|
||||
{
|
||||
start--;
|
||||
switch (serializer_get_instr (instrs_p, start).op_idx)
|
||||
switch (serializer_get_instr (bytecode_data_p, start).op_idx)
|
||||
{
|
||||
case VM_OP_CALL_N:
|
||||
case VM_OP_CONSTRUCT_N:
|
||||
@@ -393,7 +393,7 @@ pp_op_meta (const vm_instr_t *instrs_p,
|
||||
}
|
||||
}
|
||||
}
|
||||
vm_instr_t start_op = serializer_get_instr (instrs_p, start);
|
||||
vm_instr_t start_op = serializer_get_instr (bytecode_data_p, start);
|
||||
switch (start_op.op_idx)
|
||||
{
|
||||
case VM_OP_CALL_N:
|
||||
@@ -440,7 +440,7 @@ pp_op_meta (const vm_instr_t *instrs_p,
|
||||
}
|
||||
for (vm_instr_counter_t counter = start; counter <= oc; counter++)
|
||||
{
|
||||
vm_instr_t meta_op = serializer_get_instr (instrs_p, counter);
|
||||
vm_instr_t meta_op = serializer_get_instr (bytecode_data_p, counter);
|
||||
|
||||
switch (meta_op.op_idx)
|
||||
{
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
|
||||
#include "jrt.h"
|
||||
#ifdef JERRY_ENABLE_PRETTY_PRINTER
|
||||
#include "bytecode-data.h"
|
||||
#include "vm.h"
|
||||
#include "scopes-tree.h"
|
||||
|
||||
void pp_op_meta (const vm_instr_t*, vm_instr_counter_t, op_meta, bool);
|
||||
void pp_op_meta (const bytecode_data_header_t *, vm_instr_counter_t, op_meta, bool);
|
||||
#endif // JERRY_ENABLE_PRETTY_PRINTER
|
||||
|
||||
#endif // PRETTY_PRINTER
|
||||
|
||||
+14
-11
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bytecode-data.h"
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-gc.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "mem-allocator.h"
|
||||
#include "vm.h"
|
||||
#include "vm-stack.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
/**
|
||||
* Top (current) interpreter context
|
||||
@@ -46,7 +48,7 @@ static const opfunc __opfuncs[VM_OP__COUNT] =
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (vm_instr_t) <= 4);
|
||||
|
||||
const vm_instr_t *__program = NULL;
|
||||
const bytecode_data_header_t *__program = NULL;
|
||||
|
||||
#ifdef MEM_STATS
|
||||
static const char *__op_names[VM_OP__COUNT] =
|
||||
@@ -295,7 +297,7 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *frame_ctx_p,
|
||||
frame_ctx_p->context_peak_allocated_pool_chunks = JERRY_MAX (frame_ctx_p->context_peak_allocated_pool_chunks,
|
||||
pools_stats_after.allocated_chunks);
|
||||
|
||||
vm_instr_t instr = vm_get_instr (frame_ctx_p->instrs_p, instr_position);
|
||||
vm_instr_t instr = vm_get_instr (frame_ctx_p->bytecode_header_p->instrs_p, instr_position);
|
||||
|
||||
printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
|
||||
indent_prefix,
|
||||
@@ -351,7 +353,7 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *frame_ctx_p,
|
||||
* Initialize interpreter.
|
||||
*/
|
||||
void
|
||||
vm_init (const vm_instr_t *program_p, /**< pointer to byte-code program */
|
||||
vm_init (const bytecode_data_header_t *program_p, /**< pointer to byte-code data */
|
||||
bool dump_mem_stats) /** dump per-instruction memory usage change statistics */
|
||||
{
|
||||
#ifdef MEM_STATS
|
||||
@@ -394,7 +396,7 @@ vm_run_global (void)
|
||||
bool is_strict = false;
|
||||
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->instrs_p,
|
||||
start_pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
@@ -443,11 +445,11 @@ vm_run_global (void)
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
vm_run_eval (const vm_instr_t *instrs_p, /**< instructions array */
|
||||
vm_run_eval (const bytecode_data_header_t *bytecode_data_p, /**< byte-code data header */
|
||||
bool is_direct) /**< is eval called directly? */
|
||||
{
|
||||
vm_instr_counter_t first_instr_index = 0u;
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p,
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (bytecode_data_p->instrs_p,
|
||||
first_instr_index++);
|
||||
bool is_strict = ((scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) != 0);
|
||||
|
||||
@@ -474,7 +476,7 @@ vm_run_eval (const vm_instr_t *instrs_p, /**< instructions array */
|
||||
lex_env_p = strict_lex_env_p;
|
||||
}
|
||||
|
||||
ecma_completion_value_t completion = vm_run_from_pos (instrs_p,
|
||||
ecma_completion_value_t completion = vm_run_from_pos (bytecode_data_p,
|
||||
first_instr_index,
|
||||
this_binding,
|
||||
lex_env_p,
|
||||
@@ -529,12 +531,12 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
|| (run_scope_p->start_oc <= frame_ctx_p->pos
|
||||
&& frame_ctx_p->pos <= run_scope_p->end_oc));
|
||||
|
||||
const vm_instr_t *curr = &frame_ctx_p->instrs_p[frame_ctx_p->pos];
|
||||
const vm_instr_t *curr = &frame_ctx_p->bytecode_header_p->instrs_p[frame_ctx_p->pos];
|
||||
|
||||
#ifdef MEM_STATS
|
||||
const vm_instr_counter_t instr_pos = frame_ctx_p->pos;
|
||||
|
||||
interp_mem_stats_opcode_enter (frame_ctx_p->instrs_p,
|
||||
interp_mem_stats_opcode_enter (frame_ctx_p->bytecode_header_p->instrs_p,
|
||||
instr_pos,
|
||||
&heap_stats_before,
|
||||
&pools_stats_before);
|
||||
@@ -590,7 +592,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
* Run the code, starting from specified instruction position
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
vm_run_from_pos (const bytecode_data_header_t *header_p, /**< byte-code data header */
|
||||
vm_instr_counter_t start_pos, /**< position of starting instruction */
|
||||
ecma_value_t this_binding_value, /**< value of 'ThisBinding' */
|
||||
ecma_object_t *lex_env_p, /**< lexical environment to use */
|
||||
@@ -599,6 +601,7 @@ vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
const vm_instr_t *instrs_p = header_p->instrs_p;
|
||||
const vm_instr_t *curr = &instrs_p[start_pos];
|
||||
JERRY_ASSERT (curr->op_idx == VM_OP_REG_VAR_DECL);
|
||||
|
||||
@@ -612,7 +615,7 @@ vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_t);
|
||||
|
||||
vm_frame_ctx_t frame_ctx;
|
||||
frame_ctx.instrs_p = instrs_p;
|
||||
frame_ctx.bytecode_header_p = header_p;
|
||||
frame_ctx.pos = (vm_instr_counter_t) (start_pos + 1);
|
||||
frame_ctx.this_binding = this_binding_value;
|
||||
frame_ctx.lex_env_p = lex_env_p;
|
||||
|
||||
+4
-3
@@ -16,17 +16,18 @@
|
||||
#ifndef VM_H
|
||||
#define VM_H
|
||||
|
||||
#include "bytecode-data.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "jrt.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
extern void vm_init (const vm_instr_t* program_p, bool dump_mem_stats);
|
||||
extern void vm_init (const bytecode_data_header_t *program_p, bool dump_mem_stats);
|
||||
extern void vm_finalize (void);
|
||||
extern jerry_completion_code_t vm_run_global (void);
|
||||
extern ecma_completion_value_t vm_run_eval (const vm_instr_t *instrs_p,
|
||||
extern ecma_completion_value_t vm_run_eval (const bytecode_data_header_t *bytecode_data_p,
|
||||
bool is_direct);
|
||||
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 vm_instr_t *instrs_p,
|
||||
extern ecma_completion_value_t vm_run_from_pos (const bytecode_data_header_t *header_p,
|
||||
vm_instr_counter_t start_pos,
|
||||
ecma_value_t this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
|
||||
Reference in New Issue
Block a user