Skip to content

Commit a599e5b

Browse files
committed
fix bug in vm call_stack_size calculation
call_stack_size should be register_count + maximum stack depth We don't add in the parser to save the size of snapshot header JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang [email protected]
1 parent baeb83d commit a599e5b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
10371037
}
10381038

10391039
JERRY_DEBUG_MSG ("\nFinal byte code dump:\n\n Maximum stack depth: %d\n Flags: [",
1040-
(int) stack_limit);
1040+
(int) (stack_limit + register_end));
10411041

10421042
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING))
10431043
{
@@ -1450,7 +1450,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
14501450
needs_uint16_arguments = false;
14511451
total_size = sizeof (cbc_uint8_arguments_t);
14521452

1453-
if ((context_p->register_count + context_p->stack_limit) > CBC_MAXIMUM_BYTE_VALUE
1453+
if (context_p->stack_limit > CBC_MAXIMUM_BYTE_VALUE
14541454
|| context_p->literal_count > CBC_MAXIMUM_BYTE_VALUE)
14551455
{
14561456
needs_uint16_arguments = true;
@@ -1471,7 +1471,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
14711471
{
14721472
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) compiled_code_p;
14731473

1474-
args_p->stack_limit = (uint16_t) (context_p->register_count + context_p->stack_limit);
1474+
args_p->stack_limit = context_p->stack_limit;
14751475
args_p->argument_end = context_p->argument_count;
14761476
args_p->register_end = context_p->register_count;
14771477
args_p->ident_end = ident_end;
@@ -1485,7 +1485,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
14851485
{
14861486
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) compiled_code_p;
14871487

1488-
args_p->stack_limit = (uint8_t) (context_p->register_count + context_p->stack_limit);
1488+
args_p->stack_limit = (uint8_t) context_p->stack_limit;
14891489
args_p->argument_end = (uint8_t) context_p->argument_count;
14901490
args_p->register_end = (uint8_t) context_p->register_count;
14911491
args_p->ident_end = (uint8_t) ident_end;

0 commit comments

Comments
 (0)