Skip to content

Commit 2058ea1

Browse files
authored
Implement eval support for functions with arguments lexical env. (#3806)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent fed1b0c commit 2058ea1

File tree

11 files changed

+208
-38
lines changed

11 files changed

+208
-38
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,24 @@ typedef enum
110110
ECMA_PARSE_MODULE = (1u << 1), /**< module is parsed */
111111
ECMA_PARSE_EVAL = (1u << 2), /**< eval is called */
112112
ECMA_PARSE_DIRECT_EVAL = (1u << 3), /**< eval is called directly (ECMA-262 v5, 15.1.2.1.1) */
113+
ECMA_PARSE_CLASS_CONSTRUCTOR = (1u << 4), /**< a class constructor is being parsed */
113114

114-
/* These 4 status flags must be in this order. See PARSER_SAVED_FLAGS_OFFSET. */
115-
ECMA_PARSE_CLASS_CONSTRUCTOR = (1u << 4), /**< a class constructor is being parsed (this value must be kept in
116-
* in sync with PARSER_CLASS_CONSTRUCTOR) */
115+
/* These four status flags must be in this order. The first three are also parser status flags.
116+
* See PARSER_SAVE_STATUS_FLAGS / PARSER_RESTORE_STATUS_FLAGS. */
117117
ECMA_PARSE_ALLOW_SUPER = (1u << 5), /**< allow super property access */
118118
ECMA_PARSE_ALLOW_SUPER_CALL = (1u << 6), /**< allow super constructor call */
119119
ECMA_PARSE_ALLOW_NEW_TARGET = (1u << 7), /**< allow new.target access */
120+
ECMA_PARSE_FUNCTION_CONTEXT = (1u << 8), /**< function context is present (ECMA_PARSE_DIRECT_EVAL must be set) */
120121

121-
ECMA_PARSE_GENERATOR_FUNCTION = (1u << 8), /**< generator function is parsed */
122+
ECMA_PARSE_GENERATOR_FUNCTION = (1u << 9), /**< generator function is parsed */
122123

123124
/* These flags are internally used by the parser. */
124125
#ifndef JERRY_NDEBUG
125126
/**
126127
* This flag represents an error in for in/of statements, which cannot be set
127128
* if the parsing is completed successfully.
128129
*/
129-
ECMA_PARSE_INTERNAL_FOR_IN_OFF_CONTEXT_ERROR = (1u << 9),
130+
ECMA_PARSE_INTERNAL_FOR_IN_OFF_CONTEXT_ERROR = (1u << 30),
130131
#endif /* !JERRY_NDEBUG */
131132
} ecma_parse_opts_t;
132133

@@ -707,7 +708,8 @@ typedef enum
707708
/**
708709
* Get JERRY_CONTEXT (status_flags) top 8 bits.
709710
*/
710-
#define ECMA_GET_LOCAL_PARSE_OPTS() (JERRY_CONTEXT (status_flags) >> ECMA_LOCAL_PARSE_OPTS_OFFSET)
711+
#define ECMA_GET_LOCAL_PARSE_OPTS() \
712+
(JERRY_CONTEXT (status_flags) >> (ECMA_LOCAL_PARSE_OPTS_OFFSET - JERRY_LOG2 (ECMA_PARSE_ALLOW_SUPER)))
711713

712714
/**
713715
* Clear JERRY_CONTEXT (status_flags) top 8 bits.

jerry-core/include/jerryscript-snapshot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C"
3030
/**
3131
* Jerry snapshot format version.
3232
*/
33-
#define JERRY_SNAPSHOT_VERSION (46u)
33+
#define JERRY_SNAPSHOT_VERSION (47u)
3434

