Replace array of literals with literal storage.
JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin e.gavrin@samsung.com JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
@@ -14,14 +14,11 @@
|
||||
*/
|
||||
|
||||
#include "opcodes-dumper.h"
|
||||
|
||||
#include "serializer.h"
|
||||
#include "jrt.h"
|
||||
#include "lexer.h"
|
||||
#include "stack.h"
|
||||
#include "syntax-errors.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "opcodes-native-call.h"
|
||||
#include "serializer.h"
|
||||
|
||||
#define MIN_TEMP_NAME 128
|
||||
static idx_t temp_name, max_temp_name;
|
||||
@@ -136,7 +133,7 @@ next_temp_name (void)
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id2, literal_index_t lit_id3)
|
||||
create_op_meta (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3)
|
||||
{
|
||||
op_meta ret;
|
||||
|
||||
@@ -155,43 +152,43 @@ create_op_meta_000 (opcode_t op)
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_001 (opcode_t op, literal_index_t lit_id)
|
||||
create_op_meta_001 (opcode_t op, lit_cpointer_t lit_id)
|
||||
{
|
||||
return create_op_meta (op, NOT_A_LITERAL, NOT_A_LITERAL, lit_id);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_010 (opcode_t op, literal_index_t lit_id)
|
||||
create_op_meta_010 (opcode_t op, lit_cpointer_t lit_id)
|
||||
{
|
||||
return create_op_meta (op, NOT_A_LITERAL, lit_id, NOT_A_LITERAL);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_011 (opcode_t op, literal_index_t lit_id2, literal_index_t lit_id3)
|
||||
create_op_meta_011 (opcode_t op, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3)
|
||||
{
|
||||
return create_op_meta (op, NOT_A_LITERAL, lit_id2, lit_id3);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_100 (opcode_t op, literal_index_t lit_id)
|
||||
create_op_meta_100 (opcode_t op, lit_cpointer_t lit_id)
|
||||
{
|
||||
return create_op_meta (op, lit_id, NOT_A_LITERAL, NOT_A_LITERAL);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_101 (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id3)
|
||||
create_op_meta_101 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id3)
|
||||
{
|
||||
return create_op_meta (op, lit_id1, NOT_A_LITERAL, lit_id3);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_110 (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id2)
|
||||
create_op_meta_110 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2)
|
||||
{
|
||||
return create_op_meta (op, lit_id1, lit_id2, NOT_A_LITERAL);
|
||||
}
|
||||
|
||||
static op_meta
|
||||
create_op_meta_111 (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id2, literal_index_t lit_id3)
|
||||
create_op_meta_111 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3)
|
||||
{
|
||||
return create_op_meta (op, lit_id1, lit_id2, lit_id3);
|
||||
}
|
||||
@@ -214,27 +211,27 @@ name_to_native_call_id (operand obj)
|
||||
{
|
||||
return OPCODE_NATIVE_CALL__COUNT;
|
||||
}
|
||||
if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "LEDToggle"))
|
||||
if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "LEDToggle"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_LED_TOGGLE;
|
||||
}
|
||||
else if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "LEDOn"))
|
||||
else if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "LEDOn"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_LED_ON;
|
||||
}
|
||||
else if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "LEDOff"))
|
||||
else if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "LEDOff"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_LED_OFF;
|
||||
}
|
||||
else if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "LEDOnce"))
|
||||
else if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "LEDOnce"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_LED_ONCE;
|
||||
}
|
||||
else if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "wait"))
|
||||
else if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "wait"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_WAIT;
|
||||
}
|
||||
else if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "print"))
|
||||
else if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "print"))
|
||||
{
|
||||
return OPCODE_NATIVE_CALL_PRINT;
|
||||
}
|
||||
@@ -614,11 +611,11 @@ dump_prop_setter_op_meta (op_meta last, operand op)
|
||||
}
|
||||
|
||||
static operand
|
||||
create_operand_from_tmp_and_lit (idx_t tmp, literal_index_t lit_id)
|
||||
create_operand_from_tmp_and_lit (idx_t tmp, lit_cpointer_t lit_id)
|
||||
{
|
||||
if (tmp != LITERAL_TO_REWRITE)
|
||||
{
|
||||
JERRY_ASSERT (lit_id == NOT_A_LITERAL);
|
||||
JERRY_ASSERT (lit_id.packed_value == MEM_CP_NULL);
|
||||
|
||||
operand ret;
|
||||
|
||||
@@ -629,7 +626,7 @@ create_operand_from_tmp_and_lit (idx_t tmp, literal_index_t lit_id)
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (lit_id != NOT_A_LITERAL);
|
||||
JERRY_ASSERT (lit_id.packed_value != MEM_CP_NULL);
|
||||
|
||||
operand ret;
|
||||
|
||||
@@ -688,12 +685,12 @@ empty_operand (void)
|
||||
}
|
||||
|
||||
operand
|
||||
literal_operand (literal_index_t lit_id)
|
||||
literal_operand (lit_cpointer_t lit_cp)
|
||||
{
|
||||
operand ret;
|
||||
|
||||
ret.type = OPERAND_LITERAL;
|
||||
ret.data.lit_id = lit_id;
|
||||
ret.data.lit_id = lit_cp;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -733,7 +730,7 @@ dumper_is_intrinsic (operand obj)
|
||||
{
|
||||
if (obj.type == OPERAND_LITERAL)
|
||||
{
|
||||
if (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "assert"))
|
||||
if (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "assert"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -746,7 +743,7 @@ dump_intrinsic (operand obj, operand arg)
|
||||
{
|
||||
JERRY_ASSERT (obj.type == OPERAND_LITERAL);
|
||||
TODO (/* Rewrite when there will be more intrinsics. */)
|
||||
JERRY_ASSERT (literal_equal_type_s (lexer_get_literal_by_id (obj.data.lit_id), "assert"));
|
||||
JERRY_ASSERT (lit_literal_equal_type_zt (lit_get_literal_by_cp (obj.data.lit_id), (const ecma_char_t *) "assert"));
|
||||
dump_assert (arg);
|
||||
return dump_undefined_assignment_res ();
|
||||
}
|
||||
@@ -786,7 +783,7 @@ dump_boolean_assignment_res (bool is_true)
|
||||
}
|
||||
|
||||
void
|
||||
dump_string_assignment (operand op, literal_index_t lit_id)
|
||||
dump_string_assignment (operand op, lit_cpointer_t lit_id)
|
||||
{
|
||||
switch (op.type)
|
||||
{
|
||||
@@ -806,7 +803,7 @@ dump_string_assignment (operand op, literal_index_t lit_id)
|
||||
}
|
||||
|
||||
operand
|
||||
dump_string_assignment_res (literal_index_t lit_id)
|
||||
dump_string_assignment_res (lit_cpointer_t lit_id)
|
||||
{
|
||||
operand op = tmp_operand ();
|
||||
dump_string_assignment (op, lit_id);
|
||||
@@ -814,7 +811,7 @@ dump_string_assignment_res (literal_index_t lit_id)
|
||||
}
|
||||
|
||||
void
|
||||
dump_number_assignment (operand op, literal_index_t lit_id)
|
||||
dump_number_assignment (operand op, lit_cpointer_t lit_id)
|
||||
{
|
||||
switch (op.type)
|
||||
{
|
||||
@@ -834,7 +831,7 @@ dump_number_assignment (operand op, literal_index_t lit_id)
|
||||
}
|
||||
|
||||
operand
|
||||
dump_number_assignment_res (literal_index_t lit_id)
|
||||
dump_number_assignment_res (lit_cpointer_t lit_id)
|
||||
{
|
||||
operand op = tmp_operand ();
|
||||
dump_number_assignment (op, lit_id);
|
||||
@@ -1097,15 +1094,17 @@ void
|
||||
dump_prop_name_and_value (operand name, operand value)
|
||||
{
|
||||
JERRY_ASSERT (name.type == OPERAND_LITERAL);
|
||||
const literal lit = lexer_get_literal_by_id (name.data.lit_id);
|
||||
literal_t lit = lit_get_literal_by_cp (name.data.lit_id);
|
||||
operand tmp;
|
||||
if (lit.type == LIT_STR || lit.type == LIT_MAGIC_STR || lit.type == LIT_MAGIC_STR_EX)
|
||||
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.data.lit_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (lit.type == LIT_NUMBER);
|
||||
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
|
||||
tmp = dump_number_assignment_res (name.data.lit_id);
|
||||
}
|
||||
switch (value.type)
|
||||
@@ -1130,15 +1129,17 @@ dump_prop_getter_decl (operand name, operand func)
|
||||
{
|
||||
JERRY_ASSERT (name.type == OPERAND_LITERAL);
|
||||
JERRY_ASSERT (func.type == OPERAND_TMP);
|
||||
const literal lit = lexer_get_literal_by_id (name.data.lit_id);
|
||||
literal_t lit = lit_get_literal_by_cp (name.data.lit_id);
|
||||
operand tmp;
|
||||
if (lit.type == LIT_STR || lit.type == LIT_MAGIC_STR || lit.type == LIT_MAGIC_STR_EX)
|
||||
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.data.lit_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (lit.type == LIT_NUMBER);
|
||||
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
|
||||
tmp = dump_number_assignment_res (name.data.lit_id);
|
||||
}
|
||||
const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_GETTER, tmp.data.uid, func.data.uid);
|
||||
@@ -1150,15 +1151,17 @@ dump_prop_setter_decl (operand name, operand func)
|
||||
{
|
||||
JERRY_ASSERT (name.type == OPERAND_LITERAL);
|
||||
JERRY_ASSERT (func.type == OPERAND_TMP);
|
||||
const literal lit = lexer_get_literal_by_id (name.data.lit_id);
|
||||
literal_t lit = lit_get_literal_by_cp (name.data.lit_id);
|
||||
operand tmp;
|
||||
if (lit.type == LIT_STR || lit.type == LIT_MAGIC_STR || lit.type == LIT_MAGIC_STR_EX)
|
||||
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.data.lit_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (lit.type == LIT_NUMBER);
|
||||
JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T);
|
||||
tmp = dump_number_assignment_res (name.data.lit_id);
|
||||
}
|
||||
const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_SETTER, tmp.data.uid, func.data.uid);
|
||||
@@ -1347,8 +1350,10 @@ dump_delete (operand res, operand op, bool is_strict, locus loc)
|
||||
{
|
||||
case OPERAND_LITERAL:
|
||||
{
|
||||
const literal lit = lexer_get_literal_by_id (op.data.lit_id);
|
||||
if (lit.type == LIT_MAGIC_STR || lit.type == LIT_MAGIC_STR_EX || lit.type == LIT_STR)
|
||||
literal_t lit = lit_get_literal_by_cp (op.data.lit_id);
|
||||
if (lit->get_type () == LIT_STR_T
|
||||
|| lit->get_type () == LIT_MAGIC_STR_T
|
||||
|| lit->get_type () == LIT_MAGIC_STR_EX_T)
|
||||
{
|
||||
syntax_check_delete (is_strict, loc);
|
||||
switch (res.type)
|
||||
@@ -1368,7 +1373,7 @@ dump_delete (operand res, operand op, bool is_strict, locus loc)
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (lit.type == LIT_NUMBER)
|
||||
else if (lit->get_type () == LIT_NUMBER_T)
|
||||
{
|
||||
dump_boolean_assignment (res, true);
|
||||
}
|
||||
@@ -2372,7 +2377,7 @@ dump_throw (operand op)
|
||||
}
|
||||
|
||||
bool
|
||||
dumper_variable_declaration_exists (literal_index_t lit_id)
|
||||
dumper_variable_declaration_exists (lit_cpointer_t lit_id)
|
||||
{
|
||||
for (opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1);
|
||||
oc > 0; oc--)
|
||||
@@ -2382,7 +2387,7 @@ dumper_variable_declaration_exists (literal_index_t lit_id)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (var_decl_op_meta.lit_id[0] == lit_id)
|
||||
if (var_decl_op_meta.lit_id[0].packed_value == lit_id.packed_value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2391,7 +2396,7 @@ dumper_variable_declaration_exists (literal_index_t lit_id)
|
||||
}
|
||||
|
||||
void
|
||||
dump_variable_declaration (literal_index_t lit_id)
|
||||
dump_variable_declaration (lit_cpointer_t lit_id)
|
||||
{
|
||||
const opcode_t opcode = getop_var_decl (LITERAL_TO_REWRITE);
|
||||
serializer_dump_op_meta (create_op_meta_100 (opcode, lit_id));
|
||||
|
||||
Reference in New Issue
Block a user