Remove block result (#4799)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
Robert Fancsik
2021-10-27 10:59:00 +02:00
committed by GitHub
parent c6f9ea65ce
commit 24c1a93d91
15 changed files with 96 additions and 71 deletions
+2 -2
View File
@@ -352,8 +352,8 @@
VM_OC_SET_BYTECODE_PTR) \
CBC_OPCODE (CBC_RETURN, CBC_NO_FLAG, -1, \
VM_OC_RETURN | VM_OC_GET_STACK) \
CBC_OPCODE (CBC_RETURN_WITH_BLOCK, CBC_NO_FLAG, 0, \
VM_OC_RETURN) \
CBC_OPCODE (CBC_RETURN_FUNCTION_END, CBC_NO_FLAG, 0, \
VM_OC_RETURN_FUNCTION_END) \
CBC_OPCODE (CBC_RETURN_WITH_LITERAL, CBC_HAS_LITERAL_ARG, 0, \
VM_OC_RETURN | VM_OC_GET_LITERAL) \
CBC_OPCODE (CBC_SET_LITERAL_PROPERTY, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \
+3 -1
View File
@@ -314,7 +314,9 @@ typedef struct
(PARSER_IS_BASIC_OPCODE (op) ? cbc_flags[(op)] : cbc_ext_flags[PARSER_GET_EXT_OPCODE (op)])
#define PARSER_OPCODE_IS_RETURN(op) \
((op) == CBC_RETURN || (op) == CBC_RETURN_WITH_BLOCK || (op) == CBC_RETURN_WITH_LITERAL)
((op) == CBC_RETURN \
|| (op) == CBC_RETURN_FUNCTION_END \
|| (op) == CBC_RETURN_WITH_LITERAL)
#define PARSER_ARGS_EQ(op, types) \
((PARSER_GET_FLAGS (op) & CBC_ARG_TYPES) == (types))
+1 -1
View File
@@ -3169,7 +3169,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
parser_emit_cbc (context_p, CBC_RETURN_FUNCTION_END);
break;
}
+3 -3
View File
@@ -1277,7 +1277,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
if (!(context_p->status_flags & PARSER_NO_END_LABEL))
{
*dst_p++ = CBC_RETURN_WITH_BLOCK;
*dst_p++ = CBC_RETURN_FUNCTION_END;
#if JERRY_ESNEXT
if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
@@ -2150,8 +2150,8 @@ parser_parse_source (void *source_p, /**< source code */
parser_branch_t branch;
parser_emit_cbc_forward_branch (&context, CBC_JUMP_FORWARD, &branch);
scanner_create_variables (&context, SCANNER_CREATE_VARS_NO_OPTS);
parser_emit_cbc (&context, CBC_RETURN_WITH_BLOCK);
scanner_create_variables (&context, SCANNER_CREATE_VARS_IS_MODULE);
parser_emit_cbc (&context, CBC_RETURN_FUNCTION_END);
parser_set_branch_to_current_position (&context, &branch);
}
+8 -3
View File
@@ -2001,7 +2001,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
: info_p->type == SCANNER_TYPE_FUNCTION));
uint32_t scope_stack_reg_top = (check_type != PARSER_CHECK_GLOBAL_CONTEXT ? context_p->scope_stack_reg_top
: 0);
: 1); /* block result */
#else /* !JERRY_ESNEXT */
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
@@ -2333,6 +2333,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
JERRY_ASSERT (info_type == SCANNER_TYPE_FUNCTION
|| !(option_flags & (SCANNER_CREATE_VARS_IS_FUNCTION_ARGS | SCANNER_CREATE_VARS_IS_FUNCTION_BODY)));
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
if (info_type == SCANNER_TYPE_FUNCTION && !(option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY))
{
JERRY_ASSERT (context_p->scope_stack_p == NULL);
@@ -2349,6 +2351,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
context_p->scope_stack_p = scope_stack_p;
scope_stack_end_p = scope_stack_p + context_p->scope_stack_size;
if (option_flags & (SCANNER_CREATE_VARS_IS_SCRIPT | SCANNER_CREATE_VARS_IS_MODULE))
{
scope_stack_reg_top++; /* block result */
}
}
else
{
@@ -2359,8 +2366,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
scope_stack_p += context_p->scope_stack_top;
}
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
literal.char_p = info_p->source_p - 1;
while (next_data_p[0] != SCANNER_STREAM_TYPE_END)
+3 -2
View File
@@ -284,8 +284,9 @@ typedef enum
{
SCANNER_CREATE_VARS_NO_OPTS = 0, /**< no options */
SCANNER_CREATE_VARS_IS_SCRIPT = (1 << 0), /**< create variables for script or direct eval */
SCANNER_CREATE_VARS_IS_FUNCTION_ARGS = (1 << 1), /**< create variables for function arguments */
SCANNER_CREATE_VARS_IS_FUNCTION_BODY = (1 << 2), /**< create variables for function body */
SCANNER_CREATE_VARS_IS_MODULE = (1 << 1), /**< create variables for module */
SCANNER_CREATE_VARS_IS_FUNCTION_ARGS = (1 << 2), /**< create variables for function arguments */
SCANNER_CREATE_VARS_IS_FUNCTION_BODY = (1 << 3), /**< create variables for function body */
} scanner_create_variables_flags_t;
/**