Skip to content
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

Support of for-in statement #241

Merged
merged 4 commits into from
Jun 26, 2015
Merged
Changes from 1 commit
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
Next Next commit
Introduce explicit description of registers (temporary variables) ran…
…ges.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
ruben-ayrapetyan committed Jun 26, 2015
commit 9b414deb8d8240c721fa3f56160c1856bf501915
37 changes: 28 additions & 9 deletions jerry-core/parser/js/opcodes-dumper.cpp
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
#include "syntax-errors.h"
#include "opcodes-native-call.h"

#define MIN_TEMP_NAME 128
static idx_t temp_name, max_temp_name;

#define OPCODE(name) (__op__idx_##name)
@@ -115,22 +114,42 @@ enum
};
STATIC_STACK (reg_var_decls, opcode_counter_t)

/**
* Reset counter of register variables allocator
* to identifier of first general register
*/
static void
reset_temp_name (void)
{
temp_name = MIN_TEMP_NAME;
}
temp_name = OPCODE_REG_GENERAL_FIRST;
} /* reset_temp_name */

/**
* Allocate next register variable
*
* @return identifier of the allocated variable
*/
static idx_t
next_temp_name (void)
{
temp_name++;
if (max_temp_name < temp_name)
idx_t next_reg = temp_name++;

if (next_reg > OPCODE_REG_GENERAL_LAST)
{
max_temp_name = temp_name;
/*
* FIXME:
* Implement mechanism, allowing reusage of register variables
*/
PARSE_ERROR ("Not enough register variables", 0);
}
return temp_name;
}

if (max_temp_name < next_reg)
{
max_temp_name = next_reg;
}

return next_reg;
} /* next_temp_name */

static op_meta
create_op_meta (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3)
@@ -2500,7 +2519,7 @@ void
dump_reg_var_decl_for_rewrite (void)
{
STACK_PUSH (reg_var_decls, serializer_get_current_opcode_counter ());
serializer_dump_op_meta (create_op_meta_000 (getop_reg_var_decl (MIN_TEMP_NAME, INVALID_VALUE)));
serializer_dump_op_meta (create_op_meta_000 (getop_reg_var_decl (OPCODE_REG_FIRST, INVALID_VALUE)));
}

void
12 changes: 12 additions & 0 deletions jerry-core/vm/opcodes.h
Original file line number Diff line number Diff line change
@@ -102,6 +102,18 @@ typedef enum : idx_t
* 'eval' identifier */
} opcode_scope_code_flags_t;

/**
* Enumeration of registers (temp variables) ranges
*/
typedef enum : idx_t
{
OPCODE_REG_FIRST = 128, /** identifier of first special register */
OPCODE_REG_SPECIAL_EVAL_RET = OPCODE_REG_FIRST, /**< eval return value */
OPCODE_REG_GENERAL_FIRST, /** identifier of first non-special register */
OPCODE_REG_GENERAL_LAST = 253, /** identifier of last non-special register */
OPCODE_REG_LAST = OPCODE_REG_GENERAL_FIRST /**< identifier of last register */
} opcode_special_reg_t;

/**
* Forward declaration of opcode structure
*/