Rename idx_t -> vm_idx_t, opcode_special_reg_t -> vm_reg_t, INVALID_VALUE -> VM_IDX_EMPTY / VM_IDX_REWRITE_GENERAL_CASE, LITERAL_TO_REWRITE -> VM_IDX_REWRITE_LITERAL_UID.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-07-28 16:55:32 +03:00
parent 0111a73702
commit 173becc3ac
23 changed files with 460 additions and 378 deletions
@@ -23,7 +23,7 @@
* @{
*
* \addtogroup lit_id_hash_table Literal identifiers hash table
* The hash table connects pairs (instruction block, idx_t value) with literal identifiers.
* The hash table connects pairs (instruction block, vm_idx_t value) with literal identifiers.
* @{
*/
@@ -87,7 +87,7 @@ lit_id_hash_table_free (lit_id_hash_table *table_p) /**< table's header */
*/
void
lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
idx_t uid, /**< value of byte-code instruction's argument */
vm_idx_t uid, /**< value of byte-code instruction's argument */
vm_instr_counter_t oc, /**< instruction counter of the instruction */
lit_cpointer_t lit_cp) /**< literal identifier */
{
@@ -111,7 +111,7 @@ lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */
*/
lit_cpointer_t
lit_id_hash_table_lookup (lit_id_hash_table *table_p, /**< table's header */
idx_t uid, /**< value of byte-code instruction's argument */
vm_idx_t uid, /**< value of byte-code instruction's argument */
vm_instr_counter_t oc) /**< instruction counter of the instruction */
{
JERRY_ASSERT (table_p != NULL);
@@ -31,7 +31,7 @@ typedef struct
lit_id_hash_table *lit_id_hash_table_init (uint8_t*, size_t, size_t, size_t);
size_t lit_id_hash_table_get_size_for_table (size_t, size_t);
void lit_id_hash_table_free (lit_id_hash_table *);
void lit_id_hash_table_insert (lit_id_hash_table *, idx_t, vm_instr_counter_t, lit_cpointer_t);
lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, idx_t, vm_instr_counter_t);
void lit_id_hash_table_insert (lit_id_hash_table *, vm_idx_t, vm_instr_counter_t, lit_cpointer_t);
lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, vm_idx_t, vm_instr_counter_t);
#endif /* LIT_ID_HASH_TABLE */
-1
View File
@@ -19,7 +19,6 @@
#include "lit-literal.h"
#include "lit-strings.h"
#define INVALID_VALUE 255
#define INVALID_LITERAL (rcs_cpointer_t::null_cp ())
/* Keywords. */
File diff suppressed because it is too large Load Diff
+20 -11
View File
@@ -89,10 +89,19 @@ public:
* @return constructed operand
*/
static jsp_operand_t
make_reg_operand (idx_t reg_index) /**< register index */
make_reg_operand (vm_idx_t reg_index) /**< register index */
{
JERRY_ASSERT (reg_index != INVALID_VALUE
&& reg_index != LITERAL_TO_REWRITE);
/*
* The following check currently leads to 'comparison is always true
* due to limited range of data type' warning, so it is turned off.
*
* If VM_IDX_GENERAL_VALUE_FIRST is changed to value greater than 0,
* the check should be restored.
*/
// JERRY_ASSERT (reg_index >= VM_IDX_GENERAL_VALUE_FIRST);
static_assert (VM_IDX_GENERAL_VALUE_FIRST == 0, "See comment above");
JERRY_ASSERT (reg_index <= VM_IDX_GENERAL_VALUE_LAST);
jsp_operand_t ret;
@@ -142,12 +151,12 @@ public:
} /* is_literal_operand */
/**
* Get idx_t for operand
* Get idx for operand
*
* @return LITERAL_TO_REWRITE (for jsp_operand_t::LITERAL),
* @return VM_IDX_REWRITE_LITERAL_UID (for jsp_operand_t::LITERAL),
* or register index (for jsp_operand_t::TMP).
*/
idx_t
vm_idx_t
get_idx (void) const
{
JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED);
@@ -158,13 +167,13 @@ public:
}
else if (_type == jsp_operand_t::LITERAL)
{
return LITERAL_TO_REWRITE;
return VM_IDX_REWRITE_LITERAL_UID;
}
else
{
JERRY_ASSERT (_type == jsp_operand_t::EMPTY);
return INVALID_VALUE;
return VM_IDX_EMPTY;
}
} /* get_idx */
@@ -198,7 +207,7 @@ public:
private:
union
{
idx_t uid; /**< byte-code register index (for jsp_operand_t::TMP) */
vm_idx_t uid; /**< byte-code register index (for jsp_operand_t::TMP) */
lit_cpointer_t lit_id; /**< literal (for jsp_operand_t::LITERAL) */
} _data;
@@ -243,8 +252,8 @@ void dump_number_assignment (jsp_operand_t, lit_cpointer_t);
jsp_operand_t dump_number_assignment_res (lit_cpointer_t);
void dump_regexp_assignment (jsp_operand_t, lit_cpointer_t);
jsp_operand_t dump_regexp_assignment_res (lit_cpointer_t);
void dump_smallint_assignment (jsp_operand_t, idx_t);
jsp_operand_t dump_smallint_assignment_res (idx_t);
void dump_smallint_assignment (jsp_operand_t, vm_idx_t);
jsp_operand_t dump_smallint_assignment_res (vm_idx_t);
void dump_undefined_assignment (jsp_operand_t);
jsp_operand_t dump_undefined_assignment_res (void);
void dump_null_assignment (jsp_operand_t);
+3 -3
View File
@@ -803,7 +803,7 @@ parse_literal (void)
case TOK_REGEXP: return dump_regexp_assignment_res (token_data_as_lit_cp ());
case TOK_NULL: return dump_null_assignment_res ();
case TOK_BOOL: return dump_boolean_assignment_res ((bool) token_data ());
case TOK_SMALL_INT: return dump_smallint_assignment_res ((idx_t) token_data ());
case TOK_SMALL_INT: return dump_smallint_assignment_res ((vm_idx_t) token_data ());
default:
{
EMIT_ERROR (JSP_EARLY_ERROR_SYNTAX, "Expected literal");
@@ -2073,7 +2073,7 @@ jsp_parse_for_in_statement_iterator (jsp_operand_t *base_p, /**< out: base value
* tmp <- Collection (Expression)
* for_in instruction (tmp, instruction counter of for-in end mark)
* {
* Assignment of OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME to
* Assignment of VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME to
* Iterator (VariableDeclarationNoIn / LeftHandSideExpression)
* }
* Body (Statement)
@@ -2127,7 +2127,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost
// Dump for-in instruction
vm_instr_counter_t for_in_oc = dump_for_in_for_rewrite (collection);
// Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME
// Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME
lexer_seek (iterator_loc);
tok = lexer_next_token ();
+13 -13
View File
@@ -21,7 +21,7 @@
static hash_table lit_id_to_uid = null_hash;
static vm_instr_counter_t global_oc;
static idx_t next_uid;
static vm_idx_t next_uid;
static void
assert_tree (scopes_tree t)
@@ -29,7 +29,7 @@ assert_tree (scopes_tree t)
JERRY_ASSERT (t != NULL);
}
static idx_t
static vm_idx_t
get_uid (op_meta *op, uint8_t i)
{
JERRY_ASSERT (i < 4);
@@ -38,7 +38,7 @@ get_uid (op_meta *op, uint8_t i)
}
static void
set_uid (op_meta *op, uint8_t i, idx_t uid)
set_uid (op_meta *op, uint8_t i, vm_idx_t uid)
{
JERRY_ASSERT (i < 4);
raw_instr *raw = (raw_instr *) &op->op;
@@ -151,7 +151,7 @@ start_new_block_if_necessary (void)
hash_table_free (lit_id_to_uid);
lit_id_to_uid = null_hash;
}
lit_id_to_uid = hash_table_init (sizeof (lit_cpointer_t), sizeof (idx_t), HASH_SIZE, lit_id_hash);
lit_id_to_uid = hash_table_init (sizeof (lit_cpointer_t), sizeof (vm_idx_t), HASH_SIZE, lit_id_hash);
}
}
@@ -188,16 +188,16 @@ change_uid (op_meta *om, lit_id_hash_table *lit_ids, uint16_t mask)
{
if (is_possible_literal (mask, i))
{
if (get_uid (om, i) == LITERAL_TO_REWRITE)
if (get_uid (om, i) == VM_IDX_REWRITE_LITERAL_UID)
{
JERRY_ASSERT (om->lit_id[i].packed_value != MEM_CP_NULL);
lit_cpointer_t lit_id = om->lit_id[i];
idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
vm_idx_t *uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
if (uid == NULL)
{
hash_table_insert (lit_id_to_uid, &lit_id, &next_uid);
lit_id_hash_table_insert (lit_ids, next_uid, global_oc, lit_id);
uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
JERRY_ASSERT (uid != NULL);
JERRY_ASSERT (*uid == next_uid);
next_uid++;
@@ -223,15 +223,15 @@ insert_uids_to_lit_id_map (op_meta *om, uint16_t mask)
{
if (is_possible_literal (mask, i))
{
if (get_uid (om, i) == LITERAL_TO_REWRITE)
if (get_uid (om, i) == VM_IDX_REWRITE_LITERAL_UID)
{
JERRY_ASSERT (om->lit_id[i].packed_value != MEM_CP_NULL);
lit_cpointer_t lit_id = om->lit_id[i];
idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
vm_idx_t *uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
if (uid == NULL)
{
hash_table_insert (lit_id_to_uid, &lit_id, &next_uid);
uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
JERRY_ASSERT (uid != NULL);
JERRY_ASSERT (*uid == next_uid);
next_uid++;
@@ -416,11 +416,11 @@ generate_instr (linked_list instr_list, /**< instruction list */
*
* @return number of new literals
*/
static idx_t
static vm_idx_t
count_new_literals_in_instr (op_meta *om_p) /**< instruction */
{
start_new_block_if_necessary ();
idx_t current_uid = next_uid;
vm_idx_t current_uid = next_uid;
switch (om_p->op.op_idx)
{
case VM_OP_PROP_GETTER:
@@ -549,7 +549,7 @@ count_new_literals_in_instr (op_meta *om_p) /**< instruction */
break;
}
}
return (idx_t) (next_uid - current_uid);
return (vm_idx_t) (next_uid - current_uid);
} /* count_new_literals_in_instr */
/**