Skip to content

Commit 24c1a93

Browse files
author
Robert Fancsik
authored
Remove block result (#4799)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent c6f9ea6 commit 24c1a93

File tree

15 files changed

+96
-71
lines changed

15 files changed

+96
-71
lines changed

jerry-core/ecma/base/ecma-gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
765765
register_p++;
766766
}
767767

768-
if (ecma_is_value_object (executable_object_p->frame_ctx.block_result))
768+
if (ecma_is_value_object (executable_object_p->iterator))
769769
{
770-
ecma_gc_set_object_visited (ecma_get_object_from_value (executable_object_p->frame_ctx.block_result));
770+
ecma_gc_set_object_visited (ecma_get_object_from_value (executable_object_p->iterator));
771771
}
772772
} /* ecma_gc_mark_executable_object */
773773

jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
9393
{
9494
if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
9595
{
96-
ecma_value_t iterator = generator_object_p->frame_ctx.block_result;
96+
ecma_value_t iterator = generator_object_p->iterator;
9797
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
9898

9999
bool done = false;
@@ -120,7 +120,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
120120
}
121121

122122
ECMA_EXECUTABLE_OBJECT_RESUME_EXEC (generator_object_p);
123-
generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
123+
generator_object_p->iterator = ECMA_VALUE_UNDEFINED;
124124

125125
JERRY_ASSERT (generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
126126
|| ecma_is_value_object (generator_object_p->frame_ctx.stack_top_p[-1]));
@@ -175,7 +175,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
175175

176176
ecma_deref_object (ecma_get_object_from_value (iterator));
177177
generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
178-
generator_object_p->frame_ctx.block_result = iterator;
178+
generator_object_p->iterator = iterator;
179179

180180
if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED)
181181
{

jerry-core/ecma/operations/ecma-async-generator-object.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ecma_async_yield_call (ecma_value_t function, /**< function (takes reference) */
107107
}
108108

109109
ecma_object_t *return_obj_p = ecma_get_object_from_value (function);
110-
ecma_value_t iterator = async_generator_object_p->frame_ctx.block_result;
110+
ecma_value_t iterator = async_generator_object_p->iterator;
111111
ecma_value_t result;
112112

113113
if (argument == ECMA_VALUE_EMPTY)
@@ -136,7 +136,7 @@ static ecma_value_t
136136
ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< async generator */
137137
ecma_value_t value) /**< thrown value */
138138
{
139-
ecma_object_t *obj_p = ecma_get_object_from_value (async_generator_object_p->frame_ctx.block_result);
139+
ecma_object_t *obj_p = ecma_get_object_from_value (async_generator_object_p->iterator);
140140
ecma_value_t result = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_THROW);
141141

