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:
@@ -449,13 +449,11 @@ 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 = vm_get_opcode (int_data->pos);
|
||||
if (next_opcode.op_idx == __op__idx_meta
|
||||
&& next_opcode.data.meta.type == OPCODE_META_TYPE_STRICT_CODE)
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (int_data->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
is_strict = true;
|
||||
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_string_t *function_name_string_p = ecma_new_ecma_string_from_lit_index (function_name_lit_id);
|
||||
@@ -548,13 +546,11 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
||||
int_data) + int_data->pos);
|
||||
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)
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (int_data->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
is_strict = true;
|
||||
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_object_t *scope_p;
|
||||
@@ -1651,7 +1647,7 @@ opfunc_meta (opcode_t opdata, /**< operation data */
|
||||
return ecma_make_meta_completion_value ();
|
||||
}
|
||||
|
||||
case OPCODE_META_TYPE_STRICT_CODE:
|
||||
case OPCODE_META_TYPE_SCOPE_CODE_FLAGS:
|
||||
case OPCODE_META_TYPE_UNDEFINED:
|
||||
case OPCODE_META_TYPE_THIS_ARG:
|
||||
case OPCODE_META_TYPE_FUNCTION_END:
|
||||
|
||||
+11
-1
@@ -70,9 +70,19 @@ typedef enum
|
||||
OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, /**< literal index containing name of variable with exception object */
|
||||
OPCODE_META_TYPE_FINALLY, /**< mark of beginning of finally block containing pointer to end of finally block */
|
||||
OPCODE_META_TYPE_END_TRY_CATCH_FINALLY, /**< mark of end of try-catch, try-finally, try-catch-finally blocks */
|
||||
OPCODE_META_TYPE_STRICT_CODE /**< mark of beginning of strict code */
|
||||
OPCODE_META_TYPE_SCOPE_CODE_FLAGS /**< set of flags indicating various properties of the scope's code
|
||||
* (See also: opcode_scope_code_flags_t) */
|
||||
} opcode_meta_type;
|
||||
|
||||
/**
|
||||
* Flags indicating various properties of a scope's code
|
||||
*/
|
||||
typedef enum : idx_t
|
||||
{
|
||||
OPCODE_SCOPE_CODE_FLAGS__NO_FLAGS = (0u), /**< initializer for empty flag set */
|
||||
OPCODE_SCOPE_CODE_FLAGS_STRICT = (1u << 0), /**< code is strict mode code */
|
||||
} opcode_scope_code_flags_t;
|
||||
|
||||
/**
|
||||
* Interpreter context
|
||||
*/
|
||||
|
||||
@@ -625,9 +625,18 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
|
||||
printf ("end try");
|
||||
break;
|
||||
}
|
||||
case OPCODE_META_TYPE_STRICT_CODE:
|
||||
case OPCODE_META_TYPE_SCOPE_CODE_FLAGS:
|
||||
{
|
||||
printf ("use strict;");
|
||||
idx_t scope_flags = opm.op.data.meta.data_1;
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
printf ("[use strict] ");
|
||||
scope_flags &= (idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_STRICT);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (scope_flags == 0);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
+17
-4
@@ -366,12 +366,11 @@ vm_run_global (void)
|
||||
bool is_strict = false;
|
||||
opcode_counter_t start_pos = 0;
|
||||
|
||||
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)
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (start_pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
is_strict = true;
|
||||
start_pos++;
|
||||
}
|
||||
|
||||
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
|
||||
@@ -557,6 +556,20 @@ vm_get_opcode (opcode_counter_t counter) /**< opcode counter */
|
||||
return __program[ counter ];
|
||||
} /* vm_get_opcode */
|
||||
|
||||
/**
|
||||
* Get scope code flags from opcode specified by opcode counter
|
||||
*
|
||||
* @return mask of scope code flags
|
||||
*/
|
||||
opcode_scope_code_flags_t
|
||||
vm_get_scope_flags (opcode_counter_t counter) /**< opcode counter */
|
||||
{
|
||||
opcode_t flags_opcode = vm_get_opcode (counter);
|
||||
JERRY_ASSERT (flags_opcode.op_idx == __op__idx_meta
|
||||
&& flags_opcode.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS);
|
||||
return (opcode_scope_code_flags_t) flags_opcode.data.meta.data_1;
|
||||
} /* vm_get_scope_flags */
|
||||
|
||||
/**
|
||||
* Get this binding of current execution context
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ extern ecma_completion_value_t vm_run_from_pos (opcode_counter_t start_pos,
|
||||
bool is_eval_code);
|
||||
|
||||
extern opcode_t vm_get_opcode (opcode_counter_t counter);
|
||||
extern opcode_scope_code_flags_t vm_get_scope_flags (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