Parser optimizations.
- parser is now non-recursive (i.e. parse function is not called recursively in any case);
- byte-code is now more compact:
- constants are now not immediately dumped upon occurence, but later - where necessary;
- assignments are combined with unary / binary operations;
- binary operations are encoded more compactly in many cases;
- byte-code arrays are now allocated separately for each scope (so, GC of the scopes now becomes possible);
- byte-code is dumped directly into corresponding byte-code arrays:
- linked lists of op_meta are not now used for main code of a scope.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
committed by
Ruben Ayrapetyan
parent
b1de93abd6
commit
50d124bfc3
@@ -21,7 +21,6 @@
|
||||
#include "lexer.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "serializer.h"
|
||||
#include "lit-literal.h"
|
||||
|
||||
static const char* opcode_names[] =
|
||||
@@ -52,6 +51,8 @@ static uint8_t opcode_sizes[] =
|
||||
#include "vm-opcodes.inc.h"
|
||||
};
|
||||
|
||||
const bytecode_data_header_t *bc_to_print_header_p = NULL;
|
||||
|
||||
static char buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
|
||||
|
||||
static void
|
||||
@@ -110,7 +111,9 @@ var_to_str (vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, u
|
||||
}
|
||||
else
|
||||
{
|
||||
return lit_cp_to_str (serializer_get_literal_cp_by_uid (instr.data.raw_args[current_arg - 1], NULL, oc));
|
||||
return lit_cp_to_str (bc_get_literal_cp_by_uid (instr.data.raw_args[current_arg - 1],
|
||||
bc_to_print_header_p,
|
||||
oc));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +189,8 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
op_meta opm,
|
||||
bool rewrite)
|
||||
{
|
||||
bc_to_print_header_p = bytecode_data_p;
|
||||
|
||||
dump_asm (oc, opm.op);
|
||||
printf (" // ");
|
||||
|
||||
@@ -301,6 +306,11 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VM_OP_FUNC_EXPR_REF:
|
||||
{
|
||||
printf ("%s = function ();", VAR (1));
|
||||
break;
|
||||
}
|
||||
case VM_OP_FUNC_EXPR_N:
|
||||
{
|
||||
if (opm.op.data.func_expr_n.arg_list == 0)
|
||||
@@ -378,7 +388,7 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
while ((int16_t) start >= 0 && !found)
|
||||
{
|
||||
start--;
|
||||
switch (serializer_get_instr (bytecode_data_p, start).op_idx)
|
||||
switch (bc_get_instr (bytecode_data_p, start).op_idx)
|
||||
{
|
||||
case VM_OP_CALL_N:
|
||||
case VM_OP_CONSTRUCT_N:
|
||||
@@ -392,7 +402,7 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
}
|
||||
}
|
||||
}
|
||||
vm_instr_t start_op = serializer_get_instr (bytecode_data_p, start);
|
||||
vm_instr_t start_op = bc_get_instr (bytecode_data_p, start);
|
||||
switch (start_op.op_idx)
|
||||
{
|
||||
case VM_OP_CALL_N:
|
||||
@@ -439,7 +449,7 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
}
|
||||
for (vm_instr_counter_t counter = start; counter <= oc; counter++)
|
||||
{
|
||||
vm_instr_t meta_op = serializer_get_instr (bytecode_data_p, counter);
|
||||
vm_instr_t meta_op = bc_get_instr (bytecode_data_p, counter);
|
||||
|
||||
switch (meta_op.op_idx)
|
||||
{
|
||||
@@ -550,48 +560,6 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p,
|
||||
printf ("end try");
|
||||
break;
|
||||
}
|
||||
case OPCODE_META_TYPE_SCOPE_CODE_FLAGS:
|
||||
{
|
||||
if (opm.op.data.meta.data_1 != VM_IDX_REWRITE_GENERAL_CASE
|
||||
&& opm.op.data.meta.data_1 != VM_IDX_EMPTY)
|
||||
{
|
||||
vm_idx_t scope_flags = opm.op.data.meta.data_1;
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
printf ("[use strict] ");
|
||||
scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_STRICT);
|
||||
}
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER)
|
||||
{
|
||||
printf ("[no 'arguments'] ");
|
||||
scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER);
|
||||
}
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER)
|
||||
{
|
||||
printf ("[no 'eval'] ");
|
||||
scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER);
|
||||
}
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_ARGUMENTS_ON_REGISTERS)
|
||||
{
|
||||
printf ("[arguments are placed on registers] ");
|
||||
scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_ARGUMENTS_ON_REGISTERS);
|
||||
}
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NO_LEX_ENV)
|
||||
{
|
||||
printf ("[no lexical environment should be created for the scope] ");
|
||||
scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NO_LEX_ENV);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (scope_flags == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("[to be rewritten]");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
|
||||
Reference in New Issue
Block a user