Skip to content
Snippets Groups Projects
Commit cdc0d140 authored by pompolic's avatar pompolic
Browse files

Move stack pop at the end of function

parent d839dac4
No related branches found
No related tags found
No related merge requests found
......@@ -84,9 +84,6 @@ class TopLevelParse:
def return_from_h_do_parse(self, parse_state, parser, ret_val):
parser_stack = self.peek_parserstack()
parser_obj = self.parser_by_address(parser) # We don't try to make a new Parser() object here, because it has to have been done in the corresponding enter_h_do_parse() call
previous_parser = parser_stack.pop()
top_of_stack = parser_stack.peek()
assert top_of_stack == parser_obj, "parser function argument is different from parser on top of stack"
# The rationale for handling the "current" parser separately from stack:
# Parsers are only pushed on the stack in perform_lowlevel_parse, which doesn't get called when h_do_parse() gets the result from cache.
# If other backends are supported, this might change to pushing/popping the stack in h_do_parse()
......@@ -106,6 +103,8 @@ class TopLevelParse:
parser_obj.add_mem_use(int(parser_stack.arena), allocated_bytes)
# TODO: allocations can be attributed to individual h_do_parse(parser) calls, thus the same per-parser per-arena stats tracking can be done
previous_parser = parser_stack.pop()
# Called from h_do_parse()'s handler, at which point we know the addresses of the state and arena
def first_h_do_parse_after_packrat_parse(self, parse_state, arena):
parser_stack = self.peek_parserstack()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment