Skip to content

Commit 70bc512

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 *jerry_snapshot_version 5 -> 6 JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang [email protected] JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang [email protected]
1 parent baeb83d commit 70bc512

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

jerry-core/jerry-snapshot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ typedef struct
3737
/**
3838
* Jerry snapshot format version
3939
*/
40-
#define JERRY_SNAPSHOT_VERSION (5u)
40+
#define JERRY_SNAPSHOT_VERSION (6u)
4141

4242
#endif /* !JERRY_SNAPSHOT_H */

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

Lines changed: 5 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,8 @@ 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
1454+
|| context_p->register_count > CBC_MAXIMUM_BYTE_VALUE
14541455
|| context_p->literal_count > CBC_MAXIMUM_BYTE_VALUE)
14551456
{
14561457
needs_uint16_arguments = true;
@@ -1471,7 +1472,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
14711472
{
14721473
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) compiled_code_p;
14731474

1474-
args_p->stack_limit = (uint16_t) (context_p->register_count + context_p->stack_limit);
1475+
args_p->stack_limit = context_p->stack_limit;
14751476
args_p->argument_end = context_p->argument_count;
14761477
args_p->register_end = context_p->register_count;
14771478
args_p->ident_end = ident_end;
@@ -1485,7 +1486,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
14851486
{
14861487
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) compiled_code_p;
14871488

1488-
args_p->stack_limit = (uint8_t) (context_p->register_count + context_p->stack_limit);
1489+
args_p->stack_limit = (uint8_t) context_p->stack_limit;
14891490
args_p->argument_end = (uint8_t) context_p->argument_count;
14901491
args_p->register_end = (uint8_t) context_p->register_count;
14911492
args_p->ident_end = (uint8_t) ident_end;

0 commit comments

Comments
 (0)