3535
/**
3636
* Flags for jerry_generate_snapshot and jerry_generate_function_snapshot.

jerry-core/parser/js/byte-code.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ JERRY_STATIC_ASSERT ((sizeof (cbc_uint16_arguments_t) % sizeof (jmem_cpointer_t)
2727
*/
2828
JERRY_STATIC_ASSERT (CBC_END == 238,
2929
number_of_cbc_opcodes_changed);
30-
JERRY_STATIC_ASSERT (CBC_EXT_END == 116,
30+
JERRY_STATIC_ASSERT (CBC_EXT_END == 118,
3131
number_of_cbc_ext_opcodes_changed);
3232

3333
#if ENABLED (JERRY_PARSER)

jerry-core/parser/js/byte-code.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@
566566
VM_OC_PUSH_LIT_POS_BYTE | VM_OC_GET_LITERAL) \
567567
CBC_OPCODE (CBC_EXT_PUSH_LITERAL_PUSH_NUMBER_NEG_BYTE, CBC_HAS_LITERAL_ARG | CBC_HAS_BYTE_ARG, 2, \
568568
VM_OC_PUSH_LIT_NEG_BYTE | VM_OC_GET_LITERAL) \
569+
CBC_OPCODE (CBC_EXT_CREATE_VAR_EVAL, CBC_HAS_LITERAL_ARG, 0, \
570+
VM_OC_EXT_VAR_EVAL) \
571+
CBC_OPCODE (CBC_EXT_CREATE_VAR_FUNC_EVAL, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \
572+
VM_OC_EXT_VAR_EVAL) \
569573
CBC_OPCODE (CBC_EXT_STRING_CONCAT, CBC_NO_FLAG, -1, \
570574
VM_OC_STRING_CONCAT | VM_OC_GET_STACK_STACK | VM_OC_PUT_STACK) \
571575
CBC_OPCODE (CBC_EXT_STRING_CONCAT_RIGHT_LITERAL, CBC_HAS_LITERAL_ARG, 0, \

jerry-core/parser/js/js-parser-expr.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,16 +2224,23 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */
22242224
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
22252225

22262226
#if ENABLED (JERRY_ES2015)
2227+
uint16_t eval_flags = PARSER_SAVE_STATUS_FLAGS (context_p->status_flags);
2228+
const uint32_t required_flags = PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED;
2229+
22272230
if (context_p->status_flags & PARSER_FUNCTION_IS_PARSING_ARGS)
22282231
{
22292232
context_p->status_flags |= PARSER_LEXICAL_BLOCK_NEEDED;
22302233
}
2234+
else if (((context_p->status_flags & (required_flags | PARSER_IS_STRICT)) == required_flags)
2235+
|| ((context_p->global_status_flags & ECMA_PARSE_FUNCTION_CONTEXT)
2236+
&& !(context_p->status_flags & PARSER_IS_FUNCTION)))
2237+
{
2238+
eval_flags |= PARSER_GET_EVAL_FLAG (ECMA_PARSE_FUNCTION_CONTEXT);
2239+
}
22312240

2232-
if (context_p->status_flags & (PARSER_ALLOW_SUPER_CALL | PARSER_ALLOW_SUPER | PARSER_ALLOW_NEW_TARGET))
2241+
if (eval_flags != 0)
22332242
{
2234-
parser_emit_cbc_ext_call (context_p,
2235-
CBC_EXT_LOCAL_EVAL,
2236-
PARSER_SAVE_STATUS_FLAGS (context_p->status_flags));
2243+
parser_emit_cbc_ext_call (context_p, CBC_EXT_LOCAL_EVAL, eval_flags);
22372244
}
22382245
else
22392246
{

jerry-core/parser/js/js-parser-internal.h

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ typedef enum
6767
PARSER_FUNCTION_IS_PARSING_ARGS = (1u << 17), /**< set when parsing function arguments */
6868
PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM = (1u << 18), /**< function has a non simple parameter */
6969
PARSER_FUNCTION_HAS_REST_PARAM = (1u << 19), /**< function has rest parameter */
70-
/* These 4 status flags must be in this order. See PARSER_SAVED_FLAGS_OFFSET. */
7170
PARSER_CLASS_CONSTRUCTOR = (1u << 20), /**< a class constructor is parsed
7271
* Note: PARSER_ALLOW_SUPER must be present */
72+
/* These three status flags must be in this order. See PARSER_SAVED_FLAGS_OFFSET. */
7373
PARSER_ALLOW_SUPER = (1u << 21), /**< allow super property access */
7474
PARSER_ALLOW_SUPER_CALL = (1u << 22), /**< allow super constructor call
7575
* Note: PARSER_CLASS_CONSTRUCTOR must be present */
@@ -154,41 +154,53 @@ typedef enum
154154

155155
#if ENABLED (JERRY_ES2015)
156156
/**
157-
* Offset between PARSER_CLASS_CONSTRUCTOR and ECMA_PARSE_CLASS_CONSTRUCTOR
157+
* Offset of PARSER_ALLOW_SUPER
158158
*/
159159
#define PARSER_SAVED_FLAGS_OFFSET \
160-
(JERRY_LOG2 (PARSER_CLASS_CONSTRUCTOR) - JERRY_LOG2 (ECMA_PARSE_CLASS_CONSTRUCTOR))
160+
JERRY_LOG2 (PARSER_ALLOW_SUPER)
161161

162162
/**
163-
* Count of ecma_parse_opts_t class parsing options related bits
163+
* Mask of saved flags
164164
*/
165-
#define PARSER_SAVED_FLAGS_COUNT \
166-
(JERRY_LOG2 (ECMA_PARSE_ALLOW_NEW_TARGET) - JERRY_LOG2 (ECMA_PARSE_CLASS_CONSTRUCTOR) + 1)
165+
#define PARSER_SAVED_FLAGS_MASK \
166+
((1 << (JERRY_LOG2 (PARSER_ALLOW_NEW_TARGET) - JERRY_LOG2 (PARSER_ALLOW_SUPER) + 1)) - 1)
167+
168+
/**
169+
* Get class option bits from parser_general_flags_t
170+
*/
171+
#define PARSER_SAVE_STATUS_FLAGS(opts) \
172+
((uint16_t) (((opts) >> PARSER_SAVED_FLAGS_OFFSET) & PARSER_SAVED_FLAGS_MASK))
167173

168174
/**
169175
* Mask for get class option bits from ecma_parse_opts_t
170176
*/
171-
#define PARSER_CLASS_ECMA_PARSE_OPTS_TO_PARSER_OPTS_MASK \
172-
(((1 << PARSER_SAVED_FLAGS_COUNT) - 1) << JERRY_LOG2 (ECMA_PARSE_CLASS_CONSTRUCTOR))
177+
#define PARSER_RESTORE_STATUS_FLAGS_MASK \
178+
(((ECMA_PARSE_ALLOW_NEW_TARGET << 1) - 1) - (ECMA_PARSE_ALLOW_SUPER - 1))
173179

174180
/**
175-
* Get class option bits from ecma_parse_opts_t
181+
* Shift for get class option bits from ecma_parse_opts_t
176182
*/
177-
#define PARSER_GET_SAVED_FLAGS(opts) \
178-
(((opts) & PARSER_CLASS_ECMA_PARSE_OPTS_TO_PARSER_OPTS_MASK) << PARSER_SAVED_FLAGS_OFFSET)
183+
#define PARSER_RESTORE_STATUS_FLAGS_SHIFT \
184+
(JERRY_LOG2 (PARSER_ALLOW_SUPER) - JERRY_LOG2 (ECMA_PARSE_ALLOW_SUPER))
179185

180186
/**
181-
* Get class option bits from parser_general_flags_t
187+
* Get class option bits from ecma_parse_opts_t
182188
*/
183-
#define PARSER_SAVE_STATUS_FLAGS(opts) \
184-
((uint16_t) (((opts) >> PARSER_SAVED_FLAGS_OFFSET) & PARSER_CLASS_ECMA_PARSE_OPTS_TO_PARSER_OPTS_MASK))
189+
#define PARSER_RESTORE_STATUS_FLAGS(opts) \
190+
(((opts) & PARSER_RESTORE_STATUS_FLAGS_MASK) << PARSER_RESTORE_STATUS_FLAGS_SHIFT)
185191

186192
/**
187193
* All flags that affect exotic arguments object creation.
188194
*/
189195
#define PARSER_ARGUMENTS_RELATED_FLAGS \
190196
(PARSER_ARGUMENTS_NEEDED | PARSER_FUNCTION_HAS_NON_SIMPLE_PARAM | PARSER_IS_STRICT)
191197

198+
/**
199+
* Get the corresponding eval flag for a ecma_parse_opts_t flag
200+
*/
201+
#define PARSER_GET_EVAL_FLAG(type) \
202+
((type) >> JERRY_LOG2 (ECMA_PARSE_ALLOW_SUPER))
203+
192204
#else /* !ENABLED (JERRY_ES2015) */
193205

194206
/**

jerry-core/parser/js/js-parser.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
2727
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
2828

2929
#if ENABLED (JERRY_ES2015)
30-
JERRY_STATIC_ASSERT ((ECMA_PARSE_CLASS_CONSTRUCTOR << PARSER_SAVED_FLAGS_OFFSET) == PARSER_CLASS_CONSTRUCTOR,
31-
ecma_saved_parse_options_must_be_transformed_to_ecma_general_flags);
30+
JERRY_STATIC_ASSERT (PARSER_SAVE_STATUS_FLAGS (PARSER_ALLOW_SUPER) == 0x1,
31+
incorrect_saving_of_ecma_parse_allow_super);
32+
JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_ALLOW_SUPER) == PARSER_ALLOW_SUPER,
33+
incorrect_restoring_of_ecma_parse_allow_super);
34+
35+
JERRY_STATIC_ASSERT (PARSER_RESTORE_STATUS_FLAGS (ECMA_PARSE_FUNCTION_CONTEXT) == 0,
36+
ecma_parse_function_context_must_not_be_transformed);
3237
#endif /* ENABLED (JERRY_ES2015) */
3338

3439
/** \addtogroup parser Parser
@@ -2016,7 +2021,7 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
20162021
}
20172022

20182023
#if ENABLED (JERRY_ES2015)
2019-
context.status_flags |= PARSER_GET_SAVED_FLAGS (parse_opts);
2024+
context.status_flags |= PARSER_RESTORE_STATUS_FLAGS (parse_opts);
20202025
context.tagged_template_literal_cp = JMEM_CP_NULL;
20212026
#endif /* ENABLED (JERRY_ES2015) */
20222027

jerry-core/parser/js/js-scanner-util.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,9 +2227,9 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
22272227
context_p->scope_stack_top = (uint16_t) (scope_stack_p - context_p->scope_stack_p);
22282228
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
22292229

2230-
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL
2231-
: CBC_CREATE_VAR);
22322230
#if ENABLED (JERRY_ES2015)
2231+
uint16_t opcode;
2232+
22332233
switch (type)
22342234
{
22352235
case SCANNER_STREAM_TYPE_LET:
@@ -2242,14 +2242,34 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
22422242
opcode = CBC_CREATE_CONST;
22432243
break;
22442244
}
2245-
case SCANNER_STREAM_TYPE_LOCAL:
2246-
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG:
2247-
case SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC:
2245+
case SCANNER_STREAM_TYPE_VAR:
2246+
{
2247+
opcode = CBC_CREATE_VAR;
2248+
2249+
if (option_flags & SCANNER_CREATE_VARS_IS_SCRIPT)
2250+
{
2251+
opcode = CBC_CREATE_VAR_EVAL;
2252+
2253+
if (context_p->global_status_flags & ECMA_PARSE_FUNCTION_CONTEXT)
2254+
{
2255+
opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_CREATE_VAR_EVAL);
2256+
}
2257+
}
2258+
break;
2259+
}
2260+
default:
22482261
{
2262+
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_LOCAL
2263+
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG
2264+
|| type == SCANNER_STREAM_TYPE_DESTRUCTURED_ARG_FUNC);
2265+
22492266
opcode = CBC_CREATE_LOCAL;
22502267
break;
22512268
}
22522269
}
2270+
#else /* !ENABLED (JERRY_ES2015) */
2271+
uint16_t opcode = ((option_flags & SCANNER_CREATE_VARS_IS_SCRIPT) ? CBC_CREATE_VAR_EVAL
2272+
: CBC_CREATE_VAR);
22532273
#endif /* ENABLED (JERRY_ES2015) */
22542274

