Extract binary lvalue operators (#2630)

This patch substitutes all binary lvalue operators with an assigment + the corresponding binary operator.
E.g. A += (expression) is pasred as A = A + (expression).

Due to this replacement, all the related binary lvalue CBC opcodes can be removed.
Also the arithmetic related VM instructions can put their result directly onto the stack, since no more checking is needed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-01-10 08:47:45 +01:00
committed by László Langó
parent e8502fa8cc
commit 93ec226650
7 changed files with 134 additions and 175 deletions
+41
View File
@@ -2567,6 +2567,47 @@ lexer_compare_raw_identifier_to_current (parser_context_t *context_p, /**< conte
return memcmp (left_ident_p->char_p, right_ident_p, right_ident_length) == 0;
} /* lexer_compare_raw_identifier_to_current */
/**
* Convert binary lvalue token to binary token
* e.g. += -> +
* ^= -> ^
*
* @return binary token
*/
uint8_t
lexer_convert_binary_lvalue_token_to_binary (uint8_t token) /**< binary lvalue token */
{
JERRY_ASSERT (LEXER_IS_BINARY_LVALUE_TOKEN (token));
JERRY_ASSERT (token != LEXER_ASSIGN);
if (token <= LEXER_ASSIGN_MODULO)
{
return (uint8_t) (LEXER_ADD + (token - LEXER_ASSIGN_ADD));
}
if (token <= LEXER_ASSIGN_UNS_RIGHT_SHIFT)
{
return (uint8_t) (LEXER_LEFT_SHIFT + (token - LEXER_ASSIGN_LEFT_SHIFT));
}
switch (token)
{
case LEXER_ASSIGN_BIT_AND:
{
return LEXER_BIT_AND;
}
case LEXER_ASSIGN_BIT_OR:
{
return LEXER_BIT_OR;
}
default:
{
JERRY_ASSERT (token == LEXER_ASSIGN_BIT_XOR);
return LEXER_BIT_XOR;
}
}
} /* lexer_convert_binary_lvalue_token_to_binary */
/**
* @}
* @}