Skip to content

Decrease byte-code's register pressure during preparation of long arguments list #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions jerry-core/parser/js/opcodes-dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,41 @@ dumper_finish_scope (void)
STACK_DROP (temp_names, 1);
}

/**
* Handle start of argument preparation instruction sequence generation
*
* Note:
* Values of registers, allocated for the code sequence, are not used outside of the sequence,
* so they can be reused, reducing register pressure.
*
* To reuse the registers, counter of register allocator is saved, and restored then,
* after finishing generation of the code sequence, using dumper_finish_varg_code_sequence.
*
* FIXME:
* Implement general register allocation mechanism
*
* See also:
* dumper_finish_varg_code_sequence
*/
void
dumper_start_varg_code_sequence (void)
{
STACK_PUSH (temp_names, temp_name);
} /* dumper_start_varg_code_sequence */

/**
* Handle finish of argument preparation instruction sequence generation
*
* See also:
* dumper_start_varg_code_sequence
*/
void
dumper_finish_varg_code_sequence (void)
{
temp_name = STACK_TOP (temp_names);
STACK_DROP (temp_names, 1);
} /* dumper_finish_varg_code_sequence */

/**
* Check that byte-code operand refers to 'eval' string
*
Expand Down
2 changes: 2 additions & 0 deletions jerry-core/parser/js/opcodes-dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ void dumper_free (void);
void dumper_new_statement (void);
void dumper_new_scope (void);
void dumper_finish_scope (void);
void dumper_start_varg_code_sequence (void);
void dumper_finish_varg_code_sequence (void);

extern bool dumper_is_eval_literal (operand);

Expand Down
81 changes: 40 additions & 41 deletions jerry-core/parser/js/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,62 +521,61 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
skip_newlines ();
while (!token_is (close_tt))
{
dumper_start_varg_code_sequence ();

operand op;
switch (vlt)

if (vlt == VARG_FUNC_DECL
|| vlt == VARG_FUNC_EXPR)
{
case VARG_FUNC_DECL:
case VARG_FUNC_EXPR:
{
current_token_must_be (TOK_NAME);
op = literal_operand (token_data_as_lit_cp ());
syntax_add_varg (op);
syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc);
break;
}
case VARG_ARRAY_DECL:
{
if (token_is (TOK_COMMA))
{
op = dump_undefined_assignment_res ();
dump_varg (op);
args_num++;
skip_newlines ();
continue;
}
/* FALLTHRU */
}
case VARG_CONSTRUCT_EXPR:
current_token_must_be (TOK_NAME);
op = literal_operand (token_data_as_lit_cp ());
syntax_add_varg (op);
syntax_check_for_eval_and_arguments_in_strict_mode (op, is_strict_mode (), tok.loc);
dump_varg (op);
skip_newlines ();
}
else if (vlt == VARG_CONSTRUCT_EXPR
|| vlt == VARG_CALL_EXPR)
{
op = parse_assignment_expression (true);
dump_varg (op);
skip_newlines ();
}
else if (vlt == VARG_ARRAY_DECL)
{
if (token_is (TOK_COMMA))
{
op = parse_assignment_expression (true);
break;
op = dump_undefined_assignment_res ();
dump_varg (op);
}
case VARG_CALL_EXPR:
else
{
op = parse_assignment_expression (true);
break;
}
case VARG_OBJ_DECL:
{
parse_property_assignment ();
break;
dump_varg (op);
skip_newlines ();
}
}

/* In case of obj_decl prop is already dumped. */
if (vlt != VARG_OBJ_DECL)
else
{
dump_varg (op);
JERRY_ASSERT (vlt == VARG_OBJ_DECL);

parse_property_assignment ();
skip_newlines ();
}
args_num++;

skip_newlines ();
if (!token_is (TOK_COMMA))
if (token_is (TOK_COMMA))
{
skip_newlines ();
}
else
{
current_token_must_be (close_tt);
break;
}

skip_newlines ();
args_num++;

dumper_finish_varg_code_sequence ();
}

if (args_count != NULL)
Expand Down
Loading