Split parser into parser itself, opcodes dumper and syntax errors checker.
Add internal hash map of literal indexes: In this hash map key is pair of block number and literal's unique identifier in the block, and the value is a literal index that unique in the whole program. Block is a continues array of opcodes. So, bytecode is splitted into blocks. Each block has its own uid counter. To get literal index the interpreter looks up it in the hash map. Thus, now JS program is able to have more than 255 identifiers/string literals. The first 128 (0-127) uids are reserved for block's uid counter, the other 128 (128-255) are reserved for tmp variables.
This commit is contained in:
@@ -18,8 +18,20 @@
|
||||
|
||||
#include "tree.h"
|
||||
#include "linked-list.h"
|
||||
#include "lexer.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "hash-table.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
#define NOT_A_LITERAL (INVALID_LITERAL - 1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
literal_index_t lit_id[3];
|
||||
opcode_t op;
|
||||
}
|
||||
op_meta;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tree_header t;
|
||||
@@ -34,12 +46,12 @@ typedef scopes_tree_int * scopes_tree;
|
||||
scopes_tree scopes_tree_init (scopes_tree);
|
||||
void scopes_tree_free (scopes_tree);
|
||||
opcode_counter_t scopes_tree_opcodes_num (scopes_tree);
|
||||
void scopes_tree_add_opcode (scopes_tree, opcode_t);
|
||||
void scopes_tree_set_opcode (scopes_tree, opcode_counter_t, opcode_t);
|
||||
void scopes_tree_add_op_meta (scopes_tree, op_meta);
|
||||
void scopes_tree_set_op_meta (scopes_tree, opcode_counter_t, op_meta);
|
||||
void scopes_tree_set_opcodes_num (scopes_tree, opcode_counter_t);
|
||||
opcode_t scopes_tree_opcode (scopes_tree, opcode_counter_t);
|
||||
op_meta scopes_tree_op_meta (scopes_tree, opcode_counter_t);
|
||||
opcode_counter_t scopes_tree_count_opcodes (scopes_tree);
|
||||
opcode_t *scopes_tree_raw_data (scopes_tree, opcode_counter_t *);
|
||||
opcode_t *scopes_tree_raw_data (scopes_tree, hash_table);
|
||||
void scopes_tree_set_strict_mode (scopes_tree, bool);
|
||||
bool scopes_tree_strict_mode (scopes_tree);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user