Introducing 'scope flags' opcode containing set of flags that indicate various properties of a scope; replacing 'strict mode' meta opcode with a flag in the flags set.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -2383,11 +2383,27 @@ dump_variable_declaration (literal_index_t lit_id)
|
||||
serializer_dump_op_meta (create_op_meta_100 (opcode, lit_id));
|
||||
}
|
||||
|
||||
void
|
||||
dump_strict_mode_header (void)
|
||||
opcode_counter_t
|
||||
dump_scope_code_flags_for_rewrite (void)
|
||||
{
|
||||
const opcode_t opcode = getop_meta (OPCODE_META_TYPE_STRICT_CODE, INVALID_VALUE, INVALID_VALUE);
|
||||
opcode_counter_t oc = serializer_get_current_opcode_counter ();
|
||||
|
||||
const opcode_t opcode = getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, INVALID_VALUE, INVALID_VALUE);
|
||||
serializer_dump_op_meta (create_op_meta_000 (opcode));
|
||||
|
||||
return oc;
|
||||
}
|
||||
|
||||
void
|
||||
rewrite_scope_code_flags (opcode_counter_t scope_code_flags_oc,
|
||||
opcode_scope_code_flags_t scope_flags)
|
||||
{
|
||||
JERRY_ASSERT ((idx_t) scope_flags == scope_flags);
|
||||
|
||||
op_meta opm = serializer_get_op_meta (scope_code_flags_oc);
|
||||
JERRY_ASSERT (opm.op.op_idx == OPCODE (meta));
|
||||
opm.op.data.meta.data_1 = (idx_t) scope_flags;
|
||||
serializer_rewrite_op_meta (scope_code_flags_oc, opm);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -217,7 +217,9 @@ void dump_throw (operand);
|
||||
bool dumper_variable_declaration_exists (literal_index_t);
|
||||
void dump_variable_declaration (literal_index_t);
|
||||
|
||||
void dump_strict_mode_header (void);
|
||||
opcode_counter_t dump_scope_code_flags_for_rewrite (void);
|
||||
void rewrite_scope_code_flags (opcode_counter_t scope_code_flags_oc,
|
||||
opcode_scope_code_flags_t scope_flags);
|
||||
|
||||
void dump_reg_var_decl_for_rewrite (void);
|
||||
void rewrite_reg_var_decl (void);
|
||||
|
||||
@@ -2648,10 +2648,14 @@ preparse_scope (bool is_global)
|
||||
const locus start_loc = tok.loc;
|
||||
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 ();
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = OPCODE_SCOPE_CODE_FLAGS__NO_FLAGS;
|
||||
|
||||
if (token_is (TOK_STRING) && literal_equal_s (lexer_get_literal_by_id (token_data ()), "use strict"))
|
||||
{
|
||||
scopes_tree_set_strict_mode (STACK_TOP (scopes), true);
|
||||
dump_strict_mode_header ();
|
||||
scope_flags = (opcode_scope_code_flags_t) (scope_flags | OPCODE_SCOPE_CODE_FLAGS_STRICT);
|
||||
}
|
||||
|
||||
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
|
||||
@@ -2688,6 +2692,8 @@ preparse_scope (bool is_global)
|
||||
skip_newlines ();
|
||||
}
|
||||
|
||||
rewrite_scope_code_flags (scope_code_flags_oc, scope_flags);
|
||||
|
||||
if (start_loc != tok.loc)
|
||||
{
|
||||
lexer_seek (start_loc);
|
||||
|
||||
@@ -354,7 +354,7 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table
|
||||
case OPCODE_META_TYPE_CATCH:
|
||||
case OPCODE_META_TYPE_FINALLY:
|
||||
case OPCODE_META_TYPE_END_TRY_CATCH_FINALLY:
|
||||
case OPCODE_META_TYPE_STRICT_CODE:
|
||||
case OPCODE_META_TYPE_SCOPE_CODE_FLAGS:
|
||||
{
|
||||
change_uid (om, lit_ids, 0x000);
|
||||
break;
|
||||
@@ -493,7 +493,7 @@ count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index)
|
||||
case OPCODE_META_TYPE_CATCH:
|
||||
case OPCODE_META_TYPE_FINALLY:
|
||||
case OPCODE_META_TYPE_END_TRY_CATCH_FINALLY:
|
||||
case OPCODE_META_TYPE_STRICT_CODE:
|
||||
case OPCODE_META_TYPE_SCOPE_CODE_FLAGS:
|
||||
{
|
||||
insert_uids_to_lit_id_map (om, 0x000);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user