Skip to content

Commit 2e2190f

Browse files
Enhancement of argument list parsing loop: removing break / continue operators, so that every iteration passes start and end of loop body.
The change makes possible simple notification of byte-code generator about start / end of byte-code generation for an argument. As register values are not passed between byte-code sequences that prepare different arguments, the change would make possible for byte-code generator to reuse registers allocated for the code sequences. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent f2ec124 commit 2e2190f

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

jerry-core/parser/js/parser.cpp

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -522,61 +522,56 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
522522
while (!token_is (close_tt))
523523
{
524524
operand op;
525-
switch (vlt)
525+
526+
if (vlt == VARG_FUNC_DECL
527+
|| vlt == VARG_FUNC_EXPR)
526528
{
527-
case VARG_FUNC_DECL:
528-
case VARG_FUNC_EXPR:
529-
{
530-
current_token_must_be (TOK_NAME);
531-
op = literal_operand (token_data_as_lit_cp ());
532-
syntax_add_varg (op);
533-
syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc);
534-
break;
535-
}
536-
case VARG_ARRAY_DECL:
537-
{
538-
if (token_is (TOK_COMMA))
539-
{
540-
op = dump_undefined_assignment_res ();
541-
dump_varg (op);
542-
args_num++;
543-
skip_newlines ();
544-
continue;
545-
}
546-
/* FALLTHRU */
547-
}
548-
case VARG_CONSTRUCT_EXPR:
529+
current_token_must_be (TOK_NAME);
530+
op = literal_operand (token_data_as_lit_cp ());
531+
syntax_add_varg (op);
532+
syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc);
533+
dump_varg (op);
534+
skip_newlines ();
535+
}
536+
else if (vlt == VARG_CONSTRUCT_EXPR
537+
|| vlt == VARG_CALL_EXPR)
538+
{
539+
op = parse_assignment_expression (true);
540+
dump_varg (op);
541+
skip_newlines ();
542+
}
543+
else if (vlt == VARG_ARRAY_DECL)
544+
{
545+
if (token_is (TOK_COMMA))
549546
{
550-
op = parse_assignment_expression (true);
551-
break;
547+
op = dump_undefined_assignment_res ();
548+
dump_varg (op);
552549
}
553-
case VARG_CALL_EXPR:
550+
else
554551
{
555552
op = parse_assignment_expression (true);
556-
break;
557-
}
558-
case VARG_OBJ_DECL:
559-
{
560-
parse_property_assignment ();
561-
break;
553+
dump_varg (op);
554+
skip_newlines ();
562555
}
563556
}
564-
565-
/* In case of obj_decl prop is already dumped. */
566-
if (vlt != VARG_OBJ_DECL)
557+
else
567558
{
568-
dump_varg (op);
559+
JERRY_ASSERT (vlt == VARG_OBJ_DECL);
560+
561+
parse_property_assignment ();
562+
skip_newlines ();
569563
}
570-
args_num++;
571564

572-
skip_newlines ();
573-
if (!token_is (TOK_COMMA))
565+
if (token_is (TOK_COMMA))
566+
{
567+
skip_newlines ();
568+
}
569+
else
574570
{
575571
current_token_must_be (close_tt);
576-
break;
577572
}
578573

579-
skip_newlines ();
574+
args_num++;
580575
}
581576

582577
if (args_count != NULL)

0 commit comments

Comments
 (0)