22552275
parser_emit_cbc_literal (context_p, opcode, map_to);
@@ -2323,6 +2343,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
23232343
|| !scanner_scope_find_let_declaration (context_p, &literal))
23242344
{
23252345
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
2346+
2347+
if (context_p->global_status_flags & ECMA_PARSE_FUNCTION_CONTEXT)
2348+
{
2349+
func_init_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_CREATE_VAR_FUNC_EVAL);
2350+
}
23262351
}
23272352
literal.char_p += data_p[1];
23282353
#else /* !ENABLED (JERRY_ES2015) */

jerry-core/vm/vm.c

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,39 +1322,41 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
13221322
{
13231323
uint32_t value_index;
13241324
READ_LITERAL_INDEX (value_index);
1325+
JERRY_ASSERT (value_index >= const_literal_end);
13251326

13261327
lit_value = vm_construct_literal_object (frame_ctx_p,
13271328
literal_start_p[value_index]);
13281329
}
13291330

13301331
READ_LITERAL_INDEX (literal_index);
1332+
JERRY_ASSERT (literal_index >= register_end);
13311333

13321334
ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
13331335
ecma_object_t *lex_env_p = frame_ctx_p->lex_env_p;
13341336

13351337
while (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_BLOCK)
13361338
{
1337-
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
1339+
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
13381340
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
13391341
{
13401342
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
13411343

13421344
JERRY_ASSERT (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_ENUMERABLE));
13431345
}
1344-
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
1346+
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
13451347

