diff options
| author | Damien George <damien.p.george@gmail.com> | 2015-09-23 10:50:43 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2015-10-02 00:11:11 +0100 |
| commit | 58e0f4ac50b3dc732cbfe0d7b04bb41951ac1329 (patch) | |
| tree | 46b94d7f78766e545c0bbda3febeeaf6d7a4bec0 /py/compile.c | |
| parent | e5635f4ab3d0fd00dd3951865fea82003205dae1 (diff) | |
py: Allocate parse nodes in chunks to reduce fragmentation and RAM use.
With this patch parse nodes are allocated sequentially in chunks. This
reduces fragmentation of the heap and prevents waste at the end of
individually allocated parse nodes.
Saves roughly 20% of RAM during parse stage.
Diffstat (limited to 'py/compile.c')
| -rw-r--r-- | py/compile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/compile.c b/py/compile.c index 797d7a95e..a3e8c49d1 100644 --- a/py/compile.c +++ b/py/compile.c @@ -3317,7 +3317,7 @@ STATIC void scope_compute_things(scope_t *scope) { } } -mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is_repl) { +mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl) { // put compiler state on the stack, it's relatively small compiler_t comp_state = {0}; compiler_t *comp = &comp_state; @@ -3326,7 +3326,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is comp->is_repl = is_repl; // create the module scope - scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, pn, emit_opt); + scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); // optimise constants (scope must be set for error messages to work) comp->scope_cur = module_scope; @@ -3485,7 +3485,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is #endif // free the parse tree - mp_parse_node_free(module_scope->pn); + mp_parse_tree_clear(parse_tree); // free the scopes mp_raw_code_t *outer_raw_code = module_scope->raw_code; |