142142
if (ECMA_IS_VALUE_ERROR (result))
@@ -204,7 +204,7 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
204204
{
205205
case ECMA_ASYNC_GENERATOR_DO_NEXT:
206206
{
207-
result = ecma_op_iterator_next (async_generator_object_p->frame_ctx.block_result,
207+
result = ecma_op_iterator_next (async_generator_object_p->iterator,
208208
async_generator_object_p->frame_ctx.stack_top_p[-1],
209209
task_p->operation_value);
210210

@@ -256,7 +256,7 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
256256
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result));
257257

258258
async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK;
259-
async_generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
259+
async_generator_object_p->iterator = ECMA_VALUE_UNDEFINED;
260260
async_generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
261261

262262
JERRY_ASSERT (async_generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
@@ -401,7 +401,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl
401401
}
402402
case ECMA_AWAIT_YIELD_RETURN:
403403
{
404-
ecma_object_t *obj_p = ecma_get_object_from_value (executable_object_p->frame_ctx.block_result);
404+
ecma_object_t *obj_p = ecma_get_object_from_value (executable_object_p->iterator);
405405
ecma_value_t result = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_RETURN);
406406

407407
if (ECMA_IS_VALUE_ERROR (result))

jerry-core/ecma/operations/ecma-jobqueue.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
307307
{
308308
if (ECMA_AWAIT_GET_STATE (executable_object_p) <= ECMA_AWAIT_YIELD_END)
309309
{
310-
JERRY_ASSERT (ecma_is_value_object (executable_object_p->frame_ctx.block_result));
311-
executable_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
310+
JERRY_ASSERT (ecma_is_value_object (executable_object_p->iterator));
311+
executable_object_p->iterator = ECMA_VALUE_UNDEFINED;
312312

313313
JERRY_ASSERT (executable_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
314314
|| ecma_is_value_object (executable_object_p->frame_ctx.stack_top_p[-1]));
@@ -349,8 +349,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
349349

350350
if (ECMA_AWAIT_GET_STATE (executable_object_p) <= ECMA_AWAIT_YIELD_END)
351351
{
352-
JERRY_ASSERT (ecma_is_value_object (executable_object_p->frame_ctx.block_result));
353-
executable_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
352+
JERRY_ASSERT (ecma_is_value_object (executable_object_p->iterator));
353+
executable_object_p->iterator = ECMA_VALUE_UNDEFINED;
354354

355355
JERRY_ASSERT (executable_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
356356
|| ecma_is_value_object (executable_object_p->frame_ctx.stack_top_p[-1]));

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 (69u)
33+
#define JERRY_SNAPSHOT_VERSION (70u)
3434

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@
352352
VM_OC_SET_BYTECODE_PTR) \
353353
CBC_OPCODE (CBC_RETURN, CBC_NO_FLAG, -1, \
354354
VM_OC_RETURN | VM_OC_GET_STACK) \
355-
CBC_OPCODE (CBC_RETURN_WITH_BLOCK, CBC_NO_FLAG, 0, \
356-
VM_OC_RETURN) \
355+
CBC_OPCODE (CBC_RETURN_FUNCTION_END, CBC_NO_FLAG, 0, \
356+
VM_OC_RETURN_FUNCTION_END) \
357357
CBC_OPCODE (CBC_RETURN_WITH_LITERAL, CBC_HAS_LITERAL_ARG, 0, \
358358
VM_OC_RETURN | VM_OC_GET_LITERAL) \
359359
CBC_OPCODE (CBC_SET_LITERAL_PROPERTY, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ typedef struct
314314
(PARSER_IS_BASIC_OPCODE (op) ? cbc_flags[(op)] : cbc_ext_flags[PARSER_GET_EXT_OPCODE (op)])
315315

316316
#define PARSER_OPCODE_IS_RETURN(op) \
317-
((op) == CBC_RETURN || (op) == CBC_RETURN_WITH_BLOCK || (op) == CBC_RETURN_WITH_LITERAL)
317+
((op) == CBC_RETURN \
318+
|| (op) == CBC_RETURN_FUNCTION_END \
319+
|| (op) == CBC_RETURN_WITH_LITERAL)
318320

319321
#define PARSER_ARGS_EQ(op, types) \
320322
((PARSER_GET_FLAGS (op) & CBC_ARG_TYPES) == (types))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3169,7 +3169,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
31693169
}
31703170
#endif /* JERRY_ESNEXT */
31713171

3172-
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
3172+
parser_emit_cbc (context_p, CBC_RETURN_FUNCTION_END);
31733173
break;
31743174
}
31753175

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
12771277

12781278
if (!(context_p->status_flags & PARSER_NO_END_LABEL))
12791279
{
1280-
*dst_p++ = CBC_RETURN_WITH_BLOCK;
1280+
*dst_p++ = CBC_RETURN_FUNCTION_END;
12811281

12821282
#if JERRY_ESNEXT
12831283
if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
@@ -2150,8 +2150,8 @@ parser_parse_source (void *source_p, /**< source code */
21502150
parser_branch_t branch;
21512151
parser_emit_cbc_forward_branch (&context, CBC_JUMP_FORWARD, &branch);
21522152

2153-
scanner_create_variables (&context, SCANNER_CREATE_VARS_NO_OPTS);
2154-
parser_emit_cbc (&context, CBC_RETURN_WITH_BLOCK);
2153+
scanner_create_variables (&context, SCANNER_CREATE_VARS_IS_MODULE);
2154+
parser_emit_cbc (&context, CBC_RETURN_FUNCTION_END);
21552155

21562156
parser_set_branch_to_current_position (&context, &branch);
21572157
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
20012001
: info_p->type == SCANNER_TYPE_FUNCTION));
20022002

20032003
uint32_t scope_stack_reg_top = (check_type != PARSER_CHECK_GLOBAL_CONTEXT ? context_p->scope_stack_reg_top
2004-
: 0);
2004+
: 1); /* block result */
20052005
#else /* !JERRY_ESNEXT */
20062006
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
20072007
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
@@ -2333,6 +2333,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
23332333
JERRY_ASSERT (info_type == SCANNER_TYPE_FUNCTION
23342334
|| !(option_flags & (SCANNER_CREATE_VARS_IS_FUNCTION_ARGS | SCANNER_CREATE_VARS_IS_FUNCTION_BODY)));
23352335

2336+
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
2337+
23362338
if (info_type == SCANNER_TYPE_FUNCTION && !(option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY))
23372339
{
23382340
JERRY_ASSERT (context_p->scope_stack_p == NULL);
@@ -2349,6 +2351,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
23492351

23502352
context_p->scope_stack_p = scope_stack_p;
23512353
scope_stack_end_p = scope_stack_p + context_p->scope_stack_size;
2354+
2355+
if (option_flags & (SCANNER_CREATE_VARS_IS_SCRIPT | SCANNER_CREATE_VARS_IS_MODULE))
2356+
{
2357+
scope_stack_reg_top++; /* block result */
2358+
}
23522359
}
23532360
else
23542361
{
@@ -2359,8 +2366,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
23592366
scope_stack_p += context_p->scope_stack_top;
23602367
}
23612368

2362-
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
2363-
23642369
literal.char_p = info_p->source_p - 1;
23652370

23662371
while (next_data_p[0] != SCANNER_STREAM_TYPE_END)

0 commit comments

Comments
 (0)