Skip to content

Enhancement of parser operand handling, compaction of instruction dumper #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions jerry-core/lit/lit-literal-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@ lit_literal_storage_t::dump ()
}
else
{
lit_utf8_byte_t buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
ecma_number_to_utf8_string (lit_p->get_number (), buff, sizeof (buff));
lit_utf8_byte_t buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER + 1u];
memset (buff, 0, sizeof (buff));

lit_utf8_size_t sz = ecma_number_to_utf8_string (lit_p->get_number (), buff, sizeof (buff));
JERRY_ASSERT (sz <= ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER);

printf ("%s : NUMBER", buff);
}

Expand Down
2 changes: 0 additions & 2 deletions jerry-core/lit/lit-literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "lit-literal-storage.h"
#include "lit-magic-strings.h"

#define LITERAL_TO_REWRITE (INVALID_VALUE - 1)

void lit_init ();
void lit_finalize ();
void lit_dump_literals ();
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/parser/js/collections/lit-id-hash-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* @{
*/

Expand Down Expand Up @@ -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 */
{
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/parser/js/collections/lit-id-hash-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
22 changes: 11 additions & 11 deletions jerry-core/parser/js/jsp-early-error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ jsp_early_error_start_checking_of_prop_names (void)
}

void
jsp_early_error_add_prop_name (operand op, prop_type pt)
jsp_early_error_add_prop_name (jsp_operand_t op, prop_type pt)
{
JERRY_ASSERT (op.type == OPERAND_LITERAL);
STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.data.lit_id), pt));
JERRY_ASSERT (op.is_literal_operand ());
STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.get_literal ()), pt));
}

void
Expand Down Expand Up @@ -199,21 +199,21 @@ jsp_early_error_start_checking_of_vargs (void)
STACK_PUSH (size_t_stack, STACK_SIZE (props));
}

void jsp_early_error_add_varg (operand op)
void jsp_early_error_add_varg (jsp_operand_t op)
{
JERRY_ASSERT (op.type == OPERAND_LITERAL);
STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.data.lit_id), VARG));
JERRY_ASSERT (op.is_literal_operand ());
STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.get_literal ()), VARG));
}

static void
emit_error_on_eval_and_arguments (operand op, locus loc __attr_unused___)
emit_error_on_eval_and_arguments (jsp_operand_t op, locus loc __attr_unused___)
{
if (op.type == OPERAND_LITERAL)
if (op.is_literal_operand ())
{
if (lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.data.lit_id),
if (lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.get_literal ()),
lit_get_magic_string_utf8 (LIT_MAGIC_STRING_ARGUMENTS),
lit_get_magic_string_size (LIT_MAGIC_STRING_ARGUMENTS))
|| lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.data.lit_id),
|| lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.get_literal ()),
lit_get_magic_string_utf8 (LIT_MAGIC_STRING_EVAL),
lit_get_magic_string_size (LIT_MAGIC_STRING_EVAL)))
{
Expand All @@ -223,7 +223,7 @@ emit_error_on_eval_and_arguments (operand op, locus loc __attr_unused___)
}

void
jsp_early_error_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict, locus loc)
jsp_early_error_check_for_eval_and_arguments_in_strict_mode (jsp_operand_t op, bool is_strict, locus loc)
{
if (is_strict)
{
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/parser/js/jsp-early-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void jsp_early_error_init (void);
void jsp_early_error_free (void);

void jsp_early_error_start_checking_of_prop_names (void);
void jsp_early_error_add_prop_name (operand, prop_type);
void jsp_early_error_add_prop_name (jsp_operand_t, prop_type);
void jsp_early_error_check_for_duplication_of_prop_names (bool, locus);

void jsp_early_error_start_checking_of_vargs (void);
void jsp_early_error_add_varg (operand);
void jsp_early_error_check_for_eval_and_arguments_in_strict_mode (operand, bool, locus);
void jsp_early_error_add_varg (jsp_operand_t);
void jsp_early_error_check_for_eval_and_arguments_in_strict_mode (jsp_operand_t, bool, locus);
void jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool, locus);

void jsp_early_error_check_delete (bool, locus);
Expand Down
2 changes: 0 additions & 2 deletions jerry-core/parser/js/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "lit-literal.h"
#include "lit-strings.h"

#define INVALID_VALUE 255
#define EVAL_RET_VALUE 128
#define INVALID_LITERAL (rcs_cpointer_t::null_cp ())

/* Keywords. */
Expand Down
Loading