Convert certain push number opcodes to literals (#2328)

Binary operations are much faster with literal arguments.
The byte immediates are still kept for other cases, e.g. array declarations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-05-18 10:22:53 +02:00
committed by yichoi
parent 64b16bf190
commit 5560c76b41
10 changed files with 232 additions and 81 deletions
+5 -6
View File
@@ -808,12 +808,6 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
{
JERRY_ASSERT (context_p->lit_object.index <= CBC_PUSH_NUMBER_BYTE_RANGE_END);
if (context_p->lit_object.index == 0)
{
parser_emit_cbc (context_p, CBC_PUSH_NUMBER_0);
break;
}
parser_emit_cbc_push_number (context_p, is_negative_number);
break;
}
@@ -1563,6 +1557,11 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
{
opcode = LEXER_BINARY_OP_TOKEN_TO_OPCODE (token);
if (PARSER_IS_PUSH_NUMBER (context_p->last_cbc_opcode))
{
lexer_convert_push_number_to_push_literal (context_p);
}
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
{
JERRY_ASSERT (CBC_SAME_ARGS (context_p->last_cbc_opcode, opcode + CBC_BINARY_WITH_LITERAL));