feat: optimize runtime (2x+ faster)
This commit is contained in:
@@ -14,6 +14,8 @@ typedef enum
|
||||
FZL_OPCODE_STORE = 0xF10003, // Push variable to environment table
|
||||
FZL_OPCODE_LOOKUP_ENV = 0xF10004, // Lookup name in environment table
|
||||
FZL_OPCODE_WRITE = 0xF10005, // Wirte into variable
|
||||
FZL_OPCODE_LOAD_LOCAL = 0xF10006, // Load local variable
|
||||
FZL_OPCODE_STORE_LOCAL = 0xF10007, // Store local variable
|
||||
|
||||
FZL_OPCODE_JMP = 0xF20001, // Jump to specified IP address
|
||||
FZL_OPCODE_JZ = 0xF20002, // Jump if top value in dstack is zero
|
||||
|
||||
@@ -23,6 +23,9 @@ typedef struct
|
||||
fzl_node_t *node;
|
||||
size_t ip;
|
||||
|
||||
bool slot_set;
|
||||
size_t slot;
|
||||
|
||||
char *classname;
|
||||
} fzl_sym_t;
|
||||
|
||||
@@ -32,6 +35,8 @@ typedef struct
|
||||
size_t size;
|
||||
size_t remainder;
|
||||
|
||||
size_t free_slot;
|
||||
|
||||
fzl_sym_t *symbols;
|
||||
} fzl_symtable_t;
|
||||
|
||||
@@ -46,6 +51,9 @@ fzl_symtable_res_t fzl_symt_put(fzl_symtable_t *symt, fzl_node_t *node,
|
||||
fzl_symtable_res_t fzl_symt_setobjclass(fzl_symtable_t *symt, char *name,
|
||||
char *classname);
|
||||
|
||||
// Assign a local slot to a variable
|
||||
int fzl_symt_setslot(fzl_symtable_t *symt, char *name);
|
||||
|
||||
// Get entry from specified symtable
|
||||
bool fzl_symt_get(fzl_symtable_t *symt, char *name, fzl_sym_t *res);
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ int op_rm_envtable(fzl_vm_t *vm);
|
||||
int op_store(fzl_vm_t *vm);
|
||||
int op_lookup_env(fzl_vm_t *vm);
|
||||
int op_write(fzl_vm_t *vm);
|
||||
int op_load_local(fzl_vm_t *vm);
|
||||
int op_store_local(fzl_vm_t *vm);
|
||||
|
||||
// --- flow ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user