13461348
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
13471349
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
13481350
}
13491351

1350-
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
1352+
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
13511353
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
13521354
{
13531355
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
13541356

13551357
JERRY_ASSERT (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_ENUMERABLE));
13561358
}
1357-
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
1359+
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
13581360

13591361
result = vm_var_decl (lex_env_p, name_p, frame_ctx_p->is_eval_code);
13601362

@@ -1375,6 +1377,68 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
13751377

13761378
continue;
13771379
}
1380+
#if ENABLED (JERRY_ES2015)
1381+
case VM_OC_EXT_VAR_EVAL:
1382+
{
1383+
uint32_t literal_index;
1384+
ecma_value_t lit_value = ECMA_VALUE_UNDEFINED;
1385+
1386+
JERRY_ASSERT (byte_code_start_p[0] == CBC_EXT_OPCODE);
1387+
1388+
if (opcode == CBC_EXT_CREATE_VAR_FUNC_EVAL)
1389+
{
1390+
uint32_t value_index;
1391+
READ_LITERAL_INDEX (value_index);
1392+
JERRY_ASSERT (value_index >= const_literal_end);
1393+
1394+
lit_value = vm_construct_literal_object (frame_ctx_p,
1395+
literal_start_p[value_index]);
1396+
}
1397+
1398+
READ_LITERAL_INDEX (literal_index);
1399+
JERRY_ASSERT (literal_index >= register_end);
1400+
1401+
ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
1402+
ecma_object_t *lex_env_p = frame_ctx_p->lex_env_p;
1403+
ecma_object_t *prev_lex_env_p = NULL;
1404+
1405+
while (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_BLOCK)
1406+
{
1407+
#if !(defined JERRY_NDEBUG)
1408+
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
1409+
{
1410+
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
1411+
1412+
JERRY_ASSERT (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_ENUMERABLE));
1413+
}
1414+
#endif /* !JERRY_NDEBUG */
1415+
1416+
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
1417+
prev_lex_env_p = lex_env_p;
1418+
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
1419+
}
1420+
1421+
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
1422+
JERRY_ASSERT (prev_lex_env_p != NULL
1423+
&& ecma_get_lex_env_type (prev_lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
1424+
JERRY_ASSERT (ecma_find_named_property (prev_lex_env_p, name_p) == NULL);
1425+
1426+
ecma_property_value_t *property_value_p;
1427+
property_value_p = ecma_create_named_data_property (prev_lex_env_p,
1428+
name_p,
1429+
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
1430+
NULL);
1431+
1432+
if (lit_value == ECMA_VALUE_UNDEFINED)
1433+
{
1434+
continue;
1435+
}
1436+
1437+
property_value_p->value = lit_value;
1438+
ecma_deref_object (ecma_get_object_from_value (lit_value));
1439+
continue;
1440+
}
1441+
#endif /* ENABLED (JERRY_ES2015) */
13781442
#if ENABLED (JERRY_SNAPSHOT_EXEC)
13791443
case VM_OC_SET_BYTECODE_PTR:
13801444
{

jerry-core/vm/vm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ typedef enum
219219
VM_OC_CREATE_BINDING, /**< create variables */
220220
VM_OC_SET_BYTECODE_PTR, /**< setting bytecode pointer */
221221
VM_OC_VAR_EVAL, /**< variable and function evaluation */
222+
#if ENABLED (JERRY_ES2015)
223+
VM_OC_EXT_VAR_EVAL, /**< variable and function evaluation for
224+
* functions with separate argument context */
225+
#endif /* ENABLED (JERRY_ES2015) */
222226
VM_OC_INIT_ARG_OR_FUNC, /**< create and init a function or argument binding */
223227

224228
#if ENABLED (JERRY_DEBUGGER)
@@ -298,6 +302,8 @@ typedef enum
298302
VM_OC_LINE = VM_OC_NONE, /**< line number of the next statement is unused */
299303
#endif /* !ENABLED (JERRY_LINE_INFO) */
300304
#if !ENABLED (JERRY_ES2015)
305+
VM_OC_EXT_VAR_EVAL = VM_OC_NONE, /**< variable and function evaluation for
306+
* functions with separate argument context */
301307
VM_OC_CHECK_VAR = VM_OC_NONE, /**< check redeclared vars in the global scope */
302308
VM_OC_CHECK_LET = VM_OC_NONE, /**< check redeclared lets in the global scope */
303309
VM_OC_ASSIGN_LET_CONST = VM_OC_NONE, /**< assign values to let/const declarations */

0 commit comments

Comments
 (0)