Optimize object literal byte-code - store property names as literal arguments, instead passing them through register variables.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-11-01 19:22:59 +03:00
parent 1fe2817457
commit 911163e787
4 changed files with 41 additions and 55 deletions
+12 -39
View File
@@ -1115,22 +1115,13 @@ dump_prop_name_and_value (jsp_operand_t name, jsp_operand_t value)
{
JERRY_ASSERT (name.is_literal_operand ());
literal_t lit = lit_get_literal_by_cp (name.get_literal ());
jsp_operand_t tmp;
if (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T)
{
tmp = dump_string_assignment_res (name.get_literal ());
}
else
{
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
tmp = dump_number_assignment_res (name.get_literal ());
}
JERRY_ASSERT (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T);
dump_triple_address (VM_OP_META,
jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_DATA),
tmp,
name,
value);
}
@@ -1140,22 +1131,13 @@ dump_prop_getter_decl (jsp_operand_t name, jsp_operand_t func)
JERRY_ASSERT (name.is_literal_operand ());
JERRY_ASSERT (func.is_register_operand ());
literal_t lit = lit_get_literal_by_cp (name.get_literal ());
jsp_operand_t tmp;
if (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T)
{
tmp = dump_string_assignment_res (name.get_literal ());
}
else
{
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
tmp = dump_number_assignment_res (name.get_literal ());
}
JERRY_ASSERT (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T);
dump_triple_address (VM_OP_META,
jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_GETTER),
tmp,
name,
func);
}
@@ -1165,22 +1147,13 @@ dump_prop_setter_decl (jsp_operand_t name, jsp_operand_t func)
JERRY_ASSERT (name.is_literal_operand ());
JERRY_ASSERT (func.is_register_operand ());
literal_t lit = lit_get_literal_by_cp (name.get_literal ());
jsp_operand_t tmp;
if (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T)
{
tmp = dump_string_assignment_res (name.get_literal ());
}
else
{
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
tmp = dump_number_assignment_res (name.get_literal ());
}
JERRY_ASSERT (lit->get_type () == LIT_STR_T
|| lit->get_type () == LIT_MAGIC_STR_T
|| lit->get_type () == LIT_MAGIC_STR_EX_T);
dump_triple_address (VM_OP_META,
jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_SETTER),
tmp,
name,
func);
}
+20 -3
View File
@@ -303,14 +303,31 @@ parse_property_name (void)
{
case TOK_NAME:
case TOK_STRING:
case TOK_NUMBER:
{
return literal_operand (token_data_as_lit_cp ());
}
case TOK_NUMBER:
case TOK_SMALL_INT:
{
literal_t lit = lit_find_or_create_literal_from_num ((ecma_number_t) token_data ());
return literal_operand (lit_cpointer_t::compress (lit));
ecma_number_t num;
if (tok.type == TOK_NUMBER)
{
literal_t num_lit = lit_get_literal_by_cp (token_data_as_lit_cp ());
JERRY_ASSERT (num_lit->get_type () == LIT_NUMBER_T);
num = lit_charset_literal_get_number (num_lit);
}
else
{
num = ((ecma_number_t) token_data ());
}
lit_utf8_byte_t buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
lit_utf8_size_t sz = ecma_number_to_utf8_string (num, buff, sizeof (buff));
JERRY_ASSERT (sz <= ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER);
literal_t str_lit = lit_find_or_create_literal_from_utf8_string (buff, sz);
return literal_operand (lit_cpointer_t::compress (str_lit));
}
case TOK_KEYWORD:
{